• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

noob question

Status
Not open for further replies.
Level 1
Joined
Feb 27, 2011
Messages
2
i still suck at making triggers, and avoid them as much as possible. but heres one i cant figure out, and don't know how to make: how do you make it so that you add gold to a player's account every X seconds per each type of unit, when you have 2 buildings that are the 'units'?
 
  • Ti
  • Events
    • Time - Every 20.00 seconds of game-time
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Player(IntegerA) slot status) Equal to Is Playing
            • (Player(IntegerA) controller) Equal to User
          • Then - Actions
            • Set Group[Player number of (Player(IntegerA))] = (Units owned by (IntegerA) of type Barracks)
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • (Number of units in Group[Player number of (Player(IntegerA))]) Greater than 0
              • Then - Actions
                • Player - Add (20 x (Number of units in Group[Player number of (Player(IntegerA))])) to (Player(IntegerA))'s Current gold
              • Else - Actions
          • Custom script: call DestroyGroup (udg_Group[GetForLoopIndexA()])
      • Else - Actions
 
Pharaoh, why create a group array for this? Just one group is needed:

  • Example
    • Events
      • Time - Every 20.00 seconds of game-time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (Actions) else do (Actions)
            • If - Conditions
              • (Player(IntegerA) slot status) Equal to Is Playing
              • (Player(IntegerA) controller) Equal to User
            • Then - Actions
              • Set TempGroup = (Units owned by (Player (Integer A)) of type Barracks)
              • If (All conditions are true) then do (Actions) else do (Actions)
                • If - Conditions
                  • (Number of units in TempGroup) Greater than 0
                • Then - Actions
                  • Player - Add (20 x (Number of units in TempGroup) to (Player(IntegerA))'s Current gold
                • Else - Actions
              • Custom script: call DestroyGroup(udg_TempGroup)
            • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Filter out dead buildings, they add gold also.

You could make it without a variable, but that can result in a useless "add 0 gold function call.

  • Untitled Trigger 078
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Player = (Player((Integer A)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player controller) Equal to User
              • (Player slot status) Equal to Is playing
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Player - Add (20 x (Number of units in (Units owned by Player matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Barracks))))) to Player Current gold
            • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I tested it, once...
A trigger like this
Set it like:
Farm = 5 gold each
Barrack = 10 gold each
When it is built in the first place, it is working fine the gold gain and unit calculation
But when the Farm/Barrack dies, it calculated the wrong gold gain and thus, bugging the system (this system trigger has nothing to do with trigger in this thread)
So, I believe, it still picks up dead unit
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Units that don't decay and are non-ressurectable don't have the blood splatter effect when it explodes, I tested it on a gryphon rider and a farm, though the farm ubersplat still shows up and vanishes after a few seconds (2?).
 
Status
Not open for further replies.
Top