Key refactor. They act as pure "item givers" now.
This commit is contained in:
parent
b19c9aa2d8
commit
312c433ed3
5 changed files with 28 additions and 67 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r127 \cu(Sun 23 Jan 20:48:58 CET 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.2pre r127 \cu(2022-01-23 20:48:58)\c-";
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r128 \cu(Sun 23 Jan 20:49:20 CET 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.2pre r128 \cu(2022-01-23 20:49:20)\c-";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
extend Class SWWMHandler
|
||||
{
|
||||
bool nugflip; // h/a nugget flip-flop spawn counter
|
||||
bool equinoxhack; // hackaround for UseInventory
|
||||
|
||||
private Class<Actor> GetDRLAReplacee( Class<Actor> a )
|
||||
{
|
||||
|
|
@ -591,7 +592,7 @@ extend Class SWWMHandler
|
|||
}
|
||||
else if ( (e.Replacee is 'RedCard') && !(e.Replacee is 'ChexRedCard') )
|
||||
{
|
||||
if ( level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043" )
|
||||
if ( !equinoxhack && (level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043") )
|
||||
{
|
||||
if ( profiling ) checkreplacement_ms += MSTime()-curms;
|
||||
return; // don't replace red key in Equinox MAP13
|
||||
|
|
|
|||
|
|
@ -2260,21 +2260,6 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
if ( !k || !k.Icon.IsValid() ) continue;
|
||||
klist.Push(k);
|
||||
}
|
||||
// because we can't call GetReplacement from ui, let's wrangle something real ugly here to clean up replaced keys
|
||||
for ( int i=0; i<klist.Size(); i++ )
|
||||
{
|
||||
if ( !(klist[i] is 'SWWMKey') ) continue;
|
||||
// remove the key this replaces
|
||||
Class<Key> pc = klist[i].Species;
|
||||
if ( !pc ) continue;
|
||||
for ( int j=0; j<klist.Size(); j++ )
|
||||
{
|
||||
if ( klist[j].GetClass() != pc ) continue;
|
||||
klist.Delete(j);
|
||||
j--;
|
||||
if ( i >= j ) i--;
|
||||
}
|
||||
}
|
||||
int maxcolc = (gameinfo.gametype&GAME_DOOMCHEX)?6:4;
|
||||
for ( int i=0; i<klist.Size(); i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,49 +10,30 @@ Class SWWMKey : Key abstract
|
|||
|
||||
Property GestureWeapon : gesture;
|
||||
|
||||
override void DoEffect()
|
||||
override bool TryPickup( in out Actor toucher )
|
||||
{
|
||||
Super.DoEffect();
|
||||
if ( Icon.IsNull() )
|
||||
{
|
||||
// fetch icon from parent (if it exists)
|
||||
Class<Key> pc = Species;
|
||||
if ( !pc ) return;
|
||||
let p = GetDefaultByType(pc);
|
||||
Icon = p.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
override void AttachToOwner( Actor other )
|
||||
{
|
||||
Super.AttachToOwner(other);
|
||||
// also attach the vanilla key that we replace, mainly for script compatibility
|
||||
// attach the vanilla key that we replace
|
||||
let rt = toucher;
|
||||
if ( toucher.player ) rt = toucher.player.mo;
|
||||
Class<Key> pc = Species;
|
||||
if ( pc )
|
||||
if ( pc && !rt.FindInventory(pc) )
|
||||
{
|
||||
if ( rt.player && !deathmatch && !propagated && CVar.GetCVar('swwm_collectanimkey',rt.player).GetBool() )
|
||||
SWWMGesture.SetSpecialGesture(rt.player.mo,gesture);
|
||||
let p = Inventory(Spawn(pc));
|
||||
if ( Owner is 'Demolitionist' )
|
||||
Demolitionist(Owner).key_reentrant = true; // avoid infinite loop
|
||||
p.AttachToOwner(Owner);
|
||||
if ( Owner is 'Demolitionist' )
|
||||
Demolitionist(Owner).key_reentrant = false;
|
||||
SWWMHandler.KeyTagFix(p);
|
||||
p.AttachToOwner(rt);
|
||||
}
|
||||
}
|
||||
|
||||
override bool Use( bool pickup )
|
||||
{
|
||||
if ( Owner.player && !propagated && !deathmatch && (!pickup || CVar.GetCVar('swwm_collectanimkey',Owner.player).GetBool()) )
|
||||
SWWMGesture.SetSpecialGesture(Owner.player.mo,gesture);
|
||||
// clean up the flag
|
||||
propagated = false;
|
||||
return false;
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
|
||||
Default
|
||||
{
|
||||
+NOTDMATCH;
|
||||
+FLOATBOB;
|
||||
+INVENTORY.AUTOACTIVATE;
|
||||
FloatBobStrength 0.25;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2751,24 +2751,6 @@ Class Demolitionist : PlayerPawn
|
|||
}
|
||||
override void AddInventory( Inventory item )
|
||||
{
|
||||
// hackaround for replaced keys
|
||||
if ( (item is 'Key') && !key_reentrant )
|
||||
{
|
||||
let rep = (Class<Inventory>)(GetReplacement(item.GetClass()));
|
||||
if ( rep && (item.GetClass() != rep) )
|
||||
{
|
||||
// also add the new key
|
||||
Actor whom = player?player.mo:PlayerPawn(self);
|
||||
if ( !whom.FindInventory(rep) )
|
||||
{
|
||||
let nk = Inventory(Spawn(rep));
|
||||
nk.AttachToOwner(whom);
|
||||
nk.Use(true);
|
||||
}
|
||||
Super.AddInventory(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Super.AddInventory(item);
|
||||
if ( !player ) return;
|
||||
String cn = item.GetClassName();
|
||||
|
|
@ -2801,7 +2783,6 @@ Class Demolitionist : PlayerPawn
|
|||
if ( players[i].mo is 'Demolitionist' ) Demolitionist(players[i].mo).key_reentrant = true;
|
||||
let tkey = Inventory(Spawn(item.GetClass()));
|
||||
SWWMHandler.KeyTagFix(tkey);
|
||||
if ( tkey is 'SWWMKey' ) SWWMKey(tkey).propagated = true; // no anim
|
||||
if ( !tkey.CallTryPickup(players[i].mo) ) tkey.Destroy();
|
||||
if ( players[i].mo is 'Demolitionist' ) Demolitionist(players[i].mo).key_reentrant = false;
|
||||
}
|
||||
|
|
@ -2820,6 +2801,19 @@ Class Demolitionist : PlayerPawn
|
|||
{
|
||||
let itemtype = item.GetClass();
|
||||
if ( (player.cheats&CF_TOTALLYFROZEN) || isFrozen() ) return false;
|
||||
// do the key gesture
|
||||
if ( item is 'Key' )
|
||||
{
|
||||
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
||||
if ( hnd ) hnd.equinoxhack = true;
|
||||
let rep = (Class<SWWMKey>)(GetReplacement(item.GetClass()));
|
||||
if ( hnd ) hnd.equinoxhack = false;
|
||||
if ( rep )
|
||||
{
|
||||
SWWMGesture.SetSpecialGesture(self,GetDefaultByType(rep).gesture);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( !Actor.UseInventory(item) )
|
||||
{
|
||||
if ( player == players[consoleplayer] )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue