Increase the number of enemies spawned based on score

butterbeanbutterbean Member Posts: 4,315
edited November -1 in Working with GS (Mac)
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! :)

Comments

  • JGary321JGary321 Member Posts: 1,246
    Depends how you want it. Is it 1 enemy per 5k points or increases number of enemies spawn every 5k points. I'm assuming the latter, but you know about assuming so....

    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
  • butterbeanbutterbean Member Posts: 4,315
    Thanks JGary, I'll give that a shot! I wonder if there's an equation like the one codemonkey provided for speeding up enemies based on score increments, but that will work :)
  • JGary321JGary321 Member Posts: 1,246
    Well thats one reason I put up a suggestion for the Expression Editor for Timers. If we had one you could make the enemies just spawn faster instead of more by using an equation.
    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 =)
  • butterbeanbutterbean Member Posts: 4,315
    I actually did post something awhile back on the speed thing, and Codemonkey gave me a brilliant equation which works really well, and you did actually contribute to that forum :)

    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
  • butterbeanbutterbean Member Posts: 4,315
    We have an expression editor now for timers right? So what equation would be useful in having the enemy spawn rate increase at each 5,000 point increment?
  • harrioharrio Member Posts: 234
    what's cookin,

    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...
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Put all this in your spawner actor.

    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.
  • butterbeanbutterbean Member Posts: 4,315
    Thanks Codemonkey I'll give that a try! :)
  • butterbeanbutterbean Member Posts: 4,315
    Are Self.currentspawn rate and game.spawnratetimer both integers?

    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....
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    see edits above.
  • butterbeanbutterbean Member Posts: 4,315
    I did what you edited above and it seems to work, although it's hard to tell because I also have an equation in there that you gave me awhile back that increases the speed of the birds for every 5,000 increment in score

    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?
  • butterbeanbutterbean Member Posts: 4,315
    http://img43.imageshack.us/img43/9544/picture1bku.png

    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?)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Are the birds wrapping? Do the birds get destroyed at a certain point?

    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.
  • butterbeanbutterbean Member Posts: 4,315
    I unchecked the wrapping feature in the scene, and the birds still spawn the same, a huge mob...

    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
  • butterbeanbutterbean Member Posts: 4,315
    The wrapping feature is definitely not the problem as I have that disabled

    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...
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    If you just want to double the rate each time just change this line:

    --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.
  • butterbeanbutterbean Member Posts: 4,315
    So under global game attribute game.spawnratetimer, do I set that to 0 initially?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    No. Set it to your initial timer value. i.e. Timer every game.SpawnRateTimer seconds. Having 0 as the initial value might cause some unwanted results.
  • butterbeanbutterbean Member Posts: 4,315
    Thanks, the new equation worked like a charm! :)
  • xactoxacto Member Posts: 146
    I have a similar question... Please see my link for my code.
    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?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    http://gamesalad.com/wiki/how_to_gsc_interval_difficulty

    Though I need to fix some bugs in the game example. No pun intended.
  • xactoxacto Member Posts: 146
    Thanks CodeMonky!
Sign In or Register to comment.