• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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
 
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.
 
  • 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)
 
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:
 
  • <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.
Back
Top