PDA

View Full Version : Enemy Generator



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

The_Amaster
12-29-2006, 08:26 PM
Soo...what does it do? I'm sorry, I'm no good at interperating code.

C-Dawg
12-29-2006, 08:47 PM
I include a detailed description of each script in the comments.

// ================================================== =====
// 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.
// ================================================== ====

So you can make a beehive that constantly spits out bees (keese?), for instance. Set the FFC to be a Strike combo if you'd like Link to be able to turn it off by hitting it. Be creative, there are lots of uses for this.

cbailey78
01-01-2007, 05:40 PM
You should post a quest so people can check it out.

C-Dawg
01-01-2007, 07:24 PM
I did. Go check my thread over in the Developer's forum.

Lotus_Eater
01-01-2007, 08:40 PM
Hmm, a Gauntlet Quest is now in order :)

bluedeath
01-02-2007, 08:54 AM
I cant find the quest..

C-Dawg
01-02-2007, 10:14 AM
Then just implement the code yourself according to the instructions in the comments. Given that you're having a hard time finding the quest file, I bet it'll take you less time to compile it and set up an ffc than it will to download the file.