• 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.

[Trigger] Gold Every time if a unit is in a region

Status
Not open for further replies.
Level 3
Joined
Mar 7, 2010
Messages
29
hi i m looking for a trigger that is a unit (or more) of a player is in a region named "center" the player owned of units get 1 gold at second
thx for your help
 
Level 9
Joined
Sep 28, 2004
Messages
365
Should be something like this. Just play around with the conditions since i have no idea what type of units you want to let them gain gold in the region.
  • Gold in Region
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units owned by Player 1 (Red) matching (((Matching unit) is A structure) Equal to False))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (center contains (Picked unit)) Equal to True
            • Then - Actions
              • Player - Add 1 to (Owner of (Picked unit)) Current gold
            • Else - Actions
      • Custom script: call DestroyGroup(udg_tempGroup)
 
JeffreyQ said:
Should be something like this. Just play around with the conditions since i have no idea what type of units you want to let them gain gold in the region.
  • Gold in Region
  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
  • Actions
    • Set tempGroup = (Units owned by Player 1 (Red) matching (((Matching unit) is A structure) Equal to False))
    • Unit Group - Pick every unit in tempGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
          • (center contains (Picked unit)) Equal to True
        • Then - Actions
          • Player - Add 1 to (Owner of (Picked unit)) Current gold
        • Else - Actions
    • Custom script: call DestroyGroup(udg_tempGroup)

  • Set tempGroup = (Units owned by Player 1 (Red) matching (((Matching unit) is A structure) Equal to False))
  • Player - Add 1 to (Owner of (Picked unit)) Current gold
You initially pick every unit of Player 1 (Red) and then you try to make this MPI, by refering as (Owner of (Picked unit)), when that owner is Red already.
You need to pick every unit in the region and add gold to its owner.
 
Level 9
Joined
Sep 28, 2004
Messages
365
  • Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPos = (Center of (center))
      • Set tempGroup = (Units in tempPos matching (((Matching unit) is A structure) Equal to False))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Player - Add 1 to (Owner of (Picked unit)) Current gold
      • Custom script: call DestroyGroup(udg_tempGroup)
      • Custom script: call RemoveLocation(udg_tempPos)
 
Level 9
Joined
Oct 11, 2009
Messages
477
hi i m looking for a trigger that is a unit (or more) of a player is in a region named "center" the player owned of units get 1 gold at second
thx for your help

Here's the GUI version of the trigger I provided for you.:cute:

  • <Name of the Trigger>
    • Events
      • Time - Every 1 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (<Name of your Region>) and do (Actions)
        • Loop - Actions
          • Player - Add (1x(Number of units in (<Name of your Region>) owned by Owner of Picked Unit)) Gold to Owner of Picked Unit
x - Multiplication(Math Operator)
Note:The region <Name of your Region> can be named in anyway although region names will not affect any of your map functions, their names are for the editor refence.
I hope you understand. Reply to me if you want more info about that or another set of triggers.:grin:
 
Level 12
Joined
May 21, 2009
Messages
994
  • <Name of the Trigger>
    • Events
      • Time - Every 1 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (<Name of your Region>) and do (Actions)
        • Loop - Actions
          • Player - Add (1x(Number of units in (<Name of your Region>) owned by Owner of Picked Unit)) Gold to Owner of Picked Unit
Sorry to say it but don't use this because it leaks. You want a leak every 1 second? No, I don't think so. But it can easily be fixed by doing this:
  • <Name of the Trigger>
    • Events
      • Time - Every 1 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (<Name of your Region>) and do (Actions)
        • Loop - Actions
          • Player - Add (1x(Number of units in (<Name of your Region>) owned by Owner of Picked Unit)) Gold to Owner of Picked Unit
Now it is fixed.
 
Status
Not open for further replies.
Top