Detecting when a unit returns gold

DeepThought

New Member
Reaction score
1
Basically, I want to make a trigger that detects when a unit returns the gold that it gathered from a gold mine to it's base, so I can display a message and do a bunch of other stuff. How would I do this?
 

Virus

New Member
Reaction score
3
You need 2 triggers for this:

Trigger:
  • Events
    • Map initialization
    • Conditions
    • Actions
      • Set YourIntegerVariable = (Player 1 (Red) Current gold)



Trigger:
  • Events
    • Player - Player 1 (Red)'s Current gold becomes Greater than (Real((Player 1 (Red) Current gold)))
    • Conditions
    • Actions
      • Game - Display to (All players the text: (You have recieved + ((String(((Player 1 (Red) Current gold) - YourIntegerVariable))) + ( you now have + (String((Player 1 (Red) Current gold ))))))
      • Set YourIntegerVariable = (Player 1 (Red) Current gold)
 

Attachments

  • gold.w3m
    16.3 KB · Views: 149

PrisonLove

Hard Realist
Reaction score
78
The problem with that is, if the player kills a creep and gets the bounty from it, the trigger will also fire. I don't think there is a clean way to do what you want, unfortunately.
 

Virus

New Member
Reaction score
3
Oh, you're right.
Didn't tought about the bounty lol.

Well if you have a gatherer, then you could use 2 regions on the main building, so it's doable if you want to detect gathers only.
 

LoveRPG

Member
Reaction score
6
just put a some condition like an if then else.
if:
Dying unit is equal to (creepX)
Action - Then
Do nothing
Action - Else
The text message

Do not know if it will work, took it from the top of my head, but hopefully it will. maybe by making a different condition, checking if someone died if possible.

Also if you plan to have to many creeps:

A=The trigger u are asking for

Event:
A unit dies
Condition:
Dying unit equal to (CreepX)
Action:
Trigger - Turn off (A)
add 10 to P1 current gold
Trigger - Turn on (A)
 

tooltiperror

Super Moderator
Reaction score
231
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit comes within 256.00 of Goldmine
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Miner
    • Actions
      • Your Actions Here


It will leak, but maybe you can base it upon this.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top