• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

building=income?

Status
Not open for further replies.
Level 3
Joined
May 10, 2007
Messages
39
hey.
i wanna make a building giving me income...
and the more i have the move income...
and if i dont have that building i dont get income
how i do that?
 
This will give 100 gold for each unit of type YourUnitType to the owner of the unit every 10 seconds.

  • Income
    • Events
      • Time - Every [COLOR="Blue"]10.00[/COLOR] seconds of game time
    • Conditions
    • Actions
      • Set temp_group = (Units of type [COLOR="Blue"]YourUnitType[/COLOR])
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Player - Add [COLOR="Blue"]100[/COLOR] to (Owner of (Picked unit)) [COLOR="Blue"]Current gold[/COLOR]
            • Else - Actions
      • Custom script: call DestroyGroup(udg_temp_group)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
  • Income
    • Events
      • Time - Every [COLOR=Blue]10.00[/COLOR] seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type [COLOR=Blue]YourUnitType[/COLOR]) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Player - Add [COLOR=Blue]100[/COLOR] to (Owner of (Picked unit)) [COLOR=Blue]Current gold[/COLOR]
            • Else - Actions
For efficiency reasons, you can replace temg_group in that way
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
For even higher efficency and easier use.
Every time a building is made, you add the amount of gold to a integer array of level of the building player and every 10 seconds you loop through the array and add the gold in each level to the corrosponding player. And when the unit dies, you simply remove the quantity from the integer for the owning player. This saves you from looping through all the buildings and checking if everyone is allive and then adding the gold for the player making it demmand a lot fewer recources (processing power) to run and so will be more efficent.

I use the above system when ever possiable since it is also easier to program for multiple buildings.
 
Status
Not open for further replies.
Top