- 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:
Christoph Oelckers 2017-01-16 22:27:49 +01:00
parent c5f100a61d
commit 6990a46daf
6 changed files with 54 additions and 81 deletions

View File

@ -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 -------------------------------------------------------------
IMPLEMENT_CLASS(APowerSpeed, false, false)

View File

@ -66,17 +66,6 @@ protected:
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
{
DECLARE_CLASS (APowerSpeed, APowerup)

View File

@ -297,8 +297,8 @@ static void DrawHealth(player_t *CPlayer, int x, int y)
CR_BLUE;
const bool haveBerserk = hud_berserk_health
&& NULL != berserkpic
&& NULL != CPlayer->mo->FindInventory< APowerStrength >();
&& nullptr != berserkpic
&& nullptr != CPlayer->mo->FindInventory(PClass::FindActor(NAME_PowerStrength));
DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17);
DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17);

View File

@ -2127,6 +2127,7 @@ CCMD (soundlist)
{
Printf ("%3d. %s **not present**\n", i, sfx->name.GetChars());
}
Printf(" PitchMask = %d\n", sfx->PitchMask);
}
}

View File

@ -5921,8 +5921,7 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
{
Object->ValueType = TypeColorStruct;
}
else if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
{
auto ptype = static_cast<PPointer *>(Object->ValueType)->PointedType;
if (ptype->IsKindOf(RUNTIME_CLASS(PStruct)))

View File

@ -58,7 +58,13 @@ class PowerInvulnerable : Powerup native
}
}
class PowerStrength : Powerup native
//===========================================================================
//
// Strength
//
//===========================================================================
class PowerStrength : Powerup
{
Default
{
@ -66,6 +72,49 @@ class PowerStrength : Powerup native
Powerup.Color "ff 00 00", 0.5;
+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;
}
}
//===========================================================================