const int SPR_MUMMY_BANDAGE = 116; //Sprite used for bandage eweapons
const int SFX_BANDAGE_LAUNCH = 67; //Sound to play on bandage launching
ffc script MummyMan{
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 BandageD = ghost->WeaponDamage;
int shootfrequency = Ghost_GetAttribute(ghost, 0, 4);//Shoot Chance on halt, 1/4 by default.
int flashcset = Ghost_GetAttribute(ghost, 1, 7);//Cset used for shoot telegraphing flash.
//ghost->Extend=3;
Ghost_SetSize(this, ghost, 1, 3);
Ghost_SetFlag(GHF_NORMAL);
int OrigTile = ghost->OriginalTile;
int OrigCset = ghost->CSet;
int State = 0;
int haltcounter = -1;
eweapon Bandage;
bool canfire=false;
while(true){
if (State==0){
haltcounter =Ghost_HaltingWalk4(haltcounter, SPD, RR, HF, HNG, HR, 48);
if (Ghost_Jump < 0) Ghost_SetFlag(GHF_MOVE_OFFSCREEN);
else Ghost_UnsetFlag(GHF_MOVE_OFFSCREEN);
if (haltcounter == 48){
if (Rand(shootfrequency) == 0) canfire=true;
else canfire=false;
}
if(IsOdd(haltcounter)){
if (canfire) Ghost_CSet= flashcset;
}
else Ghost_CSet=OrigCset;
if (haltcounter ==1){
int BandageAngle=0;
if (Ghost_Dir == DIR_LEFT) BandageAngle = PI;
if (canfire){
Bandage= FireEWeapon(EW_SCRIPT1, Ghost_X, (Ghost_Y+16),
BandageAngle, 100, BandageD, SPR_MUMMY_BANDAGE, SFX_BANDAGE_LAUNCH, 1);
if (BandageAngle== 0) Bandage->Flip = 4;
if (BandageAngle== PI) Bandage->Flip = 5;
if (BandageAngle== 0)SetEWeaponMovement(Bandage, EWM_SINE_WAVE, 16, 3);
if (BandageAngle== PI)SetEWeaponMovement(Bandage, EWM_SINE_WAVE, 16, -3);
}
}
}
//debugValue(1, Ghost_Vy);
MummyAnimation(ghost, OrigTile, State, 4);
Ghost_Waitframe(this, ghost);
}
}
}
//Enemy animation routine
void MummyAnimation(npc ghost, int origtile, int state, int numframes){
int offset = 0;
if ((ghost->Dir) == DIR_RIGHT) offset += numframes*(ghost->TileWidth);
ghost->OriginalTile = origtile + offset;
}