• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Help with timers !

Status
Not open for further replies.
Level 1
Joined
Nov 16, 2013
Messages
3
hi, first of all I'm a beginner on world editor and im having some trouble with timers ! (i can't find an answer to my problem with the tutorials so im asking here).

Ok so im making a simple TD map, everything was fine until i try to use 2 timers to spawn waves. So here is how i actually do the thing :

- 5 triggers (init,creep,timer,waves,food)

init :

  • INIT
    • Events
      • Time - Elapsed game time is 15.00 seconds
    • Conditions
      • creep_level Equal 0
    • Actions
      • Quest - Display to (All players) the Avertissement message: |cff995500First lev...
      • Time - Create a timer window for creep_timer_init with title Next level spawn in...
      • Set MyTimerWindow_1 = (Last created timer window)
      • Time - Show MyTimerWindow_1
      • Time - Start creep_timer_init as a Un coup timer that will expire in 20.00 seconds
creep :

  • Creep
    • Events
      • Time - creep_timer_init expires
    • Conditions
      • creep_level Equal 0
    • Actions
      • Time - Destroy MyTimerWindow_1
      • Set creep_level = 1
      • -------- LEVEL 1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • creep_level Equal 1
        • Then - Actions
          • Set creep_level = (creep_level + 1)
          • Set creep_food = 35
          • Quest - Display to (All players) the Avertissement message: Level 1 - Sheep
          • Unit - Create 35 Level 1 - Sheep for Joueur 12 (Marron) at (Center of Spawn rouge <gen>) facing Orientation bâtiment par défaut degrees
        • Else - Actions
          • Do nothing
timer :

  • Timer
    • Events
      • Unit - A unit owned by Joueur 12 (Marron) Meurt
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • creep_food Equal 0
        • Then - Actions
          • Wait 1.00 seconds
          • Time - Create a timer window for creep_timer_spawn with title Next level in :
          • Set MyTimerWindow_2 = (Last created timer window)
          • Time - Montrer MyTimerWindow_2
          • Time - Start creep_timer_spawn as a Un coup timer that will expire in 20.00 seconds
        • Else - Actions
waves :

  • Waves
    • Events
      • Time - creep_timer_spawn expires
    • Conditions
      • creep_level Supérieur ou égal Ã* 1
    • Actions
      • Time - Destroy MyTimerWindow_2
      • -------- LEVEL 2 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • creep_level Equal 2
        • Then - Actions
          • Set creep_level = (creep_level + 1)
          • Set creep_food = (creep_food + 35)
          • Quest - Display to (All players) the Avertissement message: Level 2 - Chicken
          • Unit - Create 35 Level 2 - Chicken for Joueur 12 (Marron) at (Center of Spawn rouge <gen>) facing Orientation bâtiment par défaut degrees
        • Else - Actions
          • Game - Display to (All players) the text: BUG MAP !!!
      • -------- LEVEL 3 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • creep_level Equal 3
        • Then - Actions
          • Set creep_level = (creep_level + 1)
          • Set creep_food = (creep_food + 35)
          • Quest - Display to (All players) the Avertissement message: Level 3 - Pingu
          • Unit - Create 35 Level 3 - Pingouin for Joueur 12 (Marron) at (Center of Spawn rouge <gen>) facing Orientation bâtiment par défaut degrees
        • Else - Actions
          • Game - Display to (All players) the text: BUG MAP !!!
      • -------- LEVEL 4 --------
food :

  • Food
    • Events
      • Unit - A unit owned by Joueur 12 (Marron) Meurt
    • Conditions
    • Actions
      • Set creep_food = (creep_food - 1)
      • Game - Display to (All players) the text: (String(creep_food))
So the first level is fine, everytime you kill a creep from player12 the var creep_food(35) decrease of 1 when its on 0, a timer should popup then next levels are coming etc etc, but in my case nothing happen, the timer don't popup i tried multiple things to see whats going on but i don't get it.. i need some help !

cheers! :grin:
 
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,543
http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

This should also be in the triggers and scripts forum. This forum is for asking how to do something. Triggers and scripts is for asking how to fix something.

Place your unit types into an array keyed to the lvl you want them to spawn at.
Example:

  • Setup
  • Events
    • 0.00 time out
  • Conditions
  • Actions
    • Set spawnUnitType[1] = lvl one monster
    • Set spawnUnitType[2] = lvl two monster
    • Set spawnUnitType[3] = lvl three monster
    • ------- And so on -------
To use the above when spawning units you check the lvl that player is on then use that as the index to spawn. It will shorten your code and make it easier to edit and read.

Never use the Do nothing action. If you want to make it more readable use comments.

You leak locations in your triggers check the tutorial Things that leak on triggers and scripts page. Also take a look at my tutorial things a GUIer should know. It is in my sig.

As for your timer. It needs to be a repeating timer. Or you need to start it again.
You should not need 2 timers for this.
 
Level 1
Joined
Nov 16, 2013
Messages
3
Thanks you for the fast answer and the tips! I understand how it should be done now, and its easier with your method.. i will see if i can correctly use the timer now :D

edit: edited my first post.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
I believe the problem is that you are destroying the timer window. The timer is counting correctly but you have destroy timer window and i don't see you recreate it.

You should not destroy the timer window and it should work.

This is the bad line
  • Time - Destroy MyTimerWindow_2
There is two of them in the triggers i see.
 
Level 1
Joined
Nov 16, 2013
Messages
3
This is how i've done it the first time, but still it didn't work, i still don't know why. The second timer wasn't working.

  • Time - Destroy MyTimerWindow_2
i added this line after trying multiple things to get my second timer working, but it wasn't doing anything.

Anyway, i deleted everything and i am gonna do a fresh start, the night have been great for thinking about another method using your suggestions :thumbs_up:

cheers
 
Status
Not open for further replies.
Top