Whoever helps me fix this gets a free cookie and permission to use it as they please.
Test quest
//import "string.zh"
//import "ghost.zh"
//Attributes
//Type: Walking enemy
//Step speed: How fast to move
//3 = Death Attr 1: How high to jump
//4 = Death Attr 2: How long to stand still
//5 = Death Attr 3: How long to move
//6 = Extra shots: Collision detection (0: intangible; 1: deals damage and can be killed)
//11 = MUST BE equal to GH_INVISIBLE_COMBO in ghost.zh
//12 = Script slot number (check as you're assigning this to an FFC slot)
//DO NOT ALTER THESE CONSTANTS.
const int ANIMAL_ATTRIB_JUMPHEIGHT = 2;
const int ANIMAL_ATTRIB_STANDTIME = 3;
const int ANIMAL_ATTRIB_MOVETIME = 4;
const int ANIMAL_ATTRIB_COLLDETECT = 5;
ffc script animalNPC{
void run ( int enemyID ){
//Initialize the autoghost 'enemy'
npc ghost = Ghost_InitAutoGhost(this, enemyID, GHF_SET_DIRECTION | GHF_4WAY);
int moveCounter = 0 + Rand(ghost->Attributes[ANIMAL_ATTRIB_STANDTIME]);
bool moving = false;
ghost->CollDetection = ghost->Attributes[ANIMAL_ATTRIB_COLLDETECT];
int ghostStep = ghost->Step; //Save step speed
int ghostZ = ghost->Z; //Save z position
while ( true ){
//If it is moving and on the ground
if ( moving && ghost->Z == 0 ){
ghost->Jump = ghost->Attributes[ANIMAL_ATTRIB_JUMPHEIGHT]; //Jump
}
//Move the ghost
Ghost_Move( ghost->Dir, ghost->Step/100, 0 );
//Increment move counter
moveCounter++;
if ( moving && moveCounter > ghost->Attributes[ANIMAL_ATTRIB_MOVETIME] ){
moving = false;
moveCounter = 0 + Rand(ghost->Attributes[ANIMAL_ATTRIB_MOVETIME])/10;
ghost->Step = 0;
}
else if ( !moving && moveCounter > ghost->Attributes[ANIMAL_ATTRIB_STANDTIME] ){
moving = true;
moveCounter = 0 + Rand(ghost->Attributes[ANIMAL_ATTRIB_STANDTIME])/10;
ghost->Dir = Rand(8);
ghost->Step = ghostStep;
}
//Special waitframe for autoGhost scripts
Ghost_Waitframe(this, ghost, true, true);
}
}
}
Edited by MoscowModder, 21 April 2012 - 10:22 PM.