• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] team sell?

Status
Not open for further replies.
Level 1
Joined
May 6, 2008
Messages
3
Hello, what is the best way (or any way) To implement team sell ( when items are sold from a hero that has left the game in dota, the gold that would have been gained is given to all remaining players on that team)

Is it in the same trigger as leavers in dota or a seperate one? This information is surprisingly difficult to find....
 
There are two ways of doing that. The first way is using a periodic event to split the player's gold to the remaining players.
  • Trigger0
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Temp_Force = (All players matching (((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User))
    • Player Group - Pick every player in (Temp_Force) and do (Actions)
      • Loop - Actions
        • Player Group - Add (Picked player) to (PlayersForce)
  • //I do not leak this out on purpose.
  • Trigger1
  • Events
    • Player - Player 1 (Red) leaves the game
    • Player - Player 2 (Blue) leaves the game
    • ...
    • Player - Player 12 (Brown) leaves the game
  • Conditions
  • Actions
    • Player Group - Remove (Triggering Player) from (PlayersGroup)
    • Player Group - Add (Triggering Player) to (LeaversGroup)
    • Trigger - Turn on Trigger 2 <gen>
  • Trigger2
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • Set Number = (Number of Players in (PlayersGroup))
    • Player Group - Pick every player in (LeaversGroup) and do (Actions)
      • Loop - Actions
        • Set Player = (Picked Player)
        • Player Group - Pick every player in (PlayersGroup) and do (Actions)
          • Loop - Actions
            • Player - Add ((Player)'s Current Gold / (Number)) to (Picked Player) Current gold
        • Player - Add -((Picked Player)'s Current Gold) / Number) to (Picked Player) Current gold
and/or

add/swap the Trigger2 with this:
  • Trigger2
  • Events
    • Unit - A unit pawns an item (to shop)
  • Conditions
    • (Owner of (Triggering unit)) is in (LeaversGroup)) Equal to True
  • Actions
    • Player Group - Pick every player in (PlayersGroup) and do (Actions)
      • Loop - Actions
        • Player - Add ((Custom value of (Sold item)) / (Number of Players in (PlayersGroup))) to (Picked Player) Current gold
The custom value of the Sold item above is a way to keep a count on the item's cost.
So, for example, an item costs 325 gold:
  • Trigger
  • Events
    • Unit - A unit sells an item (from shop)
  • Conditions
    • (Item-type of (Sold item)) Equal to Ring of Death
  • Actions
    • Item - Set the custom value of (Sold item) to 325
Of course it requires loads of work in GUI, you best head for a table, in Jass, because in GUI you will need a variable with array of type "Item-type" and an additional "Integer", which will work like this:
  • Trigger9
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Items[1] = (Ring of Death)
    • Set Items[2] = (Mask of Death)
    • Set Items[3] = (King's Crown)
    • Set Items[4] = (Sword of Illusion)
    • Set ItemCosts[1] = 325
    • Set ItemCosts[2] = 175
    • Set ItemCosts[3] = 380
    • Set ItemCosts[4] = 560
and with the trigger I gave you above:
  • Trigger
  • Events
    • Unit - A unit sells an item (from shop)
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 4, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Item-type of (Sold item)) Equal to Items[(IntegerA)]
          • Then - Actions
            • Item - Set the custom value of (Sold item) to ItemCosts[(IntegerA)]
          • Else - Actions
 
Level 2
Joined
Feb 8, 2010
Messages
17
Hey there. Was trying to help you out here, but I dont know the most efficient way of doing this. This trigger probably works.... but im sure someone in here can do it better than me.

  • Trigger1 Red
    • Events
      • Player - Player 1 (Red) leaves the game
    • Conditions
    • Actions
      • Set LeftGame[1] = True
Make this trigger for all players.


  • Trigger2
    • Events
      • Unit - A unit Pawns an item (to shop)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • LeftGame[1] Equal to True
        • Then - Actions
          • Set Gold[(Player number of (Owner of (Triggering unit)))] = (Player 1 (Red) Current gold)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set PlayersActive = (PlayersActive + 1)) else do (Do nothing)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Player - Add (Gold[(Player number of (Owner of (Triggering unit)))] / PlayersActive) to (Player((Integer A))) Current gold) else do (Do nothing)
          • Set PlayersActive = 0
          • Player - Set Player 1 (Red) Current gold to 0
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
          • LeftGame[2] Equal to True
        • Then - Actions
          • Set Gold[(Player number of (Owner of (Triggering unit)))] = (Player 2 (Blue) Current gold)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set PlayersActive = (PlayersActive + 1)) else do (Do nothing)
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Player - Add (Gold[(Player number of (Owner of (Triggering unit)))] / PlayersActive) to (Player((Integer A))) Current gold) else do (Do nothing)
          • Set PlayersActive = 0
          • Player - Set Player 2 (Blue) Current gold to 0
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
          • LeftGame[6] Equal to True
        • Then - Actions
          • Set Gold[(Player number of (Owner of (Triggering unit)))] = (Player 6 (Orange) Current gold)
          • For each (Integer A) from 6 to 10, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set PlayersActive = (PlayersActive + 1)) else do (Do nothing)
          • For each (Integer A) from 6 to 10, do (Actions)
            • Loop - Actions
              • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Player - Add (Gold[(Player number of (Owner of (Triggering unit)))] / PlayersActive) to (Player((Integer A))) Current gold) else do (Do nothing)
          • Set PlayersActive = 0
          • Player - Set Player 6 (Orange) Current gold to 0
        • Else - Actions
This is only set for players 1,2 and 6 right now. But you can just edit it for more players. Sorry for not making the whole thing, but im dead tired.

Variables:
Gold - Integer Array (12) - 0 (Default)
LeftGame - Boolean Array (12) - False (Default)
PlayersActive - Integer - 0 (Default)

------------------

Regards,
Orbit




Edit: Oh, Pharaoh beat me to it. And im sure his way is better, he`s an expert :p
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
EDIT:Orbit, your trigger is a bit too specific, try to use some of this:
For the first trigger, why don't you put all the players on the event list, then

>>Set LeftGame[Numper of Triggering Player] = True<<

for the second one, use >For ech (Integer A) from 1 to 12 LOOP<
With this it takes 1/12 the time it would take with your trigger...
 
Last edited:
Level 2
Joined
Feb 8, 2010
Messages
17
EDIT:Orbit, your trigger is a bit too specific, try to use some of this:
For the first trigger, why don't you put all the players on the event list, then

>>Set LeftGame[Numper of Triggering Player] = True<<

for the second one, use >For ech (Integer A) from 1 to 12 LOOP<
With this it takes 1/12 the time it would take with your trigger...

Thanks. I did not remember how to do all players in that first trigger, so I gave up and made 10 instead xD. But thanks for refreshing my mind.

But im not sure what you mean in my 2nd trigger. I use Integer loops. But I need 2 loops, one for each team.

Loop1: player 1-5
Loop2: player 6-10

Am I misunderstanding you?


Regards,
Orbit
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
"If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
LeftGame[2] Equal to True"

This part can be surpressed so you don't have to check this for every player-as you did it :D If I got home I'll make the entire trigger for you :D
 
Status
Not open for further replies.
Top