const int I_SHORYUKEN = 35;
const int LW_SHORYUKEN = 31; //Script1
const int SHORYUKEN_DAMAGE = 8;
int scrollDir;
int scrollCounter;
int drawX;
int drawY;
int dashSwordTile = 0;
int dashSwordCSet = 0;
global script shoryuken
{
void run()
{
int lastY = Link->Y;
while(true)
{
if(Link->Item[I_SHORYUKEN] && IsSideview())
{
if(Link->InputL){
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_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;
if(IsScrewAttack){
if(!ScrewAttackCollision){
int loc = ComboAt(Link->X+8,Link->Y+
;
if(Link->Action != LA_SCROLLING && DashCounter > 10){
if((Link->Dir == DIR_UP || Link->Dir == DIR_LEFT || Link->Dir == DIR_RIGHT)&& DashCheck(Link->X+8,Link->Y+6,true) != 2){
drawY = Link->Y;
drawX = Link->X;
}
else{
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
// save our sword sprite for when scrolling
dashSwordTile = mysword->Tile;
dashSwordCSet = mysword->OriginalCSet;
}
else{ // we don't have dashSword
mysword = LoadLWeaponOf(LW_SHORYUKEN);
Remove(mysword);
dashSwordTile = 0;
dashSwordCSet = 0;
}//end mysword if
if(ComboFI(Link->X+8,Link->Y+8,CF_DASH) && Screen->ComboS[loc] == 1111b){
Screen->ComboD[loc]=Screen->UnderCombo; // comment out if using above method instead of under combo
if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
Game->PlaySound(SFX_PEGASUSBREAK);
}
DustDrawTile(); // 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 DustDrawTile(){
int dX;
int dY;
if(DashCounter%4 == 0){
for(int i = 0; i < SizeOfArray(Dust_Array); i++){
if(Dust_Array[i] == 0){
Dust_Array[i] = 1;
break;
}
}
}
for(int i = 0; i < SizeOfArray(Dust_Array); i++){
if(Dust_Array[i]==0) continue;
if(Link->Dir == DIR_UP || scrollDir == DIR_UP){
dX = drawX;
if(Dust_Array[i] < 4) dY = drawY+8;
else dY = drawY+8+3+(Dust_Array[i]-1);
}else if(Link->Dir == DIR_DOWN || scrollDir == DIR_DOWN){
dX = drawX;
if(Dust_Array[i] < 4) dY = drawY+8;
else dY = drawY+8-3-(Dust_Array[i]-1);
}else if(Link->Dir == DIR_LEFT || scrollDir == DIR_LEFT){
if(Dust_Array[i] < 4) dX = drawX;
else dX = drawX+3+(Dust_Array[i]-1);
dY = drawY+8;
}else if(Link->Dir == DIR_RIGHT || scrollDir == DIR_RIGHT){
if(Dust_Array[i] < 4) dX = drawX;
else dX = drawX-3-(Dust_Array[i]-1);
dY = drawY+8;
}
Screen->FastTile(0, dX, dY, T_DUST+ Floor(Dust_Array[i]/DustASpeed), DustCSet, 128);
if(Dust_Array[i] == DustAFrames*DustASpeed) Dust_Array[i] = 0;
else Dust_Array[i]++;
}
}
void ScrollFix(){
//function by Saffith
if(Link->Action==LA_SCROLLING){
if(scrollDir==-1)
{
if(Link->Y>160)
{
scrollDir=DIR_UP;
scrollCounter=45;
}
else if(Link->Y<0)
{
scrollDir=DIR_DOWN;
scrollCounter=45;
}
else if(Link->X>240)
{
scrollDir=DIR_LEFT;
scrollCounter=65;
}
else
{
scrollDir=DIR_RIGHT;
scrollCounter=65;
}
}
if(scrollDir==DIR_UP && scrollCounter<45 && scrollCounter>4)
drawY+=4;
else if(scrollDir==DIR_DOWN && scrollCounter<45 && scrollCounter>4)
drawY-=4;
else if(scrollDir==DIR_LEFT && scrollCounter<65 && scrollCounter>4)
drawX+=4;
else if(scrollDir==DIR_RIGHT && scrollCounter<65 && scrollCounter>4)
drawX-=4;
scrollCounter--;
}
else
{
drawX=Link->X;
drawY=Link->Y;
if(scrollDir!=-1)
scrollDir=-1;
}
}
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;
}