• 🏆 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] Gold tick trigger

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2005
Messages
319
ok so my gold tick trigger is not working correctly... and not sure how i should fix it... here they are.

this is to set the integer at the begining of the map.Goldinteger

  • Events
    • Map initialization
    • Conditions
    • Actions
      • Set Goldtick = 1
this is my gold tick integer.
  • Players Gold
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add Goldtick to Player 1 (Red) Current gold
      • Player - Add Goldtick to Player 2 (Blue) Current gold
      • Player - Add Goldtick to Player 3 (Teal) Current gold
      • Player - Add Goldtick to Player 4 (Purple) Current gold
      • Player - Add Goldtick to Player 5 (Yellow) Current gold
      • Player - Add Goldtick to Player 6 (Orange) Current gold
      • Player - Add Goldtick to Player 7 (Green) Current gold
      • Player - Add Goldtick to Player 8 (Pink) Current gold
this is the part that i am having trouble with. it should increase the gold tick my 1 every 20 seconds. yet stops after a while and starts back up and seems to be going faster then it should on increasing. like will skip a lvl or two.
  • Gold Tick
    • Events
      • Time - Elapsed game time is 40.00 seconds
    • Conditions
    • Actions
      • For each (Integer Goldtick) from 1 to 100, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Goldtick Less than or equal to 100
            • Then - Actions
              • Wait 20.00 seconds
              • Set Goldtick = (Goldtick + 1)
            • Else - Actions
              • Do nothing
any ideas or am i doing anything wrong?
 
Last edited:
Level 6
Joined
Feb 12, 2008
Messages
207
1st at all... dude, please use the GUI on the forums, to do so, just right click on the trigger title in the right hand window and then click on "Copy as Text", then just paste that text between ["TRIGGER"] and ["/TRIGGER"] (without the quotes)

well now for the trigger:
Set Goldtick = (Goldtick + 1) is unnecesary, thats what is skipping a step.. that trigger wont take you where u want to...

it should be something like this:
if you want it to be activated after 40 seconds of game time, then you should 1st have this trigger:
  • GoldTickIncreaseInit
    • Events
      • Time - Elapsed game time is 40.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn on GoldTickIncrease <gen>
and this trigger should be "Initially Off" (uncheck the "initially on" option from the upper part of the trigger editor window)
  • GoldTickIncrease
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Set Goldtick = (Goldtick + 1)
so that way the game, after 40 seconds (of game-time) it activates the 2nd trigger, wich increases in 1 the number for the gold tick.
also, if you want a max of 100 for Goldtick, then you should use this one:
  • GoldTickIncrease
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Goldtick Less than 100
        • Then - Actions
          • Set Goldtick = (Goldtick + 1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
so if goldtick becomes 100, it stops the trigger (you could also use "Do Nothing" instead of "Trigger - Turn off (This trigger)" but this way you save some memory as you wont use the trigger anymore)

hope i helped ya :)
 
Level 6
Joined
Feb 2, 2005
Messages
205
For the Players Gold Trigger use a loop

  • Players Gold
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Players) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Add Goldtick to Player(Players) Current gold
I used "Convert Player Index to Player" instead of a fixed Player

Using loops will keep your code small and efficient! Remind: Everything that repeats in the actions more than once can be looped. However you have to decide when to use a loop instead of x actions =)
 
Level 6
Joined
Jun 30, 2006
Messages
230
Since you want to stop running at 100 ticks, use KaiserG's code. Also, loops are not faster for executing small loops. This is because you have to use more variables, plus the loop actions itself take time to execute. It is however easier to read with a loop, and you are less prone to make errors.

Slightly off-topic: It's funny that you guys are so concerned with optimizing his code when you are using GUI... It's good to optimize your code, yes. However, if you were to use JASS for this you could easily do 1 trigger for all this AND it would run faster...
I'll recommend you to stick with GUI since this trigger is giving you problems.
 
Level 7
Joined
Dec 8, 2005
Messages
319
ahh but i dont know how to use GUI and not sure where i can find a class on this... or how did everyone learn gui...

and i have the same problem as before with the first 40 seconds. and every 2 seconds i should get 1 gold which = after 40 seconds, i should have 20 gold yet i still only get 19. any ideas why? and if you want to show or write a simple gui script for this. then by all means have at it... but thanks again for all the comments.
 
Level 6
Joined
Feb 12, 2008
Messages
207
sorry but then i maybe didnt understand your needings...
every 2 seconds you get "GoldTick" gold, thats right, but i didnt really understood what you said now, should the "GoldTick" value increase every 20 seconds? or every 2 seconds?
it would be cool if you can show an example over the time of how much gold you would get.

for example, on my triggering you get (if the GoldTick variable starts with 0):
0 seconds: you start with 0 gold
1 seconds: you have 0 gold yet
2 seconds: you get 0 gold (since GoldTick has still 0 as value)
40 seconds: you have still 0 gold, but the trigger to increase the goldtick is activated
60 seconds: the goldtick increase is every 20 seconds, so after the 40 seconds you have to wait for the "every 20 seconds" to reach 20 seconds
62 seconds: now that the variable is equal to 1, you get 1 gold
64 seconds: you get +1 gold (total = 2 gold)
80 seconds: the value of goldtick is increased, so far you have 10 gold
82 seconds: now you start to get 2 gold every 2 secs (+2 gold, total = 12 gold)

and so on..

maybe the problem you have is that you want to start getting gold when time elapsed is 40, so you would have to change the
  • Time - Elapsed game time is 40.00 seconds
for
  • Time - Elapsed game time is 20.00 seconds
as it will be 20 seconds from elapsed time + 20 seconds from periodic time

good triggering :)
 
Level 7
Joined
Dec 8, 2005
Messages
319
ok well from the time the game starts i want you to get gold... i have one more trigger that set the integer to 1. but every 20 seconds i increase the life of units being spawned. so i want the gold to increase according to the level.

so first 40 seconds = 20 gold. goldtickinteger =1
round 1 starts lasts 20 seconds = 10 gold. goldtickinteger =1
round 2 starts lasts 20 seconds = 20 gold. goldtickinteger =2
round 3 starts lasts 20 seconds = 30 gold. goldtickinteger =3
round 4 starts lasts 20 seconds = 40 gold. goldtickinteger =4
round 5 starts lasts 20 seconds = 50 gold. goldtickinteger =5
ect. to lvl 100.

so every 2 seconds it gives gold and every 20 seconds it increases gold. make sense?
 
Level 6
Joined
Feb 12, 2008
Messages
207
oh... then if you are making a TD or something like that, you should use another trigger:

you will need those triggers: (i made a timer window too)

  • StartingMessages
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Welcome to Hairybea...
      • Set GOLDTICK = 1
  • GoldTick
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of players), do (Actions)
        • Loop - Actions
          • Player - Add GOLDTICK to (Player((Integer A))) Current gold
  • TDStart
    • Events
      • Time - Elapsed game time is 20.00 seconds
    • Conditions
    • Actions
      • Set CURRENT_ROUND = 1
      • Game - Display to (All players) the text: The game will start...
      • Countdown Timer - Start TIMER as a Repeating timer that will expire in 20.00 seconds
      • Countdown Timer - Create a timer window for TIMER with title Round 1 will start ...
      • Set TIMER_WINDOW = (Last created timer window)
      • Countdown Timer - Show TIMER_WINDOW
  • RoundStart
    • Events
      • Time - TIMER expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Round + ((String(CURRENT_ROUND)) + has started!))
      • -------- Here you put your TD actions, like spawning. --------
      • Set GOLDTICK = (GOLDTICK + 1)
      • Set CURRENT_ROUND = (CURRENT_ROUND + 1)
      • Countdown Timer - Change the title of TIMER_WINDOW to (Round + ((String(CURRENT_ROUND)) + will start in))
good luck... :)
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
There is no need to set your integer to the value of 1. Just put the initial value to 1 (do that inside the variable in the variable editor).

Now just add the 'set +1' in your rounds trigger, no need to start counting time lol.

If you still want it to be this way, just make a tirgger that raises the integer every 20 seconds, disable it, and when the game starts (round 1), enable it.
 
Level 7
Joined
Dec 8, 2005
Messages
319
hmm true... lol i feel like a noob. i should of just set it to one in the beginning
but yes this does add a timer window which is always helpful. hmm lets give this a go and thanks alot for the help guys.
 
Level 6
Joined
Feb 12, 2008
Messages
207
give always +rep to people who deserves it for helping you, or anything. I wont get any rep as you dont have rep, and only members with at least 1 rep can give.
Anyway, remember to always give rep if they deserve it!
 
Status
Not open for further replies.
Top