ffc script MegaXBoss
{
void run(int enemyID)
{
npc ghost = Ghost_InitAutoGhost(this, enemyID);
int maxHP = Ghost_HP;
int counter = -1;
int timer_attack = 90;
int attack;
bool speedup;
eweapon ewpn;
while (true)
{
counter = Ghost_ConstantWalk4(counter, ghost->Step, ghost->Rate, ghost->Homing, ghost->Hunger);
if (timer_attack <= 0)
{
if (Ghost_HP > maxHP * 0.5)
{
attack = Choose(1, 2, 3);
}
else
{
attack = Choose(1, 2, 3, 4, 5);
}
if (Ghost_HP <= maxHP * 0.25)
{
timer_attack = Rand(45, 100);
}
else
{
timer_attack = Rand(75, 130);
}
if (attack == 1)
{
MegaXAttack1(this, ghost);
}
else if (attack == 2)
{
MegaXAttack2(this, ghost);
}
else if (attack == 3)
{
MegaXAttack3(this, ghost);
}
else if (attack == 4)
{
MegaXAttack4(this, ghost);
}
else if (attack == 5)
{
MegaXAttack5(this, ghost);
}
}
else
{
timer_attack--;
}
if (Ghost_HP <= maxHP * 0.25 && !speedup)
{
ghost->Step *= 1.5;
speedup = true;
}
MegaX_Waitframe(this, ghost);
}
}
}
void MegaXAttack1(ffc this, npc ghost)
{
int loc[3];
int npc_id[3];
MegaX_Waitframes(this, ghost, 30);
Game->PlaySound(SFX_SUMMON);
for (int i = 0; i < 3; i++)
{
loc[i] = FindSpawnPoint(true, false, false, false);
npc_id[i] = Choose(NPC_OCTOROCK1S, NPC_KEESE1, NPC_MOBLIN1);
lweapon spawnpuff = CreateLWeaponAt(LW_SPARKLE, ComboX(loc[i]), ComboY(loc[i]));
//spawnpuff->CollDetection = false;
spawnpuff->UseSprite(22);
spawnpuff->NumFrames = 3;
spawnpuff->ASpeed = 3;
//spawnpuff->DeadState = spawnpuff->NumFrames * spawnpuff->ASpeed;
}
MegaX_Waitframes(this, ghost, 12);
for (int i = 0; i < 3; i++)
{
CreateNPCAt(npc_id[i], ComboX(loc[i]), ComboY(loc[i]));
}
MegaX_Waitframes(this, ghost, 30);
}
void MegaXAttack2(ffc this, npc ghost)
{
eweapon firebomb;
float angle;
MegaX_Waitframes(this, ghost, 30);
for (int i = 0; i < 3; i++)
{
angle = Randf(0, PI2);
firebomb = FireEWeapon(EW_SCRIPT1, Ghost_X, Ghost_Y, angle, 200, ghost->WeaponDamage, 17, SFX_FIREBALL, EWF_UNBLOCKABLE);
SetEWeaponDeathEffect(firebomb, EWD_EXPLODE, ghost->WeaponDamage);
firebomb->Misc[0] = 22222;
MegaX_Waitframes(this, ghost, 20);
}
MegaX_Waitframes(this, ghost, 30);
}
void MegaXAttack3(ffc this, npc ghost)
{
eweapon bomb;
float angle;
MegaX_Waitframes(this, ghost, 30);
MegaX_JumpToCenter(this, ghost);
MegaX_Waitframes(this, ghost, 10);
for (int i = 0; i < 8; i++)
{
angle = RadianAngle(Ghost_X, Ghost_Y, Link->X, Link->Y);
bomb = FireEWeapon(EW_BOMB, Ghost_X, Ghost_Y, angle, 300, ghost->WeaponDamage * 2, 7, 0, EWF_UNBLOCKABLE | EWF_ROTATE);
bomb->Misc[0] = 33333;
MegaX_Waitframes(this, ghost, 20);
}
MegaX_Waitframes(this, ghost, 30);
}
void MegaXAttack4(ffc this, npc ghost)
{
eweapon fire;
int draw_offset_x = ghost->DrawXOffset;
int hit_offset_x = ghost->HitXOffset;
int loc;
float xscale;
float yscale;
float angle;
MegaX_Waitframes(this, ghost, 30);
for (int i = 0; i < 5; i++)
{
ghost->DrawXOffset = -1000;
ghost->HitXOffset = -1000;
Game->PlaySound(SFX_WAND);
for (int j = 0; j < 10; j++)
{
xscale = 16 * (1 - ((j + 1) / 10));
yscale = 16 * (1 + ((j + 1) / 10));
Screen->DrawTile(3, Ghost_X + 8 - (0.5 * xscale), Ghost_Y + 8 - (0.5 * yscale), ghost->Tile, 1, 1, Ghost_CSet, xscale, yscale, 0, 0, 0, 0, true, OP_OPAQUE);
MegaX_Waitframe(this, ghost);
}
loc = FindSpawnPoint(true, false, false, false);
Ghost_X = ComboX(loc);
Ghost_Y = ComboY(loc);
for (int j = 0; j < 10; j++)
{
xscale = 16 * ((j + 1) / 10);
yscale = 16 * (2 - ((j + 1) / 10));
Screen->DrawTile(3, Ghost_X + 8 - (0.5 * xscale), Ghost_Y + 8 - (0.5 * yscale), ghost->Tile, 1, 1, Ghost_CSet, xscale, yscale, 0, 0, 0, 0, true, OP_OPAQUE);
MegaX_Waitframe(this, ghost);
}
ghost->DrawXOffset = draw_offset_x;
ghost->HitXOffset = hit_offset_x;
angle = RadianAngle(Ghost_X, Ghost_Y, Link->X, Link->Y);
fire = FireEWeapon(EW_SCRIPT1, Ghost_X, Ghost_Y, angle, 200, ghost->WeaponDamage * 2, 35, SFX_FIRE, EWF_UNBLOCKABLE);
SetEWeaponDeathEffect(fire, EWD_8_FIRES, 35);
fire->Misc[0] = 44444;
MegaX_Waitframes(this, ghost, 10);
}
MegaX_Waitframes(this, ghost, 30);
}
void MegaXAttack5(ffc this, npc ghost)
{
eweapon fireball;
float angle;
MegaX_Waitframes(this, ghost, 30);
MegaX_JumpToCenter(this, ghost);
MegaX_Waitframes(this, ghost, 30);
for (int i = 0; i < 300; i++)
{
if (i % 5 == 0)
{
angle = RadianAngle(Ghost_X, Ghost_Y, Link->X, Link->Y);
fireball = FireEWeapon(EW_SCRIPT1, Ghost_X, Ghost_Y, angle, 200, ghost->WeaponDamage, 17, SFX_FIREBALL, EWF_UNBLOCKABLE);
}
MegaX_Waitframe(this, ghost);
}
MegaX_Waitframes(this, ghost, 30);
}
void MegaX_JumpToCenter(ffc this, npc ghost)
{
float jump = 4;
Game->PlaySound(SFX_JUMP);
Ghost_Jump = jump;
float x = Ghost_X;
float y = Ghost_Y;
int dest_x = 120;
int dest_y = 80;
float t;
float t0 = jump / (0.5 * GRAVITY);
float t1 = (jump + TERMINAL_VELOCITY) / GRAVITY;
float t2 = ((-0.5 * GRAVITY * Pow(t1, 2)) + (jump * t1)) / TERMINAL_VELOCITY;
if (t0 < t1)
{
t = t0;
}
else
{
t = t1 + t2;
}
float v = Distance(Ghost_X, Ghost_Y, dest_x, dest_y) / t;
float angle = Angle(Ghost_X, Ghost_Y, dest_x, dest_y);
Ghost_ForceDir(AngleDir4(WrapDegrees(angle)));
for (int i = 0; i < t; i++)
{
x += VectorX(v, angle);
y += VectorY(v, angle);
Ghost_X = Round(x);
Ghost_Y = Round(y);
MegaX_Waitframe(this, ghost);
}
}
void MegaX_Waitframe(ffc this, npc ghost)
{
eweapon ewpn;
float e_vx;
float e_vy;
float e_vx_new;
float e_vy_new;
float step;
for (int i = 1; i <= Screen->NumEWeapons(); i++)
{
ewpn = Screen->LoadEWeapon(i);
if (ewpn->ID == EW_SCRIPT1 && ewpn->Misc[0] == 22222)
{
step = ewpn->Step * 0.01;
e_vx = VectorX(step, RadtoDeg(ewpn->Angle));
e_vy = VectorY(step, RadtoDeg(ewpn->Angle));
e_vx_new = e_vx;
e_vy_new = e_vy;
if (e_vx < 0 && (Screen->isSolid(ewpn->X, ewpn->Y + 8) || ewpn->X <= 0))
{
e_vx_new *= -1;
}
if (e_vx > 0 && (Screen->isSolid(ewpn->X + 16, ewpn->Y + 8) || ewpn->X + 16 >= 255))
{
e_vx_new *= -1;
}
if (e_vy < 0 && (Screen->isSolid(ewpn->X + 8, ewpn->Y) || ewpn->Y <= 0))
{
e_vy_new *= -1;
}
if (e_vy > 0 && (Screen->isSolid(ewpn->X + 8, ewpn->Y + 16) || ewpn->Y + 16 >= 175))
{
e_vy_new *= -1;
}
if (e_vx != e_vx_new || e_vy != e_vy_new)
{
ewpn->Angle = ArcTan(e_vx_new, e_vy_new);
ewpn->Misc[1]++;
}
if (ewpn->Misc[1] > 4 || LinkCollisionMod(ewpn))
{
KillEWeapon(ewpn);
ewpn->Misc[1] = 100;
}
if (ewpn->Misc[1] < 100 && ewpn->X > -4 && ewpn->X < 260 && ewpn->Y > -4 && ewpn->Y < 180)
{
ewpn->DeadState = WDS_ALIVE;
}
}
if (ewpn->ID == EW_BOMB && ewpn->Misc[0] == 33333 && false)
{
if (Screen->isSolid(ewpn->X + 8, ewpn->Y + 8))
{
KillEWeapon(ewpn);
}
}
if (ewpn->ID == EW_SCRIPT1 && ewpn->Misc[0] == 44444)
{
if (Screen->isSolid(ewpn->X + 8, ewpn->Y + 8))
{
KillEWeapon(ewpn);
}
}
}
Ghost_Waitframe(this, ghost, 1, true);
}
void MegaX_Waitframes(ffc this, npc ghost, int num)
{
for (int i = 0; i < num; i++)
{
MegaX_Waitframe(this, ghost);
}
}
bool LinkCollisionMod(eweapon b)
{
int ax = Link->X + Link->HitXOffset;
int bx = b->X + b->HitXOffset;
int ay = Link->Y + Link->HitYOffset;
int by = b->Y + b->HitYOffset;
return RectCollision(ax+8, ay+8, ax+Link->HitWidth-8, ay+Link->HitHeight-8, bx, by, bx+b->HitWidth, by+b->HitHeight) && (Link->Z + Link->HitZHeight >= b->Z) && (Link->Z <= b->Z + b->HitZHeight);
}