This commit is contained in:
commit
2d1a5e6b36
16 changed files with 315 additions and 269 deletions
|
|
@ -1609,140 +1609,6 @@ void APowerTimeFreezer::EndEffect()
|
|||
}
|
||||
}
|
||||
|
||||
// Damage powerup ------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerDamage, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerDamage :: InitEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerDamage::InitEffect( )
|
||||
{
|
||||
Super::InitEffect();
|
||||
|
||||
// Use sound channel 5 to avoid interference with other actions.
|
||||
if (Owner != NULL) S_Sound(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerDamage :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerDamage::EndEffect( )
|
||||
{
|
||||
Super::EndEffect();
|
||||
// Use sound channel 5 to avoid interference with other actions.
|
||||
if (Owner != NULL) S_Sound(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerDamage :: ModifyDamage
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bool passive)
|
||||
{
|
||||
if (!passive && damage > 0)
|
||||
{
|
||||
int newdam;
|
||||
DmgFactors *df = GetClass()->DamageFactors;
|
||||
if (df != NULL && df->CountUsed() != 0)
|
||||
{
|
||||
newdam = MAX(1, df->Apply(damageType, damage));// don't allow zero damage as result of an underflow
|
||||
}
|
||||
else
|
||||
{
|
||||
newdam = damage * 4;
|
||||
}
|
||||
if (Owner != NULL && newdam > damage) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
|
||||
newdamage = damage = newdam;
|
||||
}
|
||||
if (Inventory != NULL) Inventory->ModifyDamage(damage, damageType, newdamage, passive);
|
||||
}
|
||||
|
||||
// Quarter damage powerup ------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerProtection, false, false)
|
||||
|
||||
#define PROTECTION_FLAGS3 (MF3_NORADIUSDMG | MF3_DONTMORPH | MF3_DONTSQUASH | MF3_DONTBLAST | MF3_NOTELEOTHER)
|
||||
#define PROTECTION_FLAGS5 (MF5_NOPAIN | MF5_DONTRIP)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerProtection :: InitEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerProtection::InitEffect( )
|
||||
{
|
||||
Super::InitEffect();
|
||||
|
||||
if (Owner != NULL)
|
||||
{
|
||||
S_Sound(Owner, CHAN_AUTO, SeeSound, 1.0f, ATTN_NONE);
|
||||
|
||||
// Transfer various protection flags if owner does not already have them.
|
||||
// If the owner already has the flag, clear it from the powerup.
|
||||
// If the powerup still has a flag set, add it to the owner.
|
||||
flags3 &= ~(Owner->flags3 & PROTECTION_FLAGS3);
|
||||
Owner->flags3 |= flags3 & PROTECTION_FLAGS3;
|
||||
|
||||
flags5 &= ~(Owner->flags5 & PROTECTION_FLAGS5);
|
||||
Owner->flags5 |= flags5 & PROTECTION_FLAGS5;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerProtection :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerProtection::EndEffect( )
|
||||
{
|
||||
Super::EndEffect();
|
||||
if (Owner != NULL)
|
||||
{
|
||||
S_Sound(Owner, CHAN_AUTO, DeathSound, 1.0f, ATTN_NONE);
|
||||
Owner->flags3 &= ~(flags3 & PROTECTION_FLAGS3);
|
||||
Owner->flags5 &= ~(flags5 & PROTECTION_FLAGS5);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerProtection :: AbsorbDamage
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage, bool passive)
|
||||
{
|
||||
if (passive && damage > 0)
|
||||
{
|
||||
int newdam;
|
||||
DmgFactors *df = GetClass()->DamageFactors;
|
||||
if (df != NULL && df->CountUsed() != 0)
|
||||
{
|
||||
newdam = MAX(0, df->Apply(damageType, damage));
|
||||
}
|
||||
else
|
||||
{
|
||||
newdam = damage / 4;
|
||||
}
|
||||
if (Owner != NULL && newdam < damage) S_Sound(Owner, CHAN_AUTO, ActiveSound, 1.0f, ATTN_NONE);
|
||||
newdamage = damage = newdam;
|
||||
}
|
||||
if (Inventory != NULL)
|
||||
{
|
||||
Inventory->ModifyDamage(damage, damageType, newdamage, passive);
|
||||
}
|
||||
}
|
||||
|
||||
// Morph powerup ------------------------------------------------------
|
||||
|
||||
|
|
@ -1760,7 +1626,6 @@ DEFINE_FIELD(APowerMorph, MorphFlash)
|
|||
DEFINE_FIELD(APowerMorph, UnMorphFlash)
|
||||
DEFINE_FIELD(APowerMorph, MorphStyle)
|
||||
DEFINE_FIELD(APowerMorph, MorphedPlayer)
|
||||
DEFINE_FIELD(APowerMorph, bInUndoMorph)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
@ -1778,77 +1643,3 @@ void APowerMorph::Serialize(FSerializer &arc)
|
|||
("morphedplayer", MorphedPlayer);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerMorph :: InitEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerMorph::InitEffect( )
|
||||
{
|
||||
Super::InitEffect();
|
||||
|
||||
if (Owner != nullptr && Owner->player != nullptr && PlayerClass != nullptr)
|
||||
{
|
||||
player_t *realplayer = Owner->player; // Remember the identity of the player
|
||||
if (P_MorphPlayer(realplayer, realplayer, PlayerClass, INT_MAX/*INDEFINITELY*/, MorphStyle, MorphFlash, UnMorphFlash))
|
||||
{
|
||||
Owner = realplayer->mo; // Replace the new owner in our owner; safe because we are not attached to anything yet
|
||||
ItemFlags |= IF_CREATECOPYMOVED; // Let the caller know the "real" owner has changed (to the morphed actor)
|
||||
MorphedPlayer = realplayer; // Store the player identity (morphing clears the unmorphed actor's "player" field)
|
||||
}
|
||||
else // morph failed - give the caller an opportunity to fail the pickup completely
|
||||
{
|
||||
ItemFlags |= IF_INITEFFECTFAILED; // Let the caller know that the activation failed (can fail the pickup if appropriate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerMorph :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerMorph::EndEffect( )
|
||||
{
|
||||
Super::EndEffect();
|
||||
|
||||
// Abort if owner already destroyed or unmorphed
|
||||
if (Owner == nullptr || MorphedPlayer == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Abort if owner is dead; their Die() method will
|
||||
// take care of any required unmorphing on death.
|
||||
if (MorphedPlayer->health <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Unmorph if possible
|
||||
if (!bInUndoMorph)
|
||||
{
|
||||
int savedMorphTics = MorphedPlayer->morphTics;
|
||||
P_UndoPlayerMorph (MorphedPlayer, MorphedPlayer, 0, !!(MorphedPlayer->MorphStyle & MORPH_UNDOALWAYS));
|
||||
|
||||
// Abort if unmorph failed; in that case,
|
||||
// set the usual retry timer and return.
|
||||
if (MorphedPlayer != NULL && MorphedPlayer->morphTics)
|
||||
{
|
||||
// Transfer retry timeout
|
||||
// to the powerup's timer.
|
||||
EffectTics = MorphedPlayer->morphTics;
|
||||
// Reload negative morph tics;
|
||||
// use actual value; it may
|
||||
// be in use for animation.
|
||||
MorphedPlayer->morphTics = savedMorphTics;
|
||||
// Try again some time later
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Unmorph suceeded
|
||||
MorphedPlayer = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue