| 08-20-2006, 02:14 PM | #1 |
Sorry, I suck when it gets to angles. Now I need a condition where a unit is facing directly at another unit, and it will return true, without taking in matter the target's facing. |
| 08-20-2006, 02:46 PM | #2 |
JASS:local unit facer = YOUR_UNIT local unit target = TARGET local real angle = bj_RADTODEG * Atan2(GetUnitY(target) - GetUnitY(facer), GetUnitX(target) - GetUnitX(facer))) if (angle < 0) then set angle = angle + 360 endif return (angle = GetUnitFacing(facer)) |
| 08-20-2006, 03:19 PM | #3 |
That doesnt work. blu da noob's function works for a unit facing a unit, like this: -> <- here it is JASS:local real f1 = GetUnitFacing(yourunit) local real f2 = GetUnitFacing(targetunit) + 180. local real angle = AngleBetweenUnits(yourunit,targetunit) //Use your equivalent of this local real diff1 = RAbsBJ(f1-f2) local real diff2 = RAbsBJ(f1-angle) local real tolerance = 30. //How far it can be from exact facing return ( diff1 <= tolerance or diff1 >= (360 - tolerance) ) and ( diff2 <= tolerance or diff2 >= (360 - tolerance) ) I want the condition to be true if the target faces the caster, and it doesnt matter which angle the caster faces. |
| 08-20-2006, 03:31 PM | #4 |
JASS:local real f1 = GetUnitFacing(yourunit) local real angle = AngleBetweenUnits(yourunit,targetunit) //Use your equivalent of this local real diff = RAbsBJ(f1-angle) //or RMaxBJ(f1,angle)-RMinBJ(f1,angle) local real tolerance = 30. //How far it can be from exact facing return diff <= tolerance or diff >= (360 - tolerance) |
| 08-20-2006, 03:31 PM | #5 | |
Quote:
JASS:local unit facer = GetSpellTargetUnit() local unit faced = GetTriggerUnit() local real angle = bj_RADTODEG * Atan2(GetUnitY(faced) - GetUnitY(facer), GetUnitX(faced) - GetUnitX(facer)) local real tolerance = 30.00 if (angle < 0) then set angle = angle + 360.00 endif return RAbsBJ(angle - GetUnitFacing(facer)) < tolerance |
| 08-20-2006, 03:40 PM | #6 |
lol blu, perfect.. what would i do without ya :D |
