From 312c433ed3acc57e9b137c3d3c3b3757344943d6 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Sun, 23 Jan 2022 20:49:20 +0100 Subject: [PATCH] Key refactor. They act as pure "item givers" now. --- language.version | 4 +- zscript/handler/swwm_handler_replacements.zsc | 3 +- zscript/hud/swwm_hud.zsc | 15 ------- zscript/items/swwm_keys.zsc | 41 +++++-------------- zscript/swwm_player.zsc | 32 ++++++--------- 5 files changed, 28 insertions(+), 67 deletions(-) diff --git a/language.version b/language.version index 99f9dea10..c02140181 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r127 \cu(Sun 23 Jan 20:48:58 CET 2022)\c-"; -SWWM_SHORTVER="\cw1.2pre r127 \cu(2022-01-23 20:48:58)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r128 \cu(Sun 23 Jan 20:49:20 CET 2022)\c-"; +SWWM_SHORTVER="\cw1.2pre r128 \cu(2022-01-23 20:49:20)\c-"; diff --git a/zscript/handler/swwm_handler_replacements.zsc b/zscript/handler/swwm_handler_replacements.zsc index 09ecb89db..cc9024d68 100644 --- a/zscript/handler/swwm_handler_replacements.zsc +++ b/zscript/handler/swwm_handler_replacements.zsc @@ -3,6 +3,7 @@ extend Class SWWMHandler { bool nugflip; // h/a nugget flip-flop spawn counter + bool equinoxhack; // hackaround for UseInventory private Class GetDRLAReplacee( Class a ) { @@ -591,7 +592,7 @@ extend Class SWWMHandler } else if ( (e.Replacee is 'RedCard') && !(e.Replacee is 'ChexRedCard') ) { - if ( level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043" ) + if ( !equinoxhack && (level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043") ) { if ( profiling ) checkreplacement_ms += MSTime()-curms; return; // don't replace red key in Equinox MAP13 diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index 2f091c55d..854061e7f 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -2260,21 +2260,6 @@ Class SWWMStatusBar : BaseStatusBar if ( !k || !k.Icon.IsValid() ) continue; klist.Push(k); } - // because we can't call GetReplacement from ui, let's wrangle something real ugly here to clean up replaced keys - for ( int i=0; i pc = klist[i].Species; - if ( !pc ) continue; - for ( int j=0; j= j ) i--; - } - } int maxcolc = (gameinfo.gametype&GAME_DOOMCHEX)?6:4; for ( int i=0; i pc = Species; - if ( !pc ) return; - let p = GetDefaultByType(pc); - Icon = p.Icon; - } - } - - override void AttachToOwner( Actor other ) - { - Super.AttachToOwner(other); - // also attach the vanilla key that we replace, mainly for script compatibility + // attach the vanilla key that we replace + let rt = toucher; + if ( toucher.player ) rt = toucher.player.mo; Class pc = Species; - if ( pc ) + if ( pc && !rt.FindInventory(pc) ) { + if ( rt.player && !deathmatch && !propagated && CVar.GetCVar('swwm_collectanimkey',rt.player).GetBool() ) + SWWMGesture.SetSpecialGesture(rt.player.mo,gesture); let p = Inventory(Spawn(pc)); - if ( Owner is 'Demolitionist' ) - Demolitionist(Owner).key_reentrant = true; // avoid infinite loop - p.AttachToOwner(Owner); - if ( Owner is 'Demolitionist' ) - Demolitionist(Owner).key_reentrant = false; + SWWMHandler.KeyTagFix(p); + p.AttachToOwner(rt); } - } - - override bool Use( bool pickup ) - { - if ( Owner.player && !propagated && !deathmatch && (!pickup || CVar.GetCVar('swwm_collectanimkey',Owner.player).GetBool()) ) - SWWMGesture.SetSpecialGesture(Owner.player.mo,gesture); // clean up the flag propagated = false; - return false; + GoAwayAndDie(); + return true; } Default { +NOTDMATCH; +FLOATBOB; - +INVENTORY.AUTOACTIVATE; FloatBobStrength 0.25; } } diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 5b1c07ba1..50b3bf1cb 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -2751,24 +2751,6 @@ Class Demolitionist : PlayerPawn } override void AddInventory( Inventory item ) { - // hackaround for replaced keys - if ( (item is 'Key') && !key_reentrant ) - { - let rep = (Class)(GetReplacement(item.GetClass())); - if ( rep && (item.GetClass() != rep) ) - { - // also add the new key - Actor whom = player?player.mo:PlayerPawn(self); - if ( !whom.FindInventory(rep) ) - { - let nk = Inventory(Spawn(rep)); - nk.AttachToOwner(whom); - nk.Use(true); - } - Super.AddInventory(item); - return; - } - } Super.AddInventory(item); if ( !player ) return; String cn = item.GetClassName(); @@ -2801,7 +2783,6 @@ Class Demolitionist : PlayerPawn if ( players[i].mo is 'Demolitionist' ) Demolitionist(players[i].mo).key_reentrant = true; let tkey = Inventory(Spawn(item.GetClass())); SWWMHandler.KeyTagFix(tkey); - if ( tkey is 'SWWMKey' ) SWWMKey(tkey).propagated = true; // no anim if ( !tkey.CallTryPickup(players[i].mo) ) tkey.Destroy(); if ( players[i].mo is 'Demolitionist' ) Demolitionist(players[i].mo).key_reentrant = false; } @@ -2820,6 +2801,19 @@ Class Demolitionist : PlayerPawn { let itemtype = item.GetClass(); if ( (player.cheats&CF_TOTALLYFROZEN) || isFrozen() ) return false; + // do the key gesture + if ( item is 'Key' ) + { + let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( hnd ) hnd.equinoxhack = true; + let rep = (Class)(GetReplacement(item.GetClass())); + if ( hnd ) hnd.equinoxhack = false; + if ( rep ) + { + SWWMGesture.SetSpecialGesture(self,GetDefaultByType(rep).gesture); + return false; + } + } if ( !Actor.UseInventory(item) ) { if ( player == players[consoleplayer] )