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

Detecting Unit Attacking Ground

Status
Not open for further replies.
Level 10
Joined
Aug 15, 2008
Messages
448
EDIT: blast, posted in the wrong section, is it possible to move this in "Triggers & Scripts"? Thanks.

Greetings everyone,

I have been trying to find a way on how to detect when a unit attacks using the "ground attack" command; looking around, I've found this:

Attack Ground Event 1.01

which, in theory, would serve the purpose alright, but judging by the review it seems it can bug out, which is a bit annoying if I am to make it foolproof.

The purpose of the system I'm looking for is to work similarly to the "A unit is under attack" event, so I can register a few valuable data for other things to work. I kind of need the artillery attack so I can have the projectile actually hit where it goes (whereas just using "missile" acts wonky against moving targets) and I have opted against using a full projectile system (for the time being, at least).

Any ideas on how to detect ground attacks, then (working on patch 1.29)?
Thanks in advance.
 
Level 12
Joined
Jan 30, 2020
Messages
875
I am not sure the natives were there in 1.29 as I was not back to map making yet.

But you could try to use the event "A unit takes damage".

Unfortunately, last time I checked, you have no native constant to access the object editor field "ua1w" that is "Combat - Attack 1 Weapon Type".
But as you probably don't change the attack weapon type ingame, you could just use that kind of trigger :

  • Events
    • Unit - No unit Takes damage
  • Conditions
    • (Unit-type of (Damage source)) Equal to *unit-type of your unit with artillery here*
  • Actions
    • Do your things
 
Level 12
Joined
Jan 30, 2020
Messages
875
I see !

Well why not just using the event "A unit is attacked" ?

I suppose it would be pretty easy to add a check in Conditions to filter out source damages that don't have artillery attack.

IIRC, A unit is attacked fires just before the attack is actually fired.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Yes that makes sense as the unit is damaged but not targeted.

I suppose you already tried the event "a unit is issued an order" and checking if the order is attack ground ?
I don't think there is any simple alternative if you want to detect the attack ground before the attack actually starts.

If there are unexpected side-effects with detecting when the order is issued, you probably could add extra conditions to make it fit.
 
Level 10
Joined
Aug 15, 2008
Messages
448

There are a few caveats with that approach, including but not limited to:

- A unit is ordered to attack ground out of range
- A unit is ordered to attack ground (once) and fires multiple times
- A unit is ordered to attack ground but is stopped before actually firing (example: has to turn first)

Like you said, simple alternatives don't seem to exist... but hey, fingers crossed!
 
Level 12
Joined
Jan 30, 2020
Messages
875
Yes I am aware of quirks.

Maybe use :
- Range check
- stop order detection on the unit with artillery (anything that prevents attack ground will end up with a stop order)

- as for the multiple attack it gets trickier and probably requires a global boolean and a dummy unit with invisible model that would change the boolean and gets removes the first time it takes damage, then the event for attack ground order could be stopped from firing more than once thanks to the boolean.

In all fairness I admit that there is currently no way to do this perfectly.

It reminds me the nearly impossible issue I had when I wanted to detect when a unit roots / unroots. It would simply have required a ton of triggers to make it work properly.
But it does not mean it's impossible. This said I don't see any easy way to detect when a unit starts firing an attack ground.
If this is the only way for you to set the "valuable data" you were mentioning, you'll have to take steps ans study every possibility.

I have the feeling implementing this in GUI will end up being extremely complex if you want to make it mui and not leak.
I would sincerely advise you to consider Lua for this.
 
Status
Not open for further replies.
Top