//Evil Slider
//Slides around like iceblock - in a straight way until hitting obstacle. If Weapon Damage is >0, he fires eweapon for every combo traveled during slide.
//Uses 2 rows for animation. Homing factor determines whether it prefers moving torwards Link, or in random direction. Step speed used.
ffc script Evil_Slider{
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 Slidedelay = Ghost_GetAttribute(ghost, 0, 0);//Delay between slides.
int WPNS = Ghost_GetAttribute(ghost, 1, -1);//Eweapon sprite.
int sizex = Ghost_GetAttribute(ghost, 2, 1);//Tile Width
int sizey = Ghost_GetAttribute(ghost, 3, 1);//Tile Height
int terrain = Ghost_GetAttribute(ghost, 4, 0);//Allowed terrain to land onto. Add together: 1 - solid combos, 2 - water, 4 - pits.
int hitsfx = Ghost_GetAttribute(ghost, 5, 0);//Sound to play, when enemy finishes slide by hitting an obstacle.
int wpnspeed = Ghost_GetAttribute(ghost, 6, 80);//Eweapon firing speed
int startsfx = Ghost_GetAttribute(ghost, 7, 0);//Sound to play, when enemy starts sliding
ghost->Extend=3;
Ghost_SetSize(this, ghost, sizex, sizey);
if (sizex>2)Ghost_SetHitOffsets(ghost, 8, 8, 8, 8);
Ghost_SetFlag(GHF_NORMAL);
int haltcounter = -1;
int statecounter = Slidedelay;
eweapon e;
int angle=0;
int dir=Ghost_Dir;
int origtile = ghost->OriginalTile;
int offset = 0;
int angle4[4]={-90,0,90,180};
int cmb = ComboAt(CenterX(ghost),CenterY(ghost));
int origcmb = cmb;
int State=0;
Ghost_SetFlag(GHF_NORMAL);
Ghost_UnsetFlag(GHF_KNOCKBACK);
if ((terrain&1)>0)Ghost_SetFlag(GHF_IGNORE_SOLIDITY);
if ((terrain&2)>0)Ghost_SetFlag(GHF_IGNORE_WATER);
if ((terrain&4)>0)Ghost_SetFlag(GHF_IGNORE_PITS);
int defs[18];
Ghost_StoreDefenses(ghost,defs);
while(true){
if (State==0){
statecounter--;
if (statecounter==0){
angle = Angle(CenterX(ghost),CenterY(ghost),CenterLinkX(),CenterLinkY());
if (Rand(256)>=HF) dir = Rand(3);
else dir = AngleDir4(angle);
offset = 20*Ghost_TileHeight;
if(Ghost_CanMove(dir, 1, 3)){
Game->PlaySound(startsfx);
State=1;
}
else statecounter = 4;
}
}
else if (State==1){
Ghost_Move(dir, SPD/100, 3);
cmb = ComboAt(Ghost_X+7,Ghost_Y+7);
if (cmb!=origcmb&&WPND>0){
e=FireAimedEWeapon(ghost->Weapon, CenterX(ghost)-8, CenterY(ghost)-8, 0, wpnspeed, WPND, WPNS, -1, EWF_ROTATE);
origcmb=cmb;
}
if(!Ghost_CanMove(dir, 1, 3)){
Game->PlaySound(hitsfx);
//cmb = ComboAt(Ghost_X+7,Ghost_Y+7);
Ghost_X = ComboX(cmb);
Ghost_Y = ComboY(cmb);
statecounter = Slidedelay;
offset = 0;
State=0;
}
}
ghost->OriginalTile = origtile+offset;
Ghost_Waitframe(this, ghost);
}
ghost->OriginalTile = origtile+offset;
Ghost_Waitframe(this, ghost);
}
}