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

[Trigger] hey how can i make this?

Status
Not open for further replies.
Level 16
Joined
Jul 21, 2008
Messages
1,121
Try this:

  • Income
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • -------- This trigger requires 1 unit group variable (TempGroup) --------
      • -------- We are setting a variable to avoid leaks --------
      • Set TempGroup = (Units of type Farm)
      • -------- Now, picking every farm and giving gold to its owner --------
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Player - Add 1 to (Owner of (Picked unit)) Current gold
      • -------- Clearing group variable to avoid leaks --------
      • Custom script: call DestroyGroup(udg_TempGroup)
      • -------- Basicaly, this trigger gives 1 gold to each player for every farm every 10 seconds --------
 
Level 11
Joined
May 31, 2008
Messages
698
ok guys that doesnt have ANYTHING to do with the farm... All you are doing is selecting units, then giving gold. You have to set a variable to the number of units type of farm owned by player 1 that are alive, then multiply that by the income per farm (in this case 1 so dont multiply) then you have to set player 1 gold to player 1 current gold plus the variable you just made.

Heres the trigger:
  • Actions
    • Set Farms = (Number of living Farm units owned by Player 1 (Red))
    • Player - Set Player 1 (Red) Current gold to ((Farms x 1) + (Player 1 (Red) Current gold))
If you created upgraded farms that provided additional income (and food) you can change the (Farms x 1) to (Farms x 2) or 3 or whatever. I just put the x 1 there cuz if the farm gives anything but 1 income you need it, but if ur only doin 1 income you dont. You will have to make this for each player too (in same trigger just copy the actions and change player 1 to player 2, etc)
 
Level 11
Joined
Nov 15, 2007
Messages
800
ok guys that doesnt have ANYTHING to do with the farm... All you are doing is selecting units, then giving gold. You have to set a variable to the number of units type of farm owned by player 1 that are alive, then multiply that by the income per farm (in this case 1 so dont multiply) then you have to set player 1 gold to player 1 current gold plus the variable you just made.

Heres the trigger:
  • Actions
    • Set Farms = (Number of living Farm units owned by Player 1 (Red))
    • Player - Set Player 1 (Red) Current gold to ((Farms x 1) + (Player 1 (Red) Current gold))
If you created upgraded farms that provided additional income (and food) you can change the (Farms x 1) to (Farms x 2) or 3 or whatever. I just put the x 1 there cuz if the farm gives anything but 1 income you need it, but if ur only doin 1 income you dont. You will have to make this for each player too (in same trigger just copy the actions and change player 1 to player 2, etc)

Actually pick every unit and do X is a looping function that repeats the trigger for each unit. So it does practically the exact same thing as your considerably longer trigger. And why would you use set property instead of add property...? Though you are right about the group being better as only living units. So,

  • Farmz
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Farm) and (((Matching unit) is alive) Equal to True))) and do (Player - Add 1 to (Owner of (Picked unit)) Current gold)
That'll work fine. Try it yourself. Plus, your way would have to be done individually for every player in the game.
 
Level 11
Joined
May 31, 2008
Messages
698
ok ok i will say it just because ur waiting for me to say ur right myself so you can revel in your glory and laugh at my defeat and whatnot... you, Sir Squiggy (and everyone else who agreed with him and said what he said), are indeed correct. Happy? :xxd: lol
 
Status
Not open for further replies.
Top