[Trigger] Need help inverting Backstab Trigger

Level 9
Mar 17, 2016
Hi, I want to make a skill like Rikis Backstab from dota 2, but instead of the back it would do the effect if the attacking unit is striking from the front.

What I know so far is to have a damage detection trigger, condition "if unit has buff", then I have this

  • Then - Actions
    • Set VariableSet Backstab_Point[3] = (Position of UnitPlayerCaster[14])
    • Set VariableSet Backstab_Point[4] = (Position of AbilTargetUnit[3])
    • Set VariableSet Backstab_Angle = (Angle from Backstab_Point[3] to Backstab_Point[4])
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • And - All (Conditions) are true
              • Conditions
                • (Facing of UnitPlayerCaster[14]) Greater than or equal to ((Facing of AbilTargetUnit[3]) - 120.00)
                • (Facing of UnitPlayerCaster[14]) Less than or equal to ((Facing of AbilTargetUnit[3]) + 120.00)
            • And - All (Conditions) are true
              • Conditions
                • Backstab_Angle Greater than or equal to ((Facing of AbilTargetUnit[3]) - 120.00)
                • Backstab_Angle Less than or equal to ((Facing of AbilTargetUnit[3]) + 120.00)
      • Then - Actions
        • Game - Display to (All players) the text: step 3 - damage
        • Unit - Cause UnitPlayerCaster[14] to damage AbilTargetUnit[3], dealing 5 damage of attack type Hero and damage type Normal
      • Else - Actions
I've tried rotating and shifting the numbers that calculate the locations but I can't seem to make it work from the front, only varying degrees from the back and that's not what this hero will be about. I know that I must be missing something and I'm hoping someone can identify the issue, because I've ran out of ideas.

Level 13
May 10, 2009
Here's a function that I have stored on my PC -- I'm not sure who made it anymore, sorry (Maker or Killcide, maybe?). Anyway... declare the following function in your map header and use it like this:
function IsUnitBehindTarget takes unit u, unit t, real tolerance returns boolean
    // Acos( Cos( (angle from U to T) - T facing angle )) <= Tolerance
    return (Acos(Cos(Atan2(GetUnitY(t) - GetUnitY(u), GetUnitX(t) - GetUnitX(u)) - GetUnitFacing(t) * bj_DEGTORAD)) <= tolerance * bj_DEGTORAD)

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set source = Footman 0001 <gen>
      • Set target = Peasant 0000 <gen>
  • Events
    • Time - Every 0.15 seconds of game time
  • Conditions
  • Actions
    • Cinematic - Clear the screen of text messages for (All players)
    • Custom script: if not IsUnitBehindTarget(udg_source, udg_target, 115) then
    • Game - Display to (All players) the text: Source is in front of target
    • Custom script: endif
Do note that "Tolerance" (the third function parameter) ranges from 0 to 180 degrees.


  • FaceMe.w3x
    17.3 KB · Views: 16