//Spiralonster
//Moves in spiral pattern, firing eweapons. Best used with enemy spawners.
ffc script Spiralonster{
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 InitAngle = Ghost_GetAttribute(ghost, 0, 0);//Initial angle in polar coordinate system, relative to original spawn point.
int InitR = Ghost_GetAttribute(ghost, 1, 0);//Initial radius in polar coordinate system, relative to original spawn point.
int Rspeed = Ghost_GetAttribute(ghost, 2, 20);//spiral growth speed, in 1/100th of pixel per frame.
int AngSpeed = Ghost_GetAttribute(ghost, 3, 1);//Angular speed of moving, in 1/10th of degree per frame. Negative for counter-clockwise movement.
int sizex = Ghost_GetAttribute(ghost, 4, 1);//Tile Width
int sizey = Ghost_GetAttribute(ghost, 5, 1);//Tile Height
int shootspeed = Ghost_GetAttribute(ghost, 6, 60);//Delay between shooting, in frames.
int WPNS = Ghost_GetAttribute(ghost, 7, -1);//Eweapon sprite.
ghost->Extend=3;
Ghost_SetSize(this, ghost, sizex, sizey);
if (sizex>2)Ghost_SetHitOffsets(ghost, 8, 8, 8, 8);
Ghost_SetFlag(GHF_NORMAL);
Ghost_SetFlag(GHF_MOVE_OFFSCREEN);
int OrigTile = ghost->OriginalTile;
int State = 0;
int statecounter = shootspeed;
int haltcounter = -1;
int angle = InitAngle;
int radius = InitR;
int origX = Ghost_X;
int origY = Ghost_Y;
eweapon e;
while(true){
if (State==0){
radius+=Rspeed/100;
angle+=AngSpeed/10;
if (angle>360)angle-=360;
if (angle<0)angle+=360;
Ghost_X=origX+(radius*Cos(angle));
Ghost_Y=origY+(radius*Sin(angle));
statecounter--;
if(statecounter==0 && WPND>0){
FireAimedEWeapon(ghost->Weapon, CenterX(ghost)-8, CenterY(ghost)-8, 0, 80, WPND, WPNS, -1, EWF_ROTATE);
statecounter=shootspeed;
}
else if (WPND==0)statecounter=shootspeed;
}
Ghost_Waitframe(this, ghost);
}
}
}