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 The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top