guys can someone help me find a solution?
I have a group of enemies and each of them has been assigned a danger value.
example:
enemy 1 - value 1
enemy2 - value 2
enemy3 - value 3
I would like the enemies to be created by calculating the danger value that increases with each wave.
example:
if the danger value is equal to 5 - create 2 enemy2 and 1 enemy1 or 1 enemy3 and 1 enemy2
if the danger value is 10 - create 5 enemy2 or 2 enemy3 1enemy2 2enemy1
I hope I was clear on what I want
I attach screens of current events and folder with current project.
I remember watching a tutorial video about variables in GD and came across this vid. He uses waves as an example to explain variables similar to you on your creation.
I do remember him explaining and showing how to add enemies in waves using variables.
The key is the picking of the enemy. This is rough and might need tweaking.
Variables.
Level =0
Max =1
Remaining =0
EnemyNumber=0
(let’s say the enemies were enemy1, enemy2 and so on and in a group named EnemyGroup)
Example start of wave
Level +1
RemainingEnemies=level (or some other formula)
MaxEnemy = min(MaxEnemy+1, highest enemy number)
Start spawn timer
FYI, min() takes the minimal number.
min(3,10) would return 3
min(3,1) would return 1
Using min() here prevents the MaxMaxEnemy from being higher the maximum enemy.
You could either create a wave list using an array or pick an enemy each time the timer elapses
Timer >3
RemainingEnemies > 0
Resart timer
Set enemyNumber = RandomInRange(min(trunc (MaxEnemy) , RemainingEnemies ))
Add object by name from EnemyGroup
The enemy name would be
“Enemy” + ToString(number)
Remaining - enemyNumber
Using MaxEnemy would allow you to gradually increase the maximum enemy. It’s up to you.
Either after the last enemy is killed (number in scene is 0 and remaining is 0) or a time limit then the next wave would begin.
My concept choose a number between 1 and either the max enemy or the number of enemies left in the wave.
hi keith,
i’m using arrays but it’s still very challenging and repetitive to create hundreds of waves of enemies.
if the player is so good that he survives all the waves I create he would find himself without enemies.
for this reason I would need to create an infinite automatic system.
what i would like to achieve is to create a difficulty index and assign a degree of danger to each enemy.
every time the enemies are defeated increase the number of the wave and therefore increase the difficulty value to then create enemies in relation to that value
example:
enemy1 danger =1
enemy2 danger =2
enemy3 danger =3
wave 1 - difficulty =5
create 3 enemy1 and 1 enemy2 or 1 enemy3 and 1 enemy2
What type of game is it? Is an enemy spawned every X seconds? You said you’re using an array. Do you want to do the math as the enemies are being spawned or create an array of enemies at the beginning of the wave and then use that array to spean the enemies?
Did you try to build something with what I suggested in my previous reply? Does any of the ideas seem useful?
the game is a topdown Survivor shooter similar to vampire Survivor. yes I’m currently writing the enemies to be created on an Array but I would like them to be created randomly starting from a low difficulty level and going up
oooh thank you so much keith that looks awesome! one last question why did you set that .5 in the spawn timer? if i remove the . it works.
how can i create waves when enemies are defeated without having to repress the button to respawn them
I used.5 for testing. I wanted to run the waves as quick as possible instead of waiting.
As far as starting a wave, that’s up to you. You could start a new wave when the remaining variable is zero. You could also check if the enemies are all dead or use a timer or wait.
Remaining is 0
Count of enemies in scene is zero
Start a new wave
Or
Remaining is zero
Start a timer
If remaining is zero
Time elapsed > 5
Delete timer
Start next wave
last thing for the creation of enemies do you think it is possible to set a danger value instead of the number of enemies?
if it is possible to modify this good otherwise I will find a way to manage it in this other way
assign a certain danger value to the enemies
for example, enemy 1,2 and 3 have a value of 1 while enemy 4,5,6 have a value of 2
so create the enemies in relation to that value and not to the number
I hope I explained myself correctly.
if it were possible I would have wanted this to happen otherwise I will find a way to manage the waves with the number as it is now.
also forgive my ignorance but I can’t set the events
I don’t have the time today for anything too in depth. The current method could be used to pick the level and then you could pick an object in that level using another random number.
There are so many different ways to do that. Most would involve picking a random item from a array based on the Rand value. You could use a different event for each level or use an array of arrays. The arrays would contain the object names arranged by level.
Another method would to be to build the enemy name to be used with create object by name.
Again, I don’t have the time to expand on either concept. Maybe, tomorrow if you’re still stuck.
I seem to have lost my test project. I might not have saved it. Anyways, my concept uses the last version. It uses the value in Rand for the enemy level and then creates another random number to pick an object name of that level.
I created an array of arrays. It’s also called a 2-dimensional array in some languages.
The first element or child is the level and the array within each element is a list of object names.
Meaning Waves[0][0] thru Waves[0][2] are level 0 enemy object names. I added fewer enemies to each array to test the concept. The object name arrays can be of any size. My event uses the size of the the choose array to choose a random object name from the list. Since the original events for Rand picks a number between 1 and 3, you could either add a dummy index 0 and just use indexes 1 thru 3 or you could subtract 1 from Rand for the first index.
hello sorry for my absence but this period I am very busy with work. I did as described above but how do I create the enemies then?
I attach the project if you can take a look I would be grateful