At a random point, the boss is supposed to jump, then it can decide from one of two attacks. Now, when it jumps, the boss stops in mid-air, and stops working. It's attacks when its on the ground works smoothly, just not the ones that it's in the air.
I've tried changing the condition to see if it's finished jumping to something that would never happen, and it worked. (Sort of, the boss doesn't even jump, just starts it's attack. That wouldn't be SO bad if it weren't for the fact that both attacks pretty much require it to be in the air.)
I can also confirm that when it stops, the ghosted enemy is NOT there. It appears to have vanished, since when I attack it, nothing happens.
The boss is intended for a side-scrolling screen.
CODE
//DAMAGE
const int prinnyRaid = 32; //Damage for Prinny Raid (raining prinnies)
const int prinnyBarage = 16; //Damage for Prinny Barage (slashes)
const int prinnyPound = 64; //Damage for Prinny Pound
//COMBOS
const int prinnycmb = 1908; //Combo for still Prinny (up, left, down, right)
const int prinnywalkcmb = 1912; //Combo for walking Prinny (up, left, down, right)
const int prinnyruncmb = 1916; //Combo for running Prinny (up, left, down, right)
const int prinnyjumpcmb = 1930; //Combo for jumping Prinny
const int prinnypoundcmb = 71920; //Combo for pounding Prinny (Frame 1 - 4, Pound)
const int prinnyattackcmb = 1932; //Combo for attacking Prinny (left, right)
const int prinnyspin = 1936; //Combo for spinning prinny (slow, fast, fastest)
//TILES
const int prinnyraidtile = 65405; //Tile for raining prinnies
const int prinnyattack = 65480; //Tile for attack (prinny barrage)
const int poundburst = 65481; //Tile for burst after pound
//SOUNDS
const int jumpsound = 45; //Sound for jumping
const int swipesound = 85; //Sound for slicing
const int poundsound = 86; //Sound for pounding
const int poundsound2 = 88; //Sound for pounding (2)
const int flipsound = 87; //Sound for flipping
const int fattacksound = 4; //Sound for flying attack
const int dashsound = 89; //Sound for dash
const int dancesound = 90; //Sound for dance
const int raidsound = 91; //Sound for Prinny Raid (falling prinnies)
//MISC
const int walk = 4; //Walk speed
ffc script prinny
{
void run()
{
//General Set-Up
int dir = 1; //(up, right, down, left)
int random; //General Purpose Random Number
int delay = 100; //Delay used to decide attack time
bool delaySet = false; //General Purpose Delay Bool
npc ghost = Screen->CreateNPC(85);
int prevHP = ghost->HP; //Get previous HP
int prinnyHP = 11100; //HP for prinny
ghost->HP = prinnyHP;
ghost->X = this->X;
ghost->Y = this->Y;
dir = 3;
int origCset = ghost->CSet; //Get normal Cset
int invuln = 0; //Invulnerability counter
int state = 0; //0 = Moving
//1 = Dead
//2 = Jumping
//3 = Prinny Barage
//4 = Prinny Stomp
//5 = Prinny Raid
//6 = Spinning
//7 = Running
//8 = Falling
//9 = Dizzy (After Running)
while(state != 1)
{
this->X = ghost->X;
this->Y = ghost->Y;
Waitframe();
if(invuln <= 0)
{
this->CSet = origCset;
}//Invuln Check End
else
{
invuln --;
this->CSet ++;
}//Else End
if(prevHP > ghost->HP)
{
invuln = 40;
}//Damage Check End
if(ghost->HP < 100)
{
ghost->HP = 0;
this->Vx = 300;
state = 1;
}//Hp Check End
//=============
//Walking State
//=============
if(state == 0)
{
if(dir == 1)
{
if(canMove(ghost->X+1, ghost->Y-25))
{
ghost->X ++;
this->Data = prinnywalkcmb+3;
}
else
{
dir = 3;
}
} //End CanMove (Right)
if(dir == 3)
{
if(canMove(ghost->X-1, ghost->Y-25))
{
ghost->X --;
this->Data = prinnywalkcmb+1;
}
else
{
dir = 1;
}
} //End CanMove (Left)
//Prevent Leaving Unless Dead
if ( state != 1 )
{
if ( (!canMove(this->X-18, this->Y)) && (this->Vx < 0)){this->Vx=0;}
if ( (!canMove(this->X+25, this->Y)) && (this->Vx > 0)){this->Vx=0;}
if ( (!canMove(this->X, this->Y-18)) && (this->Vy < 0)){this->Vy=0;}
if ( (!canMove(this->X, this->Y+25)) && (this->Vy > 0)){this->Vy=0;}
}//End Prevent Leave
delay --;
if(delay == 0)
{
delay = 100;
random = Rand(3);
if(random == 1)
{
state = 2;
random = 0;
} //Rand 1 End
if(random == 2)
{
state = 6;
} //Rand 1 End
}//Delay End
} // State 0 End
//=============
//Jumping State
//=============
if(state == 2)
{
if(!delaySet)
{
Game->PlaySound(jumpsound);
delaySet = true;
}
if(dir == 1)
{
if(canMove(ghost->X+1, ghost->Y-25))
{
this->Data = prinnyjumpcmb+1;
ghost->X ++;
ghost->Y -= 3;
}
else
{
dir = 3;
}
} //End CanMove (Right)
if(dir == 3)
{
if(canMove(ghost->X-1, ghost->Y-25))
{
this->Data = prinnyjumpcmb;
ghost->X --;
ghost->Y -= 3;
}
else
{
dir = 1;
}
} //End CanMove (Left)
if(ghost->Y <= 20)
{
random = Rand(3);
if(random == 1)
{
delaySet = false;
delay = 25;
state = 3;
} //Rand 1 End
if(random == 2)
{
delaySet = false;
delay = 25;
state = 4;
} //Rand 2 End
} //Jump Check End
} //State 2 End
//==============
//Prinny Barrage
//==============
if(state == 3)
{
if(dir == 3)
{
this->Data = prinnyattackcmb;
}//Dir Check End
if(dir == 1)
{
this->Data = prinnyattackcmb + 1;
}//Dir Check End
Game->PlaySound(swipesound);
homingprojectile(ghost->X,ghost->Y, prinnyattack, 2, prinnyBarage, 500, 8, 2);
Waitframes(5);
Game->PlaySound(fattacksound);
if(delay == 0)
{
state = 8;
delaySet = false;
}//Delay Check End
delay--;
}//Barrage End
//============
//Prinny Stomp
//============
if(state == 4)
{
if(!delaySet)
{
if(dir ==3)
{
Game->PlaySound(flipsound);
ghost->Damage = prinnyPound;
this->Data = prinnypoundcmb;
Waitframes(3);
this->Data = prinnypoundcmb+1;
Waitframes(3);
this->Data = prinnypoundcmb+2;
Waitframes(3);
this->Data = prinnypoundcmb+3;
Waitframes(3);
this->Data = prinnypoundcmb+4;
delaySet = true;
}
if(dir == 1)
{
Game->PlaySound(flipsound);
ghost->Damage = prinnyPound;
this->Data = prinnypoundcmb+5;
Waitframes(3);
this->Data = prinnypoundcmb+6;
Waitframes(3);
this->Data = prinnypoundcmb+7;
Waitframes(3);
this->Data = prinnypoundcmb+8;
Waitframes(3);
this->Data = prinnypoundcmb+9;
delaySet = true;
}
}//Delay Check End
if(ghost->Y <= 96)
{
ghost->Y += 4;
}//Coor Check End
if(ghost->Y >= 96)
{
ghost->Y = 96;
Game->PlaySound(poundsound);
Game->PlaySound(poundsound2);
eweapon p = Screen->CreateEWeapon(31);
p->Tile = poundburst;
p->OriginalTile = poundburst;
p->CSet = 1;
p->X = this->X; p->Y = this->Y;
p->Step = 400;
p->Damage = prinnyBarage;
p->Angular = false;
p->Dir = 2;
eweapon p2 = Screen->CreateEWeapon(31);
p2->Tile = poundburst+4;
p2->OriginalTile = poundburst+4;
p2->CSet = 1;
p2->X = this->X; p2->Y = ghost->Y;
p2->Step = 400;
p2->Damage = prinnyBarage;
p2->Angular = false;
p2->Dir = 3;
delaySet = false;
delay = 100;
state = 0;
ghost->Damage = 2;
}//Coor Check End
}//Prinny Pound End
//===========
//Prinny Raid
//===========
if(state == 5)
{
if(!delaySet)
{
delaySet = true;
this->Data = prinnyspin+2;
}
delay --;
Game->PlaySound(raidsound);
eweapon j = Screen->CreateEWeapon(138);
j->Tile = prinnyraidtile;
j->OriginalTile = prinnyraidtile;
j->CSet = 1;
j->X = Rand(240);
j->Y = 1;
j->Step = 400;
j->Damage = prinnyRaid;
j->Angular = false;
j->Dir = 1;
j->NumFrames = 4;
j->ASpeed = 5;
Waitframes(10);
if(delay == 0)
{
delaySet = false;
state = 9;
delay = 200;
}
}
//============
//Prinny Dance
//============
if(state == 6)
{
Game->PlaySound(dancesound);
this->Data = prinnyspin;
Waitframes(20);
this->Data = prinnyspin+1;
Waitframes(15);
this->Data = prinnyspin+2;
Waitframes(10);
random = Rand(3);
if (random == 1)
{
state = 7;
delay = 300;
}
if (random == 2)
{
state = 5;
delay = 25;
}
}
//=============
//Running State
//=============
if(state == 7)
{
if(!delaySet)
{
Game->PlaySound(dashsound);
delaySet = true;
}
ghost->Damage = 8;
if(Link->X > ghost->X)
{
this->Data = prinnyruncmb+3;
ghost->X += 2;
}
if(Link->X < ghost->X)
{
this->Data = prinnyruncmb+1;
ghost->X -= 2;
}
delay --;
//Prevent Leaving Unless Dead
if ( state != 1 )
{
if ( (!canMove(this->X-18, this->Y)) && (this->Vx < 0)){this->Vx=0;}
if ( (!canMove(this->X+25, this->Y)) && (this->Vx > 0)){this->Vx=0;}
if ( (!canMove(this->X, this->Y-18)) && (this->Vy < 0)){this->Vy=0;}
if ( (!canMove(this->X, this->Y+25)) && (this->Vy > 0)){this->Vy=0;}
}//End Prevent Leave
if(delay == 0)
{
delaySet = false;
state = 9;
ghost->Damage = 4;
delay = 150;
}
} // State 7 End
//=======
//Falling
//=======
if(state == 8)
{
if(ghost->Y <= 96)
{
ghost->Y += 3;
if(ghost->Y >= 96)
{
ghost->Y = 96;
state = 0;
delay = 100;
}
}
}
//=====
//Dizzy
//=====
if(state == 9)
{
if(!delaySet)
{
this->Data = prinnyspin+1;
delaySet = true;
}
delay --;
ghost->Damage = 0;
if(delay == 0)
{
state = 0;
delay = 100;
ghost->Damage = 4;
delaySet = false;
}
}
prevHP = ghost->HP; //Get previous HP
} //While End
}//Void Run End
//==========
//Collision
//==========
bool canMove(int x, int y)
{
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove
//==================================
//Homing Projectile
//==================================
void homingprojectile(int x, int y, int tile, int cset, int dmg, int spd, int num, int fspd)
{
eweapon w = Screen->CreateEWeapon(31);
w->Tile = tile; w->OriginalTile = tile;
w->CSet = cset;
w->NumFrames = num; w->ASpeed = fspd;
w->X = x; w->Y = y;
w->Step = spd;
w->Damage = dmg;
w->Angular = true;
int angle = ArcTan((Link->X-x),(Link->Y-y));
w->Angle = angle;
if(angle==-PI || angle==PI) w->Dir=2;
else if(angle==-PI/2) w->Dir=0;
else if(angle==PI/2) w->Dir=1;
else if(angle==0) w->Dir=3;
else if(angle<-PI/2) w->Dir=4;
else if(angle<0) w->Dir=5;
else if(angle>(PI/2)) w->Dir=6;
else w->Dir=7;
}
}//Script End
Thank you to anyone who can help!