Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


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:
#include "zcommon.acs"

#define FRACBITS 16
#define MAXRADIUS 320.0

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

int ar_r[1300];
int ar_x[1300];
int ar_y[1300];

script 5 (int tid, int type, int quantity)
quantity = random(8, 30);
type = random(1,6);
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 circle_radius = random(94.0, MAXRADIUS);
int radius;
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;

case 1: // SPHERE
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);
radius = FixedMul(circle_radius, sin(zAngle));
spawnX = FixedMul(radius,cos(angle));
spawnY = FixedMul(radius,sin(angle));
ar_r[index_r] = radius;
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,
basez + circle_radius + FixedMul(FixedMul(circle_radius, 0.82), cos(zAngle)),
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);
for(int k = 700; k <= r_tag; ++k)
radius = ar_r[k-700];
for (i=0; i<steps; i++)
angle = FixedDiv(i << FRACBITS, steps << FRACBITS);
x = FixedMul(radius,cos(angle));
y = FixedMul(radius,sin(angle));
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);
Additional commands: [link=]Spawn[/link], [link=]FixedDiv[/link], [link=]FixedMul[/link], [link=]SetActorVelocity[/link]

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.

1. To see what is really happening you need a game WAD: [link=]For worst[/link]
The file is attached here too.

2. To play that wad you need the game istelf: [link=]ZDOOM[/link]

3. To edit game map space or ACS script you need: [link=]Doom builder[/link]

4. Here is a picture to better understand the view and maybe to see what's wrong. It's a view from top to bottom: [img=]

I look forward to hearing from you.
Sign In or Register to comment.