Fix softlock if a weapon is picked up during headpats.

This commit is contained in:
Mari the Deer 2022-03-29 16:00:03 +02:00
commit c0624d1a0f
2 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.3 \cu(Mon 28 Mar 22:57:24 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.3 \cu(2022-03-28 22:57:24)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.4 \cu(Tue 29 Mar 16:00:25 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.4 \cu(2022-03-29 16:00:25)\c-";

View file

@ -48,6 +48,10 @@ Class SWWMGesture : SWWMWeapon
override void DoEffect()
{
Super.DoEffect();
// if we're supposed to headpat but we're NOT the pending/ready weapon, something's very wrong here
// try to fix that by force
if ( pats && Owner && Owner.player && (Owner.player.ReadyWeapon != self) && (Owner.player.PendingWeapon != self) )
SetGesture(Owner.player.mo,GS_Headpat,true);
if ( !Owner || !Owner.player || (Owner.player.ReadyWeapon != self) )
return;
let psp = Owner.player.FindPSprite(PSP_WEAPON);
@ -75,11 +79,11 @@ Class SWWMGesture : SWWMWeapon
}
}
static SWWMGesture SetGesture( PlayerPawn mo, int which )
static SWWMGesture SetGesture( PlayerPawn mo, int which, bool force = false )
{
if ( !mo || !(mo is 'Demolitionist') ) return null; // only Demo
if ( mo.Health <= 0 ) return null; // dead
if ( mo.player.cheats&CF_TOTALLYFROZEN ) return null; // frozen today
if ( !force && (mo.player.cheats&CF_TOTALLYFROZEN) ) return null; // frozen today (unless forced)
SWWMGesture w = SWWMGesture(mo.FindInventory("SWWMGesture"));
if ( w && ((mo.player.PendingWeapon is 'SWWMGesture') || (mo.player.ReadyWeapon is 'SWWMGesture')
|| (mo.player.PendingWeapon is 'SWWMItemGesture') || (mo.player.ReadyWeapon is 'SWWMItemGesture')) )
@ -108,11 +112,11 @@ Class SWWMGesture : SWWMWeapon
}
// "special" gestures are run by switching to another "weapon"
static SWWMGesture SetSpecialGesture( PlayerPawn mo, Class<SWWMItemGesture> a )
static SWWMGesture SetSpecialGesture( PlayerPawn mo, Class<SWWMItemGesture> a, bool forced = false )
{
if ( !mo || !(mo is 'Demolitionist') ) return null; // only Demo
if ( mo.Health <= 0 ) return null; // dead
if ( mo.player.cheats&CF_TOTALLYFROZEN ) return null; // frozen today
if ( !forced && (mo.player.cheats&CF_TOTALLYFROZEN) ) return null; // frozen today (unless forced)
if ( !a ) return null;
SWWMGesture w = SWWMGesture(mo.FindInventory("SWWMGesture"));
if ( w && ((mo.player.PendingWeapon is 'SWWMGesture') || (mo.player.ReadyWeapon is 'SWWMGesture')
@ -218,6 +222,7 @@ Class SWWMGesture : SWWMWeapon
Demolitionist(player.mo).scriptedinvul = false;
let pt = invoker.pats;
if ( !pt ) return;
invoker.pats = null;
pt.patting = false;
let t = pt.target;
if ( t )