Wc3C.net [Help] Weird Angles
 Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar

09-22-2008, 10:55 AM   #1
Tide-Arc Ephemera
Overdoses result in death

Join Date: Jan 2007
Posts: 2,365

Submissions (3)

[Help] Weird Angles

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.
__________________

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
 Originally Posted by Alevice You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.

Last edited by Tide-Arc Ephemera : 09-22-2008 at 10:55 AM.

 09-22-2008, 11:36 AM #2 Vestras User Project Member: LoC   Join Date: Dec 2007 Posts: 756 Submissions (4) Angle should be bj_RADTODEG * Atan2(...)
 09-22-2008, 11:38 AM #3 Malf I LIKE PIZZA! | >     Join Date: Sep 2007 Posts: 625 Submissions (2) "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 Vestras User Project Member: LoC   Join Date: Dec 2007 Posts: 756 Submissions (4) Damn...
09-22-2008, 11:58 AM   #5
Tide-Arc Ephemera
Overdoses result in death

Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Quote:
 Originally Posted by Vestras Angle should be bj_RADTODEG * Atan2(...)
The description of Atan2 said it gave off radians...

Quote:
 Originally Posted by Milf "Trig_TAE_" lolololol xD set y2 = y1 + (y1 + dist * Cos(ang)) should be set y2 = y1 + (y1 + dist * Sin(ang))

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.
__________________

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
 Originally Posted by Alevice You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.

 09-22-2008, 12:00 PM #6 Malf I LIKE PIZZA! | >     Join Date: Sep 2007 Posts: 625 Submissions (2) Milf omg, asa pa xD __________________
09-22-2008, 12:15 PM   #7
Tide-Arc Ephemera
Overdoses result in death

Join Date: Jan 2007
Posts: 2,365

Submissions (3)

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.
__________________

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
 Originally Posted by Alevice You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.

 09-22-2008, 12:18 PM #8 Vestras User Project Member: LoC   Join Date: Dec 2007 Posts: 756 Submissions (4) Maybe try making it like Atan2(xa - x1, ya - y1)
09-22-2008, 12:23 PM   #9
Tide-Arc Ephemera
Overdoses result in death

Join Date: Jan 2007
Posts: 2,365

Submissions (3)

lolololol stupid mistake.

Anyway. I remembered that with Atan2, y inputs come before x inputs. Silly Tide.

+Rep to whoever tried to help.
__________________

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
 Originally Posted by Alevice You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.