const int I_SHORYUKEN = 35;
const int LW_SHORYUKEN = 31; //Script1
const int SHORYUKEN_DAMAGE = 8;
global script shoryuken
{
void run()
{
int lastY = Link->Y;
while(true)
{
if(Link->Item[I_SHORYUKEN] && IsSideview())
{
if(Link->InputL && Link->Y < lastY)IsScrewAttack = true;
else
{
IsScrewAttack = false;
for(int i = 1; i <= Screen->NumNPCs(); i++)
{
lweapon weap = Screen->LoadLWeapon(i);
if(weap->ID == LW_SHORYUKEN)
weap->DeadState = WDS_DEAD;
}
}
lastY = Link->Y;
}
ScrewAttack();
Waitdraw();
JumpWithL();
Waitframe();
}
}
}
const int JUMP_HEIGHT_NORMAL = 4; //This is the jump height when you don't have the high jump item. It uses feather jump height instead of script jump height for compatibility purposes.
const int JUMP_HEIGHT_HIGH = 8; //This is the jump height when you have the high jump item.
const int I_NORMALJUMP = 91;
const int I_HIGHJUMP = 123; //This is the item used for the high jump boots. Just having the item will make you jump higher with the script. Uses Roc's Feather by default.
const int I_SPACE_JUMP = 51;
const int SPACE_JUMP_LOWER_BOUND = 20; // How many frames Link has to fall before Space Jump can be used.
const int SPACE_JUMP_UPPER_BOUND = 50; // How many frames Link can fall before Space Jump use is barred.
const int SF_NOJUMP = 0000100b; //This is the Misc screen flag used by the script to find screens where jumping is disabled. It uses General Use 1 (Scripts) by default.
int StoredY;
int SpaceJumpFalling;
//This is the jump function. Put this in the while loop of your global script.
void JumpWithL(){
int JumpHeight = JUMP_HEIGHT_NORMAL;
if(Link->Item[I_HIGHJUMP])JumpHeight = JUMP_HEIGHT_HIGH;
if(IsSideview()){ //For sideview screens
if(Link->PressL&&OnSidePlatform(Link->X, Link->Y, Link->HitXOffset, Link->HitYOffset, Link->HitHeight)&&Link->Action<=2&&!(Screen->Flags[SF_MISC]&SF_NOJUMP)){
Link->Jump = (JumpHeight+2)*0.8;
Game->PlaySound(SFX_JUMP);
}
else if (Link->PressL&&Link->Item[I_SPACE_JUMP]&&SpaceJumpFalling>=SPACE_JUMP_LOWER_BOUND&&SpaceJumpFalling<SPACE_JUMP_UPPER_BOUND&&Link->Action<=2&&!(Screen->Flags[SF_MISC]&SF_NOJUMP)){
Link->Jump = (JumpHeight+2)*0.8;
Game->PlaySound(SFX_JUMP);
}
if (Link->Y > StoredY)
{
SpaceJumpFalling++;
}
else
{
SpaceJumpFalling = 0;
}
StoredY = Link->Y;
}
else{ //For top-down screens
if(Link->PressL&&Link->Z==0&&Link->Action<=2&&!(Screen->Flags[SF_MISC]&SF_NOJUMP)){
Link->Jump = (JumpHeight+2)*0.8;
Game->PlaySound(SFX_JUMP);
}
}
Link->InputL = false;
}
const int T_DUST = 1526; //Dust Kick-up tile
const int DustAFrames = 4; //Dust Kick-up animation frames
const int DustASpeed = 4; //Dust Kick-up animation speed
const int DustCSet = 3; //Dust Kick-up CSet
const int DashSFXLength = 9; //Time between repeating Dash SFX
bool IsScrewAttack;
bool ScrewAttackCollision;
const int CF_DASH = 98; //Flag that Link can't dash through if walkable, and will break if solid
const int SFX_DASH = 69;
const int SFX_PEGASUSBREAK = 41;
int DashCounter;
int Dust_Array[4]; // Array size should be max number of dust animations active at one time ( DustAFrames*DustASpeed / 4 )
void ScrewAttack(){
lweapon mysword;
int loc;
if(IsScrewAttack){
if(!ScrewAttackCollision){
if(Link->Action != LA_SCROLLING && DashCounter > 10){
if(Link->Dir == DIR_DOWN || DashCheck(Link->X+8,Link->Y+6,true) == 2){
ScrewAttackCollision = true;
DashCounter = 0;
}
}
mysword = LoadLWeaponOf(LW_SHORYUKEN);
if(!mysword->isValid()) {
mysword = Screen->CreateLWeapon(LW_SHORYUKEN);
mysword->Damage = SHORYUKEN_DAMAGE;
mysword->X = Link->X;
mysword->Y = Link->Y;
mysword->Dir = Link->Dir;
if(mysword->Dir < 2){ //dir is up or down
if(mysword->Dir == DIR_DOWN) mysword->Flip = 3;
}
else{ //dir is left or right
mysword->OriginalTile += 1;
mysword->Tile = mysword->OriginalTile;
if(mysword->Dir == DIR_LEFT) mysword->Flip = 1;
mysword->Y += 3;
}//end dir if
}
else{ // we don't have dashSword
mysword = LoadLWeaponOf(LW_SHORYUKEN);
Remove(mysword);
}//end mysword if
if(Link->Item[I_NORMALJUMP]){
if((Link->Dir == DIR_RIGHT || Link->Dir == DIR_LEFT || Link->Dir == DIR_UP)&& Screen->State[ST_SECRET] == false && ((Screen->isSolid(Link->X+16, Link->Y) && ComboFI(Link->X+16,Link->Y,CF_DASH) ) || (Screen->isSolid(Link->X+16, Link->Y+15) && ComboFI(Link->X+16,Link->Y+15,CF_DASH) ) )){
loc = ComboAt(Link->X+8, Link->Y-8);
if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
Game->PlaySound(27);
Screen->TriggerSecrets();
Screen->State[ST_SECRET] = true;
}
}
if(Link->Item[I_HIGHJUMP] || Link->Item[I_SPACE_JUMP]){
if((Link->Dir == DIR_RIGHT || Link->Dir == DIR_LEFT || Link->Dir == DIR_UP) && Screen->State[ST_SECRET] == false && ((Screen->isSolid(Link->X+16, Link->Y) && ComboFI(Link->X+16,Link->Y,CF_DASH) ) || (Screen->isSolid(Link->X+16, Link->Y-15) && ComboFI(Link->X+16,Link->Y-15,CF_DASH) ) )){
loc = ComboAt(Link->X+16, Link->Y-16);
if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
Game->PlaySound(27);
Screen->TriggerSecrets();
Screen->State[ST_SECRET] = true;
}
}
DustDrawLW(); // use new dust draw code that works while scrolling
if(DashCounter%DashSFXLength == 0) Game->PlaySound(SFX_DASH);
}
else{ //is ScrewAttackCollision
NoAction();
DashCounter = 0;
IsScrewAttack = false;
ScrewAttackCollision = false;
}
DashCounter++;
}
}
void DustDrawLW(){
lweapon Dust;
if(DashCounter%4 == 0){
for(int j=Screen->NumLWeapons();j>0;j--){
Dust = Screen->LoadLWeapon(j);
if(Dust->ID != LW_SCRIPT10) continue;
if (Link->Dir == DIR_UP) Dust->Y-=3;
else if(Link->Dir == DIR_DOWN) Dust->Y+=3;
else if(Link->Dir == DIR_LEFT) Dust->X-=3;
else if(Link->Dir == DIR_RIGHT) Dust->X+=3;
}//end for loop
Dust = Screen->CreateLWeapon(LW_SCRIPT10);
Dust->OriginalTile = T_DUST;
Dust->CSet = DustCSet;
Dust->Y = Link->Y+8;
Dust->X = Link->X;
Dust->NumFrames = DustAFrames;
Dust->ASpeed = DustASpeed;
Dust->DeadState = DustAFrames*DustASpeed;
}//end dust if
}
int DashCheck(int x, int y, bool xy){
int xoffset; int yoffset;
bool Solid;
if(xy) xoffset = 4;
else yoffset = 3;
if(Screen->isSolid(x-xoffset,y-yoffset) || Screen->isSolid(x+xoffset,y+yoffset)) Solid = true;
if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH)
&& !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH)
|| ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
else return 2;
}