
It's a thing based spiral staircase actor. You drop the thing at the center, a mapspot where it starts, feed it some args, and it builds the staircase for you.
Code: Select all
ACTOR SpiralStairBuilder 20003
{
var int user_domeargs[5];
States
{
Spawn:
TNT1 A 0 // Dummy first frame
TNT1 A 0 A_SetUserArray(user_domeargs, 0, args[0])
TNT1 A 0 A_SetUserArray(user_domeargs, 1, args[1])
TNT1 A 0 A_SetUserArray(user_domeargs, 2, args[2])
TNT1 A 0 A_SetUserArray(user_domeargs, 3, args[3])
TNT1 A 0 A_SetUserArray(user_domeargs, 4, args[4])
TNT1 A 0 ACS_ExecuteAlways (900, 0)
TNT1 A -1
stop
}
}
Code: Select all
function int Range (int t1, int t2)
{
int x = GetActorX(t1) - GetActorX(t2) >> 16;
int y = GetActorY(t1) - GetActorY(t2) >> 16;
int r = sqrt((x * x) + (y * y));
return r;
}
function int sqrt(int number)
{
if(number <= 3)
{
if(number > 0)
{
return 1;
}
return 0;
}
int oldAns = number >> 1, // initial guess
newAns = (oldAns + number / oldAns) >> 1; // first iteration
// main iterative method
while(newAns < oldAns)
{
oldAns = newAns;
newAns = (oldAns + number / oldAns) >> 1;
}
return oldAns;
}
script 900 (void) {
int Start = GetUserArray (0, "user_domeargs", 0);
int Radius = Range(0, Start);
int z = GetActorZ(Start);
int Arc = 1.0/GetUserArray (0, "user_domeargs", 1);
int Height = GetUserArray (0, "user_domeargs", 2) * GetUserArray (0, "user_domeargs", 3) * 1.0;
int StepHeight = GetUserArray (0, "user_domeargs", 3) * 1.0;
int a = VectorAngle(GetActorX(Start) - GetActorX(0), GetActorY(Start) - GetActorY(0));
while (z <= GetActorZ(Start) + Height)
{
Spawn ("SpiralStairStep",
GetActorX(0) + cos(a) * Radius,
GetActorY(0) + sin(a) * Radius,
z, 0);
a = a + Arc;
if (a > 1.0){a = a - 1.0;}
z = z + StepHeight;
}
}
arg1 - TID of starting spot
arg2 - # of steps around center (4 would produce steps every 90 degrees, 8 every 45, and so on)
arg3 - total # of steps
arg4 - height of each step
I don't like how the total height is determined (desired height/step height = # of steps), but I couldn't think of a better way I personally liked.
The stair actor itself (not included) would obviously need to be a +NOGRAVITY +SOLID actor, but the rest would be customized to the needs of the map author.

