const int SFX_KING_ZOL_LAND = 3;//Sound to play when King Zol lands on ground during intro.
const int KING_ZOL_INITDELAY = 180;//Knig slime introduction duration, in frames.
//King Zol
//Falls from seiling, then moves around, firing eweapons at Link. Repeatedly deal damage to him to split into other enemies, otherwise regenerates.
//Place splitting frame sequence beneath King Zol `s normal tiles.
ffc script SplitSlime{
void run(int enemyID){
npc ghost = Ghost_InitAutoGhost(this, enemyID);
int HF = ghost->Homing;
int HR = ghost->Haltrate;
int RR = ghost->Rate;
int HNG = ghost->Hunger;
int SPD = ghost->Step;
int WPND = ghost->WeaponDamage;
int sizex = Ghost_GetAttribute(ghost, 0, 4);//Tile Width
int sizey = Ghost_GetAttribute(ghost, 1, 4);//Tile Height
int introenemy = Ghost_GetAttribute(ghost, 2, 42);//ID of enemy to split into on death
int splitsizex = Ghost_GetAttribute(ghost, 3, 6);//Splitting sequence X size, in tiles
int splitsizey = Ghost_GetAttribute(ghost, 4, 4);//Splitting sequence Y size, in tiles
int splitnumframes = Ghost_GetAttribute(ghost, 5, 4);//Number of frames in splittinf sequence
int regenspeed = Ghost_GetAttribute(ghost, 6, 30);//HP regeneration delay, in frames
int WPNS = Ghost_GetAttribute(ghost, 7, -1);//Eweapon sprite
int shotspeed = Ghost_GetAttribute(ghost, 8, 180);//Delay between shooting eweapons.
int splitnumenemies = Ghost_GetAttribute(ghost, 9, 2);//Number of enemies to split into on death
ghost->Extend=3;
Ghost_SetSize(this, ghost, sizex, sizey);
if (sizex>2)Ghost_SetHitOffsets(ghost, 4, 4, 8, 8);
int State = 0;
int haltcounter = -1;
int statecounter = KING_ZOL_INITDELAY;
eweapon e;
lweapon l;
int shootcounter=shotspeed;
int Ghost_MaxHP = Ghost_HP;
int origmidi = Game->GetMIDI();
int origtile = ghost->OriginalTile;
Game->PlayMIDI(0);
int offset = 0;
Ghost_SetFlag(GHF_NORMAL);
Ghost_UnsetFlag(GHF_KNOCKBACK);
Ghost_SetFlag(GHF_NO_FALL);
Ghost_SetFlag(GHF_8WAY);
Ghost_UnsetFlag(GHF_KNOCKBACK);
if (KING_ZOL_INITDELAY>0)Ghost_Z = 256;
while(true){
if (State==0){
if (statecounter>0){
statecounter--;
if (statecounter==Floor(KING_ZOL_INITDELAY/2)){
npc drop = SpawnNPC(introenemy);
drop->Z=256;
Game->PlaySound(SFX_FALL);
}
if (statecounter==0){
Game->PlaySound(SFX_FALL);
Ghost_UnsetFlag(GHF_NO_FALL);
}
}
if (Ghost_Z<=0){
if (KING_ZOL_INITDELAY>0){
Game->PlaySound(SFX_KING_ZOL_LAND);
Screen->Quake = 10*sizex*sizey;
}
if (Game->GetMIDI()<=0)Game->PlayMIDI(origmidi);
State=1;
}
}
else if (State==1){
haltcounter = Ghost_ConstantWalk8(haltcounter, SPD, RR, HF, HNG);
shootcounter--;
if (shootcounter<=0){
e = FireAimedEWeapon(ghost->Weapon, CenterX(ghost), CenterY(ghost), 0, 180, WPND, WPNS, -1, 0);
shootcounter=shotspeed;
}
if (Ghost_HP<Ghost_MaxHP){
State=2;
ghost->OriginalTile = GH_BLANK_TILE;
statecounter = regenspeed;
}
}
else if (State==2){
offset = Floor(Lerp(splitnumframes, 0, (Ghost_HP/Ghost_MaxHP)))*splitsizex;
Screen->DrawTile (2, CenterX(ghost)-8*splitsizex, CenterY(ghost)-8*splitsizey, origtile+20*Ghost_TileHeight+offset, splitsizex, splitsizey,Ghost_CSet, -1, -1,0, 0, 0,0,true, OP_OPAQUE);
statecounter--;
if (statecounter<=0){
Ghost_HP++;
statecounter = regenspeed;
if (Ghost_HP==Ghost_MaxHP){
State=1;
ghost->OriginalTile=origtile;
}
}
}
// debugValue(1, Ghost_HP);
// debugValue(2, offset);
if(!Ghost_Waitframe(this, ghost, false, false)){
for (int i=1;i<=splitnumenemies;i++){
npc n = CreateNPCAt(introenemy,Ghost_X+Rand(splitsizex*16),Ghost_Y+Rand(splitsizey*16));
}
Quit();
}
}
}
}
//King Zol (no intro)
//Moves around, firing eweapons at Link. Repeatedly deal damage to him to split into other enemies, otherwise regenerates.
//Place splitting frame sequence beneath King Zol `s normal tiles.
ffc script SplitSlimeNoIntro{
void run(int enemyID){
npc ghost = Ghost_InitAutoGhost(this, enemyID);
int HF = ghost->Homing;
int HR = ghost->Haltrate;
int RR = ghost->Rate;
int HNG = ghost->Hunger;
int SPD = ghost->Step;
int WPND = ghost->WeaponDamage;
int sizex = Ghost_GetAttribute(ghost, 0, 4);//Tile Width
int sizey = Ghost_GetAttribute(ghost, 1, 4);//Tile Height
int introenemy = Ghost_GetAttribute(ghost, 2, 42);// ID of enemy to split into on death,
int splitsizex = Ghost_GetAttribute(ghost, 3, 6);//Splitting sequence X size, in tiles
int splitsizey = Ghost_GetAttribute(ghost, 4, 4);//Splitting sequence Y size, in tiles
int splitnumframes = Ghost_GetAttribute(ghost, 5, 4);//Number of frames in splittinf sequence
int regenspeed = Ghost_GetAttribute(ghost, 6, 30);//HP regeneration delay, in frames
int WPNS = Ghost_GetAttribute(ghost, 7, -1);//Eweapon sprite
int shotspeed = Ghost_GetAttribute(ghost, 8, 180);//Delay between shooting eweapons.
int splitnumenemies = Ghost_GetAttribute(ghost, 9, 2);//Number of enemies to split into on death
ghost->Extend=3;
Ghost_SetSize(this, ghost, sizex, sizey);
if (sizex>2)Ghost_SetHitOffsets(ghost, 4, 4, 8, 8);
int State = 1;
int haltcounter = -1;
int statecounter = 0;
eweapon e;
lweapon l;
int shootcounter=shotspeed;
int Ghost_MaxHP = Ghost_HP;
// int origmidi = Game->GetMIDI();
int origtile = ghost->OriginalTile;
// Game->PlayMIDI(0);
int offset = 0;
Ghost_SetFlag(GHF_NORMAL);
Ghost_UnsetFlag(GHF_KNOCKBACK);
Ghost_SetFlag(GHF_NO_FALL);
Ghost_SetFlag(GHF_8WAY);
Ghost_UnsetFlag(GHF_KNOCKBACK);
while(true){
if (State==1){
haltcounter = Ghost_ConstantWalk8(haltcounter, SPD, RR, HF, HNG);
shootcounter--;
if (shootcounter<=0){
e = FireAimedEWeapon(ghost->Weapon, CenterX(ghost), CenterY(ghost), 0, 180, WPND, WPNS, -1, 0);
shootcounter=shotspeed;
}
if (Ghost_HP<Ghost_MaxHP){
State=2;
ghost->OriginalTile = GH_BLANK_TILE;
statecounter = regenspeed;
}
}
else if (State==2){
offset = Floor(Lerp(splitnumframes, 0, (Ghost_HP/Ghost_MaxHP)))*splitsizex;
Screen->DrawTile (2, CenterX(ghost)-8*splitsizex, CenterY(ghost)-8*splitsizey, origtile+20*Ghost_TileHeight+offset, splitsizex, splitsizey,Ghost_CSet, -1, -1,0, 0, 0,0,true, OP_OPAQUE);
statecounter--;
if (statecounter<=0){
Ghost_HP++;
statecounter = regenspeed;
if (Ghost_HP==Ghost_MaxHP){
State=1;
ghost->OriginalTile=origtile;
}
}
}
if(!Ghost_Waitframe(this, ghost, false, false)){
for (int i=1;i<=splitnumenemies;i++){
npc n = CreateNPCAt(introenemy,Ghost_X+Rand(splitsizex*16),Ghost_Y+Rand(splitsizey*16));
}
Quit();
}
}
}
}