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

[General] Gold to both players

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,602
Hey,

Can someone quickly create for me a trigger that gives "x" player "a" amount of gold "y" player receives from selling an item (so both players receive same amount of money).

Map is attached. No idea how to create one.
 

Attachments

  • GIVE SAME AMOUNT OF GOLD TO BOTH PLAYERS.w3x
    17.3 KB · Views: 42

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
I suppose you need to have a loop trigger to count the current gold of the player(s). Then once the item is sold you calculate the difference between the old gold and the current gold. Divide that by 2 and you get how much you should abstract from the selling player and how much you should add to the other player.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
try this.
  • System
    • Events
      • Unit - A unit Pawns an item (to shop)
    • Conditions
    • Actions
      • Set gold = (Player 1 (Red) Current gold)
      • Wait 0.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • gold Greater than or equal to (Player 1 (Red) Current gold)
        • Then - Actions
          • Set calc = (gold - (Player 1 (Red) Current gold))
        • Else - Actions
          • Set calc = ((Player 1 (Red) Current gold) - gold)
      • Set calc = (calc / 2)
      • Player - Add calc to Player 2 (Blue) Current gold
      • Player - Add (calc - (calc x 2)) to Player 1 (Red) Current gold
with floating text:

  • System
    • Events
      • Unit - A unit Pawns an item (to shop)
    • Conditions
    • Actions
      • Set gold = (Player 1 (Red) Current gold)
      • Wait 0.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • gold Greater than or equal to (Player 1 (Red) Current gold)
        • Then - Actions
          • Set calc = (gold - (Player 1 (Red) Current gold))
        • Else - Actions
          • Set calc = ((Player 1 (Red) Current gold) - gold)
      • Set calc = (calc / 2)
      • Player - Add calc to Player 2 (Blue) Current gold
      • Player - Add (calc - (calc x 2)) to Player 1 (Red) Current gold
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Floating Text - Create floating text that reads (+ + (String(calc))) at (Position of (Triggering unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
      • Custom script: endif
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
That system is imperfect. The player could earn gold from kills or mining which would also carry over during that time. They could also be mean and spend it on items, units or upgrades before the other player gets it. You will probably need a 0 second timer to prevent this from happening.
 
Status
Not open for further replies.
Top