# Sphere formation & its rotation problem

Hello. I'm Doom game mapper and scripter. I create complex scripts to do sophisticated actions. And it's pure C-like programming or ACS scripts which are native to that.

I'm forming a sphere of elements and everything is fine. But I face problems when trying to make it to turn around like a planet. Points istelf can do a smooth 1 circle turn.

But when I try to make them move they [b]jump[/b] to start point and start to move along whole circle arc.

I want so they all would turn from their own positions [u]without a jump[/u].

Here is the code:
[code]
#include "zcommon.acs"
//====================================

#define FRACBITS 16

str projectiles = {"DoomImpBall", "CacodemonBall", "ArachnotronPlasma", "PlasmaBall", "BaronBall", "Rocket"};

//---------------
int ar_r;
int ar_x;
int ar_y;
//---------------

script 5 (int tid, int type, int quantity)
{
quantity = random(8, 30);
type = random(1,6);
tid=1;
int steps, i, x, y, dx, dy;
steps = 40;
int index_r, index_x, index_y;
index_r=0; index_x=0; index_y=0;
int basex = GetActorX(tid);
int basey = GetActorY(tid);
int basez = GetActorZ(tid);
int spawnX, SpawnY;
int angle;
int zAngle;
//int x_angle=0;
int r_tag = 699;

Switch(1)
{
case 1: // SPHERE http://pastebin.com/L6FdWkV3
for (int z1 = 0; z1 < quantity; ++z1)
{
zAngle = FixedDiv(z1 << FRACBITS, ((quantity-1)*2) << FRACBITS);
for (int n1 = 0; n1 < quantity; ++n1)
{
//------------------------------------------------------
angle = FixedDiv(n1 << FRACBITS, quantity << FRACBITS);
//------------------------------------------------------
ar_x[index_x] = spawnX;
ar_y[index_y] = spawnY;
//------------------------------------------------------
++r_tag; ++index_r; ++index_x; ++index_y;
//------------------------------------------------------
Spawn(projectiles[type-1], basex + spawnX - 1000.0,
basey + spawnY,
r_tag, (angle + 1.0)>>8);
//------------------------------------------------------------------------------------------
print(s:"projectile: ", d:r_tag, s:" radius: ", f:ar_r[index_r-1], s:" index: ", d:index_r);
//------------------------------------------------------------------------------------------
delay(2);
}
}
break;
}
//---------------------------------------------------------------------------------------------------
for(int k = 700; k <= r_tag; ++k)
{
for (i=0; i<steps; i++)
{
angle = FixedDiv(i << FRACBITS, steps << FRACBITS);
dx = x - ar_x[k-700];
dy = y - ar_y[k-700];
ar_x[k-700] = x;
ar_y[k-700] = y;
SetActorVelocity(k, dx, dy, 0, FALSE, TRUE);
delay(1);
}
//delay(1);
}
}[/code]

I think they jump to starting point because for every point angle is counted from 0. IMHO, as there are steps/quntity steps in each part, it should be added to angle count. I don't know how and I don't know if am I right. I need your help to investigate the problem and find a solution.

The file is attached here too.