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

[Solved] Help Me On How To Distinguish Players Pick up Item Numbers

Status
Not open for further replies.
Level 5
Joined
May 8, 2020
Messages
87
I have Trigger like this
but I don't know how to distinguish the picks of each player :
for example Player Red picked it up 6 times
but until Player Blue picks it up 1 time = 7 times (even though player 2 picks it up for the first time, it counts as 7 times)
 

Attachments

  • 342101546_1293795541238521_6367278840770032495_n (1).png
    342101546_1293795541238521_6367278840770032495_n (1).png
    24.6 KB · Views: 18
Level 5
Joined
May 8, 2020
Messages
87
sorry , maybe my english is a bit bad to explain .
but it doesn't work , i will leave the picture
I'm the player (Red) who picks up the item for the 3rd time, but when the player (Blue) picks up the item it doesn't count as the 1st time, it counts as the 4th time.


1681718501142.png
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That's because you're using one global variable. This variable is going to be shared between all of your triggers and it can only have one value at a time.

So the first option that comes to mind is to create a variable for each player:
  • Set DBZGold_P1 = DBZGold_P1 + 1
  • Set DBZGold_P2 = DBZGold_P2 + 1
  • Set DBZGold_P3 = DBZGold_P3 + 1
This is NOT a good idea though. With this design you will have to make a trigger for EACH player or use a bunch of If Then Else actions to determine who picked up the item.

What you're looking for is a global variable with an Array enabled. Arrays allow you to assign many different values to a single variable at the same time. These values are separated based on their [index] in the Array. It's sort of like numbering items on a grocery list.

So for example, instead of giving P1, P2, and P3 their own unique DBZ variable you would use a single Array variable with 3 different [indexes]:
  • Set DBZGold[1] = DBZGold_[1] + 1
  • Set DBZGold[2] = DBZGold_[2] + 1
  • Set DBZGold[3] = DBZGold_[3] + 1
The Integer in the [index] can represent anything you want. In this case I'm using it to represent the Player Number of each Player.
1 = Red, 2 = Blue, 3 = Teal.

Here's how your trigger should look after switching to an Array variable:
  • Events
    • Unit - A unit Acquires an item
  • Conditions
    • (Item-type of (Item being manipulated)) Equal to Gold Coins
  • Actions
    • Set PN = (Player number of (Owner of (Triggering unit)))
    • Set DBZGold[PN] = DBZGold[PN] + 1
    • Trigger - Turn on Untitled Trigger 002
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • DBZGold[PN] Equal to 7
      • Then - Actions
        • Unit - Create 1 Footman for Player 1 (Red)
      • Else - Actions
PN is a new Integer variable that I created. It helps make the trigger more efficient, clean, and easy to work with.

Here's how you can post your triggers on Hiveworkshop:
I recommend doing this instead of taking a picture, it saves us a lot of time.
 
Last edited:
Level 5
Joined
May 8, 2020
Messages
87
thanks , Is there any way for me to give money to people who no pick up that item ( only hero ) ?
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
thanks , Is there any way for me to give money to people who can't pick up that item ( only hero ) ?
Give your Units a new version of the Inventory (Hero) ability and edit this new ability to have an Item Capacity of 0.

You need to hold Shift when opening the data field to give it a value < 1.

Shift allows you to bypass most data limitations and enables new concepts for existing abilities. For example, giving the Devotion Aura ability a negative value for it's bonus armor and making it targets enemies instead of allies will create a negative armor aura. You can do a lot of cool stuff with this.
 
Last edited:
Level 5
Joined
May 8, 2020
Messages
87
I still don't understand Inventory (Hero) < 1 , usually 1 hero has all 6 empty cells , inventory to = 0 does it change anything
Another sentence:
for example player 1 gets gold coins , is there any correct way for other players player 3 , player 4 to get + money but minus player 1 ?( because picked up gold coins)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I still don't understand Inventory (Hero) < 1 , usually 1 hero has all 6 empty cells , inventory to = 0 does it change anything
It's the Item Capacity, which means how many Inventory Slots the unit has.

If you set it to 3 for example, the unit with the ability will only be able to carry 3 items.

By setting it to 0 it makes it so the unit has 0 inventory slots BUT they can still pick up Powerups (gold coins).

Anyway, I think I misunderstood what you originally said. I thought you wanted non-Hero units to be able to pick up Gold Coins without actually having any Inventory Slots (so they can't pick up Boots of Speed for example).

for example player 1 gets gold coins , is there any correct way for other players player 3 , player 4 to get + money but minus player 1 ?( because picked up gold coins)
Do you mean that Player 1 doesn't get ANY gold? And P3 and P4 get all of the gold? Do they split the gold like 250 / 2 = 125 per player?
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
yes , each player in the game will get half of that gold (ally or enemy)
Half implies that each player gets 125. Do you mean that it's divided between all of the players?

So if 5 Players, then it's 250 / 5 = 50 gold per player.

10 Players: 250 / 10 = 25 gold per player.

I guess I'll show you how to do both:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Coins
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • 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 Player 1 (Red)
            • Then - Actions
              • Player - Add 125 to (Picked player).Current gold
            • Else - Actions
      • Player - Add -250 to Player 1 (Red).Current gold
  • Untitled Trigger 002
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Coins
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Set VariableSet GoldCoin_Amount = (250 / (Number of players in (All players)))
      • 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 Player 1 (Red)
            • Then - Actions
              • Player - Add GoldCoin_Amount to (Picked player).Current gold
            • Else - Actions
      • Player - Add -250 to Player 1 (Red).Current gold
You'll probably want to change (All players) to a Player Group only containing those who should receive the gold.
 
Last edited:
Status
Not open for further replies.
Top