Angle Comparison to Create Backstab??

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Hi! ok here's a tricky one:

I want to create a passive backstab ability. This 4-level ability causes the thief to gain 40/60/80/100 percent of his agility in bonus damage whenever he is directly behind his target.

GUI only please.
Mechanics:
Event:
A unit is attacked

Conditions:
Attacking unit=thief
Attacking unit within 50 distance (his attack range) of attacked unit (how to do this?)
Attacking unit has ability Backstab (how to determine this?)

Actions:
Set target and caster variables and angle facing variables.
Compare the facing angle of target to facing angle of the thief, if there is less then 45 degree deviation damage target using above formula and create a "blood" special effect.

I am at a complete loss on how to compare facing angles with a margin of 45o! Please help me with this math! :( Any advice or direction appreciated. Thanks! :)
 

Darkchaoself

What is this i dont even
Reaction score
106
Well the theif is melee, so the 2nd condition you dont need, the 3rd is
Code:
Level of Backstab equal to 1
Do that in If/Then/Else
such as
Code:
If Level of Backstab equal to 1
Then- Level 1 Actions
Else-
If Level of Backstab equal to 2
Then- etc etc.
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
I don't see why that should cause an error. What's the line above that? Sometimes the Editor doesn't catch the error until the next line.
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Code:
Custom Script: local real udg_Backstab_Angle

(I'm cooking dinner atm and doing chores, so please bear with me) :)

Here's the jass code I copied, and attached is my trigger, and the error message... if you are so inclined as to take a look.
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

Thanks again.
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
Have you created the variables? lol, that might be the 'error' you get....
:)
the name after "udg_" is a variable. And try remove one of the custom script lines, and enabel teh trigger, if you still get an error, delete the other one also, still an error? jesus, if so... :) Why? well, then you know for usre, which line it is=)
 

0zaru

Learning vJASS ;)
Reaction score
60
that i know there is not native called GetAttackedUnit (Not without BJ)

So it must be
Code:
Custom Script: set udg_Backstab_Angle = Backstab_GetAngleDifference(GetUnitFacing([COLOR="Red"]GetTriggerUnit()[/COLOR]), GetUnitFacing(GetAttacker()))

no ? or add the BJ

Also:
GetAttackedUnitBJ() returns GetTriggerUnit()
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
Blasphemous. Sorry for the error in my tutorial; I've since fixed it.
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Haha! Well, I'm certainly glad my lack of knowledge was able to make the Helper a better place! :)
 

0zaru

Learning vJASS ;)
Reaction score
60
All can make the helper a better place :D

P.S I am still trying to fix up my jass :p (Pyro in the grades of one of the contest :p)
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Uh-oh. Houston, we have a problem.

Taking Ozaru's changes into account, backstab does function. But unfortunately, the angle doesn't matter! Once the hero learns the ability, he gets the backstab bonus from any angle! Panic! Panic! :eek:
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Hmm, yeah, I'm using the same code i posted above, just with Ozaru's change to the second line of custom script. arg, why does life have to be so hard?
 

Foresector

Member
Reaction score
16
http://www.thehelper.net/forums/showthread.php?t=55085

Umm this is a submission I made a while back.

It actually gives you critical strike according to your positioning Ie, Behind=50% chance, sides=25%

If you want to convert this to a backstab,
add in the condition If blurbladeangle greater than 169

EDIT: This is what you want to convert the trigger to

Code:
Blurblade
    Events
        Unit - A unit Is attacked
    Conditions
        (Level of Blurblade  for (Attacking unit)) Greater than 0
        ((Attacked unit) is A structure) Equal to False
    Actions
        Set BlurBladeAngle = ((Integer((Facing of (Attacked unit)))) - (Integer((Facing of (Attacking unit)))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                BlurBladeAngle Less than or equal to 0
            Then - Actions
                Set BlurBladeAngle = (BlurBladeAngle + 180)
            Else - Actions
                Set BlurBladeAngle = (BlurBladeAngle - 180)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                BlurBladeAngle Less than 0
            Then - Actions
                Set BlurBladeAngle = (BlurBladeAngle x -1)
            Else - Actions
                Do nothing
        Set BlurbladeDamage = ((Agility of (Attacking unit) (Include bonuses)) x (Level of Blurblade  for (Attacking unit)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                [B][U]BlurBladeAngle Greater than 169[/U][/B]
            Then - Actions
                Floating Text - Create floating text that reads (String(BlurbladeDamage)) above (Attacking unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
                Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                Floating Text - Change (Last created floating text): Disable permanence
                Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Real(BlurbladeDamage)) damage of attack type Hero and damage type Normal
                Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
                Special Effect - Destroy (Last created special effect)
                Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
                Special Effect - Destroy (Last created special effect)
            Else - Actions
                Do nothing
 

Hero

─║╣ero─
Reaction score
250
If it's a back stab you might wanna check and see if there facing the same angle +15 and -15

So that it gives a little leniency
 

Foresector

Member
Reaction score
16
What happens when you come to the 180 mark though?

Someone could be facing 180 degrees while someone could be facing 3 degrees. Only 3 degree difference but with that sort of function it would say its greater than 15+ thus the unit is not behind. :S
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
If it's a back stab you might wanna check and see if there facing the same angle +15 and -15
So that it gives a little leniency

That's the idea

What happens when you come to the 180 mark though?
Someone could be facing 180 degrees while someone could be facing 3 degrees. Only 3 degree difference but with that sort of function it would say its greater than 15+ thus the unit is not behind. :S

With Pyrogasm's code the way I have it, the backstab occurs at all angles. I'll give your code a try later tonight Foresector, thanks.
 

neckface

terrain contest winner! :) dance contest loser. :(
Reaction score
34
Tried modifying Foresector's method but did it wrong, as the trigger didn't work. Then my wrist started to hurt from all the clicking I've been doing getting my damn spells in order so i gave up!

Anyone have any ideas as to why Pyro's method isn't working right for me? :banghead:
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
Pyro's method should be working fine, unless you copied something wrong somewhere :D

Anyway, to provide me 2 cents:
What I did is find out the attack comes from left or right, if it comes from the left, I would simply just add 180 degrees to the value
(thus avoid the 360 = 0 problem)

According to a circle, 90 degrees would be assigned to the back, however, I prefer the back to be smaller, thus i set it to 60 degrees (of 30 degrees in both directions.

Lastly, just replaced the "Special Effects" with whatever extra damage or blood you want. I put something prominent there for the testing to be extremely obvious.

Code:
Actions
    Set a1 = (Facing of (Attacking unit))
    Set a2 = (Facing of (Attacked unit))
    -------- Checking if unit is attacking from left or right?  --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            Or - Any (Conditions) are true
                Conditions
                    a1 Less than 90.00
                    a1 Greater than 270.00
        Then - Actions
            Set a1 = ((a1 + 180.00) mod 360.00)
            Set a2 = ((a2 + 180.00) mod 360.00)
        Else - Actions
    -------- Checking if unit is behind --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            ((Max(a1, a2)) - (Min(a1, a2))) Less than 30.00
        Then - Actions
            Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
            Special Effect - Destroy (Last created special effect)
        Else - Actions
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top