- Joined
- Jan 11, 2009
- Messages
- 3,414
Hi.
I am using a system in my map to detect which direction an attack is coming from to decide how front, side, and rear armor affects the damage.
This is how my code looks for the angle detection itself:
Then i have this script for puting it to practice:
As you see, i'm assuming that if the direction is neither from the back nor front, it has to be from the side.
There are two problems with this though; firstly, it appears that the system will jude something as EITHER back or front, sides are simply never registered. I think this have to do with the Back function, but i just can't visualize how the angles look by just seing theese numbers.
The other problem is that it is exploitable. I know that this is the most commonly used method, but i would like it to use the units location rather than facing angle.
Can someone show me how it should be?
I am using a system in my map to detect which direction an attack is coming from to decide how front, side, and rear armor affects the damage.
This is how my code looks for the angle detection itself:
JASS:
function Front takes unit u, unit t returns boolean
return RAbsBJ(GetUnitFacing(t)-GetUnitFacing(u)) >= 35.
endfunction
function Back takes unit u, unit t returns boolean
return not (RAbsBJ(GetUnitFacing(t)-GetUnitFacing(u)) >= 145.)
endfunction
Then i have this script for puting it to practice:
JASS:
if Back(u1, u2) then
call BJDebugMsg("Back")
else
if Front(u1, u2) then
call BJDebugMsg("Front")
else
call BJDebugMsg("Side")
endif
endif
As you see, i'm assuming that if the direction is neither from the back nor front, it has to be from the side.
There are two problems with this though; firstly, it appears that the system will jude something as EITHER back or front, sides are simply never registered. I think this have to do with the Back function, but i just can't visualize how the angles look by just seing theese numbers.
The other problem is that it is exploitable. I know that this is the most commonly used method, but i would like it to use the units location rather than facing angle.
Can someone show me how it should be?