From a2855dfc9aa76235eaa31c4ff7d4cc8a4e058c7b Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sat, 18 Feb 2023 11:54:30 +0100 Subject: [PATCH] Don't use inventory tokens for mapper-toggleable store/revive. Tokens are icky. --- MAPPING.md | 8 ++++---- language.version | 4 ++-- zscript/handler/swwm_handler.zsc | 13 +++++++++++++ zscript/hud/swwm_hud.zsc | 2 +- zscript/kbase/swwm_kbasetab_store.zsc | 2 +- zscript/player/swwm_player.zsc | 8 +++++--- zscript/player/swwm_player_items.zsc | 20 -------------------- zscript/player/swwm_player_think.zsc | 3 ++- zscript/swwm_thinkers.zsc | 3 +++ 9 files changed, 31 insertions(+), 32 deletions(-) diff --git a/MAPPING.md b/MAPPING.md index 077bd847b..0225097da 100644 --- a/MAPPING.md +++ b/MAPPING.md @@ -1,11 +1,11 @@ # Notes for mappers -### Tokens +### Toggling features -- **Disabling the store:**
Give the player `"SWWMStoreDisabler"` item on map load. -- **Disabling revives:**
Give the player `"SWWMReviveDisabler"` item on map load. +- **Store:**
`CallACS("SWWMHandler","ToggleStore",#)`
Passing **0** disables the store, any other number will enable it again. +- **Reviving:**
`CallACS("SWWMHandler","ToggleRevive",#)`
Passing **0** disables reviving, any other number will enable it again. -**Note:** Tokens are flagged as *"unclearable"*, so they have to be removed directly with `TakeInventory`. +**Note:** These settings will persist between level changes. ### Mission log diff --git a/language.version b/language.version index 2c8a9c38b..07cb1a480 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r762 \cu(Sat 18 Feb 11:54:24 CET 2023)\c-"; -SWWM_SHORTVER="\cw1.3pre r762 \cu(2023-02-18 11:54:24)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r763 \cu(Sat 18 Feb 11:54:30 CET 2023)\c-"; +SWWM_SHORTVER="\cw1.3pre r763 \cu(2023-02-18 11:54:30)\c-"; diff --git a/zscript/handler/swwm_handler.zsc b/zscript/handler/swwm_handler.zsc index e06857a7a..097a5d263 100644 --- a/zscript/handler/swwm_handler.zsc +++ b/zscript/handler/swwm_handler.zsc @@ -70,6 +70,19 @@ Class SWWMHandler : EventHandler prof_calls[idx]++; } + static play void ToggleStore( bool val ) + { + let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( !hnd || !hnd.gdat ) return; // shouldn't happen, but doesn't hurt to check + hnd.gdat.disablestore = !val; + } + static play void ToggleRevive( bool val ) + { + let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( !hnd || !hnd.gdat ) return; // shouldn't happen, but doesn't hurt to check + hnd.gdat.disablerevive = !val; + } + override void OnRegister() { // oneliner RNG must be relative to consoleplayer diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index f452cd04b..e38657431 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -561,7 +561,7 @@ Class SWWMStatusBar : BaseStatusBar xx = int((ss.x-len)/2.); yy = ss.y/2.; Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); - if ( goner || CPlayer.mo.FindInventory("SWWMReviveDisabler") || !swwm_revive ) + if ( goner || hnd.gdat.disablerevive || !swwm_revive ) return (1.-dimalph); alph = clamp((deadtimer-160)/60.,0.,1.); str = String.Format(StringTable.Localize("$SWWM_URDED3")); diff --git a/zscript/kbase/swwm_kbasetab_store.zsc b/zscript/kbase/swwm_kbasetab_store.zsc index c0a2add59..8983a8f7f 100644 --- a/zscript/kbase/swwm_kbasetab_store.zsc +++ b/zscript/kbase/swwm_kbasetab_store.zsc @@ -71,7 +71,7 @@ Class DemolitionistStoreTab : DemolitionistMenuTab override DemolitionistMenuTab Init( DemolitionistMenu master ) { title = StringTable.Localize("$SWWM_STORETAB"); - bDisabled = (deathmatch||(G_SkillPropertyInt(SKILLP_ACSReturn)>=4)||players[consoleplayer].mo.FindInventory("SWWMStoreDisabler")); + bDisabled = (deathmatch||(G_SkillPropertyInt(SKILLP_ACSReturn)>=4)||master.hnd.gdat.disablestore); return Super.Init(master); } override void OnDestroy() diff --git a/zscript/player/swwm_player.zsc b/zscript/player/swwm_player.zsc index 9fe113ca6..a02733973 100644 --- a/zscript/player/swwm_player.zsc +++ b/zscript/player/swwm_player.zsc @@ -123,6 +123,8 @@ Class Demolitionist : PlayerPawn double bobtime, oldbobtime, oldbob; + SWWMHandler hnd; + Default { Tag "$T_DEMOLITIONIST"; @@ -363,7 +365,7 @@ Class Demolitionist : PlayerPawn damage = 0; if ( (swwm_strictuntouchable >= 2) && (damage > 0) && player ) { - let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); if ( hnd ) hnd.tookdamage[PlayerNumber()] = true; } if ( (mod == 'Crush') && player && (player.mo == self) ) @@ -559,7 +561,7 @@ Class Demolitionist : PlayerPawn if ( !player ) return false; int score = 100; // last secret (this is called before counting it up, so have to subtract) - let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); if ( !deathmatch && !(gameinfo.gametype&GAME_Hexen) && (level.found_secrets == level.total_secrets-1) && (!hnd || !hnd.allsecrets) ) { if ( hnd ) hnd.allsecrets = true; @@ -718,7 +720,7 @@ Class Demolitionist : PlayerPawn } } // re-add ourselves to the "suckable list" (otherwise the Ynykron Singularity won't hurt us) - let hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); + if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); if ( hnd && (hnd.SuckableActors.Find(self) >= hnd.SuckableActors.Size()) ) hnd.SuckableActors.Push(self); } diff --git a/zscript/player/swwm_player_items.zsc b/zscript/player/swwm_player_items.zsc index 7eaa2e27a..e340aebb9 100644 --- a/zscript/player/swwm_player_items.zsc +++ b/zscript/player/swwm_player_items.zsc @@ -1,25 +1,5 @@ // player-specific item stuff -// tokens for custom maps -Class SWWMStoreDisabler : Inventory -{ - Default - { - +INVENTORY.UNCLEARABLE; - +INVENTORY.UNDROPPABLE; - +INVENTORY.UNTOSSABLE; - } -} -Class SWWMReviveDisabler : Inventory -{ - Default - { - +INVENTORY.UNCLEARABLE; - +INVENTORY.UNDROPPABLE; - +INVENTORY.UNTOSSABLE; - } -} - // lucky collar // made by Ashley Knox, given to you and Ibuki by Saya Class SayaCollar : SWWMArmor diff --git a/zscript/player/swwm_player_think.zsc b/zscript/player/swwm_player_think.zsc index fbeab6ad0..eac81e295 100644 --- a/zscript/player/swwm_player_think.zsc +++ b/zscript/player/swwm_player_think.zsc @@ -290,6 +290,7 @@ extend Class Demolitionist deadtimer++; if ( (deadtimer == 60) && (player == players[consoleplayer]) ) A_StartSound("demolitionist/youdied",CHAN_DEMOVOICE,CHANF_OVERLAP|CHANF_UI); + if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler")); if ( multiplayer || level.AllowRespawn || sv_singleplayerrespawn || G_SkillPropertyInt(SKILLP_PlayerRespawn) ) { // standard behaviour, respawn normally @@ -308,7 +309,7 @@ extend Class Demolitionist player.playerstate = PST_ENTER; if ( special1 > 2 ) special1 = 0; } - else if ( (player.cmd.buttons&BT_ATTACK) && (deadtimer > 120) && !FindInventory("SWWMReviveDisabler") && swwm_revive ) + else if ( (player.cmd.buttons&BT_ATTACK) && (deadtimer > 120) && (!hnd || !hnd.gdat.disablerevive) && swwm_revive ) { // reboot (if possible) if ( !FindInventory("ReviveCooldown") && (((swwm_revivecooldown >= 0) && (G_SkillPropertyInt(SKILLP_ACSReturn) < 4)) || !hasrevived) ) diff --git a/zscript/swwm_thinkers.zsc b/zscript/swwm_thinkers.zsc index 6d2cc44b1..ed4b812eb 100644 --- a/zscript/swwm_thinkers.zsc +++ b/zscript/swwm_thinkers.zsc @@ -264,6 +264,9 @@ Class SWWMGlobals : SWWMStaticThinker // for oneliners Array lastlines; + // toggleable mapping stuff + bool disablestore, disablerevive; + static play SWWMGlobals Get() { let ti = ThinkerIterator.Create("SWWMGlobals",STAT_STATIC);