ffc script whip21{ void run(int damage, int length, int sound, int startsprite, int mainsprite, int lifespan, int HPdrain){ if (Link->HP<=HPdrain*8)Quit(); //If Whip drains HP per use, no one wants unfair and nasty death. Link->HP = Link->HP-HPdrain; // Drain Link`s HP Game->PlaySound(sound); // Play whip sound lweapon whip_start = Screen->CreateLWeapon(LW_SCRIPT2); // Create whip starting sprite. whip_start->X=Link->X; //Place it at Link`s position whip_start->Y=Link->Y; whip_start->Damage=damage/2; //Assign damage whip_start->Extend=3; //Assign size whip_start->TileHeight=2; whip_start->HitWidth=16; whip_start->HitHeight=32; UpdateWhipStart(whip_start, startsprite); for (int counter=1; counter<=lifespan; counter++){ if (whip_start->isValid()){ if (Link->Action>1){ Remove(whip_start); Link->Invisible=false; Quit(); } whip_start->DeadState=WDS_ALIVE; //Keep whip moving with Link and don`t disappear when hitting enemy. whip_start->X=Link->X; whip_start->Y=Link->Y; UpdateWhipStart(whip_start, startsprite); Waitframe(); debugValue ( 1, whip_start->HitXOffset ); debugValue ( 2, whip_start->HitYOffset ); debugValue ( 3, whip_start->HitWidth ); debugValue ( 4, whip_start->HitHeight ); } } if (whip_start->isValid()) Remove(whip_start); // Remove starting sprite and prepare for phase 2. lweapon whip_main = Screen->CreateLWeapon(LW_SCRIPT2); whip_main->X=Link->X; whip_main->Y=Link->Y;//Create main sprite whip_main->Damage=damage; //Assign damage whip_main->Extend=3; UpdateWhipMain(whip_main, length, mainsprite); for (int counter=1; counter<=lifespan*2; counter++){ if (whip_main->isValid()){ if (Link->Action>1){ Remove(whip_main); Link->Invisible=false; Quit(); } whip_main->DeadState=WDS_ALIVE; // Again, no disappearing on hitting enemies! whip_main->X=Link->X; whip_main->Y=Link->Y; UpdateWhipMain(whip_main, length, mainsprite); Waitframe(); debugValue ( 1, whip_main->HitXOffset ); debugValue ( 2, whip_main->HitYOffset ); debugValue ( 3, whip_main->HitWidth ); debugValue ( 4, whip_main->HitHeight ); } } if (whip_main->isValid()) Remove(whip_main); Quit(); } } void UpdateWhipStart(lweapon whip_start, int startsprite){ if(Link->Dir==DIR_RIGHT){ // Assign sprite offset. Also assign direction so it properly interacts with shielded enemies. whip_start->UseSprite(startsprite); whip_start->HitXOffset=-9; whip_start->HitYOffset=-16; whip_start->DrawXOffset=-9; whip_start->DrawYOffset=-16; whip_start->Dir=DIR_LEFT; } else if(Link->Dir==DIR_LEFT){ whip_start->UseSprite(startsprite+1); whip_start->HitXOffset=9; whip_start->HitYOffset=-16; whip_start->DrawXOffset=9; whip_start->DrawYOffset=-16; whip_start->Dir=DIR_RIGHT; } else if(Link->Dir==DIR_UP){ whip_start->UseSprite(startsprite+2); whip_start->HitXOffset=0; whip_start->HitYOffset=0; whip_start->DrawXOffset=0; whip_start->DrawYOffset=0; whip_start->Dir=DIR_DOWN; } else if(Link->Dir==DIR_DOWN){ whip_start->UseSprite(startsprite+3); whip_start->HitXOffset=0; whip_start->HitYOffset=-16; whip_start->DrawXOffset=0; whip_start->DrawYOffset=-16; whip_start->Dir=DIR_UP; } } void UpdateWhipMain(lweapon whip_main, int length, int mainsprite){ if(Link->Dir==DIR_RIGHT){ whip_main->UseSprite(mainsprite); // Assign size and offsets and pay close attention to Link`s direction as well as whip length whip_main->TileWidth=length; whip_main->TileHeight=1; whip_main->HitWidth=length*16; whip_main->HitHeight=8; whip_main->HitXOffset=16; whip_main->HitYOffset=4; whip_main->DrawXOffset=16; whip_main->DrawYOffset=-0; whip_main->Dir=DIR_RIGHT; } else if(Link->Dir==DIR_LEFT){ whip_main->UseSprite(mainsprite+1); whip_main->HitXOffset=length*-16; whip_main->HitYOffset=4; whip_main->TileWidth=length; whip_main->TileHeight=1; whip_main->HitWidth=length*16; whip_main->HitHeight=8; whip_main->DrawXOffset=length*-16; whip_main->DrawYOffset=0; whip_main->Dir=DIR_LEFT; } else if(Link->Dir==DIR_UP){ whip_main->UseSprite(mainsprite+2); whip_main->HitXOffset=2; whip_main->HitYOffset=length*-16; whip_main->TileWidth=1; whip_main->TileHeight=length; whip_main->HitWidth=8; whip_main->HitHeight=length*16; whip_main->DrawXOffset=0; whip_main->DrawYOffset=length*-16; whip_main->Dir=DIR_UP; } else if(Link->Dir==DIR_DOWN){ whip_main->UseSprite(mainsprite+3); whip_main->TileWidth=1; whip_main->TileHeight=length; whip_main->HitWidth=8; whip_main->HitHeight=length*16; whip_main->HitXOffset=12; whip_main->HitYOffset=16; whip_main->DrawXOffset=0; whip_main->DrawYOffset=16; whip_main->Dir=DIR_DOWN; } }