| 09-22-2008, 10:55 AM | #1 |
JASS:function Trig_TAE_Make_Attacks_Actions takes nothing returns nothing local unit u local real x1 = (GetUnitX(GetAttacker())) local real y1 = (GetUnitY(GetAttacker())) local real xa = (GetUnitX(GetTriggerUnit())) local real ya = (GetUnitY(GetTriggerUnit())) local real x2 = 0. local real y2 = 0. local real dist = 0. local real ang = Atan2((ya - y1), (xa - x1)) if (GetUnitPointValue(GetAttacker())==1) or (GetUnitPointValue(GetAttacker())==3) then set dist = 15. elseif (GetUnitPointValue(GetAttacker())==2) then set dist = 150. endif set x2 = x1 + (x1 + dist * Cos(ang)) set y2 = y1 + (y1 + dist * Cos(ang)) set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h003', x2, y2, 0.) // Requires configuration call UnitApplyTimedLife(u, 'BHwe', 1.) // Requires configuration call IssueTargetOrder(GetAttacker(), "attack", u) set u = null set ang = ang * bj_RADTODEG call BJDebugMsg("Angle of attack: " + R2S(ang)) endfunction Please acknowledge I'm still trying to learn Jass. Alrighty, what this does is it... 1. Detects whether units R, P or S attack 2. Makes a dummy unit for neutral passive at a certain distance and angle 3. Makes the attackING unit attack the dummy Now, thing is, I get really weird and seemingly random numbers. It may be that I'm trying to improvise Atan2 because I saw it inside that BJ that detected angle between points, but it's really weird. My problems include... 1. It gives off appearing random angles It may probably because I was out of what little practice I had before, but help would be appreciated. Thanks. |
| 09-22-2008, 11:36 AM | #2 |
Angle should be bj_RADTODEG * Atan2(...) |
| 09-22-2008, 11:38 AM | #3 |
"Trig_TAE_" lolololol xD set y2 = y1 + (y1 + dist * Cos(ang)) should be set y2 = y1 + (y1 + dist * Sin(ang)) |
| 09-22-2008, 11:42 AM | #4 |
Damn... |
| 09-22-2008, 11:58 AM | #5 | ||
Quote:
Quote:
I'll give it a go next time I get access to WE, and it's not intended as the Philippine word. It's intended as in Tide-Arc Ephemera, thank you very much. |
| 09-22-2008, 12:00 PM | #6 |
Milf omg, asa pa xD |
| 09-22-2008, 12:15 PM | #7 |
Hindi ako maronong nag Tagalog. Seriously. JASS:function Trig_TAE_Make_Attacks_Actions takes nothing returns nothing local unit u local real x1 = (GetUnitX(GetAttacker())) local real y1 = (GetUnitY(GetAttacker())) local real xa = (GetUnitX(GetTriggerUnit())) local real ya = (GetUnitY(GetTriggerUnit())) local real x2 = 0. local real y2 = 0. local real dist = 0. local real ang = Atan2((xa - x1), (ya - y1)) if (GetUnitPointValue(GetAttacker())==1) or (GetUnitPointValue(GetAttacker())==3) then set dist = 15. elseif (GetUnitPointValue(GetAttacker())==2) then set dist = 150. endif set x2 = x1 + dist * Cos(ang) set y2 = y1 + dist * Sin(ang) set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h003', x2, y2, 0.) // Requires configuration call UnitApplyTimedLife(u, 'BHwe', 1.) // Requires configuration call IssueTargetOrder(GetAttacker(), "attack", u) set u = null set ang = ang * bj_RADTODEG call BJDebugMsg("Angle of attack: " + R2S(ang)) endfunction I tried both solutions, neither... how to say, worked. It still gives fucked angles. |
| 09-22-2008, 12:18 PM | #8 |
Maybe try making it like Atan2(xa - x1, ya - y1) |
| 09-22-2008, 12:23 PM | #9 |
lolololol stupid mistake. Anyway. I remembered that with Atan2, y inputs come before x inputs. Silly Tide. +Rep to whoever tried to help. |
