HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detect unit state/stop creep aggression

04-26-2009, 11:59 AM#1
tamisrah
My goal is to create a function that prevents aggro from 0 damage events.
The problem with it is, that units can attack nearby enemies without having the "attack", "smart" or "patrol" order.
The following code is what I got so far.
Expand JASS:

Therefore my question: Is there anyway to check what a unit is currently doing, especially if it is attacking anything?

If you have any other suggestions to improve my code please post them aswell.
Attached Files
File type: w3xDamageDetectionTest.w3x (57.3 KB)
04-26-2009, 12:38 PM#2
Opossum
When units start to attack nearby enemies by themselves they trigger the EVENT_UNIT_ACQUIRED_TARGET event. When they disengage because they're lured too far away from their idle spot then they get a move order.
You can use these two events to determine if a unit is in combat.
Sometimes a unit also disengages without using the move order... then you'd have to check periodically if its current order is "idle".

I wrote a little script that stores information like this and also adds interface functions for several important events that have to do with combat behavior but I haven't really tested it enough to recommend it yet. If you're interested I can pm you my current results though.
04-26-2009, 02:37 PM#3
tamisrah
Sounds definitely interesting, I'd love to get that PM.

Already tried to use the approach you suggested.
Expand JASS:

Works, looks nice, but has a flaw I'd like to get rid off.
I currently use a TriggerSleepAction within the onAcquire method to allow the user to force disengage the unit before the unit is detected as engaging.

So I'm still hoping for suggestions on code improvement.