| 04-07-2007, 02:27 PM | #1 |
I want a trigger only to fired off if the specific unit is looking at its opponent. (There must be a way, because Ive seen a minigame in UtherParty in which a spell only works if the enemy is behind you.) There is no GUI condition for this, afaik, but maybe there is an easy Jass way? |
| 04-07-2007, 02:38 PM | #2 |
Check the angle beetween the attacker and the attacked unit. Or use the spell windwalk ('AOwk') and the field DataCX (dont know how say it in english) EDIT: Hmm no this field is for behind not facing |
| 04-07-2007, 03:06 PM | #4 |
Wow thx for the fast answer, problem solved :D If I wanted the attacked unit also facing the attacker, do I need to change the angles? |
| 04-07-2007, 03:14 PM | #5 | |
Quote:
Just add conditions |
| 04-07-2007, 06:36 PM | #7 |
this does not work around the 0 angle. |
| 04-07-2007, 10:25 PM | #8 |
who cares about that |
| 04-07-2007, 10:31 PM | #9 |
Then you have a bug, and players get pissed off and stop playing. The solution is somewhere in these forums, just use the search feature. |
| 04-07-2007, 10:37 PM | #10 |
maybe the player when it screws up the game? how damn lazy JASS:function IsUnitFacingUnit takes unit u1, unit u2, real allowedangle returns boolean local real xd = GetUnitX(u2) - GetUnitX(u1) local real yd = GetUnitY(u2) - GetUnitY(u1) local real a1 = GetUnitFacing(u1) local real a2 = Atan2(yd, xd)*bj_RADTODEG local real x 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 set x = -x endif if x < allowedangle/2 then return true endif return false endfunction This always works. First param is the unit to check. Second param is the unit it's going to check for facing toward. Last one is the allowed angle difference (i.e. set it to 90 and it will return true if the unit is in a 90 degree cone in front) This could be generalized into a function that can check for being behind or to the side of a unit fairly easily, but this is all you need to check if a unit is facing another unit. credit to angles_getangledifference which is clearly ripped off for this function |
| 04-08-2007, 12:18 AM | #11 | |
Some links for you: And here's what grim001 just wrote, except in GUI: Quote:
|
