- skip switch animation checks for custom switch actors.

This commit is contained in:
Christoph Oelckers 2022-12-29 13:55:59 +01:00
parent 95a2b85fae
commit b980789ddf
4 changed files with 61 additions and 54 deletions

View file

@ -125,7 +125,7 @@ void CallStaticSetup(DDukeActor* actor);
void CallPlayFTASound(DDukeActor* actor);
void CallStandingOn(DDukeActor* actor, player_struct* p);
void CallRunState(DDukeActor* actor);
bool CallTriggerSwitch(DDukeActor* actor, player_struct* p);
int CallTriggerSwitch(DDukeActor* actor, player_struct* p);
extern FTextureID mirrortex, foftex;

View file

@ -560,7 +560,7 @@ void CallStandingOn(DDukeActor* actor, player_struct* p)
}
}
bool CallTriggerSwitch(DDukeActor* actor, player_struct* p)
int CallTriggerSwitch(DDukeActor* actor, player_struct* p)
{
int nval = false;
IFVIRTUALPTR(actor, DDukeActor, TriggerSwitch)

View file

@ -1610,6 +1610,7 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
int lotag, hitag, correctdips, numdips;
DVector2 spos;
FTextureID texid;
int swresult = 0;
if (wwal == nullptr && act == nullptr) return 0;
correctdips = 1;
@ -1625,7 +1626,8 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
switchpal = act->spr.pal;
// custom switches that maintain themselves can immediately abort.
if (CallTriggerSwitch(act, &ps[snum])) return true;
swresult = CallTriggerSwitch(act, &ps[snum]);
if (swresult == 1) return true;
}
else
{
@ -1639,67 +1641,72 @@ bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
auto& ext = GetExtInfo(texid);
auto& swdef = switches[ext.switchindex];
// check if the switch may be activated.
switch (swdef.type)
if (swresult == 0)
{
case SwitchDef::Combo:
break;
// check if the switch may be activated.
switch (swdef.type)
{
case SwitchDef::Combo:
break;
case SwitchDef::Access:
if (!fi.checkaccessswitch(snum, switchpal, act, wwal))
return 0;
[[fallthrough]];
case SwitchDef::Access:
if (!fi.checkaccessswitch(snum, switchpal, act, wwal))
return 0;
[[fallthrough]];
case SwitchDef::Regular:
case SwitchDef::Multi:
if (check_activator_motion(lotag)) return 0;
break;
case SwitchDef::Regular:
case SwitchDef::Multi:
if (check_activator_motion(lotag)) return 0;
break;
default:
if (isadoorwall(texid) == 0) return 0;
break;
default:
if (isadoorwall(texid) == 0) return 0;
break;
}
togglespriteswitches(act, ext, lotag, correctdips, numdips);
togglewallswitches(wwal, ext, lotag, correctdips, numdips);
if (lotag == -1)
{
setnextmap(false);
return 1;
}
// Yet another crude RRRA hack that cannot be fully generalized.
if (hitag == 10001 && swdef.flags & SwitchDef::oneway && isRRRA())
{
act->spr.setspritetexture(swdef.states[1]);
if (ps[snum].SeaSick == 0)
ps[snum].SeaSick = 350;
operateactivators(668, &ps[snum]);
operatemasterswitches(668);
S_PlayActorSound(328, ps[snum].GetActor());
return 1;
}
}
togglespriteswitches(act, ext, lotag, correctdips, numdips);
togglewallswitches(wwal, ext, lotag, correctdips, numdips);
if (lotag == -1)
{
setnextmap(false);
return 1;
}
DVector3 v(spos, ps[snum].GetActor()->getOffsetZ());
// Yet another crude RRRA hack that cannot be fully generalized.
if (hitag == 10001 && swdef.flags & SwitchDef::oneway && isRRRA())
{
act->spr.setspritetexture(swdef.states[1]);
if (ps[snum].SeaSick == 0)
ps[snum].SeaSick = 350;
operateactivators(668, &ps[snum]);
operatemasterswitches(668);
S_PlayActorSound(328, ps[snum].GetActor());
return 1;
}
if (swdef.type != SwitchDef::None || isadoorwall(texid))
{
if (swdef.type == SwitchDef::Combo)
if (swresult == 0)
{
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
if (numdips != correctdips) return 0;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v);
}
if (swdef.type == SwitchDef::Multi)
{
lotag += ext.switchphase;
if (hitag == 10000 && act && isRRRA()) // no idea if the game check is really needed for something this far off the beaten path...
if (swdef.type == SwitchDef::Combo)
{
tag10000specialswitch(snum, act, v);
return 1;
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
if (numdips != correctdips) return 0;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v);
}
if (swdef.type == SwitchDef::Multi)
{
lotag += ext.switchphase;
if (hitag == 10000 && act && isRRRA()) // no idea if the game check is really needed for something this far off the beaten path...
{
tag10000specialswitch(snum, act, v);
return 1;
}
}
}

View file

@ -86,7 +86,7 @@ class RedneckBellSwitch : DukeActor
self.detail = 132;
self.setSpriteSetImage(1);
self.changeStat(STAT_MISC); // needs to be made to call Tick
return false; // still needs to act as a switch.
return 2; // 2 lets the switch code perform the trigger action without messing around with this actor.
}
override void Tick()