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

Problem with Gold Generator Trigger

Status
Not open for further replies.
Level 1
Joined
Dec 17, 2009
Messages
5
hello everybody,

I am developping a map and i have some problem with triggers.

My problem is that, i want the player to get 10 gold every 2 seconds per unit in a region.

For example, if there are 2 workers in the region, the player gets 20 gold every 2 seconds.

I don't know that much thing about triggers and any help would be appreciated.

Thanks.
 
Level 9
Joined
Jul 10, 2011
Messages
562
i dont have wc3 on this pc so i give you the idea...

periodically pick every unit of your desired unit-type in the desired region and add the desired gold amount to the owner.

thats it.

make sure you clean the leaks.
 
Level 3
Joined
Jul 12, 2011
Messages
51
Not opening editor, so very busy atm. Something like this will do:

Event is a periodic timer.
Condition is nothing.
Action is a pick unit group in region matching conditions.

Event: Periodic timer --> Every 2 seconds
Condition: Nothing
Action: Unit Group - pick every unit in (select your region) MATCHING unit-type of picked/matching unit is (unit type of the unit that generates gold in region) AND owner of MATCHING unit is (you the player) and do actions: property add gold +10.

Something like that. If it doesn't work, play around with picked unit/matching unit I forget which one of the two to use to make it work.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
I made the trigger to work for all players in the game for a certain region but if you have more than one region you will have to make a trigger for every one unless I come out with another solution.

Here you are:
  • Timed Gather
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Workers = (Units in Resource Domain <gen> matching (((Unit-type of (Matching unit)) Equal to Peasant) and ((Owner of (Matching unit)) Equal to (Picked player))))
          • Set numWorkers = (Number of units in Workers)
          • Custom script: call DestroyGroup(udg_Workers)
          • Player - Add (numWorkers x 10) to (Picked player) Current gold
 
Level 1
Joined
Dec 17, 2009
Messages
5
ok i found the solution, thank you ;)


And another question, my worker unit is an acolyte and i want it to play the "stand work gold" animation in loop. How can i loop a unit animation ?
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
ok i found the solution, thank you ;)


And another question, my worker unit is an acolyte and i want it to play the "stand work gold" animation in loop. How can i loop a unit animation ?

I don't know how can you loop it but all I know is that you could queue many animation so the unit will keep playing them and if the unit moves the animation is reset or you could use a dummy ability based on Channel spell.
 
Level 1
Joined
Dec 17, 2009
Messages
5
i found a solution, this animation is exactly 2 seconds so i had an action in the time gather trigger that says:

Unit Group - Pick every unit in (Units in RessourceRegion <gen> matching ((Unit-type of (Matching unit)) Equal to Acolyte)) and do (Animation - Play (Picked unit)'s stand work gold animation)
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
i found a solution, this animation is exactly 2 seconds so i had an action in the time gather trigger that says:

Unit Group - Pick every unit in (Units in RessourceRegion <gen> matching ((Unit-type of (Matching unit)) Equal to Acolyte)) and do (Animation - Play (Picked unit)'s stand work gold animation)

Ok, its better to Queue the animation not play a new one; that way you will make sure that the next animation will work with the end of the previous one just make sure that you played it for the first time once the unit starts collecting (in your case when it stands on the region) then queue the animation every 2 seconds.
 
Status
Not open for further replies.
Top