| 02-12-2007, 01:10 PM | #1 |
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
but i don't know how to capture the unit's orientation. :( |
| 02-12-2007, 01:47 PM | #2 |
getunitfacing? |
| 02-12-2007, 02:36 PM | #3 |
You need to get the facing of the attacked unit, the facing of the attacking unit and compare. Look: Code:
X
YX is facing 0, Y is facing 0. So try this: Trigger: 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 |
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 | |
Quote:
Yes your right, i'll change it. |
| 02-12-2007, 03:02 PM | #6 |
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 |
Tide's solution does not really work because angles are cyclic and all that stuff You are probably going to use one of these: 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)
endfunctionor 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 | |
Quote:
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 |
can someone explain the ModuloReal/Int? I dont quite get it. |
| 02-12-2007, 08:35 PM | #10 |
Modulo is remainder; 7 mod 3 = 1 ;( ModuloInteger(7,3)==1) , 7 = 3*2 + 1 |
| 02-12-2007, 08:44 PM | #11 |
| 02-12-2007, 10:52 PM | #12 |
Don't think thats quite correct. 7 != 3*1+1 _________ |3 * 1 = 3| _________ |3 + 1 = 4| _________ |
| 02-12-2007, 11:50 PM | #13 | |
Quote:
7 = 3*2+1 |
| 02-13-2007, 12:16 AM | #14 |
sorry.... but could someone explain to me what is going on in the JASS script? |
| 02-13-2007, 03:46 AM | #15 |
nobody? :P |
