Spiral Staircase

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
LilWhiteMouse
Posts: 2270
Joined: Tue Jul 15, 2003 7:00 pm
Location: Maine, US
Contact:

Spiral Staircase

Post by LilWhiteMouse »

Anyone want this?
Image
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;
	}
}
Args of builder actor:
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.
User avatar
Ryan Cordell
Posts: 4349
Joined: Sun Feb 06, 2005 6:39 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia (Modern GZDoom)
Location: Capital of Explodistan

Re: Spiral Staircase

Post by Ryan Cordell »

You could post this under the Resources forum if you want to share it with others then.
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Spiral Staircase

Post by Amuscaria »

You can have rotations from below and above in Zdoom (like ROTT)? D:
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: Spiral Staircase

Post by Xaser »

Wheee, GAD's!
User avatar
printz
Posts: 2649
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Spiral Staircase

Post by printz »

Looks kinda cartoony, but the point raised by Eriance makes it interesting...
User avatar
.+:icytux:+.
Posts: 2661
Joined: Thu May 17, 2007 1:53 am
Location: Finland

Re: Spiral Staircase

Post by .+:icytux:+. »

Um yeah what I'm really interested about is how you made the ROTT style platform stuff? Couldn't you post a wad with the actor and sprites included too? :3
Theres nothing on the wiki about making theese kinds of sprites. Did it with ACS or something?
User avatar
LilWhiteMouse
Posts: 2270
Joined: Tue Jul 15, 2003 7:00 pm
Location: Maine, US
Contact:

Re: Spiral Staircase

Post by LilWhiteMouse »

There's no trick. Check the vector angle between the step and player, adjust state accordingly. Add as many angles as you care to. I'm not the first person to do this.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: Spiral Staircase

Post by Xaser »

How often does it run the check, though? I can imagine it'd be a bit processor intensive if lots of GAD's are in view (or even in the map, if checks are unconditional with respect to to line-of-sight).
User avatar
LilWhiteMouse
Posts: 2270
Joined: Tue Jul 15, 2003 7:00 pm
Location: Maine, US
Contact:

Re: Spiral Staircase

Post by LilWhiteMouse »

I run it every four tics per step. That's feather weight compared to the ACS I use in other mods.
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Spiral Staircase

Post by Amuscaria »

I'm really confused what ACS is, personally. I always thought it was just a bunch of scripts that I can add some C++ like elements to, such as variables. So I've only used it as such. I wasn't aware that I could write complex functions as you've mentioned. o.o
User avatar
Salad Viking
Posts: 752
Joined: Tue Apr 20, 2010 8:58 pm
Location: In high orbit

Re: Spiral Staircase

Post by Salad Viking »

Eriance wrote:I'm really confused what ACS is, personally. I always thought it was just a bunch of scripts that I can add some C++ like elements to, such as variables. So I've only used it as such. I wasn't aware that I could write complex functions as you've mentioned. o.o
It is (though it's much more like classic C, for the record). Just take a look at all these built-in functions you can call with ACS. It's slow, but you can still programs a lot of functionality into your mod with it. Just take a look at some of the stuff done in Stronghold or Shotgun Frenzy. Changing sprites based on the viewing angle of the player is on the simpler end of the scale (I wouldn't suggest doing that for every object on a map however).
User avatar
Nash
 
 
Posts: 17505
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Spiral Staircase

Post by Nash »

Ah so that's how you did it. It won't be multiplayer friendly then...
User avatar
LilWhiteMouse
Posts: 2270
Joined: Tue Jul 15, 2003 7:00 pm
Location: Maine, US
Contact:

Re: Spiral Staircase

Post by LilWhiteMouse »

Nash wrote:Ah so that's how you did it. It won't be multiplayer friendly then...
Multiplayer? What's that?
User avatar
Tragos
Posts: 624
Joined: Tue Jun 02, 2009 5:59 pm
Location: [Getting frisky with Xeno's]
Contact:

Re: Spiral Staircase

Post by Tragos »

LilWhiteMouse wrote:
Nash wrote:Ah so that's how you did it. It won't be multiplayer friendly then...
Multiplayer? What's that?
It's when a bunch of people with elevated virtual ego's blast away at each other within an extremely antiquated game engine..... :lol:
User avatar
.+:icytux:+.
Posts: 2661
Joined: Thu May 17, 2007 1:53 am
Location: Finland

Re: Spiral Staircase

Post by .+:icytux:+. »

Nash wrote:Ah so that's how you did it. It won't be multiplayer friendly then...
Are you sure? In skulltag theres this thing called "Clientside" scripts and actors.
Locked

Return to “Editing (Archive)”