Fix for Plutonia MAP05 fast scrollers

Like feature suggestions, but you've actually written code to make it happen. More likely to make it into the game than some random request in feature suggestions.

Moderator: GZDoom Developers

Forum rules
Please see Code submission guidelines

GZDoom Status:
Image

Legacy Status:
Image Image

QZDoom Status:
Image
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Fix for Plutonia MAP05 fast scrollers

Post by hfc2x »

Just wondering if this could be added to the level compatibility post-processor, since most source ports display the rapid scrollers in Ghost Town, but GZDoom does not (for good reason). A quick compat option can be made to restore the effect:

Code: Select all

version "4.5"

CLASS PlFix : LevelPostProcessor
{
	protected void Apply(Name checksum, String mapname)
	{
		int speed = 64;
		int i;

		switch (checksum)
		{
			case 'eb0d04aeb2841d5225caa576d7300d43': // Plutonia.wad MAP05
			{
				for (i = 602; i < 648; i++)
				{
					if (level.lines[i].special == 100)
						level.lines[i].args[0] = speed*24;
				}
				for (i = 1065; i < 1069; i++)
				{
					if (level.lines[i].special == 100)
						level.lines[i].args[0] = speed*4;
				}
			}
		}
	}
}
And yes, tested with both "default" and Anthology Plutonia (same map checksum) and works as intended. See attached file.
Attachments
PlFix.wad
Fix for fast scrollers in Plutonia MAP05
(547 Bytes) Downloaded 125 times
User avatar
Rachael
Posts: 13561
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Fix for Plutonia MAP05 fast scrollers

Post by Rachael »

Before adding this, I would prefer to ask the other devs if it would be more worth it to add a compatibility option to emulate this effect directly.

To do so, the linedefs themselves could be iterated and each sidedef could be labeled with how many lines are referencing it. Then the texture scroller can look this number up and multiply the scrolling directly by this value.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Fix for Plutonia MAP05 fast scrollers

Post by Gez »

I'd be in favor of direct support (by line counting) and don't see a need for it to be compat-optioned. The effect is used in other maps too and it's really not a mapping trick that can be used accidentally.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Fix for Plutonia MAP05 fast scrollers

Post by Graf Zahl »

Don't count on it. If you use a buggy sidedef compressor that's not aware of the original behavior you can easily end up with maps that accidentally merge these things.
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: Fix for Plutonia MAP05 fast scrollers

Post by hfc2x »

Graf Zahl wrote:If you use a buggy sidedef compressor that's not aware of the original behavior you can easily end up with maps that accidentally merge these things.
This is precisely why I thought level post-processor compat detection option was better in this single one instance. Everything seems to point to this particular map being compressed, causing that (accidental) distinctive effect, and in turn is probably what led to people to discover how editing the LINEDEFS lump could achieve the same thing.

Sidedef counting could be useful for maps known to be made with the deliberate intention to achieve this effect, but in the case of Ghost Town, it's mostly just to restore one of the most distinctive features of it.
User avatar
Rachael
Posts: 13561
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Fix for Plutonia MAP05 fast scrollers

Post by Rachael »

Yeah I definitely was not asking to apply that unconditionally across all maps. However, Ghost Town definitely is not the only map which makes use of this effect, and the effect should be applied per-map, but having a compatibility option for it lets us curate individual maps for it rather than having to do it manually as has been done in the PR.
User avatar
hfc2x
Posts: 646
Joined: Mon Aug 17, 2009 11:37 am
Location: Chule

Re: Fix for Plutonia MAP05 fast scrollers

Post by hfc2x »

Rachael wrote:Yeah I definitely was not asking to apply that unconditionally across all maps. However, Ghost Town definitely is not the only map which makes use of this effect, and the effect should be applied per-map, but having a compatibility option for it lets us curate individual maps for it rather than having to do it manually as has been done in the PR.
So, I had some time (after over a year, I know) and I decided to rewrite this script so the particular cases can be added to the Level Postprocessor. I think this should handle most cases where specific maps require the fast scrolling effect, but I haven't had the time to figure out if this can be optimized somehow.

The biggest problem I found was that GZDoom outright separates all the Sidedefs, so counting multiple references to a single one of them separately simply wasn't going to happen. That's why the script compares front-side textures. This works for Plutonia's MAP05, but I haven't seen any maps that require this effect that use a Linedef's back side, so that could be added if necessary.

Code: Select all

version "4.5"

CLASS PlFix : LevelPostProcessor
{
	protected void Apply(Name checksum, String mapname)
	{
		switch (checksum)
		{
			case 'eb0d04aeb2841d5225caa576d7300d43': // Plutonia.wad MAP05
			{
				int speed = 64;
				int scrollers[64]; // Max number of possible scrollers in vanilla levels
				int multipliers[63] = {0};
				int currentscroller = 0;
				int maxscrollers;
				String textures[3];

				for (int i = 0; i < level.lines.Size(); i++)
				{
					if (level.lines[i].special == 100)
					{
						scrollers[currentscroller] = level.lines[i].Index();
						currentscroller++;
						if (currentscroller >= 64)
							break;
					}
				}

				maxscrollers = currentscroller;

				currentscroller = 0;
				textures[0] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(0));
				textures[1] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(1));
				textures[2] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(2));

				for (int j = 0; j < maxscrollers; j++)
				{
					// This would never work for non-compressed levels...
					if (!(TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(0)) == textures[0] &&
					      TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(1)) == textures[1] &&
						  TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(2)) == textures[2]))
					{
						currentscroller++;
						textures[0] = TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(0));
						textures[1] = TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(1));
						textures[2] = TexMan.GetName(level.lines[scrollers[j]].sidedef[0].GetTexture(2));
					}
					multipliers[currentscroller]++;
				}

				currentscroller = 0;
				textures[0] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(0));
				textures[1] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(1));
				textures[2] = TexMan.GetName(level.lines[scrollers[0]].sidedef[0].GetTexture(2));

				for (int k = 0; k < maxscrollers; k++)
				{
					if (!(TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(0)) == textures[0] &&
					      TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(1)) == textures[1] &&
						  TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(2)) == textures[2]))
					{
						currentscroller++;
						textures[0] = TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(0));
						textures[1] = TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(1));
						textures[2] = TexMan.GetName(level.lines[scrollers[k]].sidedef[0].GetTexture(2));
					}

					level.lines[scrollers[k]].args[0] = speed*multipliers[currentscroller];
				}
			}
		}
	}
}
Attachments
plfix.wad
PWAD with the ZScript lump
(2.76 KiB) Downloaded 73 times
Post Reply

Return to “Code Submissions”