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

Backstab-problem

Status
Not open for further replies.
Level 2
Joined
Nov 19, 2008
Messages
13
Hi!
I did a Backstabtrigger by using Pyrogasms Tutorial (Detecting a "Backstab" (GUI) - Wc3campaigns)
and I have a problem, cause it doesnt work!
Please help me!
Trigger 1
JASS:
function Backstab_GetAngleDifference takes real a1, real a2 returns real
     local real x
        // The Modulo will get the co-terminal angle if the angle is less than -360 or greater than 360.
        set a1=ModuloReal(a1,360)
        set a2=ModuloReal(a2,360)
        // makes sure angle 1 is the smaller angle.  If it isn't it switches them.
        if a1>a2 then
            set x=a1
            set a1=a2
            set a2=x
        endif
        // Subtracts 360, to get the first negative co-terminal angle, this is then used in a comparison to check if the angle is greater than 180
        set x=a2-360
        if a2-a1 > a1-x then
            //  If it is, use the negative angle instead
            set a2=x
        endif
        //  Now, get the difference between the 2 angles.
        set x=a1-a2
        //  If the difference is negative, make it positive and return it.  If its positive, return it.
        if (x<0) then
            return -x
        endif
     return x
    endfunction

Trigger 2

  • Backstabtest
    • Ereignisse
      • Einheit - A unit is attacked
    • Bedingungen
      • (Level of Hinterhalt (Eigen-Schurkin) for (Attacking unit)) greater than 0
    • Aktionen
      • Custom script: local real udg_Backstab_Angle
      • Custom script: set udg_Backstab_Angle = Backstab_GetAngleDifference(GetUnitFacing(GetTriggerUnit()), GetUnitFacing(GetAttacker()))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • Backstab_Angle less or equal to 60.00
        • 'THEN'-Aktionen
          • Einheit - Cause (Attacking unit) to damage (Triggering unit), dealing 300.00 damage of attack type Magie and damage type Normal
          • Schwebender Text - Create floating text that reads (String(Backstab_Angle)) above (Attacking unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Schwebender Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Schwebender Text - Change (Last created floating text): Deaktivieren permanence
          • Schwebender Text - Change the lifespan of (Last created floating text) to 2.25 seconds
        • 'ELSE'-Aktionen
My problem is that the unit does Extradamage on each attack. The Floating text i created to show (String(Backstab_Angle)) detects the right amount, but the condition (Backstab_Angle less or equal to 60.00) doesnt work because the Attacking Unit does Extradamage, if there is a 121.00, too!
 
Level 7
Joined
Jul 20, 2008
Messages
377
Ye it works i know :p

There is only one small "problem" if we could say thats the problem. You have to be actually facing the units back, before first attack, you can't go around it like zig-zag and hit it it in the back it doesn't work the first time. But once you figure that out how it works thats not a problem anymore :D
That would be because you're considering the facing angle of the attacker, not the angle from the position of the attacker to the victim. Just change that, and you can zigzag.
 
Status
Not open for further replies.
Top