• 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 for giving resources to allies.

Status
Not open for further replies.
Level 7
Joined
May 11, 2010
Messages
278
So, i want a trigger that, every minute, checks if any players has [building]. If there is a player that control atleast one [building], a fourth of his gold and lumber is given to his ally.
You can only have one ally in my game mode. any player on the map can become allied with anyone.

so, if the picked player controls atleast one [building] AND has an ally, a fourth of his gold and lumber is removed, and those resources are given to the ally.
 
Last edited:
Level 6
Joined
Dec 9, 2008
Messages
233
And if this player has more than one building also fourth of gold and lumber will be transferred to his ally?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Event - Every 60 minutes of game time
  • Actions
    • Player Group - Pick players in All players
      • if Ally[Player number of picked player] not equal to null then
        • Custom script: set bj_wantDestroyGroup = true
        • set integer = Number of units in units owned by picked player matching (matching unit) is alive and (matching unit) is a building
          • if integer > 0 then
            • Player - Add Current gold of picked player / 4 to Ally[Player number of picked player] current gold
            • Player - Add Current lumber of picked player / 4 to Ally[Player number of picked player] current lumber
Instead of All players, you could pick players in a custom player group. Add all players you want to check into that group at map initialization.

Ally is a player array variable. When a player loses an ally, do this:
  • Custom script: set udg_Ally[GetConvertedPlayerId(GetTriggerPlayer())] = null
GetTriggerPlayer = Triggering player. If your trigger doesn't have triggering player, replace it with something else.
 
Level 7
Joined
May 11, 2010
Messages
278
ah. i see. i'll try.

So, will this work?
Doesn't it screw up when there is four players, player A and B is allied, and player C and D is allied?

I know there are leaks, but lets ignore them for now.

  • Meat Cage
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Meat Cage
      • (Owner of (Dying unit)) Not equal to (Owner of (Killing unit))
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Ally[(Player number of (Picked player))] Not equal to Neutral Hostile
            • Then - Actions
              • Player - Make (Owner of (Dying unit)) treat (Picked player) as an Enemy
              • Set Ally[(Player number of (Picked player))] = Neutral Hostile
            • Else - Actions
      • Wait 0.01 seconds
      • Player - Add 25 to (Owner of (Killing unit)) Current lumber
      • Player - Make (Owner of (Dying unit)) treat (Owner of (Killing unit)) as an Ally with shared vision
      • Set Ally[(Player number of (Owner of (Killing unit)))] = (Owner of (Killing unit))
      • Game - Display to (All players) the text: ((Name of (Owner of (Dying unit))) + ( and + ((Name of (Owner of (Killing unit))) + is now Allied!)))
  • give resources to ally
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Ally[(Player number of (Picked player))] Not equal to Neutral Hostile
            • Then - Actions
              • Set number = (Number of units in (Units owned by (Picked player) matching (((Unit-type of (Matching unit)) Equal to Town Hall (human)) and (((Matching unit) is alive) Equal to True))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • number Greater than 0
                • Then - Actions
                  • Player - Add (((Picked player) Current gold) / 4) to Ally[(Player number of (Picked player))] Current gold
                  • Player - Add (((Picked player) Current lumber) / 4) to Ally[(Player number of (Picked player))] Current gold
                • Else - Actions
            • Else - Actions
 
Last edited by a moderator:
Level 7
Joined
May 11, 2010
Messages
278
okay, will fix that.

it's supposed to break a previous alliance. as if you have an ally and a newly built "meat cage" is destroyed, the previous ally is now your enemy.
it does work, right?
 
Last edited:
Level 7
Joined
May 11, 2010
Messages
278
i can't get one thing to work. when you become allied with someone else, you are still allied with your previous ally. i don't want this to happen.

i tried changing the trigger to this, but it still doesn't work.
  • Meat Cage
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Meat Cage
      • (Owner of (Dying unit)) Not equal to (Owner of (Killing unit))
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked player) Not equal to (Owner of (Dying unit))
              • ((Picked player) is an ally of (Owner of (Dying unit))) Equal to True
            • Then - Actions
              • Player - Make (Owner of (Dying unit)) treat (Picked player) as an Enemy
              • Player - Make (Picked player) treat (Owner of (Dying unit)) as an Enemy
              • Set Ally[(Player number of (Picked player))] = Neutral Hostile
            • Else - Actions
      • Wait 0.01 seconds
      • Player - Add 25 to (Owner of (Killing unit)) Current lumber
      • Player - Make (Owner of (Dying unit)) treat (Owner of (Killing unit)) as an Ally with shared vision
      • Player - Make (Owner of (Killing unit)) treat (Owner of (Dying unit)) as an Ally with shared vision
      • Set Ally[(Player number of (Owner of (Killing unit)))] = (Owner of (Killing unit))
      • Set Ally[(Player number of (Owner of (Dying unit)))] = (Owner of (Dying unit))
      • Game - Display to (All players) the text: ((Name of (Owner of (Dying unit))) + ( and + ((Name of (Owner of (Killing unit))) + is now Allied!)))
Is it because i am trying the trigger out with bots or is it something else?
 
Level 7
Joined
May 11, 2010
Messages
278
Got it to work!
help me clean up leaks? :3
  • Meat Cage
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Meat Cage
      • (Owner of (Dying unit)) Not equal to (Owner of (Killing unit))
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make (Picked player) treat (Owner of (Killing unit)) as an Enemy
          • Player - Make (Owner of (Killing unit)) treat (Picked player) as an Enemy
      • Wait 0.10 seconds
      • Player - Add 25 to (Owner of (Killing unit)) Current lumber
      • Player - Make (Owner of (Dying unit)) treat (Owner of (Killing unit)) as an Ally with shared vision
      • Player - Make (Owner of (Killing unit)) treat (Owner of (Dying unit)) as an Ally with shared vision
      • Game - Display to (All players) the text: ((Name of (Owner of (Dying unit))) + ( and + ((Name of (Owner of (Killing unit))) + is now Allied!)))
 
Status
Not open for further replies.
Top