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

[Trigger] Determining Left, Right, Front, Behind to Caster?

Status
Not open for further replies.
Level 7
Joined
Nov 4, 2006
Messages
153
Hey, I need help with making an instant cast ability (eg Thunder clap). When cast, it will detect nearby units and determine if the unit is to the right, left, front (but not back) of the hero. The front and back will have +- 35 degree. I tried a couple of ways but got lost in my if statements :( although I did write things on paper...
 
Level 10
Joined
Aug 15, 2008
Messages
720
It won't be all. You will need to do 4 cone areas. To get right angles for detection, then 1st would be forward, which would be from Caster's angle + 45 to Caster's angle -45. 2nd would be left which would be from Caster's angle +135 to Caster's angle + 45. 3rd would be behind, which would be from Caster's angle +225 to Caster's angle + 135. 4th would be right, which would be from Caster's angle -135 to Caster's angle - 45.

You can make it easier using action Integer A or B loop.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Temp_Real_3 = Your facing
Temp_Loc_3 = Your position
Temp_Loc_4 = The other unit's position

Front left:
  • (Cos(((Temp_Real_3 + 45.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
Front Right:
  • (Cos(((Temp_Real_3 - 45.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
Front
  • (Cos(((Temp_Real_3 + 90.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
Back left:
  • (Cos(((Temp_Real_3 + 135.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
Back right:
  • (Cos(((Temp_Real_3 - 135.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
Back:
  • (Cos(((Temp_Real_3 - 90.00) - (Angle from Temp_Loc_3 to Temp_Loc_4)))) Greater than (Cos(45.00))
 
Status
Not open for further replies.
Top