• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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,479
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 30
Joined
Feb 18, 2014
Messages
3,623
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 73
Joined
Aug 10, 2018
Messages
7,872
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