- scriptified APowerInvisibility.
- changed AlterWeaponSprite so that it doesn't expose renderer internals to the script code.
This commit is contained in:
parent
a5edd421bd
commit
d3ab691afb
12 changed files with 339 additions and 349 deletions
|
|
@ -540,25 +540,6 @@ void APowerInvulnerable::EndEffect ()
|
|||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvulnerable :: AlterWeaponSprite
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
int APowerInvulnerable::AlterWeaponSprite (visstyle_t *vis)
|
||||
{
|
||||
int changed = Inventory == NULL ? false : Inventory->AlterWeaponSprite(vis);
|
||||
if (Owner != NULL)
|
||||
{
|
||||
if (Mode == NAME_Ghost && !(Owner->flags & MF_SHADOW))
|
||||
{
|
||||
vis->Alpha = MIN<float>(0.25f + (float)Owner->Alpha*0.75f, 1.f);
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// Strength (aka Berserk) Powerup --------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerStrength, false, false)
|
||||
|
|
@ -624,211 +605,6 @@ PalEntry APowerStrength::GetBlend ()
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Invisibility Powerup ------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerInvisibility, false, false)
|
||||
|
||||
// Invisibility flag combos
|
||||
#define INVISIBILITY_FLAGS1 (MF_SHADOW)
|
||||
#define INVISIBILITY_FLAGS3 (MF3_GHOST)
|
||||
#define INVISIBILITY_FLAGS5 (MF5_CANTSEEK)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvisibility :: InitEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerInvisibility::InitEffect ()
|
||||
{
|
||||
Super::InitEffect();
|
||||
// This used to call CommonInit(), which used to contain all the code that's repeated every
|
||||
// tic, plus the following code that needs to happen once and only once.
|
||||
// The CommonInit() code has been moved to DoEffect(), so this now ends with a call to DoEffect(),
|
||||
// and DoEffect() no longer needs to call InitEffect(). CommonInit() has been removed for being redundant.
|
||||
if (Owner != NULL)
|
||||
{
|
||||
flags &= ~(Owner->flags & INVISIBILITY_FLAGS1);
|
||||
Owner->flags |= flags & INVISIBILITY_FLAGS1;
|
||||
flags3 &= ~(Owner->flags3 & INVISIBILITY_FLAGS3);
|
||||
Owner->flags3 |= flags3 & INVISIBILITY_FLAGS3;
|
||||
flags5 &= ~(Owner->flags5 & INVISIBILITY_FLAGS5);
|
||||
Owner->flags5 |= flags5 & INVISIBILITY_FLAGS5;
|
||||
|
||||
CallDoEffect();
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvisibility :: DoEffect
|
||||
//
|
||||
//===========================================================================
|
||||
void APowerInvisibility::DoEffect ()
|
||||
{
|
||||
Super::DoEffect();
|
||||
// Due to potential interference with other PowerInvisibility items
|
||||
// the effect has to be refreshed each tic.
|
||||
double ts = (Strength / 100) * (special1 + 1);
|
||||
|
||||
if (ts > 1.) ts = 1.;
|
||||
Owner->Alpha = clamp((1. - ts), 0., 1.);
|
||||
switch (Mode)
|
||||
{
|
||||
case (NAME_Fuzzy):
|
||||
Owner->RenderStyle = STYLE_OptFuzzy;
|
||||
break;
|
||||
case (NAME_Opaque):
|
||||
Owner->RenderStyle = STYLE_Normal;
|
||||
break;
|
||||
case (NAME_Additive):
|
||||
Owner->RenderStyle = STYLE_Add;
|
||||
break;
|
||||
case (NAME_Stencil):
|
||||
Owner->RenderStyle = STYLE_Stencil;
|
||||
break;
|
||||
case (NAME_AddStencil) :
|
||||
Owner->RenderStyle = STYLE_AddStencil;
|
||||
break;
|
||||
case (NAME_TranslucentStencil) :
|
||||
Owner->RenderStyle = STYLE_TranslucentStencil;
|
||||
break;
|
||||
case (NAME_None) :
|
||||
case (NAME_Cumulative):
|
||||
case (NAME_Translucent):
|
||||
Owner->RenderStyle = STYLE_Translucent;
|
||||
break;
|
||||
default: // Something's wrong
|
||||
Owner->RenderStyle = STYLE_Normal;
|
||||
Owner->Alpha = 1.;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvisibility :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerInvisibility::EndEffect ()
|
||||
{
|
||||
Super::EndEffect();
|
||||
if (Owner != NULL)
|
||||
{
|
||||
Owner->flags &= ~(flags & INVISIBILITY_FLAGS1);
|
||||
Owner->flags3 &= ~(flags3 & INVISIBILITY_FLAGS3);
|
||||
Owner->flags5 &= ~(flags5 & INVISIBILITY_FLAGS5);
|
||||
|
||||
Owner->RenderStyle = STYLE_Normal;
|
||||
Owner->Alpha = 1.;
|
||||
|
||||
// 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)->DoEffect();
|
||||
}
|
||||
item = item->Inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvisibility :: AlterWeaponSprite
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
int APowerInvisibility::AlterWeaponSprite (visstyle_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;
|
||||
vis->Alpha = 1.f;
|
||||
return 1;
|
||||
}
|
||||
else if (changed == 1)
|
||||
{
|
||||
// something else set the weapon sprite back to opaque but this item is still active.
|
||||
float ts = float((Strength / 100) * (special1 + 1));
|
||||
vis->Alpha = clamp<>((1.f - ts), 0.f, 1.f);
|
||||
switch (Mode)
|
||||
{
|
||||
case (NAME_Fuzzy):
|
||||
vis->RenderStyle = STYLE_OptFuzzy;
|
||||
break;
|
||||
case (NAME_Opaque):
|
||||
vis->RenderStyle = STYLE_Normal;
|
||||
break;
|
||||
case (NAME_Additive):
|
||||
vis->RenderStyle = STYLE_Add;
|
||||
break;
|
||||
case (NAME_Stencil):
|
||||
vis->RenderStyle = STYLE_Stencil;
|
||||
break;
|
||||
case (NAME_TranslucentStencil) :
|
||||
vis->RenderStyle = STYLE_TranslucentStencil;
|
||||
break;
|
||||
case (NAME_AddStencil) :
|
||||
vis->RenderStyle = STYLE_AddStencil;
|
||||
break;
|
||||
case (NAME_None) :
|
||||
case (NAME_Cumulative):
|
||||
case (NAME_Translucent):
|
||||
default:
|
||||
vis->RenderStyle = STYLE_Translucent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Handling of Strife-like cumulative invisibility powerups, the weapon itself shouldn't become invisible
|
||||
if ((vis->Alpha < 0.25f && special1 > 0) || (vis->Alpha == 0))
|
||||
{
|
||||
vis->Alpha = clamp((1.f - float(Strength/100)), 0.f, 1.f);
|
||||
vis->colormap = SpecialColormaps[INVERSECOLORMAP].Colormap;
|
||||
}
|
||||
return -1; // This item is valid so another one shouldn't reset the translucency
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerInvisibility :: HandlePickup
|
||||
//
|
||||
// If the player already has the first stage of a cumulative powerup, getting
|
||||
// it again increases the player's alpha. (But shouldn't this be in Use()?)
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool APowerInvisibility::HandlePickup (AInventory *item)
|
||||
{
|
||||
if (Mode == NAME_Cumulative && ((Strength * special1) < 1.) && item->GetClass() == GetClass())
|
||||
{
|
||||
APowerup *power = static_cast<APowerup *>(item);
|
||||
if (power->EffectTics == 0)
|
||||
{
|
||||
power->ItemFlags |= IF_PICKUPGOOD;
|
||||
return true;
|
||||
}
|
||||
// Only increase the EffectTics, not decrease it.
|
||||
// Color also gets transferred only when the new item has an effect.
|
||||
if (power->EffectTics > EffectTics)
|
||||
{
|
||||
EffectTics = power->EffectTics;
|
||||
BlendColor = power->BlendColor;
|
||||
}
|
||||
special1++; // increases power
|
||||
power->ItemFlags |= IF_PICKUPGOOD;
|
||||
return true;
|
||||
}
|
||||
return Super::HandlePickup (item);
|
||||
}
|
||||
|
||||
// Speed Powerup -------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerSpeed, false, false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue