• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[General] Angle between

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

Get a random real between 270 and 360. 0 to 90 for north to east.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I dont really understand your question.

Angle is a real value between 0 and 360 that indeed starts to east and increases against the clock.

An angle to east is equal to 0 AND 360 as these are the same.
An angle to north is equal to 90.
An angle to west is equal to 180.
An angle to south is equal to 270.

If you want an angle to a point somewhere to the south-east, you have an angle pointing to 270 til 360 degrees.
415 degrees is exacly the middle.

Pointing north east is somewhere between 0 and 90 and 45 is the middle.


If you want the angle between the east of the map and the south of the map it could be a bit different.
If the map is a square, it is no big problem, but if it is not then you need something to determine it.
In GUI there is a function that can calculate the angle between 2 points.
I don't know how to get the size of the map because I haven't got an editor right now but that shouldnt be a problem.

This might have answered your question but I don't really know what you mean.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You switched north-west and south-west.
The trigger you need is this:
(degrees work fine)
(Only switch the reals in the random real part. Nothing more.)
  • v corners
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • -------- === NORTHWEST === --------
      • Set TempInteger = 1
      • Set TempLoc = (Center of 1 <gen>)
      • Set TempLoc2 = (TempLoc offset by 150.00 towards (Random real number between 270.00 and 360.00) degrees)
      • Unit - Create 1 Enemy Ability Dummy Unit 1 (TEMPLATE) for Neutral Hostile at TempLoc facing TempLoc2
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm TempLoc2
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
      • -------- === NORTHEAST === --------
      • Set TempInteger = 2
      • Set TempLoc = (Center of 2 <gen>)
      • Set TempLoc2 = (TempLoc offset by 150.00 towards (Random real number between 180.00 and 270.00) degrees)
      • Unit - Create 1 Enemy Ability Dummy Unit 1 (TEMPLATE) for Neutral Hostile at TempLoc facing TempLoc2
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm TempLoc2
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
      • -------- === SOUTHWEST === --------
      • Set TempInteger = 3
      • Set TempLoc = (Center of 3 <gen>)
      • Set TempLoc2 = (TempLoc offset by 150.00 towards (Random real number between 90.00 and 180.00) degrees)
      • Unit - Create 1 Enemy Ability Dummy Unit 1 (TEMPLATE) for Neutral Hostile at TempLoc facing TempLoc2
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm TempLoc2
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
      • -------- === SOUTHEAST === --------
      • Set TempInteger = 4
      • Set TempLoc = (Center of 4 <gen>)
      • Set TempLoc2 = (TempLoc offset by 150.00 towards (Random real number between 0.00 and 90.00) degrees)
      • Unit - Create 1 Enemy Ability Dummy Unit 1 (TEMPLATE) for Neutral Hostile at TempLoc facing TempLoc2
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm TempLoc2
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
 
Level 5
Joined
Feb 17, 2011
Messages
95

202808-albums7315-picture92595.png


Note: If it's above 360 it goes down to 0, but the value is still above 360. So 720 = 0, 540 = 180
Yup, angle + 2*k*pi
 
Level 4
Joined
Feb 28, 2014
Messages
70
How can North be 90º and West 270º? Fuck Logic.

Whatever.

0 and 360 - East - 0 and 2pi
45 - Northeast - pi/4
90 - North - pi/2
135 - Northwest 3pi/4
180 - West - pi
225 - Southwest - 5pi/4
270 - South - 3pi/2
315 - Southeast - 7pi/4

Just as bajaist posted
 
Status
Not open for further replies.
Top