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

[Solved] Reallllly need help with simple backstab trigger

Status
Not open for further replies.
Level 5
Joined
Feb 13, 2019
Messages
128
Helllloo I'm still learning the ropes to say the least and I was hoping someone could lend me hand with setting up a backstab trigger, I'm going to attempt to use a damage engine with this so I just need it to work as if a unit cast a spell behind another unit this goes off to alert the damage engine so I can have spells/attacks do more damage from behind.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set u1 = (Attacking unit)
      • Set u2 = (Attacked unit)
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Acos((Cos((Angle from p1 to p2))))) Less than 90.00
        • Then - Actions
          • Floating Text - Create floating text that reads backstab! at p1 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
        • Else - Actions
          • Custom script: call RemoveLocation(udg_p1)
          • Custom script: call RemoveLocation(udg_p2)


really the issue I'm mainly having is just putting this trigger I found here on hive into my map, I got pretty close but I can't seem to figure out how to make my:

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Acos((Cos((Angle from p1 to p2))))) Less than 90.00

Into:

joinminus.gif
cond.gif
If - Conditions

  • empty.gif
    line.gif
    line.gif
    joinbottom.gif
    if.gif
    (Acos((Cos(((Angle from p1 to p2) - (Facing of u2)))))) Less than 90.00

Like in this trigger:

  • BS3
  • Events
  • Unit - A unit Is attacked
  • Conditions
  • Actions
  • Set u1 = (Attacking unit)
  • Set u2 = (Attacked unit)
  • Set p1 = (Position of u1)
  • Set p2 = (Position of u2)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Acos((Cos(((Angle from p1 to p2) - (Facing of u2)))))) Less than 90.00
  • Then - Actions
  • Game - Display to Player Group - Player 1 (Red) the text: Backstab!
  • Else - Actions
  • Custom script: call RemoveLocation(udg_p1)
  • Custom script: call RemoveLocation(udg_p2)

It's just finding the "- (Facing of u2))))))" part of this trigger in the GUI that has me confused, I'd really appreciate the help from the old pros!


But I feel like I need the "- (Facing of u2))))))" because what I have now doesn't seem to react properly, I get the backstab alert to pop up, but it seems as if it's not updating with the units, say my footman is backstabbing the peon and he runs in another direction I can no longer proc the back stab, and sometimes I can proc it when the units are face to face which needless to say is not how I'd like my backstab trigger to perform xD
 
Level 7
Joined
Apr 17, 2017
Messages
316
You need to use arithmetics, but gui arithmetics are so messy so I guess you can do this:
  • Custom script: if Acos(Cos(AngleBetweenPoints(udg_p1, udg_p2) - GetUnitFacing(udg_u2))) < 90. then
  • Game - Display to Player Group - Player 1 (Red) the text: Backstab!
  • Custom script: else
  • Custom script: call RemoveLocation(udg_p1)
  • Custom script: call RemoveLocation(udg_p2)
  • Custom script: endif
 
Level 5
Joined
Feb 13, 2019
Messages
128
I mean I'd love to start using JASS if you want to help break it down for me I'd really appreciate that, but thank you so much, you are my hero lol!
 
Level 5
Joined
Feb 13, 2019
Messages
128
Ummmm I feel like I may have implemented this incorrectly, I can proc the backstab text regardless of my angle of attack D:

Sorry, I'm still really new to this!


  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set u1 = (Attacking unit)
      • Set u2 = (Attacked unit)
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • Custom script: if Acos(Cos(AngleBetweenPoints(udg_p1, udg_p2) - GetUnitFacing(udg_u2))) < 90. then
      • Game - Display to Player Group - Player 1 (Red) the text: backstab!
      • Custom script: else
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Custom script: endif

trigger4.png
 
Level 7
Joined
Apr 17, 2017
Messages
316
Ummmm I feel like I may have implemented this incorrectly, I can proc the backstab text regardless of my angle of attack D:

Sorry, I'm still really new to this!


  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set u1 = (Attacking unit)
      • Set u2 = (Attacked unit)
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • Custom script: if Acos(Cos(AngleBetweenPoints(udg_p1, udg_p2) - GetUnitFacing(udg_u2))) < 90. then
      • Game - Display to Player Group - Player 1 (Red) the text: backstab!
      • Custom script: else
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Custom script: endif

View attachment 321337
I didn't look at the code at first,sorry haha. Jass trigonometry functions like sine cosine, returns the value in radians, but gui versions return the value in degree that's why it got messed up. Here's the gui version:
  • BackStab Gui
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set Point[1] = (Position of (Attacked unit))
      • Set Point[2] = (Position of (Attacking unit))
      • Set Angle[1] = (Facing of (Attacked unit))
      • Set Angle[2] = (Angle from Point[1] to Point[2])
      • Set Angle[3] = (Acos((Cos((Angle[2] - Angle[1])))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Angle[3] Greater than or equal to 120.00) and (Angle[3] Less than or equal to 240.00)
        • Then - Actions
          • -------- your actions here --------
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[2])
 
Level 5
Joined
Feb 13, 2019
Messages
128
You are a godsend, thank you so much! But while I have you here you wouldn't happen to know how implement this into Bribe's damage engine by any chance would you? D:


I don't realllly want to have it as just a GUI trigger where it goes "oh hey they're attacking or casting a spell behind the unit, just do X dmg because it started the attack"

Example:
  • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing 500.00 damage of attack type Spells and damage type Normal
I want it to be like oh the attack went through, it landed, wasn't interrupted via stuns or anything of the sort, but because you hit them from behind, here is some extra damage.

If not I understand! Honestly you've already done a lot for me and I really appreciate it!


Edit: I feel like it's worth mentioning I already have the damage system activated on a map, and obviously I'm going to try to figure it out from here myself, I was just wondering if you had experience with a (or this) damage system in the past maybe, and knew offhand how to amplify damage and make it run in conjunction with the trigger, I just feel like it would be easier to grasp if I had someone explain it instead of digging through the information myself.

(I'm not trying to be lazy, I just feel as if I'd learn easier, and faster, with a little help from a guru, and honestly I have a pretty busy schedule, you know how life is I don't have as much time as I'd like to to practice and study up lol)
 
Last edited:
Level 7
Joined
Apr 17, 2017
Messages
316
  • Backstab
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to False
    • Actions
      • -------- DamageEventSource is the unit dealing the damage --------
      • Set AttackingUnit = DamageEventSource
      • -------- DamageEventTarget is the unit that takes damage --------
      • Set AttackedUnit = DamageEventTarget
      • Set Point[1] = (Position of AttackedUnit)
      • Set Point[2] = (Position of AttackingUnit)
      • Set Angle[1] = (Facing of AttackedUnit)
      • Set Angle[2] = (Angle from Point[1] to Point[2])
      • Set Angle[3] = (Acos((Cos((Angle[2] - Angle[1])))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Angle[3] Greater than or equal to 120.00) and (Angle[3] Less than or equal to 240.00)
        • Then - Actions
          • -------- Instead of using unit-damage target, we use DamageEventAmount variable to change the damage amount --------
          • Set DamageEventAmount = (DamageEventAmount x 2.00)
          • -------- this will deal 2x damage, when backstabbed --------
          • Special Effect - Create a special effect at Point[1] using Objects\Spawnmodels\Human\HumanBlood\HumanBloodPriest.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[2])
I have tried to add comments. Try to experiment with Damage Engine, you will realize it's not that hard to use :)
 
Level 5
Joined
Feb 13, 2019
Messages
128
Wait so what type of variables are the angles? D:


  • set.gif
    Set Angle[1] = (Facing of AttackedUnit)
  • empty.gif
    join.gif
    set.gif
    Set Angle[2] = (Angle from Point[1] to Point[2])
  • empty.gif
    join.gif
    set.gif
    Set Angle[3] = (Acos((Cos((Angle[2] - Angle[1])))))

Also I can't seem to locate the "facing of" and "Angle" and "Acos", I imagine once I find the correct variable setting it should be right in the function list or? o_O
 
Last edited:
Level 11
Joined
Oct 16, 2013
Messages
246
I'll def look into this, I like the idea of only beingable to damage something on a certain side, for like a boss or something of the sort, so thank you!

I mean you can make a backstab damage trigger with the code from my post. Just detect when the attack comes from behind and apply some damage multiplier instead of blocking it.
 
Status
Not open for further replies.
Top