[Script] Enemy Spawn Limiter

Viper Snake

Member
I couldn't find any scripts here for this, so I made my own by modifying the MP limiter script. This will prevent an enemy from performing an animation based on how many are alive.

Code:
void spawnlimiter(int Limit)
{// Prevents an enemy from performing an animation if there are too many enemies alive.
 // Viper Snake - 6/16/2015
    void self = getlocalvar("self");
    int spawnMAX = openborvariant("count_enemies"); //How many enemies?
    int y = getentityproperty(self,"a"); //Get entity's altitude
    int b = getentityproperty(self, "base"); //Get entity's base

   if(spawnMAX>=Limit) //Enemy limit reached?
   {
     if(y > b) // Mid air?
     {
       changeentityproperty(self, "animation", openborconstant("ANI_JUMP") );
     } else{
       setidle(self); //Don't play the animation
     }
   }
}

Usage: @cmd spawnlimiter <enemy limit>

Example:

The Melty Zombie from Castlevania: Harmony of Dissonance can spit out acid that creates another Melty Zombie. This script prevents the game from eventually locking up due to a massive amount of Melty Zombies on screen.

Code:
anim	attack2
	@cmd	spawnlimiter 10
	delay	10
	range	220 260
	loop	0
	offset	64 84
	bbox	32 14 92 70
	attack7	30 12 92 72 10 0 0 1 0 0
	move	0
	frame	data/chars/melty_zombie/8.png
	attack7	0 0 0 0 0 0 0 0 0 0
	bbox	36 12 92 72
	offset	66 84
	frame	data/chars/melty_zombie/11.png
	attack7	34 8 94 76 10 0 1 0 0 0
	bbox	36 10 94 74
	offset	64 84
	frame	data/chars/melty_zombie/12.png
	attack7	0 0 0 0 0 0 0 0 0 0
	bbox	36 4 102 80
	frame	data/chars/melty_zombie/13.png
	attack7	34 2 102 82 10 0 0 1 0 0
	@cmd	spawn01map "melty_zombie_spit" 80 30 0	
	frame	data/chars/melty_zombie/14.png
	attack7	0 0 0 0 0 0 0 0 0 0
	bbox	36 10 94 74
	frame	data/chars/melty_zombie/12.png
	delay	5
	attack7	32 10 94 74 10 0 0 1 0 0
	bbox	36 12 92 72
	offset	66 84
	frame	data/chars/melty_zombie/11.png
	attack7	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/melty_zombie/11.png

 
Hi Viper.
I think you had posted the wrong code. That code, actually, checks if the entity is on the air and, if so, changes to the JUMP animation. There is no entity check on that.
 
O Ilusionista said:
Hi Viper.
I think you had posted the wrong code. That code, actually, checks if the entity is on the air and, if so, changes to the JUMP animation. There is no entity check on that.

That is just so the entity animation looks good if airborne when trying to attack instead of just using idle. This script uses "count_enemies" to check how many exist.
 
O Ilusionista said:
Ah, Now it uses count :)

I didn't change the script at all, when I edited my original post I fixed a small typo:
Usage: @cmd <enemy limit>
to
Usage: @cmd spawnlimiter <enemy limit>
It was correct in the example. :)
 
Back
Top Bottom