Increase the number of enemies spawned based on score
butterbean
Member Posts: 4,315
So I have a shooter set up so that each time the main player reaches increments of 5,000 in score, that the enemies fly faster, thanks to Codemonkey's brilliant equation.
How can I increase the number of enemies spawned by each increment of 5,000 in score?
I found that as the enemies travelled faster, there were less of them being spawned, since enemies spawned is based on timer, every X amount of seconds.
Thanks! Easiest solution, or equation would be nice!
How can I increase the number of enemies spawned by each increment of 5,000 in score?
I found that as the enemies travelled faster, there were less of them being spawned, since enemies spawned is based on timer, every X amount of seconds.
Thanks! Easiest solution, or equation would be nice!
Comments
Anyways, if it's the latter then...you could do something like this.
Have a rule for each 5k increment.
If points = > 1 & < 5,000 spawn actor
If points = > 4,999 & < 10,000 spawn actor, spawn actor
And when I say spawn actor, you still need the timer & everything too. However you have your actor spawning you need that 2 times.
This is one way to do it. Not sure if it's the most efficient, but at least it'll get ya started. I find that as I work I find one way to do things, but then later I realize another way that makes it 'neater' & probably more efficient.
-JGary
That would achieve the same results.
Maybe we should get Expression Editor for spawn actor too... Hrmm... that's another good idea. Actually I just think we need the Expression Editor for ANY field, but that's just me. You never know when a math equation will save the day
EDIT: Speed is easy, I did it in my game. Every round the enemies increased in speed. My equation was speed = round/2 + 30. That way they started slow at speed 30. But by level 100 (which is the last level) they would be running at around 80. Math makes things ALOT easier. If you ever need help with that MRS. Butter, you know where to find me. I don't remember seeing you post anything about the speed one, but maybe I overlooked it
I remember having a hard time, and was overlooking how easy it was, just plug in the equation and it works like a charm
So yes, I wish there were another equation I could plug in to make enemies spawn more, b/c as the enemies speed up, if I don't up their spawn rate, they become scarce as they travel faster b/c they are spawning based on timer
my math is rusty at best so correct me if i'm wrong, but i think something like [ if score modulus 5000 = 0 ] then increase spawn rate. this should return zero for every multiple of 5000. if i'm thinking correctly.
noodles...
Attributes Needed:
--self.Zero = 0 just an integer that holds the number 0.
--self.CurrentSpawnRate real type
--game.SpawnRateTimer real type
Rule: If self.Zero = game.Score%5000
--Change Attribute: game.SpawnRateTimer = max(.1, game.SpawnRateTimer - .1)
====This is so the Timer is never 0.
Rule: If self.CurrentSpawnRate == game.SpawnRateTimer
--Timer: For Every: self.CurrentSpawnRate
-----Spawn Actor:...
Otherwise:
--Change Attribute: self.CurrentSpawnRate = game.SpawnRateTimer
Reasons for the madness:
The Timer behavior does not actively change with the expression editor value. It would be utter chaos if it did. So it only evaluates the expression editor the each time it is started. So to keep the same Timer, you would need a way to turn the Timer behavior on and off when the spawn rate is changed.
Rule: If self.CurrentSpawnRate == game.SpawnRateTimer
--Timer: For Every: self.CurrentSpawnRate
-----Spawn Actor:...
Otherwise:
--Change Attribute: self.CurrentSpawnRate = game.SpawnRateTimer
Rule: If self.Zero = game.Score%5000
--Change Attribute: game.SpawnRateTimer = max(.1, game.SpawnRateTimer - .1)
====This is so the Timer is never 0.
Do both these rules go into an invisible actor together? OR into the enemy actor or player1 actor? I placed them into an invisible actor that will be onscreen for now....
Attributes Needed:
--self.Zero = 0 just an integer that holds the number 0.
--self.CurrentSpawnRate real type
--game.SpawnRateTimer real type
The first 2 attributes are for the spawner (thus the self)
The last attribute is a global game attribute correct? or is that also an attribute for the spawner I presumed global since it's "game.spawnrate..."
So this equation is supposed to spawn more birds every 5,000 points attained right?
Also, is the rate that the enemies speed up by each 5,000 point increment by a 100th of a second?
I have them set to spawn every 0.7 seconds, so does that increase their spawn rate to 0.6 and 0.5 by each 5000 points attained?
Update: I think I got it to work, but there are WAY too many birds on the screen, they are flooding it....
Any way of making this a gradual increase?
The bottom rule that was cut off was: --Change Attribute: self.CurrentSpawnRate = game.SpawnRateTimer
Anything wrong with the rules? The birds are spawning like crazy at the top of the screen in one big mass
The equation you gave me, can I tweak with it to change the spawning? Or did I flub with the rules?
Also,
--self.Zero = 0 just an integer that holds the number 0. (attribute in spawner)
--self.CurrentSpawnRate real type (attribute in spawner)
--game.SpawnRateTimer real type (attribute as global game attribute- or does this go into the spawner as well?)
Did you check with the new wrapping features that you gave yourself some extra scene borders (if you want wrapping) that the birds get destroyed correctly?
i.e. with the new seamless wrapping cases, there is not a chance that actors can have a position less than 0 or greater than the width of the scene.
I even went back to my old rule of just spawning them every 0.7 seconds, and it was fine, the birds were spawning every 0.7 seconds
Also, I put a rule in to destroy the birds if y is less than: 0,
They are spawning from Y axis 310; X axis( random 10,470)
So once the birds reach below y axis 0, they are destroyed
Do I need to change the equation?
Basically before this rule, I started out spawning the birds every 0.7 seconds, so I want to keep that, but double the spawn rate every time 5,000 points is attained b/c the speed increases every 5,000 points, thus, less birds are being spawned as score goes up
Can I change the .1 in the equation to a higher number like .5?
I just want enemy spawn rate to double each 5K points achieved...
--Change Attribute: game.SpawnRateTimer = max(.1, game.SpawnRateTimer - .1)
to
--Change Attribute: game.SpawnRateTimer = game.SpawnRateTimer/2
Just make sure you give it a limit on how fast your Timer goes, or it will spawn too much. Give or set the game.SpawnRateTimer with your initial time.
What I want to do is every 1000 points (until the player dies), spawn an enemyOrb.
http://farm4.static.flickr.com/3271/3858256874_965d7bdfba_o.png
I created a rules that checked game.score when ANY condition is true:
game.score = 1000
game.score =2000
game.score=3000
This works great if the score equals 1000; however it will skip if my score increase to 1010 or 2003 ect....
(if I use >= on all of the conditions it will bomb)
Is there a better way of doing this or do I have to manually enter each rule for each 1000?
Though I need to fix some bugs in the game example. No pun intended.