CODE
//Pits and lava by Joe123
//Hover boots mod by MM
//==== • Pits and Lava w/ Hover Boots • ================================================
// D0: Whether this screen has pits or lava. 0 for pits, 1 for lava
// D1: Whether to warp Link after falling (example: pits that take you to a lower floor in a dungeon)
// D2: Damage Link takes from falling, in 16ths of a heart. Default damage is half a heart
// D3: Time in frames of hover duration
const int WSP_FALLING = 96; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA = 95; //Weapon/Misc. sprite for Link drowning in lava
const int CMB_HOVERGLOW = 100; //Hover boots glow *combo*
const int CSET_HOVERGLOW = 7; //CSet of this combo
const int SFX_FALLING = 38; //SFX for falling down a hole
const int SFX_LAVA = 55; //SFX for drowning in lava
const int CMB_AUTOWARP = 12483; //Combo ID of a transparent AutoWarp A combotype
const int CT_HOLELAVA = 11; //Combotype to give hole functionality to (default is Left Statue)
const int I_PITBOOTS = 92; //Pit hover boots (default hover boots)
ffc script HoleLava{
void run(int lava, int warpto, int damage, int hoverDur){
int hoverTime;
//Set up correct graphic and sound effect
this->Misc[0] = WSP_FALLING; this->Misc[1] = SFX_FALLING;
if(lava){
this->Misc[0] = WSP_LAVA;
this->Misc[1] = SFX_LAVA;
}
//Find return point when falling in lava. (this->X,this->Y) used if ffc is not at (0,0)
if((this->X == 0 && this->Y == 0) || this->Flags[FFCF_CHANGER]){
Waitframes(5);
this->X = Link->X; this->Y = Link->Y;
}
this->Misc[2] = warpto;
if(damage) this->Misc[3] = damage;
else this->Misc[3] = 8;
//Per-frame loop
while(true){
//Wait while not on pit
while(!OnPitCombo()){
if ( Link->Item[I_PITBOOTS] ) //If Link has hover boots
hoverTime = hoverDur; //Reset hover boots time
Waitframe(); //Idle while not on pit
}
//Hover boots active
if ( Link->Item[I_PITBOOTS] ){
Game->PlaySound(SFX_HOVER);
while(OnPitCombo() && hoverTime-- > 0){
Screen->FastCombo( 2, Link->X, Link->Y, CMB_HOVERGLOW, CSET_HOVERGLOW, 64 ); //If opaque, change to 128
Waitframe();
}
}
//No hover boots
int pitclk = 0;
while(OnPitCombo() && pitclk++ < 4) Waitframe(); //Wait for four frames whilst on pit
if(pitclk >= 5) Fall(this); //Fall
}
}
void Fall(ffc Info){
Screen->ClearSprites(SL_LWPNS);
Game->PlaySound(Info->Misc[1]);
int wait = CreateGraphic(Info->Misc[0]);
Link->Invisible = true; Link->CollDetection = false;
for(int i=0;i<wait+30;i++) WaitNoAction();
Link->Invisible = false; Link->CollDetection = true;
if(Info->Misc[2]) Warp(Info);
Link->X = Info->X; Link->Y = Info->Y;
Link->HP -= Info->Misc[3];
Game->PlaySound(SFX_OUCH);
}
void Warp(ffc Warp){
int orig = Warp->Data;
Warp->Data = CMB_AUTOWARP;
Warp->Flags[FFCF_CARRYOVER] = true;
Waitframe();
Warp->Data = orig;
Warp->Flags[FFCF_CARRYOVER] = false;
Link->Z = Link->Y;
Quit();
}
bool OnPitCombo(){
return (Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_HOLELAVA && Link->Z <= 0 && Link->Action != LA_FROZEN);
}
int CreateGraphic(int sprite){
lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
l->HitXOffset = 500;
l->UseSprite(sprite);
l->DeadState = l->NumFrames*l->ASpeed;
l->X = Link->X; l->Y = Link->Y;
return l->DeadState;
}
}