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

How can I detect a unit being attacked from the front?

Status
Not open for further replies.
Level 14
Joined
Apr 20, 2009
Messages
1,543
the title says it all... How can I detect that a unit gets attacked in the front? Instead of in the back?

For example:

detection.jpg


edit: ow maybe I didn't explain it that good :S the unit is supposed not to get any damage under a certain boolean condition when he is being attacked from the front...
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Use facing of the attacked unit as a degree to detect if its attacked from infront.

Do I also need a damage detection system? Or not?

and how would I be planning to do this? I'm not that good with degrees ;(

if facing of attacked unit == ????
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
facing of attacked unit == facing of attacking unit - that means if the attacked unit is facing degree equals to the attacking unit.

If its not equal then, it won't take damage.

And no, you don't need big damage detection system, just pick all units that will use the trigger, and put them in an action "Unit - (Picked unit) takes damage", then do the conditions and actions.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
facing of attacked unit == facing of attacking unit - that means if the attacked unit is facing degree equals to the attacking unit.

If its not equal then, it won't take damage.

And no, you don't need big damage detection system, just pick all units that will use the trigger, and put them in an action "Unit - (Picked unit) takes damage", then do the conditions and actions.

But doesn't that mean they both have to have exactly the same degree of facing? Or does that degree vary between a value of the point of view?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
It means, if both unit are facing each other, then the attacked unit will take damage.

yeah, but I use a system that changes the facing of a unit when you press a arrow key. Does that mean that the attacking unit has to have exactly the same facing as the defending unit? (because facing is in degrees right?)

When you play the game and you order a unit to attack another unit by using your mouse the units automatically face each other... This time it's the job of the player to face his unit to the other unit... And the other unit (player in this case) has to do exactly the same ;)

shouldn't it then be the unit that is attacking must be inbetween 90 degrees of the facing of the unit that is being attacked?

EDIT: damn that sounds complicated 0.o!
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
If im not wrong, facing of unit +/- 72 degrees is the back of the unit (like Backstab), thus it will allow you to deal damage only if you attack from behind and the degree is the same

In your case, you want the unit to take damage only infront, then play with the degrees, I think (Facing of <Unit>) + 180 degrees is exactly infront of the target.

Then, I think it should be (Facing of (Attacked Unit)) == (Facing of (Attacked Unit)) + 180 degrees
 
Status
Not open for further replies.
Top