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

[Trigger] Making unit go behind itself

Status
Not open for further replies.
Get the angle from the position of the attacked unit to the position of the attacker. Add the resulting angle by 180° (pi if radians), and project the resulting angle from the position of the unit by a certain distance.

In pseudo-code:
Lua:
angle = atand(GetUnitY(targ)-GetUnitY(source), GetUnitX(targ)-GetUnitX(source))
-- Depending on the result, add by pi or 180
angle = angle + 180
-- angle = angle + pi
targLoc = PolarProjection(GetUnitLoc(targ), angle, dist)
 
Level 24
Joined
Feb 28, 2007
Messages
3,480
Get the angle from the position of the attacked unit to the position of the attacker. Add the resulting angle by 180° (pi if radians), and project the resulting angle from the position of the unit by a certain distance.

In pseudo-code:
Lua:
angle = atand(GetUnitY(targ)-GetUnitY(source), GetUnitX(targ)-GetUnitX(source))
-- Depending on the result, add by pi or 180
angle = angle + 180
-- angle = angle + pi
targLoc = PolarProjection(GetUnitLoc(targ), angle, dist)
Would we not be able to use the attacking unit's facing angle here? I believe it's safe to assume that the attacking unit must face the target unit?
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Easy trigger?
  • Move
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Triggering unit) Equal to Paladin 0000 <gen>
    • Actions
      • Set Temp_Point = (Position of (Attacked unit))
      • Unit - Order (Attacked unit) to Move to (Temp_Point offset by 256.00 towards (Facing of (Attacking unit)) degrees)
      • Custom script: call RemoveLocation (udg_Temp_Point)
However, you need a use DDS instead of A unit is attacked event as it's not reliable.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
I think he wants the attacked unit to blink behind the attacker like a counter-attack move.

Set the position of the attacker as Point A (variable), then set Point B using Point with polar offset:
Set Point B = Point A offset by -100 towards facing of attacker's degrees.

Then move the attacked unit to Point B.
 
Status
Not open for further replies.
Top