• 🏆 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] Income System

Status
Not open for further replies.
Level 2
Joined
Nov 21, 2010
Messages
29
Yea already done that.. but the actions... I don't know what should i do next..

I've made some basic income trigger for you. These work for all 12 players (I don't know how much players your map has) and increases their income every 2 minutes, with income being given out every 30 seconds. If you want to make a specific event for the increase of income just change the event of the more income trigger to E.G. 'Unit Dies' and checking if the unit is the 'income unit', than increasing the income. Anyway, here are the triggers:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Set Income[(Integer A)] = 100)
  • Income
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Add Income[(Integer A)] to (Player((Integer A))) Current gold
          • Game - Display to (Player group((Player((Integer A))))) the text: (Your income is + (String(Income[(Integer A)])))
  • More Income
    • Events
      • Time - Every 120.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Set Income[(Integer A)] = (Income[(Integer A)] + 100))
Hope it helped!
 
Level 2
Joined
Nov 21, 2010
Messages
29
@Baskey
Do not use integer A / B
They are slower and less efficient than using a Temp Integer.

Take a look at my tutorial things a GUIer should know.

Also you are leaking player groups.

Figured. I really need to stop making triggers before the evening, I always forget simple stuff like that.
@OP You can indeed use a Temp Integer or Integer A/B, I just feel like Integer A is easier to understand for new people and the only difference is efficiency and speed, but that will 90% of the time be of no issue whatsoever.

For the leak, change the income trigger to:
  • Income
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set TempPlayerGroup = (Player group((Player((Integer A)))))
          • Game - Display to TempPlayerGroup the text: (Your income is + (String(Income[(Integer A)])))
          • Player - Add Income[(Integer A)] to (Player((Integer A))) Current gold
          • Custom script: call DestroyForce(udg_TempPlayerGroup)
Sorry for giving you a leaking trigger (dafuq, brain D:)
 
Level 6
Joined
May 13, 2013
Messages
111
Figured. I really need to stop making triggers before the evening, I always forget simple stuff like that.
@OP You can indeed use a Temp Integer or Integer A/B, I just feel like Integer A is easier to understand for new people and the only difference is efficiency and speed, but that will 90% of the time be of no issue whatsoever.

For the leak, change the income trigger to:
  • Income
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set TempPlayerGroup = (Player group((Player((Integer A)))))
          • Game - Display to TempPlayerGroup the text: (Your income is + (String(Income[(Integer A)])))
          • Player - Add Income[(Integer A)] to (Player((Integer A))) Current gold
          • Custom script: call DestroyForce(udg_TempPlayerGroup)
Sorry for giving you a leaking trigger (dafuq, brain D:)

Ok.. But I'm currently making a map, and I want a Farm generates 1 gold per 10 seconds. Can you help me?
 
Level 13
Joined
Mar 24, 2010
Messages
950
this is a really quick job but will work
  • Untitled Trigger 002
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Custom Script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Farm)) and do (Actions)
        • Loop - Actions
          • Player - Add 1 to (Owner of (Picked unit)) Current gold
 
Level 6
Joined
May 13, 2013
Messages
111
this is a really quick job but will work
  • Untitled Trigger 002
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Custom Script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Farm)) and do (Actions)
        • Loop - Actions
          • Player - Add 1 to (Owner of (Picked unit)) Current gold

That's what I'm looking for, thanks a lot. I will put you in my credits and +rep for those who helped me.. =)
 
Status
Not open for further replies.
Top