- scriptified PowerIronFeet and PowerMask.

This commit is contained in:
Christoph Oelckers 2017-01-16 19:04:03 +01:00
parent 65b7e344f7
commit 616f954153
6 changed files with 56 additions and 92 deletions

View file

@ -229,6 +229,8 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
// This code is taken and adapted from APowerProtection::ModifyDamage(). // This code is taken and adapted from APowerProtection::ModifyDamage().
// The differences include not using a default value, and of course the way // The differences include not using a default value, and of course the way
// the damage factor info is obtained. // the damage factor info is obtained.
// ApplyDamageFactors(ArmorType, damageType, damage, damage);
DmgFactors *df = PClass::FindActor(ArmorType)->DamageFactors; DmgFactors *df = PClass::FindActor(ArmorType)->DamageFactors;
if (df != NULL) if (df != NULL)
{ {

View file

@ -829,77 +829,6 @@ bool APowerInvisibility::HandlePickup (AInventory *item)
return Super::HandlePickup (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 ------------------------------------------------------------- // Speed Powerup -------------------------------------------------------------
IMPLEMENT_CLASS(APowerSpeed, false, false) IMPLEMENT_CLASS(APowerSpeed, false, false)

View file

@ -89,22 +89,6 @@ protected:
virtual int AlterWeaponSprite (visstyle_t *vis) override; 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 class APowerSpeed : public APowerup
{ {
DECLARE_CLASS (APowerSpeed, APowerup) DECLARE_CLASS (APowerSpeed, APowerup)

View file

@ -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 // 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 // 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. // 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) for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory)
{ {
if (ironfeet->IsKindOf (RUNTIME_CLASS(APowerIronFeet))) if (ironfeet->IsKindOf(pitype))
break; break;
} }
@ -578,9 +579,10 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType)
if (Terrains[floorType].AllowProtection) if (Terrains[floorType].AllowProtection)
{ {
auto pitype = PClass::FindActor(NAME_PowerIronFeet);
for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory) for (ironfeet = player->mo->Inventory; ironfeet != NULL; ironfeet = ironfeet->Inventory)
{ {
if (ironfeet->IsKindOf (RUNTIME_CLASS(APowerIronFeet))) if (ironfeet->IsKindOf (pitype))
break; break;
} }
} }

View file

@ -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. // 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. // 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<DThinker>(obj); auto think = dyn_cast<DThinker>(obj);
if (think != nullptr) if (think != nullptr)

View file

@ -84,16 +84,45 @@ class PowerShadow : PowerInvisibility
} }
} }
class PowerIronFeet : Powerup native //===========================================================================
//
// IronFeet
//
//===========================================================================
class PowerIronFeet : Powerup
{ {
Default Default
{ {
Powerup.Duration -60; Powerup.Duration -60;
Powerup.Color "00 ff 00", 0.125; 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 Default
{ {
@ -102,6 +131,24 @@ class PowerMask : PowerIronFeet native
+INVENTORY.HUBPOWER +INVENTORY.HUBPOWER
Inventory.Icon "I_MASK"; 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);
}
}
} }
//=========================================================================== //===========================================================================