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

Is there a way to check if the unit is getting attacked from the side or back?

Status
Not open for further replies.
Level 13
Joined
Dec 3, 2005
Messages
501
Is there a way to check if the unit is getting attacked from the side or back? I'm trying to develop a system and I need to be able to tell if a unit is getting attacked from pretty much anywhere besides face to face. A kind of flanking system.

This is kinda what I came up with:

  • Events
  • Unit - A unit Is attacked
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Facing of (Attacking unit)) Greater than or equal to ((Facing of (Attacked unit)) + 270.00)
  • (Facing of (Attacking unit)) Equal to (Facing of (Attacked unit))
  • Then - Actions
  • Unit - Kill (Attacked unit)
  • Unit - Create 1 Peasant for Player 2 (Blue) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
  • Else - Actions
The create a peasant is only in there for testing and I'll probably end up changing the "kill" to removing a great % of life.

So is there any other way of detecting it? Because this way isn't very effective.
 
Level 22
Joined
Jun 24, 2008
Messages
3,050
Well, there is ways to do such, and one is to check the facing of target/attacker.
Just add to condition
  • (Facing of (Attacking unit)) Greater than or equal to ((Facing of (Attacked unit)) + 20.00)
  • (Facing of (Attacking unit)) Less than or equal to ((Facing of (Attacked unit)) + 20.00)
Or such.
This would check if the attacker is facing ca. same way.
 
Status
Not open for further replies.
Top