• 🏆 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] resetting timer bugs out spawn

Status
Not open for further replies.
Level 7
Joined
Sep 19, 2012
Messages
204
Hey guys,

as the Title suggests i´ve gotten myself a problem with timers and i cant find the error Oo

I made a chat command to set the timer to 1 (tried 5 as well) seconds, just for testing purposes.
But when i use this chat command to set the timer, the spawning wave has a random number of creeps and not the one predefined in the triggers....

some ideas?

  • Var
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Level 1 --------
      • Set unit_type[1] = Evil Sapling (Wave)
      • Set unit_type_var_two[1] = Evil Sapling (Wave)
      • Set unit_type_var_three[1] = Poison Spider (Wave)
      • Set unit_amount[1] = 6
      • Set unit_amount_var_two[1] = 2
      • Set unit_amount_var_three[1] = 0
      • Set lvlnum = 0
      • -------- Level 2 --------
      • Set unit_type[2] = Evil Sapling (Wave)
      • Set unit_type_var_two[2] = Small Treant (Wave)
      • Set unit_type_var_three[2] = Poison Spider (Wave)
      • Set unit_amount[2] = 6
      • Set unit_amount_var_two[2] = 2
      • Set unit_amount_var_three[2] = 0
      • -------- Level 3 --------
      • Set unit_type[3] = Evil Sapling (Wave)
      • Set unit_type_var_two[3] = Small Treant (Wave)
      • Set unit_type_var_three[3] = Poison Spider (Wave)
      • Set unit_amount[3] = 4
      • Set unit_amount_var_two[3] = 2
      • Set unit_amount_var_three[3] = 2
      • -------- Level 4 --------
      • Set unit_type[4] = Evil Sapling (Wave)
      • Set unit_type_var_two[4] = Small Treant (Wave)
      • Set unit_type_var_three[4] = Poison Spider (Wave)
      • Set unit_amount[4] = 2
      • Set unit_amount_var_two[4] = 4
      • Set unit_amount_var_three[4] = 2
      • -------- Level 5 --------
      • Set unit_type[5] = Small Treant (Wave)
      • Set unit_type_var_two[5] = Poison Spider (Wave)
      • Set unit_type_var_three[5] = Claw Beast (Wave)
      • Set unit_amount[5] = 6
      • Set unit_amount_var_two[5] = 2
      • Set unit_amount_var_three[5] = 0
      • -------- Level 6 --------
      • Set unit_type[6] = Small Treant (Wave)
      • Set unit_type_var_two[6] = Poison Spider (Wave)
      • Set unit_type_var_three[6] = Claw Beast (Wave)
      • Set unit_amount[6] = 4
      • Set unit_amount_var_two[6] = 2
      • Set unit_amount_var_three[6] = 2
      • -------- Level 7 --------
      • Set unit_type[7] = Small Treant (Wave)
      • Set unit_type_var_two[7] = Poison Spider (Wave)
      • Set unit_type_var_three[7] = Claw Beast (Wave)
      • Set unit_amount[7] = 2
      • Set unit_amount_var_two[7] = 2
      • Set unit_amount_var_three[7] = 4
      • -------- Level 8 --------
      • Set unit_type[8] = Mur´gul (Wave)
      • Set unit_type_var_two[8] = Mur´gul (Wave)
      • Set unit_type_var_three[8] = Naga Archer (Wave)
      • Set unit_amount[8] = 6
      • Set unit_amount_var_two[8] = 2
      • Set unit_amount_var_three[8] = 0
      • -------- Level 9 --------
      • Set unit_type[9] = Mur´gul (Wave)
      • Set unit_type_var_two[9] = Naga Guard (Wave)
      • Set unit_type_var_three[9] = Naga Archer (Wave)
      • Set unit_amount[9] = 6
      • Set unit_amount_var_two[9] = 2
      • Set unit_amount_var_three[9] = 0
      • -------- Level 10 --------
      • Set unit_type[10] = Mur´gul (Wave)
      • Set unit_type_var_two[10] = Naga Guard (Wave)
      • Set unit_type_var_three[10] = Naga Archer (Wave)
      • Set unit_amount[10] = 4
      • Set unit_amount_var_two[10] = 2
      • Set unit_amount_var_three[10] = 2
      • -------- Level 11 --------
      • Set unit_type[11] = Mur´gul (Wave)
      • Set unit_type_var_two[11] = Naga Guard (Wave)
      • Set unit_type_var_three[11] = Naga Archer (Wave)
      • Set unit_amount[11] = 2
      • Set unit_amount_var_two[11] = 4
      • Set unit_amount_var_three[11] = 2
      • -------- Level 12 --------
      • Set unit_type[12] = Naga Guard (Wave)
      • Set unit_type_var_two[12] = Naga Archer (Wave)
      • Set unit_type_var_three[12] = Hydra (Wave)
      • Set unit_amount[12] = 6
      • Set unit_amount_var_two[12] = 2
      • Set unit_amount_var_three[12] = 0
      • -------- Level 13 --------
      • Set unit_type[13] = Naga Guard (Wave)
      • Set unit_type_var_two[13] = Naga Archer (Wave)
      • Set unit_type_var_three[13] = Hydra (Wave)
      • Set unit_amount[13] = 4
      • Set unit_amount_var_two[13] = 2
      • Set unit_amount_var_three[13] = 2
      • -------- Level 14 --------
      • Set unit_type[14] = Naga Guard (Wave)
      • Set unit_type_var_two[14] = Naga Archer (Wave)
      • Set unit_type_var_three[14] = Hydra (Wave)
      • Set unit_amount[14] = 2
      • Set unit_amount_var_two[14] = 2
      • Set unit_amount_var_three[14] = 4
      • -------- Level 15 --------
      • Set unit_type[15] = Yeti (Wave)
      • Set unit_type_var_two[15] = Yeti (Wave)
      • Set unit_type_var_three[15] = Magnataur Warrior (Wave)
      • Set unit_amount[15] = 6
      • Set unit_amount_var_two[15] = 2
      • Set unit_amount_var_three[15] = 0
      • -------- Level 16 --------
      • Set unit_type[16] = Yeti (Wave)
      • Set unit_type_var_two[16] = Polar Bear (Wave)
      • Set unit_type_var_three[16] = Magnataur Warrior (Wave)
      • Set unit_amount[16] = 6
      • Set unit_amount_var_two[16] = 2
      • Set unit_amount_var_three[16] = 0
      • -------- Level 17 --------
      • Set unit_type[17] = Yeti (Wave)
      • Set unit_type_var_two[17] = Polar Bear (Wave)
      • Set unit_type_var_three[17] = Magnataur Warrior (Wave)
      • Set unit_amount[17] = 4
      • Set unit_amount_var_two[17] = 2
      • Set unit_amount_var_three[17] = 2
      • -------- Level 18 --------
      • Set unit_type[18] = Yeti (Wave)
      • Set unit_type_var_two[18] = Polar Bear (Wave)
      • Set unit_type_var_three[18] = Magnataur Warrior (Wave)
      • Set unit_amount[18] = 2
      • Set unit_amount_var_two[18] = 4
      • Set unit_amount_var_three[18] = 2
      • -------- Level 19 --------
      • Set unit_type[19] = Polar Bear (Wave)
      • Set unit_type_var_two[19] = Magnataur Warrior (Wave)
      • Set unit_type_var_three[19] = Magnataur Destroyer (Wave)
      • Set unit_amount[19] = 6
      • Set unit_amount_var_two[19] = 2
      • Set unit_amount_var_three[19] = 0
      • -------- Level 20 --------
      • Set unit_type[20] = Polar Bear (Wave)
      • Set unit_type_var_two[20] = Magnataur Warrior (Wave)
      • Set unit_type_var_three[20] = Magnataur Destroyer (Wave)
      • Set unit_amount[20] = 4
      • Set unit_amount_var_two[20] = 2
      • Set unit_amount_var_three[20] = 2
      • -------- Level 21 --------
      • Set unit_type[21] = Polar Bear (Wave)
      • Set unit_type_var_two[21] = Magnataur Warrior (Wave)
      • Set unit_type_var_three[21] = Magnataur Destroyer (Wave)
      • Set unit_amount[21] = 2
      • Set unit_amount_var_two[21] = 2
      • Set unit_amount_var_three[21] = 4
      • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
  • Clock
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a One-shot timer that will expire in Clock_Time_Player_Nr seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title West Wave
      • Hashtable - Save Handle Of(Last created timer window) as 0 of 0 in Hash_finalcam
      • Countdown Timer - Change the color of the time for (Last created timer window) to (100.00%, 80.00%, 20.00%) with 0.00% transparency
      • Countdown Timer - Show (Last created timer window)
      • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
  • Spawn
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a One-shot timer that will expire in Clock_Time_Player_Nr seconds
      • Set lvl_Display = (lvl_Display + 1)
      • Game - Display to (All allies of Player 1 (Red)) the text: (|c00999900Round + (|c00990000 + ((String(lvl_Display)) + (|r + |c00999900has started!|r))))
      • For each (Integer A) from 1 to unit_amount[lvlnum], do (Actions)
        • Loop - Actions
          • Set incrementx = 1
          • Set incrementy = 1
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Unit - Create 1 unit_type[lvlnum] for Player 12 (Brown) at loc[incrementy] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Unit - Create 1 unit_type[lvlnum] for Player 12 (Brown) at loc[(incrementy + 1)] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Set incrementx = (incrementx + 1)
              • Set incrementy = (incrementy + 2)
          • Wait 0.75 seconds
      • For each (Integer A) from 1 to unit_amount_var_two[lvlnum], do (Actions)
        • Loop - Actions
          • Set incrementx = 1
          • Set incrementy = 1
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Unit - Create 1 unit_type_var_two[lvlnum] for Player 12 (Brown) at loc[incrementy] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Unit - Create 1 unit_type_var_two[lvlnum] for Player 12 (Brown) at loc[(incrementy + 1)] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Set incrementx = (incrementx + 1)
              • Set incrementy = (incrementy + 2)
          • Wait 0.75 seconds
      • For each (Integer A) from 1 to unit_amount_var_three[lvlnum], do (Actions)
        • Loop - Actions
          • Set incrementx = 1
          • Set incrementy = 1
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Unit - Create 1 unit_type_var_three[lvlnum] for Player 12 (Brown) at loc[incrementy] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Unit - Create 1 unit_type_var_three[lvlnum] for Player 12 (Brown) at loc[(incrementy + 1)] facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Position of Castle 0000 <gen>)
              • Set incrementx = (incrementx + 1)
              • Set incrementy = (incrementy + 2)
          • Wait 0.75 seconds
  • Wave Increase
    • Events
      • Time - Timer expires
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • lvl_Display Equal to 4
          • lvl_Display Equal to 9
          • lvl_Display Equal to 15
          • lvl_Display Equal to 19
          • lvl_Display Equal to 24
          • lvl_Display Equal to 29
    • Actions
      • Set lvlnum = (lvlnum + 1)
      • Game - Display to (All allies of Player 1 (Red)) the text: |c00FF0000Waves are...
  • test time
    • Events
      • Player - Player 1 (Red) types a chat message containing -time as An exact match
    • Conditions
    • Actions
      • Countdown Timer - Start Timer as a One-shot timer that will expire in 1.00 seconds
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
  • Don't do this: Custom script: call DestroyTrigger( GetTriggeringTrigger() ) -- there's really no reason to destroy triggers and save the few bytes, especially here because that trigger doesn't have an event so i'm not sure what it would even destroy
  • You never use incrementx for anything. What were you trying to do?
  • You don't save the timer handle in test time like you do in Clock, but since you don't use it in Spawn or Wave Increase I'm not sure it matters. This line: Hashtable - Save Handle Of(Last created timer window) as 0 of 0 in Hash_finalcam
  • Position of Castle 0000 <gen> leaks every time it's used in Spawn
 
Level 7
Joined
Sep 19, 2012
Messages
204
  • Don't do this: Custom script: call DestroyTrigger( GetTriggeringTrigger() ) -- there's really no reason to destroy triggers and save the few bytes, especially here because that trigger doesn't have an event so i'm not sure what it would even destroy

Alright...will remove it. Does it have a negative effect on the functionality though?

The Trigger has no event because it gets started by an external trigger.

  • You never use incrementx for anything. What were you trying to do?

You are right...didnt realize it xD incrementx is just a leftover from an older version of the map...removed :)

  • You don't save the timer handle in test time like you do in Clock, but since you don't use it in Spawn or Wave Increase I'm not sure it matters. This line: Hashtable - Save Handle Of(Last created timer window) as 0 of 0 in Hash_finalcam

The handle of the timer window gets saved (not the timer itself) so i can destroy it later on. No need to save it again when im only changing the time remaining in the timer and not the timer window.

  • Position of Castle 0000 <gen> leaks every time it's used in Spawn

didnt see that as well... fixed!

Thanks for the response, but it didnt fix my problem :/
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
In the past destroying triggers could mess with the handle stack (or something else equally nefarious); I believe it’s since been patched out but better not to mess with it IMO. I see that it is manually run; my point is that the trigger that executes it is the Triggering Trigger since the one you want to destroy was never triggered. Destroying it in that manner is bad practice because it could destroy something else unintentionally.

Didn’t notice it was the timer window being saved not the timer itself.

My best guess is lvlnum isn’t being incremented properly. I see it goes up at select levels in Wave Increase but not elsewhere. You are using lvlnum as your array index everywhere and perhaps you meant to use lvl_Display. Also lvlnum starts = 0 but you didn’t use any of the 0 indices for your arrays.
 
Level 7
Joined
Sep 19, 2012
Messages
204
In the past destroying triggers could mess with the handle stack (or something else equally nefarious); I believe it’s since been patched out but better not to mess with it IMO. I see that it is manually run; my point is that the trigger that executes it is the Triggering Trigger since the one you want to destroy was never triggered. Destroying it in that manner is bad practice because it could destroy something else unintentionally.

Didn’t notice it was the timer window being saved not the timer itself.

My best guess is lvlnum isn’t being incremented properly. I see it goes up at select levels in Wave Increase but not elsewhere. You are using lvlnum as your array index everywhere and perhaps you meant to use lvl_Display. Also lvlnum starts = 0 but you didn’t use any of the 0 indices for your arrays.

lvl_num and lvl_display have different purposes...the waves get stronger every 5th wave. so lvl_num gets changed by a trigger every 5 waves. Lvl_Display is the number that gets put out every wave to tell players wich wave they are in. The spawning system itself work as intended except when i use the chat command to "shorten" the time between waves...then i get random numbers of creeps.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,011
Something is messing with the Integer A variable in that time, then; the loops using it are vulnerable because you put waits in them. Try creating a new variable and using "For each integer Variable" instead of the A loops. The B loops are fine because they have no waits in them.
 
Level 7
Joined
Sep 19, 2012
Messages
204
Something is messing with the Integer A variable in that time, then; the loops using it are vulnerable because you put waits in them. Try creating a new variable and using "For each integer Variable" instead of the A loops. The B loops are fine because they have no waits in them.

That did it :goblin_yeah::grin::ap:
its quite interesting how many weakpoints this editor has :ogre_icwydt:


Tank you very much! +rep
 
Status
Not open for further replies.
Top