Workaround to preserve collectibles after death exits.

This commit is contained in:
Mari the Deer 2020-12-16 03:01:28 +01:00
commit f163ed3bef
4 changed files with 19 additions and 1 deletions

View file

@ -1,2 +1,2 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r683 \cu(Wed 16 Dec 00:44:30 CET 2020)";
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r684 \cu(Wed 16 Dec 03:01:28 CET 2020)";

View file

@ -993,6 +993,15 @@ Class SWWMHandler : EventHandler
// reset score (optional) if inventory should be cleared
if ( swwm_resetscore && level.removeitems && !e.IsReturn )
c.credits = c.hcredits = 0;
// re-add any missing collectibles after a death exit (yes, this happens)
for ( int i=0; i<s.ownedcollectibles.Size(); i++ )
{
if ( p.mo.FindInventory(s.ownedcollectibles[i]) ) continue;
let c = SWWMCollectible(Actor.Spawn(s.ownedcollectibles[i],p.mo.pos));
c.propagated = true;
if ( !c.CallTryPickup(p.mo) )
c.Destroy();
}
}
override void PlayerRespawned( PlayerEvent e )

View file

@ -1844,6 +1844,13 @@ Class Demolitionist : PlayerPawn
if ( players[i].mo is 'Demolitionist' ) Demolitionist(players[i].mo).key_reentrant = false;
}
}
// add collectible to stats
if ( (item is 'SWWMCollectible') && mystats )
{
let cls = item.GetClass();
if ( (mystats.ownedcollectibles.Size() > 0) && (mystats.ownedcollectibles.Find(cls) < mystats.ownedcollectibles.Size()) ) return;
mystats.ownedcollectibles.Push(cls);
}
}
override bool UseInventory( Inventory item )
{

View file

@ -42,6 +42,8 @@ Class SWWMStats : Thinker
// [Strife] preserve previous mission logs
String oldlogtext;
Array<String> questbacklog;
// hackaround for stuff getting lost
Array<Class<SWWMCollectible> > ownedcollectibles;
bool GotWeapon( Class<Weapon> which )
{