diff --git a/src/g_inventory/a_armor.cpp b/src/g_inventory/a_armor.cpp index e19b50259..8bb32c921 100644 --- a/src/g_inventory/a_armor.cpp +++ b/src/g_inventory/a_armor.cpp @@ -229,6 +229,8 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage) // This code is taken and adapted from APowerProtection::ModifyDamage(). // The differences include not using a default value, and of course the way // the damage factor info is obtained. + + // ApplyDamageFactors(ArmorType, damageType, damage, damage); DmgFactors *df = PClass::FindActor(ArmorType)->DamageFactors; if (df != NULL) { diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 2ab8ca51a..51aedd809 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -829,77 +829,6 @@ bool APowerInvisibility::HandlePickup (AInventory *item) return Super::HandlePickup (item); } -// Ironfeet Powerup ---------------------------------------------------------- - -IMPLEMENT_CLASS(APowerIronFeet, false, false) - -//=========================================================================== -// -// APowerIronFeet :: AbsorbDamage -// -//=========================================================================== - -void APowerIronFeet::AbsorbDamage (int damage, FName damageType, int &newdamage) -{ - if (damageType == NAME_Drowning) - { - newdamage = 0; - } -} - -//=========================================================================== -// -// APowerIronFeet :: DoEffect -// -//=========================================================================== - -void APowerIronFeet::DoEffect () -{ - if (Owner->player != NULL) - { - Owner->player->mo->ResetAirSupply (); - } -} - - -// Strife Environment Suit Powerup ------------------------------------------- - -IMPLEMENT_CLASS(APowerMask, false, false) - -//=========================================================================== -// -// APowerMask :: AbsorbDamage -// -//=========================================================================== - -void APowerMask::AbsorbDamage (int damage, FName damageType, int &newdamage) -{ - if (damageType == NAME_Fire) - { - newdamage = 0; - } - else - { - Super::AbsorbDamage (damage, damageType, newdamage); - } -} - -//=========================================================================== -// -// APowerMask :: DoEffect -// -//=========================================================================== - -void APowerMask::DoEffect () -{ - Super::DoEffect (); - if (!(level.time & 0x3f)) - { - S_Sound (Owner, CHAN_AUTO, "misc/mask", 1, ATTN_STATIC); - } -} - - // Speed Powerup ------------------------------------------------------------- IMPLEMENT_CLASS(APowerSpeed, false, false) diff --git a/src/g_inventory/a_artifacts.h b/src/g_inventory/a_artifacts.h index d72ed42c3..5149bd2d9 100644 --- a/src/g_inventory/a_artifacts.h +++ b/src/g_inventory/a_artifacts.h @@ -89,22 +89,6 @@ protected: virtual int AlterWeaponSprite (visstyle_t *vis) override; }; -class APowerIronFeet : public APowerup -{ - DECLARE_CLASS (APowerIronFeet, APowerup) -public: - virtual void AbsorbDamage (int damage, FName damageType, int &newdamage) override; - virtual void DoEffect () override; -}; - -class APowerMask : public APowerIronFeet -{ - DECLARE_CLASS (APowerMask, APowerIronFeet) -public: - virtual void AbsorbDamage (int damage, FName damageType, int &newdamage) override; - virtual void DoEffect () override; -}; - class APowerSpeed : public APowerup { DECLARE_CLASS (APowerSpeed, APowerup) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 0909da70f..e5a1178d8 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -394,9 +394,10 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) // Allow subclasses. Better would be to implement it as armor and let that reduce // the damage as part of the normal damage procedure. Unfortunately, I don't have // different damage types yet, so that's not happening for now. + auto pitype = PClass::FindActor(NAME_PowerIronFeet); for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory) { - if (ironfeet->IsKindOf (RUNTIME_CLASS(APowerIronFeet))) + if (ironfeet->IsKindOf(pitype)) break; } @@ -578,9 +579,10 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType) if (Terrains[floorType].AllowProtection) { + auto pitype = PClass::FindActor(NAME_PowerIronFeet); for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory) { - if (ironfeet->IsKindOf (RUNTIME_CLASS(APowerIronFeet))) + if (ironfeet->IsKindOf (pitype)) break; } } diff --git a/src/serializer.cpp b/src/serializer.cpp index 5154b0700..6d7a6ef7c 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -495,7 +495,7 @@ void FSerializer::Close() { // we must explicitly delete all thinkers in the array which did not get linked into the thinker lists. // Otherwise these objects may survive a level deletion and point to incorrect data. - for (auto &obj : r->mDObjects) + for (auto obj : r->mDObjects) { auto think = dyn_cast(obj); if (think != nullptr) diff --git a/wadsrc/static/zscript/inventory/powerups.txt b/wadsrc/static/zscript/inventory/powerups.txt index db838b904..8a3e81d2e 100644 --- a/wadsrc/static/zscript/inventory/powerups.txt +++ b/wadsrc/static/zscript/inventory/powerups.txt @@ -84,16 +84,45 @@ class PowerShadow : PowerInvisibility } } -class PowerIronFeet : Powerup native +//=========================================================================== +// +// IronFeet +// +//=========================================================================== + +class PowerIronFeet : Powerup { Default { Powerup.Duration -60; Powerup.Color "00 ff 00", 0.125; } + + override void AbsorbDamage (int damage, Name damageType, out int newdamage) + { + if (damageType == 'Drowning') + { + newdamage = 0; + } + } + + override void DoEffect () + { + if (Owner.player != NULL) + { + Owner.player.mo.ResetAirSupply (); + } + } + } -class PowerMask : PowerIronFeet native +//=========================================================================== +// +// Mask +// +//=========================================================================== + +class PowerMask : PowerIronFeet { Default { @@ -102,6 +131,24 @@ class PowerMask : PowerIronFeet native +INVENTORY.HUBPOWER Inventory.Icon "I_MASK"; } + + override void AbsorbDamage (int damage, Name damageType, out int newdamage) + { + if (damageType == 'Fire' || damageType == 'Drowning') + { + newdamage = 0; + } + } + + override void DoEffect () + { + Super.DoEffect (); + if (!(level.time & 0x3f)) + { + Owner.A_PlaySound ("misc/mask", CHAN_AUTO); + } + } + } //===========================================================================