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 a2855dfc9a
9 changed files with 31 additions and 32 deletions

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

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

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

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

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

@ -264,6 +264,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);