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

Detect when a Wisp gather 5 lumber

Level 6
Joined
Jan 12, 2014
Messages
56
Hello

I want the wisp to damage the trees like other races BUT still being on it while doing so.
I can't use the other races abilities because the wisp doesn't stick to the tree.
Detect "Unit is issued with harvest order" doesnt work either. For the non-night-elves, it triggers ONLY when they bring back the ressources.

So i want a way to detect when a wisp add 5 lumber (each 8 sec) but i don't know how

Thanks
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
There is no way to detect that - there is no event that would tell you which wisp gathered lumber at the time.
All options I could think about have some drawbacks:

Option 1:
Use this event:
  • Player - Your_Player's Current lumber becomes Greater than 0.00
This event fires any time your lumber amount changes. But it tells you just that, nothing else. So you don't know if it was gathered, or because hero bought/sold item or because you spent lumber on unit training, or whatever else.
Given that you could keep track of player's previous amount of lumber and use that to determine if the lumber gained was +5 (and thus assume it was by wisp), unless the player has only a single wisp then you still don't know which wisp did it.

Option 2:
For each wisp that begins gathering wood, start a repeating timer that matches its interval to the wisp's gathering interval. Any time the timer expires, reduce tree's life. The problem here is that you don't know when is wisp flying towards a tree and when it begins gathering (since the current order for both is the same). You also don't know for sure which tree the wisp will gather from (for example: order 2 wisps to gather from same tree - one will occupy the targeted tree and the second will choose a random tree nearby). The only solution here would be to run a trigger that fires every ~0.02 seconds and for each wisp that was ordered to gather wood, but does not yet do that, pick all destructibles nearby and check if picked wisp is on top of any of the picked tree. If so, you know it started harvesting, so you can start its timer.
The disadvantage here is that you basically have 2 timers (the default gathering timer from wisp's gather ability, and your own timer in triggers) and hope that they match or the difference between both timers' start times is very tiny.

Option 3:
Trigger the entire wood harvesting yourself. You could have just a single timer, so you would know which wisp gathered which wood when. The disadvantage is that you would need to mirror the default harvesting behavior in your triggers (like the behavior when 2 wisps ordered to harvest same tree, etc.) which could prove challenging.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
Here's a working example of Option 2 that Nichilus suggested, although you don't need to pick all nearby destructibles because the Wisp always issues an order targeting a specific tree, even if it changes to another tree because the target is occupied you'll still get the correct target in the end.

Note that due to the fact that I'm using a 0.01 second repeating timer to detect when harvesting has started, there will always be an extremely small delay between the +5 lumber being credited and the damage being dealt to the tree. This means that if the user were to pull the wisp off of the tree during this delay they could get +5 lumber AND avoid the damage to the tree. That being said, the timing is so precise that I doubt anyone could intentionally pull this off and in the extremely rare cases that it happens by chance I doubt anyone will even notice.

I'm using two lightweight systems to achieve this, Bribe's Unit Indexer and my GUI Simple Timers system (never released it, but it works fine).

Requires the latest patch to open.
 

Attachments

  • Tree Gather Detection 1.w3m
    36.8 KB · Views: 2
Last edited:
Top