// import "std.zh"
// import "string.zh"
// import "ghost.zh"
////////////////////////
/// Candle Ghost FFC ///
////////////////////////
/////////////////////////////////////////////////////////////////////////////
/// D0: Sets Normal Candle or Enemy Candle Type. ///
/// Set to: 1 = Normal -- 2 = Explode (No Damage) -- 3 = Explode (Damage) ///
/// D1: Sets dropset. Set in Quest->Misc Dats->Item Drop Sets ///
/// D2: Sets base enemy. Set to 179 by default. ///
/// D3: Sets Normal, Explode (No Damage), or Explode (Damaging)
/////////////////////////////////////////////////////////////////////////////
ffc script CandleGhost
{
void run(int type, int drop, int CANDLE_ENEMY_ID, int explode, int target, int result, int sound, int dieOnComboChange)
{
if (type == 0){
npc ghost;
// Grab the combo id underneath us so we can tell when it changes.
int loc = ComboAt(CenterX(this), CenterY(this));
int underComboId = Screen->ComboD[loc];
// Wait for something to happen.
bool waiting = true;
while (waiting) {
// If <dieOnComboChange> is set and the combo does change, terminate.
if (dieOnComboChange > 0 && Screen->ComboD[loc] != underComboId) {
return;}
for (int i = 1; i <= Screen->NumLWeapons(); i++) {
lweapon lw = Screen->LoadLWeapon(i);
// If the LWeapon is touching us.
if (lw->CollDetection && Collision(this, lw)) {
waiting = false;}}
Waitframe();}
// Now loop through every combo on screen looking for combos
// matching <target>.
for (loc = 0; loc < 176; loc++) {
bool match = false;
// If <target> is positive, test for Combo ID.
if (target > 0) {
if (Screen->ComboD[loc] == target) {
match = true;}}
// If <target> is negative, test for the flag being present.
else if (target < 0) {
if (ComboFI(loc, -target)) {
match = true;}}
// If the current combo is a match, then transform the combo
// according to <result>.
if (match) {
// If <result> is positive, just change the target to <result>.
if (result > 0) {
Screen->ComboD[loc] = result;}
}}
// Now play the message and sound, if appropriate.
if (sound != 0) {Game->PlaySound(sound);}
ghost->ItemSet=drop;
}
else if (type == 1){
npc ghost;
int timer;
int weaponSprite;
int weaponDamage;
eweapon wpn;
ghost->CollDetection = false;
// Initialize
ghost=Ghost_InitCreate(this, CANDLE_ENEMY_ID);
//ghost=Ghost_Init(this, ghost);
Ghost_SetFlag(GHF_IGNORE_ALL_TERRAIN);
Ghost_SetFlag(GHF_CLOCK);
Ghost_SetFlag(GHF_NO_FALL);
Ghost_SetFlag(GHF_FLYING_ENEMY);
//Ghost_Setflag(GHF_NO_COLLISION);
Ghost_CheckFreeze(this, ghost);
Link->CollDetection = false;
Ghost_SpawnAnimationPuff(this, ghost);
Ghost_SetHitOffsets(ghost, -1, -1, -1, -1);
while(Ghost_HP > 0){
if(Ghost_HP > 0) Ghost_Waitframe(this, ghost, false, false);
}
if (explode == 0){
ghost->ItemSet=drop;
//Quit();
Ghost_Waitframe(this, ghost, true, true);
}
else if (explode == 1){
ghost->ItemSet=drop;
Ghost_Explode(this, ghost);
}
else if (explode == 2){
Link->CollDetection = true;
ghost->ItemSet=drop;
Ghost_ExplodeBlast(this, ghost);
}
}
}
}