Expand SetLineActivation to Change Repeatableness

Moderator: GZDoom Developers

Post Reply
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Expand SetLineActivation to Change Repeatableness

Post by Enjay »

For a map I have been working on, it would be useful to be able to change whether a line is repeatable or not. I am, of course, aware that there are several ways to remove a special or have a script ignore the actions of a line, but there have been a few times where it would have been best/easiest to be able to toggle whether the line was repeatable or not.

One of the most common situations where I have wanted to do this is with a switch operated line - repeatable lines always return the appearance of the switch to the off position after use. (This happens gardless of what the script does - including "brute-forcing" it to try and change the appearance by changing the texture using SetLineTexture.)

This is even more pressing where switches have several animated frames and perhaps separate on/off sounds rather than the simple on/off appearance and single sound of the default Doom switches.

So if a switch can be used many times, it needs to return to its off position to indicate that it can be used again. That's fine; that's what happens. However, if - eventually - there is one final time that the switch can be used and from that point on it is deactivated, remaining in its on appearance would look correct and give the player suitable feedback. If the repeatable nature of the switch could be turned off before that final use, setting up such a scenario would be nice and easy.

Relevant thread: viewtopic.php?f=122&t=74336

I don't know how feasible it would be, but it strikes me that adding this functionality to [wiki]SetLineActivation[/wiki] would make sense. So instead of SetLineActivation having these parameters:

SetLineActivation (int lineid, int activation);

it would have something like:

SetLineActivation (int lineid, int activation [,bool notrepeatable]);

(notrepeatable picked rather than repeatable because default should, I think, be 0/false.)
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: Expand SetLineActivation to Change Repeatableness

Post by RockstarRaccoon »

I was thinking about this too: there needs to be a switch-reset special, if nothing else, so we can just turn them back on after they're used...
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: Expand SetLineActivation to Change Repeatableness

Post by RockstarRaccoon »

Implementation notes...
Repeatability is defined by setting line_t.flags to ML_REPEAT_SPECIAL, defined in doomdefs.h.
We then go to bool P_ActivateLine in p_spec.cpp, where I see the following code...

Code: Select all

special = line->special;
if (!repeat && buttonSuccess)
{ // clear the special on non-retriggerable lines
	line->special = 0;
}

if (buttonSuccess)
{
	if (activationType == SPAC_Use || activationType == SPAC_Impact || activationType == SPAC_Push)
	{
		P_ChangeSwitchTexture (line->sidedef[0], repeat, special);
	}
}
...and that seems to be the only time deactivation ever comes up.

Looking at this, I'm realizing that you might be able to just reset the special and texture (and nothing else) to make it work, though, having the line remember its special so you can use an ACS special that just "resets" the line (animating the texture back to the off state and all) is FAR simpler for the mapper, and it sounds like it'd lead to more complex gameplay mechanics, something I'm always in favor of encouraging. All it'd really take is a flag in the flag-set that says if the trigger is "used" or something, then modifying the line-triggering code to check that when checking an activation on a non-repeatable (this isn't an intensively used operation like rendering, so that shouldn't be an issue).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expand SetLineActivation to Change Repeatableness

Post by Graf Zahl »

Added for GZDoom, the ACC include still needs to be done later

RockstarRaccoon wrote:I was thinking about this too: there needs to be a switch-reset special, if nothing else, so we can just turn them back on after they're used...

You have to set the special action again for that. It gets completely cleared when used with a one-time switch so reenabling is not possible.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”