Infinitely generated enemies

danno

Moderator
Staff member
Hey guys, long time no see, hope ya'll are doing well, I need help, looked on the forum over the last few days and couldn't find anything on infinitely generating bad guys, not one after the over so the screen fills up, more like this as an example
https://www.youtube.com/watch?v=N4LyIKU2qmM
no more than 3 or 4 enemies on the screen at one time but as soon as one dies another pops up, its the same question I posted on LavaLit years ago but it wasn't possible in those days.
 
You could do this by script you need to count enemies and use spawn to well spawn them.  You could use a level update script to keep checking and spawning enemies or a invisible entity but a level update script might be less tacky.
 
ahh script, I couldn't write a script to save my life 

void main (save life)
{
can do? if = not then death \\ this is where i die trying
caller death yes;
}

any chance you can help me out here with a script msmalik681? 
 
Lol you funny guy  ;D


Ok so you want a enemy to spawn if the enemy count drops below 4 right ?


Do you want random enemies or a fixed enemy for each level ?? Do you want enemies to spawn randomly left and right or rotation left then right ?
 
Hi Danno. I use those two script for that, on my animationscript file

Code:
void reinforcement (int Enemies,void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz)
{
    void self = getlocalvar("self");
    int Enemy = openborvariant("count_enemies");

    if(Enemy < Enemies){
	spawnAni(vName, fX, fY,fZ,Ani,Vx,Vy,Vz);
	}
}

void reinforcementCheck (int Enemies, void Ani)
{
// Check how much enemies are on the screen and if it less than the desired, change caller animation
// Douglas Baldan - 28/09/2016
    void self = getlocalvar("self");
    int Enemy = openborvariant("count_enemies");

    if(Enemy < Enemies){
	performattack(self, openborconstant(Ani));
	}
}

ReinforcementCheck was made to check how much enemies I have on the screen.  If the name is less then I want, I force the entity to change the animation;
@cmd reinforcementCheck 2 "ANI_FOLLOW3"

I put this in my the idle animation of my character. So if there are less than 2 enemies on the screen, my enemy will execute the FOLLOW3 animation.

You can use a simple summonframe to call for more enemies, or if you want a scripted funcion, you can use the one above. That function will call an enemy, at the desired position, in the desired animation and with the desired velocity.

This is how I use it:
@cmd reinforcement 3 "flamethrower" -400 30 0 "ANI_FOLLOW8" -3 0 4
@cmd reinforcement 3 "sparker" 400 30 0 "ANI_FOLLOW6" 3 0 4

This is what I use on most bosses of my Avengers game, so they are never alone and will keep calling for help if you kill all the enemies.
 
@msmalik681 Fixed enemys, level specific, random left and right but I'll give O Ilusionista's script a try first, will try it in the morning though as I'm about to go to bed, Thank you I really appreciate it.

@ O Ilusionista you've given me a reason to wake up tomorrow, I'm grateful,  I'll  update you guys with results.

 
What am I doing wrong exactly?

I named your script "spawn" and put it in the scripts folder
Code:
name	Shermie
health	50
speed	8
type	enemy
shadow	4
icon	data/chars/shermie/icon.gif
diesound data/sounds/eek.wav
animationscript  data/scripts/spawn.c
this is enemy's header
Code:
anim FOLLOW3
	loop	0
	offset	38 128
	bbox	25 21 33 110
	delay	10
        @cmd   reinforcement 3 "lobster" -400 30 0 "walk" -3 0 4
        @cmd   reinforcement 3 "lobster" 400 30 0 "walk" 3 0 4
	frame	data/chars/shermie/walk00.gif


anim walk
	loop	1
	offset	51 117
	bbox	38 9 25 110
	delay	7
@cmd    reinforcementCheck 2 "ANI_FOLLOW3"
	frame	data/chars/shermie/walk00.gif
	frame	data/chars/shermie/walk01.gif
	frame	data/chars/shermie/walk02.gif
	frame	data/chars/shermie/walk03.gif
	frame	data/chars/shermie/walk04.gif
	frame	data/chars/shermie/walk05.gif
	frame	data/chars/shermie/walk06.gif
	frame	data/chars/shermie/walk07.gif
	frame	data/chars/shermie/walk08.gif
this is animation data (which i think I did something wrong)
Code:
Can't compile script 'Shermie' data/chars/shermie/shermie.txt
I get this error as the first stage starts to load

 
Hi Danno, welcome back, been a while :D

Anyways, infinite enemy spawner is doable, in fact I've implemented that in some mods such as Castlevania collab demo, Contra : Locked 'N' Loaded, Aliens Clash and Cherry On top

I'll get back to you later (kinda busy ATM)
 
First, It's  not "walk", it should be "ANI_WALK ". You always need to add ANI_ before the animation  name.

Second, my bad, I forgot to paste the other function you will need in your animationscript

Code:
void spawnAni(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz)
{
	//spawnB (Generic spawner) + Specific animation + velocities
	//Damon Vaughn Caskey + Douglas Baldan
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fZ: Y location adjustment.
      //fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");

	clearspawnentry(); //Clear current spawn entry.
    setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
		  Vx = -Vx; //Reverse X velocity
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);
	performattack(vSpawn, openborconstant(Ani), 1);	
    
	return vSpawn; //Return spawn.
}
 
@Bloodbane Hey  :-* good to see you, hope you are happy and healthy, thanks for the welcome back, you ready for my annoying questions? hahaha

@O Ilusionista this is great.
Added the exta code to the script and changed to ANI_WALK
It does work  :o but not the desired effect, see video for example, shermie didn't spawn lobster while she was fighting alone but when more enemies were on screen (more than 2) they spawned, is this because of lobster spawn location?
https://www.youtube.com/watch?v=idWX--bjr04
 
Strange, check your "group" setting and check if Shermie is playing the right animation.
Also, WALK is a looped animation and should not be used for that. Create a new animation on those characters, like FOLLOW1, and use this animation.
 
What you suggested works much better, the only problem is I need to use loop animations like in the original Black Belt game, are there some variables I can change? because its like each enemy needs to check as soon as it spawns and travels towards the hero
https://www.youtube.com/watch?v=VFbQqQzHBM8
 
@ilu
I thought it was a bit weird you using a animation script to spawn enemies but I guess for this type of game it would fit so the animation script would be called when the hero is walking as that is when enemies should spawn.


@danno
what video mode is your mod ?
 
You know, to spawn enemies like in Black Belt game, it's best to use an invisible spawner entity to do the spawning. That spawner is a type none so it's not affected by group nor be counted as enemy
 
@BB
I disagree using the players walk animation would be the best option as when you change level you can use a weapon model with a altered walk animation to spawn different enemies and when idle enemies wont spawn.
 
msmalik681 said:
@ilu
I thought it was a bit weird you using a animation script to spawn enemies but I guess for this type of game it would fit so the animation script would be called when the hero is walking as that is when enemies should spawn.


@danno
what video mode is your mod ?
The only problem I can see with the hero walking is at some point the script is going to need to disable when the boss of the stage appears
I'm just using the default resolution for now to test things out eventually the mod i'll start working on will be 960x540

@Bloodbane could you explain in more detail and show me an example of what you mean?

I was thinking in might be best to spawn another enemy entity while in an entity's death animation so as one entity dies another is spawned
 
@ilu
I thought it was a bit weird you using a animation script to spawn enemies but I guess for this type of game it would fit so the animation script would be called when the hero is walking as that is when enemies should spawn.
I don't see why this would be weird, care to elaborate?

@dano
You can use this code into a invisible type none which check for enemies and spawn more enemies. You won't even need the second function, just the "reinforcementCheck". You can spawn more enemies using the summonframe. If you want them to just walk all the way without chasing the player, you can make their spawn animation looped.

But, again, you will need a script to force the enemy to attack the player once it gets near to a player.

How your game will work? On a 2d style like Black Belt?

I was thinking in might be best to spawn another enemy entity while in an entity's death animation so as one entity dies another is spawned
And them your game will lock in place, because GROUP /Wait setting changes only when the enemy is killed (removed from the screen). While its dying (death anim), its still a valid entity.
 
O Ilusionista said:
How your game will work? On a 2d style like Black Belt?
Yeah the same, like this but much better, I don't want to just spawn enemy at''' I would like it so even if the player doesn't scroll enemies still spawn Infinitely but no more than 4 enemies (2 on each side) at one time, I think your method is good for a boss fight on a non 2d stage but I'm not sure its fast enough for what I would like to do.
https://www.youtube.com/watch?v=gtp627_Me78
 
Back
Top Bottom