Don't use inventory tokens for mapper-toggleable store/revive. Tokens are icky.

This commit is contained in:
Mari the Deer 2023-02-18 11:54:30 +01:00
commit bb3cd9a3ec
9 changed files with 31 additions and 32 deletions

View file

@ -1,11 +1,11 @@
# Notes for mappers
### Tokens
### Toggling features
- **Disabling the store:**<br/>Give the player `"SWWMStoreDisabler"` item on map load.
- **Disabling revives:**<br/>Give the player `"SWWMReviveDisabler"` item on map load.
- **Store:**<br/>`CallACS("SWWMHandler","ToggleStore",#)`<br/>Passing **0** disables the store, any other number will enable it again.
- **Reviving:**<br/>`CallACS("SWWMHandler","ToggleRevive",#)`<br/>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

View file

@ -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-";

View file

@ -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

View file

@ -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"));

View file

@ -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()

View file

@ -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);
}

View file

@ -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

View file

@ -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) )

View file

@ -316,6 +316,9 @@ Class SWWMGlobals : SWWMStaticThinker
// for oneliners
Array<OnelinerHistory> lastlines;
// toggleable mapping stuff
bool disablestore, disablerevive;
static play SWWMGlobals Get()
{
let ti = ThinkerIterator.Create("SWWMGlobals",STAT_STATIC);