[Added] Expand SetLineActivation to Change Repeatableness

Moderator: GZDoom Developers

Expand SetLineActivation to Change Repeatableness

Postby Enjay » Tue Jan 04, 2022 6:18 am

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 SetLineActivation 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
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Expand SetLineActivation to Change Repeatableness

Postby RockstarRaccoon » Mon Jan 31, 2022 10:24 pm

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
Totally Babies
 
Joined: 31 Jul 2016

Re: Expand SetLineActivation to Change Repeatableness

Postby RockstarRaccoon » Tue Feb 01, 2022 8:24 pm

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 allExpand view
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
RockstarRaccoon
Totally Babies
 
Joined: 31 Jul 2016

Re: Expand SetLineActivation to Change Repeatableness

Postby Graf Zahl » Fri Apr 29, 2022 2:32 am

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests