[General] Gold from a building or unit

Status
Not open for further replies.
Level 3
Joined
Jul 4, 2012
Messages
31
Hello guys , so I've been working on a map which is more like vampire or troll and elves , but i don't know how to get gold from a building
i mean i know how to give gold with trigger , I've even set up a gold limiter , but i need to know how to add gold with a building , thanks :)
 
Level 12
Joined
May 20, 2009
Messages
822
Here is a (Very) rough example of how to do it.

  • Add to Income
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • For each (Integer Variable) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (Player(Variable))
            • Then - Actions
              • Set PlayerIncome[Variable] = (PlayerIncome[Variable] + 10)
            • Else - Actions
  • Remove from Income
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • For each (Integer Variable) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (Player(Variable))
            • Then - Actions
              • Set PlayerIncome[Variable] = (PlayerIncome[Variable] - 10)
            • Else - Actions
  • Income
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Variable) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Set (Player(Variable)) Current gold to (((Player(Variable)) Current gold) + PlayerIncome[Variable])
  • Building Init
    • Events
      • Map initialization
    • 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
              • ((Picked unit) is A structure) Equal to True
            • Then - Actions
              • For each (Integer Variable) from 1 to 12, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Picked unit)) Equal to (Player(Variable))
                    • Then - Actions
                      • Set PlayerIncome[Variable] = (PlayerIncome[Variable] + 10)
                    • Else - Actions
            • Else - Actions
It's pretty self-explanitory. A unit finishes construction, so we get who the owner is and add to their income.
If a unit dies, we do the same thing but subtract from their income.
We have one trigger that sets up the starting income for all the buildings on the map that weren't build but just placed on the map.
And then we have the actual periodic income trigger.

This doesn't do everything you want, though. If you want the floating text you'll have to either set that up via trigger or use a completely different method.
 
Okay.
You need some array variables then.

Gold_Unit_Group_Var[x] = Needed to store the buildings
Gold_Integer_Var[x] = Needed to count how many buildings per player there is in the map
*x is max number of players in the map

Trigger 1:
Event - A building finishes constructing
Conditions - Building finished being constructed Equal to Gold Building
Actions -
Set Gold_Integer_Var[Number of (owner of triggering unit)] = (Gold_Integer_Var[Number of (owner of triggering unit)] + 1)
Add triggering unit to Gold_Unit_Group_Var[Number of (owner of triggering unit)]

Trigger 2:
Event - A unit dies
Conditions - Unit type of Triggering unit Equal to Gold Building
Actions -
Set Gold_Integer_Var[Number of (owner of triggering unit)] = (Gold_Integer_Var[Number of (owner of triggering unit)] - 1)
Remove triggering unit to Gold_Unit_Group_Var[Number of (owner of triggering unit)]

Trigger 3:
Event - Every X seconds pf game time
Conditions -
Actions -
For each Integer A 1 to (max number of players) do actions
loop -
Pick every unit in Gold_Unit_Group_Var[Integer A]
loop -
Create a Floating Text above picked unit displaying the text (amount of gold given)
Disable permanence from Last created Floating text
Set lifespan of Last created Floating text to X seconds
Add to Owner of picked unit's gold X



Note:
Actually you don't need the integer variable. But if you want to display some form of calculation in the floating text it's good to have.
Hope it makes sense.


Edit:
ARGH! Screw you aple :p
 
Status
Not open for further replies.
Top