HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Backstab System

02-12-2007, 01:10 PM#1
notor
Trying to create a backstab evaluation... my thought was, evaluate the orientation of attacking and attacked player, and if they are plus minus X amount, then it's a backstab, so add damage or whatever. Is there a better way?

Trigger:
backstab
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
skillAssassin[(Player number of (Owner of (Attacking unit)))] Equal to True
Collapse Actions
Set unitOrient[(Player number of (Triggering player))] = 0
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Then - Actions
Else - Actions

but i don't know how to capture the unit's orientation. :(
02-12-2007, 01:47 PM#2
emjlr3
getunitfacing?
02-12-2007, 02:36 PM#3
The)TideHunter(
You need to get the facing of the attacked unit, the facing of the attacking unit and compare.

Look:
Code:
           X
           Y

X is facing 0, Y is facing 0.
So try this:
Trigger:
Actions
Set AttackedFacing = (Facing of (Attacked unit))
Set AttackerFacing = (Facing of (Attacking unit))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse And - All (Conditions) are true
Collapse Conditions
AttackerFacing Greater than or equal to (AttackedFacing - 60.00)
AttackerFacing Less than or equal to (AttackedFacing + 60.00)
Collapse Then - Actions
Backstab Actions
Else - Actions
I think that will work anyway.

BTW: the 60 is the minium and maxium angle it can be at, because think about it, its not going to be perfectly facing it, so give it some ease, if you set them both to 180, then it would count backstab as every direction, the lower that number the smaller the gap to backstab.
02-12-2007, 02:50 PM#4
Fireeye
Tide don't it have to be an and-condition? in this case it will always fire when you use an or-condition.
02-12-2007, 02:59 PM#5
The)TideHunter(
Quote:
Originally Posted by Fireeye
Tide don't it have to be an and-condition? in this case it will always fire when you use an or-condition.

Yes your right, i'll change it.
02-12-2007, 03:02 PM#6
notor
sounds good but where are you getting facing? i can't find it... is it because of my variable? i made it an integer... maybe it needs to be something else?
02-12-2007, 03:23 PM#7
Vexorian
Tide's solution does not really work because angles are cyclic and all that stuff

You are probably going to use one of these:
Collapse JASS:
    function Angles_IsAngleBetweenAngles takes real angle, real angle1, real angle2 returns boolean
     local real x
        set angle=ModuloReal(angle,360)
        set angle1=ModuloReal(angle1,360)
        set angle2=ModuloReal(angle2,360)
        if (angle1>angle2) then
            set x=angle1
            set angle1=angle2
            set angle2=x
        endif
        if (angle2-angle1)>(angle1 - (angle2-360)) then
            set angle2=angle2-360
            if angle > 180 then
                set angle=angle-360
            endif
            return angle>=angle2 and angle<=angle1
        endif
     return (angle>=angle1) and (angle<=angle2)
    endfunction

or
Collapse JASS:
    function Angles_GetAngleDifference takes real a1, real a2 returns real
     local real x
        set a1=ModuloReal(a1,360)
        set a2=ModuloReal(a2,360)
        if a1>a2 then
            set x=a1
            set a1=a2
            set a2=x
        endif
        set x=a2-360
        if a2-a1 > a1-x then
            set a2=x
        endif
        set x=a1-a2
        if (x<0) then
            return -x
        endif
     return x
    endfunction

You can complicate your life and remake the arithmetic in GUI if you are so attached to it.
02-12-2007, 04:55 PM#8
The)TideHunter(
Quote:
Originally Posted by Vexorian
Tide's solution does not really work because angles are cyclic and all that stuff

You are probably going to use one of these:
Collapse JASS:
    function Angles_IsAngleBetweenAngles takes real angle, real angle1, real angle2 returns boolean
     local real x
        set angle=ModuloReal(angle,360)
        set angle1=ModuloReal(angle1,360)
        set angle2=ModuloReal(angle2,360)
        if (angle1>angle2) then
            set x=angle1
            set angle1=angle2
            set angle2=x
        endif
        if (angle2-angle1)>(angle1 - (angle2-360)) then
            set angle2=angle2-360
            if angle > 180 then
                set angle=angle-360
            endif
            return angle>=angle2 and angle<=angle1
        endif
     return (angle>=angle1) and (angle<=angle2)
    endfunction

or
Collapse JASS:
    function Angles_GetAngleDifference takes real a1, real a2 returns real
     local real x
        set a1=ModuloReal(a1,360)
        set a2=ModuloReal(a2,360)
        if a1>a2 then
            set x=a1
            set a1=a2
            set a2=x
        endif
        set x=a2-360
        if a2-a1 > a1-x then
            set a2=x
        endif
        set x=a1-a2
        if (x<0) then
            return -x
        endif
     return x
    endfunction

You can complicate your life and remake the arithmetic in GUI if you are so attached to it.

Damn yeah, i remember being corrected by Infrane, somebody asked for this very answer and i gave the same answer as i did in this thread, and you are in Infrane's place in the thread. Deja vu lol.
02-12-2007, 08:31 PM#9
Joker
can someone explain the ModuloReal/Int? I dont quite get it.
02-12-2007, 08:35 PM#10
Vexorian
Modulo is remainder; 7 mod 3 = 1 ;( ModuloInteger(7,3)==1) ,

7 = 3*2 + 1
02-12-2007, 08:44 PM#11
CommanderZ
http://en.wikipedia.org/wiki/Modulo_operation
02-12-2007, 10:52 PM#12
Feroc1ty
Don't think thats quite correct.
7 != 3*1+1
_________
|3 * 1 = 3|
_________
|3 + 1 = 4|
_________
02-12-2007, 11:50 PM#13
Ammorth
Quote:
Originally Posted by Jokes-On-You
Don't think thats quite correct.
7 != 3*1+1
_________
|3 * 1 = 3|
_________
|3 + 1 = 4|
_________

7 = 3*2+1
02-13-2007, 12:16 AM#14
notor
sorry.... but could someone explain to me what is going on in the JASS script?
02-13-2007, 03:46 AM#15
notor
nobody? :P