3D floor with special?

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
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: 3D floor with special?

Post by hfc2x »

Project Dark Fox wrote:Though nice to have the if/else written out, it can be condensed to two lines:

Code: Select all

script 4 (void)
{
   if (GetActorFloorZ (0) >= 392)
      Teleport(1,0,0);
}
Note the lack of brackets. This works only if you have a single thing to process whatever's under the "if". The else is unnecessary and it will automatically terminate on its own.

Just thought I'd let you know is all. :P
Wow that was simple xD

Well, I want now to create a vent that thrusts players upwards when stepped on, but only till certain altitude.
Here I have this script, activated through ACS_ExecuteAlways so multiple players can be thrusted at once:

Code: Select all

int InSector[99];

script 1 (void)
{
	InSector[PlayerNumber()] = true;

	while (InSector[PlayerNumber()])
		{
		ThrustThingZ(const: 0, 80, 0, 0);
		delay(const:1);
		}
}

script 2 (void) // script to terminate Script 1
{
		InSector[PlayerNumber()] = false;
}
Well, that script thrusts players upward all the way to the ceiling, but I need to change the force at certain point... how do I do it?
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Re: 3D floor with special?

Post by Project Shadowcat »

I'm thinking that you should, again, play with GetActor(Floor)Z for this. At the same time, try lower forces. 6-10 allows it to be controllable.
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: 3D floor with special?

Post by hfc2x »

Project Dark Fox wrote:I'm thinking that you should, again, play with GetActor(Floor)Z for this. At the same time, try lower forces. 6-10 allows it to be controllable.
Well, I actually tried a script like this:

Code: Select all

script 1 (void) // ventilador
{
	InSector[PlayerNumber()] = true;

	while (InSector[PlayerNumber()])
		{
		ThrustThingZ(const: 0, 40, 0, 0);
		if ((GetActorZ (0) - GetActorFloorZ (0)) < 640) // added these
			delay(const:1);                              // lines.
		}
}
and also set a script to check the formula, so I know the values to use:

Code: Select all

script 99 ENTER
{
	while (TRUE)
	{
		Print (f:GetActorZ (0) - GetActorFloorZ (0));
		Delay (1);
	}
}
But I get a "Runaway Script 1 terminated." warning, though.
I don't know what I'm doing wrong, because I use the correct value (taken from the counter in SCRIPT 99).
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Re: 3D floor with special?

Post by Project Shadowcat »

Because the "if" statement is only applying to your delay(1);. You need that running all of the time for the script to not runaway.
Klofkac
Posts: 44
Joined: Sat Feb 06, 2010 4:02 pm

Re: 3D floor with special?

Post by Klofkac »

hfc2x wrote:
Klofkac wrote:I'm put. That "Actor hits ceiling/floor" thing affects only control sector and I don't know, what I must do for success.
I use type 1 3D floor.
You must use an "Actor Hits Floor" thing, and only works for the Vavoom-type 3D floor (the one with the inverted floor/ceiling heights)
No change.
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: 3D floor with special?

Post by hfc2x »

Klofkac wrote:
hfc2x wrote:
Klofkac wrote:I'm put. That "Actor hits ceiling/floor" thing affects only control sector and I don't know, what I must do for success.
I use type 1 3D floor.
You must use an "Actor Hits Floor" thing, and only works for the Vavoom-type 3D floor (the one with the inverted floor/ceiling heights)
No change.
Weird... it worked for me.
Are you sure you're doing everything right? Set the dummy sector to have the floor higher than its ceiling and put an "Actor Hits Ceiling" thing in it. Set the 3D floor to type 3 (Vavoom) and add the special to the "Actor Hits Floor" thing.

The created 3D floor will have the special of the Thing, but will be activated only when hitting the floor (for example if you jump on it).

I did all that, and worked... it's weird that doesn't work for you :?
Project Dark Fox wrote:Because the "if" statement is only applying to your delay(1);. You need that running all of the time for the script to not runaway.
Well, I got my script to work finally :D
I had to shift the result bits, because GetActor(Floor)Z returns a fixed point value, so the script ended like this:

Code: Select all

int InSector[99];

script 1 (void)
{
	InSector[PlayerNumber()] = true;

	SetActorProperty(0,APROP_Gravity,0.38); // Gravity gets lowered, so the player doesn't fall too
	while (InSector[PlayerNumber()])        // fast, giving it a "mid-air" feel
		{
		ThrustThingZ(0, 30, 0, 0);
		delay(1);
		if (((GetActorZ (0) - GetActorFloorZ (0)) >> 16) > 640)
			delay(45); // The extra delay is for the player to fall a bit before being thrusted again
		}
}

script 2 (void)
{
		SetActorProperty(0,APROP_Gravity,1.0);
		InSector[PlayerNumber()] = false;
}

script 98 RESPAWN // Script to prevent players from being thrusted idefinitely if they die on the ventilator
{
	ACS_ExecuteAlways(2,0,0,0,0);
}
It works like a charm now :D
Locked

Return to “Editing (Archive)”