Units that generate wood..?

GaryOak

New Member
Reaction score
0
Hey all, I was wondering if there was a way I could give a unit a passive ability to generate wood every ten seconds. I was originally trying to do it through triggers but couldnt find out how to make it only apply to specific types of units.

To give a little background information, I am making a tech wars game, and there is an income based off how many buildings you have. For each building you have created, you get 5 wood per ten seconds. However, I have a treant race that uses ancients to fight, so their buildings uproot and run off.

However the income doesn't work for the treants, because in order to get their buildings to gain the proper spells when uprooted, I have to replace them with a unit that isn't a building when uprooted, thus taking away their ability to generate income. This may sound a little complicated, but I basically just want these specific non building units to generate income like they would if they were still buildings, while not giving this ability to ALL non building units. Thanks in advance, guys.
 

tooltiperror

Super Moderator
Reaction score
231
You just need to pick every unit owned by the player, and add wood, of course.

Trigger in a second.

Code:
Lumber
    Events
        Time - Every 10.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of (Picked unit)) Equal to Footman
                        Or - Any (Conditions) are true
                            Conditions
                        (Unit-type of (Picked unit)) Equal to Footman
                    Then - Actions
                        Player - Add 20 to (Owner of (Picked unit)) Current lumber
                    Else - Actions
 

GaryOak

New Member
Reaction score
0
holy cow, thank you so much! This is exactly what I was wanting to do originally, but I didnt think to pick all units and then single them out from there. You're a life saver, and quick to reply too! Thanks again, mate!
 

tooltiperror

Super Moderator
Reaction score
231
No problem, dude, call again and I`ll be there.
 

jomik

New Member
Reaction score
17
I'll just give you one without leaks :cool:

Trigger:
  • Gold per unit
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Footman))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Player - Add 20 to (Owner of (Picked unit)) Current gold
      • Custom script: call DestroyGroup(udg_tempGroup)
 

GaryOak

New Member
Reaction score
0
0This is excellent! I am going to PDXLAN this weekend (a giant 500 man LAN in Portland, OR) and I was worried I wasn't going to be able to get this race to work properly in time. Now I get to have people at the LAN test my map out. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top