• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Harvest nearby lumber.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • AutoHarvest
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Worker
    • Actions
      • Unit - Order (Trained unit) to Harvest Nearby Lumber
The above works, but even if I set a rally point they still harvest near by lumber on spawn. How can I ignore this event if a rally point is set?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
A rally point is always set. The default rally point is at the building itself.

What you can do is detect whenever a building sets a rally point and store for that building, whether it is the default rally point or not.
With this information you can decide in your trigger, if you want to order the unit to harvest lumber.

Why would you even want to do this? If a player wants a unit to harvest lumber, the player can just set the tree as rally point.
 
Level 13
Joined
Oct 12, 2016
Messages
769
Since units automatically move when going to a rally point, and assuming you leave the rally point at the structure, a simple wait function with order detection using "triggering unit" should work:
  • Auto Harvest
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Worker
    • Actions
      • Wait 0.10 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of (Triggering unit)) Not equal to (Order(move))
        • Then - Actions
          • Unit - Order (Triggering unit) to Harvest Nearby Lumber
        • Else - Actions
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
That sounds like a good idea. I would add
(Current order of (Triggering unit)) Not equal to (Order(harvest)), so units that are ordered to specifically harvest a certain tree are not ordered to harvest trees.

Worker type units or units without an attack can move unitended, if they are being damaged.
Non-worker type units with an attack can move use the attack order, if they engage into nearby combat.

Depending on what is the desired behaviour in these cases the trigger can be adjusted.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Sadly it didn't work.
Gyazo - 210426158a8724b81bbb4d1ece830ca9.gif

I tried using a smart order as well apparently that is used when the user uses the right click. But doesn't seem to work either.

There isn't a condition that checks if a rally point is set?

"Why would you even want to do this? If a player wants a unit to harvest lumber, the player can just set the tree as rally point."

This game is all about speed on the start, setting rally points takes more time then just training workers by highlighting the building.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Got it working.


  • AutoHarvest
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Worker
    • Actions
      • Wait 0.10 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of (Trained unit)) Equal to (Current order of (Rally-Point of (Trained unit) as a unit))
        • Then - Actions
          • Unit - Order (Trained unit) to Harvest Nearby Lumber
        • Else - Actions
 
Level 11
Joined
Jun 2, 2004
Messages
849
This might cause problems due to the wait. "Trained Unit" is a global variable and if two units are trained almost at the same time it could glitch.

Not too hard to make a local variable for it though. Just put this custom script at the top of the trigger:

Code:
local unit udg_MyUnitVariable

where "MyUnitVariable" is replaced with the name of a global unit variable you defined in the trigger editor. Then, set your unit variable equal to the training unit on the second line, before the wait.
 
Level 13
Joined
Oct 12, 2016
Messages
769
Yea, that's why I suggest using "triggering unit" with an event to detect them entering the map.
"Triggering unit" remains constant throughout the trigger.
But yes, local variables would work just as effectively with "trained unit."
 
Status
Not open for further replies.
Top