• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Buildings which spawn gold that is automatically used?

Status
Not open for further replies.
Level 2
Joined
Jun 30, 2008
Messages
19
Try this:

Create a variable called RedsGold (or whatever you prefer), Variable-type: Integer, set the initial value to 0 (make one of these for each player).

Then make this trigger

  • GoldBuilding is Built
  • Events
    • Unit - A unit owned by Player 1 (Red) Finishes construction
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to GoldBuilding
  • Actions
    • Set RedsGold = (RedsGold + 1)
Where GoldBuilding is the building that produces the gold

Then make another:

  • Periodic Gold
  • Events
    • Time - Every x seconds of game time
  • Actions
    • Player - Add (RedsGold x 10) to Player 1 (Red) Current gold
    • Player - Add (BluesGold x 10) to Player 2 (Blue) Current gold
    • Player - Add (TealsGold x 10) to Player 3 (Teal) Current gold
    • etc.
Change 10 to the amount of gold you want the building to periodically give, per building, and x to how often you want the gold to be given.

This is assuming that the buildings wont die, or you want the income to be permanent. If you want to make them destroyable, and the income to stop when they are destroyed, also make this:

  • GoldBuilding is Destroyed
  • Events
    • Unit - A unit owned by Player 1 (Red) Dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to GoldBuilding
  • Actions
    • Set RedsGold = (RedsGold - 1)
You will have to make multiple copies of the first and third trigger, one for each player, as well as one variable for each player.

I have a funny feeling that there is a more efficient way to do this, but this is the only way I can think of being able to do it. I'll try and think of a better way, or maybe someone else can lend their thoughts.
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
You can make it with simple periodic trigger.

This trigger is more simple and better than previous ones.
Note that TempGroup variable is used to remove memory leaks.

  • Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • 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
              • (Unit-type of (Picked unit)) Equal to Factory
            • Then - Actions
              • Player - Add 5 to (Owner of (Picked unit)) Current gold
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
 
Level 4
Joined
Mar 26, 2008
Messages
100
I've already done this, there is a simpler method:
I gave a unit the factory ability so it created another money unit (invisible) and using a trigger I checked when a money unit was created. It then removed the unit and gave the owner a sum of money.
This way you don't have to add a timer.
 
Status
Not open for further replies.
Top