HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Finding Random Points, Timers

07-29-2006, 08:09 AM#1
TGhost
Hello
Im trying to make a spell wich would work abit like the freezing field spell in DotA. It is supposed to create random firey explosions around the caster, the problems i have ran into are these:
I need to find a random point around the caster, to create this explosion.
And it seems that everyone says never use TriggerSleepAction, use timers. My only problem is, how would i go about stopping a trigger, just like triggersleepaction, but still using a timer? I mean, having an accurate wait/sleep. Without having to save everything to a game cache and then start a whole new function when the timer runs out?
07-29-2006, 08:54 AM#2
vile
Just use global vars, that wont make it MUI but still its going to work. Each time the timer starts, set a random point around the position of the caster. If you dont know how to do that, you set a random distance (real) between the minimum range and the maximum range as variable, a random angle between 0 and 360, then you cast the desired effect using a polar projection - the position of the caster + the random distance, towards the random angle. If you want to stop it at a point, whenever the timer starts, increase an integer variable, when it reaches a certain number, destroy the timer.
07-29-2006, 09:05 AM#3
TGhost
I got it to work in JASS now, i just take a random real between -500 and 500 and add this to the casters locationX and caster locationY, ofcourse im using two diffrent random reals, or else it would be the same x and y difference. But thanks anyway, btw, the spell must be MUI since im trying to create JESP standard spells Maybe i should have mentioned that. Also, how do i make a polar point thing in jass?
And anyone knows how i could use the timers, without a global?
07-29-2006, 09:35 AM#4
vile
you cant attach variables to timers without using gamecache. If you want this to be MUI with globals, you'll have to use global arrays and search for a free slot each time you start the spell.

here is an example for a polar point in jass:
Collapse JASS:
    local unit u=GetSpellAbilityUnit()
    local real dist=GetRandomReal(-500, 500)
    local real a=GetRandomReal(0, 360)
    local real x=GetUnitX(u)+dist*Cos(a*bj_DEGTORAD)
    local real y=GetUnitY(u)+dist*Sin(a*bj_DEGTORAD)

You put the x of the caster + dist * Cos(angle * bj_DEGTORAD
When it goes to y, you use Sin.
That's polar projection in jass without any leaks.
07-29-2006, 11:00 AM#5
karukef
Quote:
you cant attach variables to timers without using gamecache.

Not true anymore. You can. Check out SmartTimers.
07-29-2006, 11:30 AM#6
vile
I saw that karukef, good job on that one, however, it still uses the return bug, so I dont trust it that much.
07-29-2006, 12:41 PM#7
blu_da_noob
Quote:
Originally Posted by vile
If you dont know how to do that, you set a random distance (real) between the minimum range and the maximum range as variable, a random angle between 0 and 360, then you cast the desired effect using a polar projection - the position of the caster + the random distance, towards the random angle.

That's doesn't provide an equal random distribution throughout the circle. Choose the random angle between 0 and 360 and get a distance by getting the squareroot of a random real between 0 and 1 and multiplying it by the maximum radius.
07-29-2006, 12:53 PM#8
PipeDream
So? I would think a flat radial distribution of error is more realistic. Blah blah magic, yes, but if you're trying to hit a target, you'll expect a normal curve with respect to radial distribution. A box is much closer to this than the V you'll get from flat area distribution.
07-29-2006, 03:05 PM#9
vile
Well, that's what I used until now and it works perfectly.