Ahhh, I see Bigjoe beat me to it. But here is the Random version!! ![Biggrin](images/smilies/biggrin.gif)
EDIT: Ah, it's pretty much the same thing....I used en_count as the cap though, feel free to change it to whatever you want.
just change 8 to 100! ....or something else, it's up to you. ![Biggrin](images/smilies/biggrin.gif)
Code:
//====================================================
// D0-D7; Enemies that might spawn,
// <in Addition to boss or any other enemies set to screen enemies> ;)
// Thanks to DarkDragon! :=D
//====================================================
bool is_walkable(int x, int y)
{
return Screen->ComboS[x+y*16]==0;
}
ffc script random_enemy_maker {
void run(int e1, int e2, int e3, int e4, int e5, int e6, int e7, int e8) {
int RandNum = Rand(8);
int en_count = 8;
while(en_count > 0){
if (RandNum == 0){
putenemy(e1);
} if (RandNum == 1){
putenemy(e2);
} if (RandNum == 2){
putenemy(e3);
} if (RandNum == 3){
putenemy(e4);
} if (RandNum == 4){
putenemy(e5);
} if (RandNum == 5){
putenemy(e6);
} if (RandNum == 6){
putenemy(e7);
} if (RandNum == 7){
putenemy(e8);
}
en_count = en_count - 1;
RandNum = Rand(8);
}
}
void putenemy(int eid)
{
//to do this properly we really need priority queues in ZScript ;)
int x = Rand(16);
int y = Rand(11);
while(!is_walkable(x,y))
{
x = Rand(16);
y = Rand(11);
}
npc en = Screen->CreateNPC(eid);
if(en->isValid())
{
en->X = x*16;
en->Y = y*16;
}
//simulate staggered spawning
Waitframe();
}
}
I just tested it too, it's freakin awesome BigJoe. There's no way you can not use this. ![Wink](images/smilies/wink.gif)
And DarkDragon that is freaking amazing. Do you realize what you've just done??? ,You've inadvertantly created freeform bosses!!! Check out a couple pics.
![](https://www.armageddongames.net/cache.php?img=http%3A%2F%2Fwww.mediafire.com%2Fimgbnc.php%2F9606e7738fe4c577630be8c82e02dfe94g.jpg)
![](https://www.armageddongames.net/cache.php?img=http%3A%2F%2Fwww.mediafire.com%2Fimgbnc.php%2F60be4d63772a5f6cd2e1dd1362105c564g.jpg)
I have almost finished a demo dungeon with random doors(and now random enemies)...Sweet. Also this awesome script deserves to be in showcase, whatdya think?