C-Dawg
12-29-2006, 08:17 PM
This enemy generator code now works.
// ================================================== =====
// ENEMY SPAWNER - This script is used to spawn enemies. The FFC running
// the script will continue to spawn a particular kind of enemy at regular intervals
// until there are too many on the screen, or the combo used by the spawner changes.
//
// D0 = enemy_id = The enemy to be spawned. Check the table in std.zh to get values.
// D1 = delay = The delay, in tics, between enemy spawns.
// D2 = max = The maximum number of enemies that the spawner will put on the screen.
// D3 = spawnX = The X value at which you want the enemy to spawn.
// D4 = spawnY = The Y value at which you want the enemy to spawn.
// ================================================== ====
ffc script enemyspawner{
void run(int enemy_id, int delay, int max, int spawnX, int spawnY){
int original_combo = this->Data; // Saves the original combo of this FFC.
int counter = delay; // Used to count the tics until it is time to spawn.
while(true){
// Checks whether the combo for this FFC has changed, or whether there are
// a maximum number of NPCs on the screen.
if ( (this->Data == original_combo) && (Screen->NumNPCs() < max) ){
// If max tics have gone by since the last time a spawn took place, spawn.
if ( counter == 0 ){
npc spawnee = Screen->CreateNPC(enemy_id);
spawnee->X = spawnX;
spawnee->Y = spawnY;
counter = delay;
}
else{
counter--;
} // end if
} // end if
Waitframe();
} // end of while loop
} // end of void run
} // end of FFC script
// ================================================== =====
// ENEMY SPAWNER - This script is used to spawn enemies. The FFC running
// the script will continue to spawn a particular kind of enemy at regular intervals
// until there are too many on the screen, or the combo used by the spawner changes.
//
// D0 = enemy_id = The enemy to be spawned. Check the table in std.zh to get values.
// D1 = delay = The delay, in tics, between enemy spawns.
// D2 = max = The maximum number of enemies that the spawner will put on the screen.
// D3 = spawnX = The X value at which you want the enemy to spawn.
// D4 = spawnY = The Y value at which you want the enemy to spawn.
// ================================================== ====
ffc script enemyspawner{
void run(int enemy_id, int delay, int max, int spawnX, int spawnY){
int original_combo = this->Data; // Saves the original combo of this FFC.
int counter = delay; // Used to count the tics until it is time to spawn.
while(true){
// Checks whether the combo for this FFC has changed, or whether there are
// a maximum number of NPCs on the screen.
if ( (this->Data == original_combo) && (Screen->NumNPCs() < max) ){
// If max tics have gone by since the last time a spawn took place, spawn.
if ( counter == 0 ){
npc spawnee = Screen->CreateNPC(enemy_id);
spawnee->X = spawnX;
spawnee->Y = spawnY;
counter = delay;
}
else{
counter--;
} // end if
} // end if
Waitframe();
} // end of while loop
} // end of void run
} // end of FFC script