[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)
 
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?
 
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.
 
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.
Back
Top