• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Unit Wave Spawning Help

Status
Not open for further replies.
Level 5
Joined
Feb 22, 2013
Messages
161
So the thing I need help with, is I am having 2 types of units spawn per 30 seconds (a wave), and then an additional unit spawns every 3 waves and then eventually every 2 waves within 35 minutes into the game itself. But I can't figure out how to keep track of wave counting without having to use a ton of if/then/else to say if the wave is on wave 3 then spawn this unit... Help would be much appreciated! :grin:

  • Spawning
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0138 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run ABarracks 1 <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0006 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run ABarracks 2 <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0139 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run ABarracks 3 <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0095 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run HBarracks 1 <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0013 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run HBarracks 2 <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Barracks 0096 <gen> is alive) Equal to True
        • Then - Actions
          • Trigger - Run HBarracks 3 <gen> (ignoring conditions)
        • Else - Actions
  • ABarracks 1
    • Events
    • Conditions
    • Actions
      • Unit - Create 3 AllianceUnit[1] for Player 2 (Blue) at (Center of ABottomUnitSp <gen>) facing 180.00 degrees
      • Unit - Create 3 AllianceUnit[2] for Player 2 (Blue) at (Center of ABottomUnitSp <gen>) facing 180.00 degrees
  • ABarracks 2
    • Events
    • Conditions
    • Actions
      • Unit - Create 3 AllianceUnit[1] for Player 2 (Blue) at (Center of AMiddleUnitSp <gen>) facing 225.00 degrees
      • Unit - Create 3 AllianceUnit[2] for Player 2 (Blue) at (Center of AMiddleUnitSp <gen>) facing 225.00 degrees
  • ABarracks 3
    • Events
    • Conditions
    • Actions
      • Unit - Create 3 AllianceUnit[1] for Player 2 (Blue) at (Center of ATopUnitSp <gen>) facing 270.00 degrees
      • Unit - Create 3 AllianceUnit[2] for Player 2 (Blue) at (Center of ATopUnitSp <gen>) facing 270.00 degrees
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Modulus operation is what you need.

Mod(X,Y) returns the remainder of the integer division of X with Y.

Mod(99,3) = 0
Mod(7,3) = 1
Mod(11,3) = 2

You can test if a wave is a multiple of Y by the comparision...
Mod(Wave, Y) equal to 0

Thus your spawn system does the following (every 30 seconds).
1. Spawn the normal wave units (both types)
2. If wave multiple of strongwave then spawn a strong wave.
3. increment wave (+1)

wave is an integer variable that starts at 0.
strongwave is an integer variable set to 3 initially.
After 35 minutes strongwave is set to 2.

This may or may not cause a double strong wave spawn during the swap over (where 2 consequitive waves spawn the strong wave as a result of the change of spawn period) however that should be a minor bug that is mostly unnoticable. One solution to such a problem would be a counter on the wave type that you reset to strongwave after every time it spawns, but this is considerably more complex. The simplest solution would be to offset the time the swap happens so it is a wave where both rates are a common denominator.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Firstly, you're leaking points. Take a look here: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

For the additional spawn every 3rd wave, use an integer to count when to spawn.
  • Your existing trigger
    • Actions
      • Set WaveCounter = WaveCounter + 1
      • If (WaveCounter Greater than or equal to 3) then ((do additional spawn) and (set WaveCounter = 0))
For your 35 minutes in problem, put those spawning creeps in the same trigger, but add another condition to the if/then/else: a boolean check, with a boolean variable.
Make another trigger with event elapsed time equal to 35 minutes, and all this trigger will do is set that boolean variable to true.
 
Level 5
Joined
Feb 22, 2013
Messages
161
Modulus operation is what you need.

Mod(X,Y) returns the remainder of the integer division of X with Y.

Mod(99,3) = 0
Mod(7,3) = 1
Mod(11,3) = 2

You can test if a wave is a multiple of Y by the comparision...
Mod(Wave, Y) equal to 0

Thus your spawn system does the following (every 30 seconds).
1. Spawn the normal wave units (both types)
2. If wave multiple of strongwave then spawn a strong wave.
3. increment wave (+1)

wave is an integer variable that starts at 0.
strongwave is an integer variable set to 3 initially.
After 35 minutes strongwave is set to 2.

This may or may not cause a double strong wave spawn during the swap over (where 2 consequitive waves spawn the strong wave as a result of the change of spawn period) however that should be a minor bug that is mostly unnoticable. One solution to such a problem would be a counter on the wave type that you reset to strongwave after every time it spawns, but this is considerably more complex. The simplest solution would be to offset the time the swap happens so it is a wave where both rates are a common denominator.

Thank you very much, that helped out a lot, I would've never thought to use the Modulus function lol, but it proved to be very useful.
 
Status
Not open for further replies.
Top