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 e9d5c8098..19b94e10b 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r748 \cu(Sat 18 Feb 12:00:23 CET 2023)\c-"; -SWWM_SHORTVER="\cw1.3pre r748 \cu(2023-02-18 12:00:23)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r749 \cu(Sat 18 Feb 12:00:36 CET 2023)\c-"; +SWWM_SHORTVER="\cw1.3pre r749 \cu(2023-02-18 12:00:36)\c-"; diff --git a/zscript/handler/swwm_handler.zsc b/zscript/handler/swwm_handler.zsc index ee879eaba..2b94d1a43 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 4d81afc80..8bae4a55b 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -558,7 +558,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 772a6d961..be9d508e5 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 a7d3e1de9..a13b70e0d 100644 --- a/zscript/player/swwm_player.zsc +++ b/zscript/player/swwm_player.zsc @@ -122,6 +122,8 @@ Class Demolitionist : PlayerPawn double bobtime, oldbobtime, oldbob; + SWWMHandler hnd; + Default { Tag "$T_DEMOLITIONIST"; @@ -358,7 +360,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) ) @@ -613,7 +615,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; @@ -765,7 +767,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 dbb5fbdb0..2e4d63729 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 a939a4d6a..c75186a8f 100644 --- a/zscript/swwm_thinkers.zsc +++ b/zscript/swwm_thinkers.zsc @@ -316,6 +316,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);