• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Random Area Max?

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I am stumped with this:
JASS:
local real randx = x+GetRandomReal(x,500)*Cos(GetRandomReal(bj_PI,2*bj_PI)) 
local real randy = y+GetRandomReal(y,500)*Sin(GetRandomReal(bj_PI,2*bj_PI))

I want to have it a max AoE of 500 around the caster(x/y being the caster). It seems that it shoots all across the map. Where am I going wrong?
 
Level 5
Joined
Oct 14, 2010
Messages
100
GetRandomReal(x, 500) should be GetRandomReal(0, 500)
In addition to this, you use GetRandomReal(bj_PI, 2*bj_PI) twice, thus generating different angles for your X and your Y coordinate. In your case, since it's supposed to be random anyway, it probably won't matter but you should probably use only 1 angle.

JASS:
local real angle = GetRandomReal(bj_PI, 2 * bj_PI)
local real distance = GetRandomReal(0, 500)
local real randx = x + distance * Cos(angle)
local real randy = y + distance * Sin(angle)
 
Status
Not open for further replies.
Top