HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Angle of 2 points

06-06-2005, 09:29 PM#1
Tim.
Alright, so I want the angle between to points. I need this for both if there is no object targeted, and if there is. So I have an If/Then/Else.

Quote:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order(smart))
Then - Actions
Set BulletDirection[1] = ((Angle from (Position of Hero[1]) to (Target point of issued order))
Else - Actions
Set BulletDirection[1] = ((Angle from (Position of Hero[1]) to (Position of (Target unit of issued order))


Now, as far as I can tell, If I select a point right next to the unit, I should get a angle relatively close to the angle I would get from selecting the unit itself. However this is not the case. I seem to be getting a wide range of angles.

I do not see any flaw in this trigger, yet clearly im forgeting some trigonometric or other mathematical functions.

Ideas?
06-07-2005, 03:45 PM#2
Tim.
Bump.
06-07-2005, 04:22 PM#3
iNfraNe
maybe hero[1] doesnt exist. thats all I can think of. Show us the trigger how you checked the value of the variable.. there isnt anything wrong with this.
06-07-2005, 05:49 PM#4
Tim.
Below is a direct copy/paste of the trigger. The only difference between this and the one above is instead of setting it always to Hero[1], it will get set to the play number shooting.

If you still see no error (As I see none myself) I can upload the map to my website under password, and you may download it freely using the password I can PM you.

Quote:

Tims Shoot
Events
Unit - Dummy Unit (Not actual name-Just so you know what it is) 0013 <gen> Is issued an order targeting a point
Unit - A unit Is issued an order targeting an object
Conditions
Or - Any (Conditions) are true
Conditions
(Issued order) Equal to (Order(smart))
(Issued order) Equal to (Order(attack))
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order(smart))
Then - Actions
Set BulletDirection[(Player number of (Owner of (Triggering unit)))] = (Angle from (Position of Hero[(Player number of (Owner of (Triggering unit)))]) to (Target point of issued order))
Else - Actions
Set BulletDirection[(Player number of (Owner of (Triggering unit)))] = (Angle from (Position of Hero[(Player number of (Owner of (Triggering unit)))]) to (Position of (Target unit of issued order)))
Unit - Create 1 BulletLauncher for Player 1 (Red) at (Position of Hero[(Player number of (Owner of (Triggering unit)))]) facing BulletDirection[(Player number of (Owner of (Triggering unit)))] degrees
Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ((Position of (Last created unit)) offset by 0.00 towards BulletDirection[(Player number of (Owner of (Triggering unit)))] degrees)
Sound - Play RifleShoot <gen> at 100.00% volume, attached to Marine 0000 <gen>
Trigger - Run Shoot Cooldown <gen> (ignoring conditions)
Wait 1.00 seconds
Unit - Remove (Last created unit) from the game


06-07-2005, 06:07 PM#5
iNfraNe
first of all, you sure triggering unit works?

then next, you use offset by 0.00, this means the unit does a carrion swarm right on the place the unit it is standing, meaning that wont do any good...
06-07-2005, 06:09 PM#6
Tim.
First, yes Triggering Unit works flawlessly.

Second, Im awre of that, but it has Range = 1000, so it shoots out in a straight line from the Hero at that angle.

Thirdly, if I only SMART, it works fine. Its only when I attack do I get issues.
06-07-2005, 06:16 PM#7
iNfraNe
well, then just try displaying the angles ingame, check if they are really that far apart. I really think the problem lies in the other part of the trigger, not that angle part.
06-07-2005, 06:21 PM#8
FriendlyWarlord
Probably what's happening is it's finding the point of a unit that doesn't exist when it targets the ground. The best thing I can think of doing would be to put the "targeting a point" and "targeting a unit" events in different triggers. Then get rid of the whole if statement, and just sepeate the unit/point actions into seperate triggers... that probably sounded confusing, so:

Event - unit targets point
Conditions - (same)
Action - Find angle between unit and point

Event - unit targets unit
Conditions - (same)
Action - Find angle between unit and other unit
06-07-2005, 06:25 PM#9
iNfraNe
Quote:
Originally Posted by Tim.
Thirdly, if I only SMART, it works fine. Its only when I attack do I get issues.
that means it doesnt check for a unit that doesnt exist ;)
06-07-2005, 07:04 PM#10
Tim.
Hmm, well It seems to work fine except for that damned attack order. Ill make a seperate trigger for attack.

I also set it to display the angle. The farther to the left or right I get, the farther the angle difference, the close I get to the Origin, the closer I get to the angle. When im directly below the unit, I get the exact inverse value of the correct angle. (-90 instead of 90 for instance)
06-07-2005, 07:25 PM#11
Tim.
I just realized somthing. The angle the ability is cast, when Attack is the order, makes it so the ability is cast aiming for the map origin, 0,0.

The angle isnt targetting the unit, rather, its targetting the origin...
06-07-2005, 07:43 PM#12
iNfraNe
then targeting location has lost its value.
Put this custom script at the top:

Code:
local location loc = GetOrderPointLoc()

And use that location in the bulletpoint (turn that action to jass).
06-07-2005, 07:50 PM#13
Tim.
You lost me. Heh. Where do I insert that JASS and how do I set up the trigger?
06-07-2005, 08:28 PM#14
iNfraNe
Code:
Tims Shoot
Events
Unit - Dummy Unit (Not actual name-Just so you know what it is) 0013 <gen> Is issued an order targeting a point
Unit - A unit Is issued an order targeting an object
Conditions
Or - Any (Conditions) are true
Conditions
(Issued order) Equal to (Order(smart))
(Issued order) Equal to (Order(attack))
Actions
[color=Red]local location loc = GetOrderPointLoc()[/color]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order(smart))
Then - Actions
Set BulletDirection[(Player number of (Owner of (Triggering unit)))] = (Angle from (Position of Hero[(Player number of (Owner of (Triggering unit)))]) to (Target point of issued order))
Else - Actions
[color=Red]Set BulletDirection[(Player number of (Owner of (Triggering unit)))] = (Angle from (Position of Hero[(Player number of (Owner of (Triggering unit)))]) to loc[/color](ofcourse, you need to convert this line to jass first)
Unit - Create 1 BulletLauncher for Player 1 (Red) at (Position of Hero[(Player number of (Owner of (Triggering unit)))]) facing BulletDirection[(Player number of (Owner of (Triggering unit)))] degrees
Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ((Position of (Last created unit)) offset by 0.00 towards BulletDirection[(Player number of (Owner of (Triggering unit)))] degrees)
Sound - Play RifleShoot <gen> at 100.00% volume, attached to Marine 0000 <gen>
Trigger - Run Shoot Cooldown <gen> (ignoring conditions)
Wait 1.00 seconds
Unit - Remove (Last created unit) from the game

oh, and btw, you know this trigger is leaking memory like a bitch right?
06-07-2005, 08:41 PM#15
Tim.
Oh? I never really understood memory leaks. Can you suggest how to fix them in this?

Note: All those 'Last Created Unit' were intended to be replaced with a variable.