• 🏆 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!

[Solved] Detect Resource Drop-Off

Status
Not open for further replies.
Is there some way to detect when a worker drops off lumber at a Town Hall or Mill? I'm trying to create a dynamically upgradeable lumber harvest ability (without having to create a custom one entirely with code), but it seems the ability doesn't respond to SetAbilityLevel. I tried swapping the ability for more powerful version of itself, but doing so removed the current amount of lumber already harvested in the worker. This is a problem, especially since the worker is meant to carry around values of up to 50 lumber at a time. I tried adding the stronger ability first, then removing the lesser one, but the lumber amount still was reset. So now, I'm trying to swap out the abilities after the lumber has been dropped off.

Alternatively, it would be helpful if I can detect when a tree was stuck by a worker.
 
Level 8
Joined
Jan 28, 2016
Messages
486
This is a tough one. You can but it would take some effort. I was going to explain how to potentially pull this off but then I remembered my post in a similar thread. If I can quote myself:

Dehua_Darbuya said:
I may have a solution to this.

When you send a worker to gather lumber (whether it be with a right-click, manually casting Gather or even issuing an attack command), it will be ordered to "harvest." Once the worker collects the maximum amount of lumber it can carry or is manually sent to drop it off, it will be issued a "resumeharvest" order. After dropping off the lumber, it is automatically issued to "harvest" again.

I sort of half-tested this in my attempt to create a custom lumber resource system but I didn't get very far with it. Anyway you could check when a unit is issued to "resumeharvest" (or if it's issued a "smart" order on a Town Hall, Lumber Mill, etc.) and add a dummy ability to the worker, then have another check to see if a worker has the dummy ability when a unit is issued to "harvest." If so, you know that it dropped off the lumber and can remove the dummy ability. Voila!

My only possible concern is when a tree dies and the worker switches to another tree, or when it's sent to gather lumber after being ordered to resumeharvest but before making it to the drop-off building, but I can't test this at the moment. However this should be a good starting point.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
can you maybe combine Dehua_Darbuya's system with a "Tree-Death"-Detector, and simply store the current tree of a unit to it into a hash table? Then, it would be simply overriden, if the tree dies ... maybe too complicated, as you wanted something without code ...
 
This is a tough one. You can but it would take some effort. I was going to explain how to potentially pull this off but then I remembered my post in a similar thread. If I can quote myself:
Toyed with this a bit and it should do. Not perfect, mostly because wc3 is just weirdly designed in places, but that's as good as it's gonna get :p
thanks +rep
 
Status
Not open for further replies.
Top