- Adjusted AlterWeaponSprite so that it properly handles multiple

invisibility powerups at the same time.


SVN r450 (trunk)
This commit is contained in:
Christoph Oelckers 2007-01-14 08:58:07 +00:00
parent 14ecb21dee
commit 554573bcb3
6 changed files with 90 additions and 13 deletions

View file

@ -1,3 +1,7 @@
January 13, 2007 (Changes by Graf Zahl)
- Adjusted AlterWeaponSprite so that it properly handles multiple
invisibility powerups at the same time.
January 13, 2007 January 13, 2007
- Integrated the fatal error display into the text logger. - Integrated the fatal error display into the text logger.
Next: Figure out how to do all this fancy new startup window stuff with GTK+ Next: Figure out how to do all this fancy new startup window stuff with GTK+

View file

@ -454,8 +454,9 @@ void APowerInvulnerable::EndEffect ()
// //
//=========================================================================== //===========================================================================
void APowerInvulnerable::AlterWeaponSprite (vissprite_t *vis) int APowerInvulnerable::AlterWeaponSprite (vissprite_t *vis)
{ {
int changed = Inventory == NULL? false : Inventory->AlterWeaponSprite(vis);
if (Owner != NULL) if (Owner != NULL)
{ {
if (mode == NAME_Ghost && !(Owner->flags & MF_SHADOW)) if (mode == NAME_Ghost && !(Owner->flags & MF_SHADOW))
@ -464,6 +465,7 @@ void APowerInvulnerable::AlterWeaponSprite (vissprite_t *vis)
if (wp_alpha != FIXED_MAX) vis->alpha = wp_alpha; if (wp_alpha != FIXED_MAX) vis->alpha = wp_alpha;
} }
} }
return changed;
} }
// Strength (aka Berserk) Powerup -------------------------------------------- // Strength (aka Berserk) Powerup --------------------------------------------
@ -574,6 +576,19 @@ void APowerInvisibility::EndEffect ()
Owner->flags3 &= ~MF3_GHOST; Owner->flags3 &= ~MF3_GHOST;
Owner->RenderStyle = STYLE_Normal; Owner->RenderStyle = STYLE_Normal;
Owner->alpha = OPAQUE; Owner->alpha = OPAQUE;
// Check whether there are other invisibility items and refresh their effect.
// If this isn't done there will be one incorrectly drawn frame when this
// item expires.
AInventory *item = Owner->Inventory;
while (item != NULL)
{
if (item->IsKindOf(RUNTIME_CLASS(APowerInvisibility)) && item != this)
{
static_cast<APowerInvisibility*>(item)->InitEffect();
}
item = item->Inventory;
}
} }
} }
@ -583,18 +598,23 @@ void APowerInvisibility::EndEffect ()
// //
//=========================================================================== //===========================================================================
void APowerInvisibility::AlterWeaponSprite (vissprite_t *vis) int APowerInvisibility::AlterWeaponSprite (vissprite_t *vis)
{ {
if (Inventory != NULL) int changed = Inventory == NULL? false : Inventory->AlterWeaponSprite(vis);
{
Inventory->AlterWeaponSprite (vis);
}
// Blink if the powerup is wearing off // Blink if the powerup is wearing off
if (EffectTics < 4*32 && !(EffectTics & 8)) if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8))
{ {
vis->RenderStyle = STYLE_Normal; vis->RenderStyle = STYLE_Normal;
return 1;
} }
else if (changed == 1)
{
// something else set the weapon sprite back to opaque but this item is still active.
vis->alpha = FRACUNIT/5;
vis->RenderStyle = STYLE_OptFuzzy;
}
return -1; // This item is valid so another one shouldn't reset the translucency
} }
// Ghost Powerup (Heretic's version of invisibility) ------------------------- // Ghost Powerup (Heretic's version of invisibility) -------------------------
@ -617,6 +637,31 @@ void APowerGhost::InitEffect ()
Owner->RenderStyle = STYLE_Translucent; Owner->RenderStyle = STYLE_Translucent;
} }
//===========================================================================
//
// APowerGhost :: AlterWeaponSprite
//
//===========================================================================
int APowerGhost::AlterWeaponSprite (vissprite_t *vis)
{
int changed = Inventory == NULL? false : Inventory->AlterWeaponSprite(vis);
// Blink if the powerup is wearing off
if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8))
{
vis->RenderStyle = STYLE_Normal;
return 1;
}
else if (changed == 1)
{
// something else set the weapon sprite back to opaque but this item is still active.
vis->alpha = HR_SHADOW;
vis->RenderStyle = STYLE_Translucent;
}
return -1; // This item is valid so another one shouldn't reset the translucency
}
// Shadow Powerup (Strife's version of invisibility) ------------------------- // Shadow Powerup (Strife's version of invisibility) -------------------------
IMPLEMENT_STATELESS_ACTOR (APowerShadow, Any, -1, 0) IMPLEMENT_STATELESS_ACTOR (APowerShadow, Any, -1, 0)
@ -637,6 +682,31 @@ void APowerShadow::InitEffect ()
Owner->RenderStyle = STYLE_Translucent; Owner->RenderStyle = STYLE_Translucent;
} }
//===========================================================================
//
// APowerShadow :: AlterWeaponSprite
//
//===========================================================================
int APowerShadow::AlterWeaponSprite (vissprite_t *vis)
{
int changed = Inventory == NULL? false : Inventory->AlterWeaponSprite(vis);
// Blink if the powerup is wearing off
if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8))
{
vis->RenderStyle = STYLE_Normal;
return 1;
}
else if (changed == 1)
{
// something else set the weapon sprite back to opaque but this item is still active.
vis->alpha = TRANSLUC25;
vis->RenderStyle = STYLE_Translucent;
}
return -1; // This item is valid so another one shouldn't reset the translucency
}
// Ironfeet Powerup ---------------------------------------------------------- // Ironfeet Powerup ----------------------------------------------------------
IMPLEMENT_STATELESS_ACTOR (APowerIronFeet, Any, -1, 0) IMPLEMENT_STATELESS_ACTOR (APowerIronFeet, Any, -1, 0)

View file

@ -69,7 +69,7 @@ protected:
void InitEffect (); void InitEffect ();
void DoEffect (); void DoEffect ();
void EndEffect (); void EndEffect ();
void AlterWeaponSprite (vissprite_t *vis); int AlterWeaponSprite (vissprite_t *vis);
}; };
class APowerStrength : public APowerup class APowerStrength : public APowerup
@ -90,7 +90,7 @@ protected:
void InitEffect (); void InitEffect ();
void DoEffect (); void DoEffect ();
void EndEffect (); void EndEffect ();
void AlterWeaponSprite (vissprite_t *vis); int AlterWeaponSprite (vissprite_t *vis);
}; };
class APowerGhost : public APowerInvisibility class APowerGhost : public APowerInvisibility
@ -98,6 +98,7 @@ class APowerGhost : public APowerInvisibility
DECLARE_STATELESS_ACTOR (APowerGhost, APowerInvisibility) DECLARE_STATELESS_ACTOR (APowerGhost, APowerInvisibility)
protected: protected:
void InitEffect (); void InitEffect ();
int AlterWeaponSprite (vissprite_t *vis);
}; };
class APowerShadow : public APowerInvisibility class APowerShadow : public APowerInvisibility
@ -105,6 +106,7 @@ class APowerShadow : public APowerInvisibility
DECLARE_STATELESS_ACTOR (APowerShadow, APowerInvisibility) DECLARE_STATELESS_ACTOR (APowerShadow, APowerInvisibility)
protected: protected:
void InitEffect (); void InitEffect ();
int AlterWeaponSprite (vissprite_t *vis);
}; };
class APowerIronFeet : public APowerup class APowerIronFeet : public APowerup

View file

@ -768,12 +768,13 @@ void AInventory::AbsorbDamage (int damage, FName damageType, int &newdamage)
// //
//=========================================================================== //===========================================================================
void AInventory::AlterWeaponSprite (vissprite_t *vis) int AInventory::AlterWeaponSprite (vissprite_t *vis)
{ {
if (Inventory != NULL) if (Inventory != NULL)
{ {
Inventory->AlterWeaponSprite (vis); return Inventory->AlterWeaponSprite (vis);
} }
return 0;
} }
//=========================================================================== //===========================================================================

View file

@ -151,7 +151,7 @@ public:
virtual void OwnerDied (); virtual void OwnerDied ();
virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); virtual void AbsorbDamage (int damage, FName damageType, int &newdamage);
virtual void AlterWeaponSprite (vissprite_t *vis); virtual int AlterWeaponSprite (vissprite_t *vis);
virtual PalEntry GetBlend (); virtual PalEntry GetBlend ();

View file

@ -2619,7 +2619,7 @@ static void ActorMass (AActor *defaults, Baggage &bag)
static void ActorXScale (AActor *defaults, Baggage &bag) static void ActorXScale (AActor *defaults, Baggage &bag)
{ {
SC_MustGetFloat(); SC_MustGetFloat();
defaults->scaleY = FLOAT2FIXED(sc_Float); defaults->scaleX = FLOAT2FIXED(sc_Float);
} }
//========================================================================== //==========================================================================