• 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 activate when I win gold (Help)

Status
Not open for further replies.
Level 3
Joined
Oct 20, 2017
Messages
52
Hello, sorry for my bad English ;-;. I am trying to create a trigger to be activated when my unit delivers the gold (being peasant or peon or acolyte or wisp), or to activate the moment I earn gold (I don't want it to be activated when the gold value is changed when I train any unit or build or buy any item).
Is it possible to do that?
 
Level 3
Joined
Oct 20, 2017
Messages
52
I tried in-game, and saw that when it returns gold the unit issues the order "harvest", so make a trigger where the unit issues an order and that's it.
I tested it here and it works only for peasant and peon, but not with acolyte and wisp and it is also counting wood collection as well.
  • Gold
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
    • Actions
      • Set Score = (Score + 1)
 
Level 13
Joined
May 10, 2009
Messages
868
You'll have to use a couple of integer variables combined with an event similar to what Ender Wiggins suggested in order to help you know how much gold a player has actually gathered/collected from mines.

Since you don't really want your trigger to be interfered by any other gold interaction, use "Total gold gathered becomes Greater than 0.00" instead. That means the event won't fire even if a player sells items, earns gold by killing neutral hostile units, buys stuff, etc.

Example:
  • Gold Gather Detection
    • Events
      • Player - Player 1 (Red)'s Total gold gathered becomes Greater than 0.00
      • Player - Player 2 (Blue)'s Total gold gathered becomes Greater than 0.00
      • Player - Player 3 (Teal)'s Total gold gathered becomes Greater than 0.00
      • Player - Player X's Total gold gathered becomes Greater than 0.00
      • -------- etc --------
    • Conditions
    • Actions
      • Set tmp_player = (Triggering player)
      • Set tmp_integer = (Player number of tmp_player)
      • -------- Compare triggering player's total gold gathered with a variable responsible for tracking their gold collected. --------
      • Set Gold_Difference = ((tmp_player Total gold gathered) - Gold_PlayerGoldGathered[tmp_integer])
      • -------- The variable below should be updated after doing the comparison above. Then: --------
      • Set Gold_PlayerGoldGathered[tmp_integer] = (tmp_player Total gold gathered)
      • -------- ---- --------
      • Game - Display to (All players) the text: (((Name of tmp_player) + has just gathered +) + ((String(Gold_Difference)) + gold.))
Do note that the trigger also takes gold tax rate into account too (no upkeep, low upkeep and high upkeep).

HOWEVER, there's only one issue remaining now which is when you give gold to a player via trigger actions in GUI. It unfortunately affects that event. There's a small work-around for it. You'll need to declare a new boolean variable and use a second trigger.
  • Gold Trigger Modifier
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player X's Current gold becomes Greater than or equal to 0.00
      • -------- etc --------
    • Conditions
      • Gold_TriggerModifier Equal to True
    • Actions
      • -------- Adding gold to a player via triggers will also affect their "Total Gold Gathered" property. Keep track of it --------
      • Set Gold_PlayerGoldGathered[(Player number of (Triggering player))] = ((Triggering player) Total gold gathered)
      • Set Gold_TriggerModifier = False
and add a boolean comparison condition to the first trigger based on the new variable
  • Gold Gather Detection
    • Events
      • Player - Player 1 (Red)'s Total gold gathered becomes Greater than 0.00
      • Player - Player 2 (Blue)'s Total gold gathered becomes Greater than 0.00
      • Player - Player 3 (Teal)'s Total gold gathered becomes Greater than 0.00
      • Player - Player X's Total gold gathered becomes Greater than 0.00
      • -------- etc --------
    • Conditions
      • Gold_TriggerModifier Equal to False
    • Actions
      • Set tmp_player = (Triggering player)
      • Set tmp_integer = (Player number of tmp_player)
      • -------- Compare triggering player's total gold gathered with a variable responsible for tracking their gold collected. --------
      • Set Gold_Difference = ((tmp_player Total gold gathered) - Gold_PlayerGoldGathered[tmp_integer])
      • -------- The variable below should be updated after doing the comparison above. Then: --------
      • Set Gold_PlayerGoldGathered[tmp_integer] = (tmp_player Total gold gathered)
      • -------- ---- --------
      • Game - Display to (All players) the text: (((Name of tmp_player) + has just gathered +) + ((String(Gold_Difference)) + gold.))
Then, every time you use any action which sets, adds or decreases player gold, you'll need to add that variable on top of it.
  • Initial gold
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Gold_TriggerModifier = True
      • Player - Set Player 1 (Red) Current gold to 100
  • Press ESC to add gold
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Gold_TriggerModifier = True
      • Player - Add 250 to Player 1 (Red) Current gold
Modifying player gold amount with SetPlayerState native + PLAYER_STATE_RESOURCE_GOLD property won't fire "Total gold gathered" events.
  • -------- Adds 100 gold to player 1 (red) --------
  • Custom script: call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + 100)
Neither "Gold Trigger Modifier" trigger, nor "Gold_TriggerModifier" variable are needed anymore in case you use the custom script above.

Mega bullshit...
 

Attachments

  • GetGoldGatheredAmount.w3x
    21.7 KB · Views: 30
Level 13
Joined
May 10, 2009
Messages
868
oh, I thought that was what he wanted...
I must confess that I got confused by the original post. So, you might be right.
activated when my unit delivers the gold (being peasant or peon or acolyte or wisp)
Then
activate the moment I earn gold (I don't want it to be activated when the gold value is changed when I train any unit or build or buy any item)
In this case, the trigger below should be enough.
  • Detect Gold Earned
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player X's Current gold becomes Greater than or equal to 0.00
      • -------- etc --------
    • Conditions
    • Actions
      • Set tmp_player = (Triggering player)
      • Set tmp_integer = (Player number of tmp_player)
      • -------- Compare triggering player's current gold with a variable responsible for tracking their gold amount --------
      • Set Gold_Difference = ((tmp_player Current gold) - Gold_PlayerGoldEarned[tmp_integer])
      • -------- The variable below should be updated after doing the comparison above. Then: --------
      • Set Gold_PlayerGoldEarned[tmp_integer] = (tmp_player Current gold)
      • -------- Check if difference is positive --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Gold_Difference Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: (((Name of tmp_player) + has earned +) + ((String(Gold_Difference)) + gold.))
        • Else - Actions
 

Attachments

  • DetectGoldEarned.w3x
    20.1 KB · Views: 33
Level 3
Joined
Oct 20, 2017
Messages
52
I must confess that I got confused by the original post. So, you might be right.

Then

In this case, the trigger below should be enough.
  • Detect Gold Earned
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to 0.00
      • Player - Player X's Current gold becomes Greater than or equal to 0.00
      • -------- etc --------
    • Conditions
    • Actions
      • Set tmp_player = (Triggering player)
      • Set tmp_integer = (Player number of tmp_player)
      • -------- Compare triggering player's current gold with a variable responsible for tracking their gold amount --------
      • Set Gold_Difference = ((tmp_player Current gold) - Gold_PlayerGoldEarned[tmp_integer])
      • -------- The variable below should be updated after doing the comparison above. Then: --------
      • Set Gold_PlayerGoldEarned[tmp_integer] = (tmp_player Current gold)
      • -------- Check if difference is positive --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Gold_Difference Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: (((Name of tmp_player) + has earned +) + ((String(Gold_Difference)) + gold.))
        • Else - Actions
Sorry for not answering, I will test and let you know if this is what I wanted :)
 
Status
Not open for further replies.
Top