• 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] How to register a "Harvest Gold" action?

Status
Not open for further replies.
Level 11
Joined
Mar 18, 2009
Messages
793
Hi!

I'm trying to find a way for the game to notice when a Peasant (specifically a Blood Elf Engineer) harvests gold from a Gold Mine. So far I've tried

  • Helper Gold Check
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Harvest (Gold and Lumber)
    • Actions
      • Unit Group - Add (Triggering unit) to HelperGoldActive
      • Game - Display to (All players) the text: Elf Active
But it doesn't work, and neither does the Return Gold function do. My goal here is to add all workers carrying gold to a exclusion group so that they do not get new orders instantly once Gold Mine A runs out and all idle workers are supposed to be sent to Gold Mine B. Tried googling beforehand but it did not give me any answer.

Is there a solution to this or any way to get around it?
I'm using standard WE 1.27 build by the way.
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
  • Harvest
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Unit-type of (Triggering unit)) Equal to Blood Elf Engineer
      • (Unit-type of (Target unit of issued order)) Equal to Gold Mine
    • Actions
      • Unit Group - Add (Triggering unit) to HarvestGroup
For return gold, use "resumeharvesting" in issued order.
 
Level 11
Joined
Mar 18, 2009
Messages
793
  • Harvest
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Unit-type of (Triggering unit)) Equal to Blood Elf Engineer
      • (Unit-type of (Target unit of issued order)) Equal to Gold Mine
    • Actions
      • Unit Group - Add (Triggering unit) to HarvestGroup

Forgive me if I'm wrong but would that not add the worker to the "active" group before he has harvested gold?

The functions I'm trying to do right now are for a CPU player, that has multiple workers running from the main base out to three separate Gold Mines on the map. Once a Gold Mine is empty I want the workers who are carrying gold to finish their task without interruption, while the ones who are not carrying gold to get assigned new orders to harvest gold from the other Gold Mines. As far as I know there is no way to check if a worker is carrying gold or not within GUI, hence the Unit Group trigger.
 
Level 13
Joined
Feb 5, 2018
Messages
567
You could use animation tags and see their current animation. The animation changes only when the unit is already carrying something.

Stand Gold 1, Stand Ready Gold 1 and so on.
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
Forgive me if I'm wrong but would that not add the worker to the "active" group before he has harvested gold?
Yes, actually. I don't think there is an easy way to check if a worker is carrying resources sadly.
You could use animation tags and see their current animation. The animation changes only when the unit is already carrying something.

Stand Gold 1, Stand Ready Gold 1 and so on.
That may work but there is no way to check a unit's current animation afaik.
 
Level 11
Joined
Mar 18, 2009
Messages
793
Yes, actually. I don't think there is an easy way to check if a worker is carrying resources sadly.

That may work but there is no way to check a unit's current animation afaik.

Yea, I was messing around with the editor and unless there is no vJASS or JASS to get unit animation, it's not possible. :(

Yep, its yet another limitation of the WE I stumbled upon.
I did some more research on the web and someone mentioned using "check order = none", and that looked promising at first but as it turns out a worker who is in the process of returning harvested gold is considered to have no orders as well, and got included with the idle workers. :(

This was my last attempt at solving this issue.
  • Helper Check
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Helper1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of Toy Factory 0010 <gen>) Greater than or equal to 1.00
              • (Current order of (Picked unit)) Equal to (Order(none))
            • Then - Actions
              • Unit - Order (Picked unit) to Harvest Toy Factory 0010 <gen>
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of Coal Mine 0012 <gen>) Greater than or equal to 1.00
                • Then - Actions
                  • Unit - Order (Picked unit) to Harvest Coal Mine 0012 <gen>
                  • Unit Group - Add (Picked unit) to Helper2
                  • Unit Group - Remove (Picked unit) from Helper1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of Goodies Shop 0011 <gen>) Greater than or equal to 1.00
                    • Then - Actions
                      • Unit - Order (Picked unit) to Harvest Goodies Shop 0011 <gen>
                      • Unit Group - Add (Picked unit) to Helper3
                      • Unit Group - Remove (Picked unit) from Helper1
                    • Else - Actions
      • Unit Group - Pick every unit in Helper2 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of Coal Mine 0012 <gen>) Greater than or equal to 1.00
              • (Current order of (Picked unit)) Equal to (Order(none))
            • Then - Actions
              • Unit - Order (Picked unit) to Harvest Coal Mine 0012 <gen>
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of Goodies Shop 0011 <gen>) Greater than or equal to 1.00
                • Then - Actions
                  • Unit - Order (Picked unit) to Harvest Goodies Shop 0011 <gen>
                  • Unit Group - Add (Picked unit) to Helper3
                  • Unit Group - Remove (Picked unit) from Helper2
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of Toy Factory 0010 <gen>) Greater than or equal to 1.00
                    • Then - Actions
                      • Unit - Order (Picked unit) to Harvest Toy Factory 0010 <gen>
                      • Unit Group - Add (Picked unit) to Helper1
                      • Unit Group - Remove (Picked unit) from Helper2
                    • Else - Actions
Its not game breaking at least, so I think I'm going to leave this as it is for the time being and revisit the issue in the future. For now whenever a Gold Mine goes empty all workers assigned to that group gets redirected to the other mines first before returning any eventual gold that they already has.

Thank you for your time at least :)
 
Status
Not open for further replies.
Top