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.
 
OK so I gave it a try and here is what I have : http://www.mediafire.com/file/djabls7asaw5zn2/Kung%20Fu%20Master%20V2.0.zip

look over mary for example remember to declare the animation script and run it before the first frame of walk, run, jump and any other moves that may move forward here is how it works:

Code:
@cmd   eSpawn "example" "Shermie" 4 1800

So to break that down its:

@cmd eSpawn (branch name) (enemy name) (max enemies) (stop spawning after x value reached)

There is also a loop that checks if any enemies on screen do not match the generic enemy you set all spawns will stop until they are defeated.  make sure you set group limit higher then enemy limit I set "group 5 5" to spawn yashero as a mini boss if you want to spawn 2 set "group 6 6" I am sure you get the idea.  also as you set the branch name you can have multiple eSpawn commands each with different variables to suite each branch any that do not match the current branch will be ignored.

here is the script behind it:

Code:
void spawnscreen(void vName, float fX, float fZ, int iDirection, char Alias)
{
   //spawnscreen (Generic spawner with alias and relative to screen)
   //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 vSpawn; //Spawn object.


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


   changeentityproperty(vSpawn, "position",openborvariant("xpos")+fX,openborvariant("ypos")+fZ, 0); //Set spawn location.
   if(iDirection){changeentityproperty(vSpawn, "direction", iDirection);} //Set direction.
       if(Alias){changeentityproperty(vSpawn, "name", Alias);} //Set Alias to spawned entity
   return vSpawn; //Return spawn.
}




void eSpawn(char branch, char name, int limitE, float limitX )
{//kung fu master style enemy spawner by msmalik681


char branchC = openborvariant("current_branch"); //current branch name
if(branchC != NULL() )
{
if(branch==branchC) //the set brach has to match current level branch name
{
float x;
int dir;
int stop = 0; //stop flag


int  iEntity; //loop number
   for(iEntity=0; iEntity<openborvariant("ent_max"); iEntity++){
   if(getentityproperty(getentity(iEntity),"name")!=name && getentityproperty(getentity(iEntity),"type")==openborconstant("TYPE_ENEMY")){stop=1;break;} //if enemy is not set enemy
        }


int ec = openborvariant("count_enemies"); //count how many enemies on screen
int random = (openborvariant("elapsed_time")/ec)%2; //random number 1 or 0
float playerX = getentityproperty(getlocalvar("self"),"x"); //get player x location


if(ec<limitE && stop==0 && playerX<limitX)
 {
 if(random==0){x=-20; dir=1;} else {x=(openborvariant("hresolution")+40); dir=0;}
 spawnscreen(name,x,openborvariant("levelheight"),dir);
 }
}
}
}


it should work on any video mode I just presumed the game will have no z depth and the level min and max are the same.
 
msmalik681 said:
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.

Danno has posted one of the reason I disagree with your idea
The second reason is with invisible enemy spawner, we can control how many enemies and from which scrollpos & to which scrollpos enemies will constantly be spawned
Watch this old video by me:

Pay attention to giant alien flies and skull aliens which spawn from left or right. FYI they aren't spawned manually using at instead they are spawned by invisible enemy spawner.
The spawners have been coded to remove themselves if they are offscreen for certain pixels. With a little spawn positioning, I can control from where the spawners work and at where the spawners stop ;)
From the video, you could see that those spawners stop spawning just before subboss and boss fight

danno said:
Could you give me a coded example of how to set up the invisible entity panel

Umm... I could give you example of that BUT using type panel won't allow you to control where spawners start spawning and where they will stop

So danno, which spawning system do you prefer?
 
I think for making a Remake of Black belt msmalik681's script is perfect, It does exactly what is needed for the game, simple a effective, however Bloodbane's script is much more complicated and probably suited for my ideas later on in the games development.

I started working on my mod again a few days ago and I don't know if it's because I'm using a higher resolution or because I only have one single enemy loaded into the engine but I could't get the script or spawning group thing to work at all, It's 8am here in england so by the end of the day I'll have something decent to show you guys in regards to what I am working on demo ready.
 
@BBYou were right I do not know what I was thinking I have updated the demo now using a spawner entity to spawn enemies.

@Danno
I have added a spawner entity to the new demo download below you could use it as a base but only thing the random code spawns more enemies from the front and a few from the back. Nice to see another UK member I am from Kent where are you ?

Download Demo: http://www.mediafire.com/file/djabls7asaw5zn2/Kung%20Fu%20Master%20V2.0.zip
 
I'm from moss side Manchester, it's a small place with a big reputation but unfortunately for the wrong reasons, I'm gonna PM you a download link as to what I've been working on so you can see what I'm aiming for mechanic wise, I wanna keep things under wraps until I have a decent demo for the public. really appreciate the input guys.
 
Back
Top Bottom