mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-31 05:40:44 +00:00
- scriptified PowerStrength.
This revealed an interesting bug: When the berserk fadout formula was changed in 2005 the result was essentially broken, resulting in values around 7000 - it only worked by happenstance because the lower 8 bits of the resulting values just happened to work to some degree and never overflowed. But the resulting fade was far too weak and a slightly different handling of the color composition code for the VM made it break down entirely. This restores the pre-2005 formula but weakened intensity which now comes a lot closer to how it is supposed to look.
This commit is contained in:
parent
c5f100a61d
commit
6990a46daf
6 changed files with 54 additions and 81 deletions
|
@ -540,71 +540,6 @@ void APowerInvulnerable::EndEffect ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strength (aka Berserk) Powerup --------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(APowerStrength, false, false)
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// APowerStrength :: HandlePickup
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
bool APowerStrength::HandlePickup (AInventory *item)
|
|
||||||
{
|
|
||||||
if (item->GetClass() == GetClass())
|
|
||||||
{ // Setting EffectTics to 0 will force Powerup's HandlePickup()
|
|
||||||
// method to reset the tic count so you get the red flash again.
|
|
||||||
EffectTics = 0;
|
|
||||||
}
|
|
||||||
return Super::HandlePickup (item);
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// APowerStrength :: InitEffect
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void APowerStrength::InitEffect ()
|
|
||||||
{
|
|
||||||
Super::InitEffect();
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// APowerStrength :: DoEffect
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void APowerStrength::Tick ()
|
|
||||||
{
|
|
||||||
// Strength counts up to diminish the fade.
|
|
||||||
assert(EffectTics < (INT_MAX - 1)); // I can't see a game lasting nearly two years, but...
|
|
||||||
EffectTics += 2;
|
|
||||||
Super::Tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// APowerStrength :: GetBlend
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
PalEntry APowerStrength::GetBlend ()
|
|
||||||
{
|
|
||||||
// slowly fade the berserk out
|
|
||||||
int cnt = 12 - (EffectTics >> 6);
|
|
||||||
|
|
||||||
if (cnt > 0)
|
|
||||||
{
|
|
||||||
cnt = (cnt + 7) >> 3;
|
|
||||||
return PalEntry (BlendColor.a*cnt*255/9,
|
|
||||||
BlendColor.r, BlendColor.g, BlendColor.b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Speed Powerup -------------------------------------------------------------
|
// Speed Powerup -------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CLASS(APowerSpeed, false, false)
|
IMPLEMENT_CLASS(APowerSpeed, false, false)
|
||||||
|
|
|
@ -66,17 +66,6 @@ protected:
|
||||||
virtual void EndEffect () override;
|
virtual void EndEffect () override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class APowerStrength : public APowerup
|
|
||||||
{
|
|
||||||
DECLARE_CLASS (APowerStrength, APowerup)
|
|
||||||
public:
|
|
||||||
PalEntry GetBlend ();
|
|
||||||
protected:
|
|
||||||
virtual void InitEffect () override;
|
|
||||||
virtual void Tick () override;
|
|
||||||
virtual bool HandlePickup (AInventory *item) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class APowerSpeed : public APowerup
|
class APowerSpeed : public APowerup
|
||||||
{
|
{
|
||||||
DECLARE_CLASS (APowerSpeed, APowerup)
|
DECLARE_CLASS (APowerSpeed, APowerup)
|
||||||
|
|
|
@ -297,8 +297,8 @@ static void DrawHealth(player_t *CPlayer, int x, int y)
|
||||||
CR_BLUE;
|
CR_BLUE;
|
||||||
|
|
||||||
const bool haveBerserk = hud_berserk_health
|
const bool haveBerserk = hud_berserk_health
|
||||||
&& NULL != berserkpic
|
&& nullptr != berserkpic
|
||||||
&& NULL != CPlayer->mo->FindInventory< APowerStrength >();
|
&& nullptr != CPlayer->mo->FindInventory(PClass::FindActor(NAME_PowerStrength));
|
||||||
|
|
||||||
DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17);
|
DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17);
|
||||||
DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17);
|
DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17);
|
||||||
|
|
|
@ -2127,6 +2127,7 @@ CCMD (soundlist)
|
||||||
{
|
{
|
||||||
Printf ("%3d. %s **not present**\n", i, sfx->name.GetChars());
|
Printf ("%3d. %s **not present**\n", i, sfx->name.GetChars());
|
||||||
}
|
}
|
||||||
|
Printf(" PitchMask = %d\n", sfx->PitchMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5921,8 +5921,7 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
|
||||||
{
|
{
|
||||||
Object->ValueType = TypeColorStruct;
|
Object->ValueType = TypeColorStruct;
|
||||||
}
|
}
|
||||||
|
if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
||||||
else if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
|
||||||
{
|
{
|
||||||
auto ptype = static_cast<PPointer *>(Object->ValueType)->PointedType;
|
auto ptype = static_cast<PPointer *>(Object->ValueType)->PointedType;
|
||||||
if (ptype->IsKindOf(RUNTIME_CLASS(PStruct)))
|
if (ptype->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||||
|
|
|
@ -58,7 +58,13 @@ class PowerInvulnerable : Powerup native
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PowerStrength : Powerup native
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Strength
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
class PowerStrength : Powerup
|
||||||
{
|
{
|
||||||
Default
|
Default
|
||||||
{
|
{
|
||||||
|
@ -66,6 +72,49 @@ class PowerStrength : Powerup native
|
||||||
Powerup.Color "ff 00 00", 0.5;
|
Powerup.Color "ff 00 00", 0.5;
|
||||||
+INVENTORY.HUBPOWER
|
+INVENTORY.HUBPOWER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override bool HandlePickup (Inventory item)
|
||||||
|
{
|
||||||
|
if (item.GetClass() == GetClass())
|
||||||
|
{ // Setting EffectTics to 0 will force Powerup's HandlePickup()
|
||||||
|
// method to reset the tic count so you get the red flash again.
|
||||||
|
EffectTics = 0;
|
||||||
|
}
|
||||||
|
return Super.HandlePickup (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// APowerStrength :: DoEffect
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
override void Tick ()
|
||||||
|
{
|
||||||
|
// Strength counts up to diminish the fade.
|
||||||
|
EffectTics += 2;
|
||||||
|
Super.Tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// APowerStrength :: GetBlend
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
override color GetBlend ()
|
||||||
|
{
|
||||||
|
// slowly fade the berserk out
|
||||||
|
int cnt = 128 - (EffectTics>>3);
|
||||||
|
|
||||||
|
if (cnt > 0)
|
||||||
|
{
|
||||||
|
return Color(BlendColor.a*cnt/256,
|
||||||
|
BlendColor.r, BlendColor.g, BlendColor.b);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
Loading…
Reference in a new issue