HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Circle trouble

04-16-2009, 05:28 PM#1
darkwulfv
Hai guyz.

Having some trouble making things go in a circle from a point. Wondering if anyone could tell me what I was doing wrong?

Collapse JASS:
  loop
  exitwhen i == 36
    set angle = (i*10)*bj_DEGTORAD
    set angle2 = radius*Cos(angle)
    set angle3 = radius*Sin(angle)
    call IssuePointOrder(CreateDummyUnit(p, 'e000', x, y, DUMMY_ID, lvl, true), "shockwave", x + (angle2), y + (angle3))
    set i = i + 1
    call BJDebugMsg(R2S(x+(angle2)))
    call BJDebugMsg(R2S(y+(angle3)))
    call PolledWaitAcc(.05)
  endloop

"angle2" and "angle3" are only set there so I could BJDebugMsg them later. They won't stay long. "x" and "y" are the centerpoint of the circle. "radius" is, obviously, the intended radius of the circle.

So what happens is the x and y never change; that is, the shockwave is always in the same exact direction, never changes. I can't seem to figure out why.
I've tried with both degrees and radians, neither works.
04-16-2009, 08:39 PM#2
0zyx0
Are all of these variables only accessible from inside the function? Are you sure radius is set to a value different from 0? Those are the only problems I could think of.
04-16-2009, 08:52 PM#3
darkwulfv
Yeah, they're all local. And I'm almost positive radius gives a value, but... I could check.
04-16-2009, 09:16 PM#4
Feroc1ty
The x and y will never change, of course, you have to worry about your angle 2+3, but from the looks of it they should be changing.

By the wait, minimum sleep is 0.2, so might as well change that polled wait to 0.2.

Also, I'm not sure if this is the case, but I think multiplication puts more pressure on the CPU than addition, so you could simply make i the angle, and each loop add 10 to i instead of having an unnecessary multiplication, along with addition to i.

Nothing else is really wrong with your formula, by the way, what's your radius? Since shockwave will go as far as the spell distance is set to anyways, the radius really makes no difference, could simply remove it and make it the length of the shockwave, so you aren't storing/accessing a useless variable.
04-17-2009, 04:30 AM#5
darkwulfv
Quote:
By the wait, minimum sleep is 0.2, so might as well change that polled wait to 0.2.
Look closer, that's not a PolledWait. (although the function I made is innacurate in online play, so it's gotta change anyways).

Quote:
Since shockwave will go as far as the spell distance is set to anyways, the radius really makes no difference, could simply remove it and make it the length of the shockwave, so you aren't storing/accessing a useless variable.
The shockwave's length is == to the radius. Really I'm getting the radius for targetting purposes. The "accessing a useless variable" is very very minor here.


I think I found the problem, at some point radius isn't getting set or is getting set improperly, so it ends up 0 (and thus things never change).
04-17-2009, 11:16 AM#6
TheKid
I'm curious, does the shockwave always go to the right? Also, could you post a little more of the code, there might be a careless error some where. Right now I can't see anything wrong with what you're doing based on the code you've given. I'm assuming that the PolledWaitAcc is not the source of the problem, either...
04-17-2009, 03:30 PM#7
darkwulfv
Doesn't matter, it's all fixed. I believe it was a problem with a constant function I had returning 0, not [value].
04-18-2009, 12:34 AM#8
Feroc1ty
Take the suggestion I made about removing radius, and making i the angle instead of having i for only looping purposes, and than having to multiply that variable to get the angle, it's like shooting 2 birds with 1 shot.