2006-02-24 04:48:15 +00:00
|
|
|
#include "info.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_spec.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "a_artifacts.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "templates.h"
|
2008-04-08 08:53:42 +00:00
|
|
|
#include "a_morph.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
|
|
|
#include "doomstat.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_palette.h"
|
2011-07-06 14:20:54 +00:00
|
|
|
#include "farchive.h"
|
2011-07-06 07:35:36 +00:00
|
|
|
#include "r_data/colormaps.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_torch ("Torch");
|
|
|
|
|
2009-06-30 22:10:51 +00:00
|
|
|
/* Those are no longer needed, except maybe as reference?
|
|
|
|
* They're not used anywhere in the code anymore, except
|
|
|
|
* MAULATORTICS as redefined in a_minotaur.cpp...
|
2006-02-24 04:48:15 +00:00
|
|
|
#define INVULNTICS (30*TICRATE)
|
|
|
|
#define INVISTICS (60*TICRATE)
|
|
|
|
#define INFRATICS (120*TICRATE)
|
|
|
|
#define IRONTICS (60*TICRATE)
|
|
|
|
#define WPNLEV2TICS (40*TICRATE)
|
|
|
|
#define FLIGHTTICS (60*TICRATE)
|
|
|
|
#define SPEEDTICS (45*TICRATE)
|
|
|
|
#define MAULATORTICS (25*TICRATE)
|
2007-05-01 15:09:44 +00:00
|
|
|
#define TIMEFREEZE_TICS ( 12 * TICRATE )
|
2009-06-30 22:10:51 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerup)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Powerup-Giver -------------------------------------------------------------
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerupGiver :: Use
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool APowerupGiver::Use (bool pickup)
|
|
|
|
{
|
2009-04-04 09:28:10 +00:00
|
|
|
if (PowerupType == NULL) return true; // item is useless
|
|
|
|
|
2006-07-16 09:10:45 +00:00
|
|
|
APowerup *power = static_cast<APowerup *> (Spawn (PowerupType, 0, 0, 0, NO_REPLACE));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-03 14:54:48 +00:00
|
|
|
if (EffectTics != 0)
|
|
|
|
{
|
|
|
|
power->EffectTics = EffectTics;
|
|
|
|
}
|
|
|
|
if (BlendColor != 0)
|
|
|
|
{
|
|
|
|
power->BlendColor = BlendColor;
|
|
|
|
}
|
2009-06-30 22:10:51 +00:00
|
|
|
if (Mode != NAME_None)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2009-06-30 22:10:51 +00:00
|
|
|
power->Mode = Mode;
|
|
|
|
}
|
|
|
|
if (Strength != 0)
|
|
|
|
{
|
|
|
|
power->Strength = Strength;
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
2006-05-03 14:54:48 +00:00
|
|
|
|
2008-03-01 16:59:17 +00:00
|
|
|
power->ItemFlags |= ItemFlags & (IF_ALWAYSPICKUP|IF_ADDITIVETIME);
|
2008-09-13 22:08:41 +00:00
|
|
|
if (power->CallTryPickup (Owner))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
power->GoAwayAndDie ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerupGiver :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerupGiver::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << PowerupType;
|
2009-06-30 22:10:51 +00:00
|
|
|
arc << EffectTics << BlendColor << Mode;
|
2009-09-14 22:12:31 +00:00
|
|
|
arc << Strength;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Powerup -------------------------------------------------------------------
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: Tick
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::Tick ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
// Powerups cannot exist outside an inventory
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner == NULL)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
if (EffectTics > 0 && --EffectTics == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Destroy ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2009-06-30 22:10:51 +00:00
|
|
|
arc << EffectTics << BlendColor << Mode;
|
2009-09-14 22:12:31 +00:00
|
|
|
arc << Strength;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: GetBlend
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
PalEntry APowerup::GetBlend ()
|
|
|
|
{
|
2006-05-03 14:54:48 +00:00
|
|
|
if (EffectTics <= BLINKTHRESHOLD && !(EffectTics & 8))
|
|
|
|
return 0;
|
|
|
|
|
2009-09-21 13:15:36 +00:00
|
|
|
if (IsSpecialColormap(BlendColor)) return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
return BlendColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::InitEffect ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::DoEffect ()
|
|
|
|
{
|
2007-10-05 08:04:38 +00:00
|
|
|
if (Owner == NULL || Owner->player == NULL)
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EffectTics > 0)
|
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
int Colormap = GetSpecialColormap(BlendColor);
|
|
|
|
|
|
|
|
if (Colormap != NOFIXEDCOLORMAP)
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
if (EffectTics > BLINKTHRESHOLD || (EffectTics & 8))
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
Owner->player->fixedcolormap = Colormap;
|
2007-01-12 15:24:10 +00:00
|
|
|
}
|
2009-09-21 13:15:36 +00:00
|
|
|
else if (Owner->player->fixedcolormap == Colormap)
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
// only unset if the fixed colormap comes from this item
|
|
|
|
Owner->player->fixedcolormap = NOFIXEDCOLORMAP;
|
2007-01-12 15:24:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
int colormap = GetSpecialColormap(BlendColor);
|
|
|
|
|
2010-03-29 06:08:22 +00:00
|
|
|
if (colormap != NOFIXEDCOLORMAP && Owner && Owner->player && Owner->player->fixedcolormap == colormap)
|
2010-03-28 04:02:57 +00:00
|
|
|
{ // only unset if the fixed colormap comes from this item
|
|
|
|
Owner->player->fixedcolormap = NOFIXEDCOLORMAP;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: Destroy
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::Destroy ()
|
|
|
|
{
|
|
|
|
EndEffect ();
|
|
|
|
Super::Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: DrawPowerup
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool APowerup::DrawPowerup (int x, int y)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!Icon.isValid())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (EffectTics > BLINKTHRESHOLD || !(EffectTics & 16))
|
|
|
|
{
|
|
|
|
FTexture *pic = TexMan(Icon);
|
|
|
|
screen->DrawTexture (pic, x, y,
|
|
|
|
DTA_HUDRules, HUD_Normal,
|
|
|
|
// DTA_TopOffset, pic->GetHeight()/2,
|
|
|
|
// DTA_LeftOffset, pic->GetWidth()/2,
|
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: HandlePickup
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool APowerup::HandlePickup (AInventory *item)
|
|
|
|
{
|
|
|
|
if (item->GetClass() == GetClass())
|
|
|
|
{
|
|
|
|
APowerup *power = static_cast<APowerup*>(item);
|
|
|
|
if (power->EffectTics == 0)
|
|
|
|
{
|
|
|
|
power->ItemFlags |= IF_PICKUPGOOD;
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-17 01:32:58 +00:00
|
|
|
// Color gets transferred if the new item has an effect.
|
|
|
|
|
|
|
|
// Increase the effect's duration.
|
2008-03-01 16:59:17 +00:00
|
|
|
if (power->ItemFlags & IF_ADDITIVETIME)
|
|
|
|
{
|
|
|
|
EffectTics += power->EffectTics;
|
|
|
|
BlendColor = power->BlendColor;
|
|
|
|
}
|
2009-07-17 01:32:58 +00:00
|
|
|
// If it's not blinking yet, you can't replenish the power unless the
|
|
|
|
// powerup is required to be picked up.
|
|
|
|
else if (EffectTics > BLINKTHRESHOLD && !(power->ItemFlags & IF_ALWAYSPICKUP))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Reset the effect duration.
|
2008-03-01 16:59:17 +00:00
|
|
|
else if (power->EffectTics > EffectTics)
|
2006-05-03 14:54:48 +00:00
|
|
|
{
|
|
|
|
EffectTics = power->EffectTics;
|
|
|
|
BlendColor = power->BlendColor;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
power->ItemFlags |= IF_PICKUPGOOD;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (Inventory != NULL)
|
|
|
|
{
|
|
|
|
return Inventory->HandlePickup (item);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: CreateCopy
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
AInventory *APowerup::CreateCopy (AActor *other)
|
|
|
|
{
|
2008-04-08 08:53:42 +00:00
|
|
|
// Get the effective effect time.
|
2006-02-24 04:48:15 +00:00
|
|
|
EffectTics = abs (EffectTics);
|
2008-04-08 08:53:42 +00:00
|
|
|
// Abuse the Owner field to tell the
|
|
|
|
// InitEffect method who started it;
|
|
|
|
// this should be cleared afterwards,
|
|
|
|
// as this powerup instance is not
|
|
|
|
// properly attached to anything yet.
|
2006-02-24 04:48:15 +00:00
|
|
|
Owner = other;
|
2008-04-08 08:53:42 +00:00
|
|
|
// Actually activate the powerup.
|
2006-02-24 04:48:15 +00:00
|
|
|
InitEffect ();
|
2008-04-08 08:53:42 +00:00
|
|
|
// Clear the Owner field, unless it was
|
|
|
|
// changed by the activation, for example,
|
|
|
|
// if this instance is a morph powerup;
|
|
|
|
// the flag tells the caller that the
|
|
|
|
// ownership has changed so that they
|
|
|
|
// can properly handle the situation.
|
|
|
|
if (!(ItemFlags & IF_CREATECOPYMOVED))
|
|
|
|
{
|
|
|
|
Owner = NULL;
|
|
|
|
}
|
|
|
|
// All done.
|
2006-02-24 04:48:15 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: CreateTossable
|
|
|
|
//
|
|
|
|
// Powerups are never droppable, even without IF_UNDROPPABLE set.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
AInventory *APowerup::CreateTossable ()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-06-18 04:10:47 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerup :: OwnerDied
|
|
|
|
//
|
|
|
|
// Powerups don't last beyond death.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerup::OwnerDied ()
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Invulnerability Powerup ---------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerInvulnerable)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvulnerable :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInvulnerable::InitEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
Owner->effects &= ~FX_RESPAWNINVUL;
|
|
|
|
Owner->flags2 |= MF2_INVULNERABLE;
|
2010-03-25 20:38:00 +00:00
|
|
|
if (Mode == NAME_None && Owner->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
|
2009-06-30 22:10:51 +00:00
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
Mode = static_cast<PClassPlayerPawn *>(Owner->GetClass())->InvulMode;
|
2009-06-30 22:10:51 +00:00
|
|
|
}
|
|
|
|
if (Mode == NAME_Reflective)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2009-06-30 22:10:51 +00:00
|
|
|
Owner->flags2 |= MF2_REFLECTIVE;
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvulnerable :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInvulnerable::DoEffect ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Super::DoEffect ();
|
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
if (Owner == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-30 22:10:51 +00:00
|
|
|
if (Mode == NAME_Ghost)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
if (!(Owner->flags & MF_SHADOW))
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
// Don't mess with the translucency settings if an
|
|
|
|
// invisibility powerup is active.
|
|
|
|
Owner->RenderStyle = STYLE_Translucent;
|
|
|
|
if (!(level.time & 7) && Owner->alpha > 0 && Owner->alpha < OPAQUE)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
if (Owner->alpha == HX_SHADOW)
|
|
|
|
{
|
|
|
|
Owner->alpha = HX_ALTSHADOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Owner->alpha = 0;
|
|
|
|
Owner->flags2 |= MF2_NONSHOOTABLE;
|
|
|
|
}
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
if (!(level.time & 31))
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
if (Owner->alpha == 0)
|
|
|
|
{
|
|
|
|
Owner->flags2 &= ~MF2_NONSHOOTABLE;
|
|
|
|
Owner->alpha = HX_ALTSHADOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Owner->alpha = HX_SHADOW;
|
|
|
|
}
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
else
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Owner->flags2 &= ~MF2_NONSHOOTABLE;
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvulnerable :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInvulnerable::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Owner->flags2 &= ~MF2_INVULNERABLE;
|
|
|
|
Owner->effects &= ~FX_RESPAWNINVUL;
|
2009-06-30 22:10:51 +00:00
|
|
|
if (Mode == NAME_Ghost)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
|
|
|
Owner->flags2 &= ~MF2_NONSHOOTABLE;
|
2007-01-12 15:24:10 +00:00
|
|
|
if (!(Owner->flags & MF_SHADOW))
|
|
|
|
{
|
|
|
|
// Don't mess with the translucency settings if an
|
|
|
|
// invisibility powerup is active.
|
|
|
|
Owner->RenderStyle = STYLE_Normal;
|
|
|
|
Owner->alpha = OPAQUE;
|
|
|
|
}
|
2006-11-07 10:20:09 +00:00
|
|
|
}
|
2009-06-30 22:10:51 +00:00
|
|
|
else if (Mode == NAME_Reflective)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
|
|
|
Owner->flags2 &= ~MF2_REFLECTIVE;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner->player != NULL)
|
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
Owner->player->fixedcolormap = NOFIXEDCOLORMAP;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-23 20:12:27 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2007-01-12 15:24:10 +00:00
|
|
|
// APowerInvulnerable :: AlterWeaponSprite
|
2006-04-23 20:12:27 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2011-07-06 13:00:51 +00:00
|
|
|
int APowerInvulnerable::AlterWeaponSprite (visstyle_t *vis)
|
2006-04-23 20:12:27 +00:00
|
|
|
{
|
2007-03-08 23:34:54 +00:00
|
|
|
int changed = Inventory == NULL ? false : Inventory->AlterWeaponSprite(vis);
|
2006-11-07 10:20:09 +00:00
|
|
|
if (Owner != NULL)
|
2006-04-23 20:12:27 +00:00
|
|
|
{
|
2009-06-30 22:10:51 +00:00
|
|
|
if (Mode == NAME_Ghost && !(Owner->flags & MF_SHADOW))
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
|
|
|
fixed_t wp_alpha = MIN<fixed_t>(FRACUNIT/4 + Owner->alpha*3/4, FRACUNIT);
|
|
|
|
if (wp_alpha != FIXED_MAX) vis->alpha = wp_alpha;
|
|
|
|
}
|
2006-04-23 20:12:27 +00:00
|
|
|
}
|
2007-01-14 08:58:07 +00:00
|
|
|
return changed;
|
2006-04-23 20:12:27 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Strength (aka Berserk) Powerup --------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerStrength)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// 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 ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerStrength :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2007-01-12 15:24:10 +00:00
|
|
|
void APowerStrength::Tick ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Strength counts up to diminish the fade.
|
2008-04-17 20:34:58 +00:00
|
|
|
assert(EffectTics < (INT_MAX - 1)); // I can't see a game lasting nearly two years, but...
|
2006-02-24 04:48:15 +00:00
|
|
|
EffectTics += 2;
|
2007-01-12 15:24:10 +00:00
|
|
|
Super::Tick();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerStrength :: GetBlend
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
PalEntry APowerStrength::GetBlend ()
|
|
|
|
{
|
2009-09-14 19:44:14 +00:00
|
|
|
// slowly fade the berserk out
|
2006-02-24 04:48:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invisibility Powerup ------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerInvisibility)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-09-14 19:44:14 +00:00
|
|
|
// Invisibility flag combos
|
2009-09-17 20:54:07 +00:00
|
|
|
#define INVISIBILITY_FLAGS1 (MF_SHADOW)
|
2009-09-14 19:44:14 +00:00
|
|
|
#define INVISIBILITY_FLAGS3 (MF3_GHOST)
|
|
|
|
#define INVISIBILITY_FLAGS5 (MF5_CANTSEEK)
|
|
|
|
|
2009-02-19 14:36:37 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2009-09-14 19:44:14 +00:00
|
|
|
// APowerInvisibility :: InitEffect
|
2009-02-19 14:36:37 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2009-09-14 19:44:14 +00:00
|
|
|
void APowerInvisibility::InitEffect ()
|
2009-02-19 14:36:37 +00:00
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
2009-09-14 19:44:14 +00:00
|
|
|
// 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.
|
2009-05-09 02:31:49 +00:00
|
|
|
if (Owner != NULL)
|
|
|
|
{
|
2009-09-14 19:44:14 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
DoEffect();
|
2009-05-09 02:31:49 +00:00
|
|
|
}
|
2009-02-19 14:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvisibility :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2007-01-12 15:24:10 +00:00
|
|
|
void APowerInvisibility::DoEffect ()
|
|
|
|
{
|
|
|
|
Super::DoEffect();
|
|
|
|
// Due to potential interference with other PowerInvisibility items
|
|
|
|
// the effect has to be refreshed each tic.
|
2013-08-12 07:13:55 +00:00
|
|
|
fixed_t ts = (Strength/100) * (special1 + 1); if (ts > FRACUNIT) ts = FRACUNIT;
|
2009-09-17 20:54:07 +00:00
|
|
|
Owner->alpha = clamp<fixed_t>((OPAQUE - ts), 0, OPAQUE);
|
2009-09-14 19:44:14 +00:00
|
|
|
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;
|
2014-05-13 19:16:06 +00:00
|
|
|
case (NAME_AddStencil) :
|
|
|
|
Owner->RenderStyle = STYLE_AddStencil;
|
|
|
|
break;
|
|
|
|
case (NAME_TranslucentStencil) :
|
|
|
|
Owner->RenderStyle = STYLE_TranslucentStencil;
|
|
|
|
break;
|
|
|
|
case (NAME_None) :
|
2009-09-17 20:54:07 +00:00
|
|
|
case (NAME_Cumulative):
|
2009-09-14 19:44:14 +00:00
|
|
|
case (NAME_Translucent):
|
|
|
|
Owner->RenderStyle = STYLE_Translucent;
|
|
|
|
break;
|
|
|
|
default: // Something's wrong
|
|
|
|
Owner->RenderStyle = STYLE_Normal;
|
|
|
|
Owner->alpha = OPAQUE;
|
|
|
|
break;
|
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvisibility :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInvisibility::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner != NULL)
|
|
|
|
{
|
2009-09-14 19:44:14 +00:00
|
|
|
Owner->flags &= ~(flags & INVISIBILITY_FLAGS1);
|
|
|
|
Owner->flags3 &= ~(flags3 & INVISIBILITY_FLAGS3);
|
|
|
|
Owner->flags5 &= ~(flags5 & INVISIBILITY_FLAGS5);
|
|
|
|
|
2009-09-17 20:54:07 +00:00
|
|
|
Owner->RenderStyle = STYLE_Normal;
|
|
|
|
Owner->alpha = OPAQUE;
|
2007-01-14 08:58:07 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2009-09-14 19:44:14 +00:00
|
|
|
static_cast<APowerInvisibility*>(item)->DoEffect();
|
2007-01-14 08:58:07 +00:00
|
|
|
}
|
|
|
|
item = item->Inventory;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInvisibility :: AlterWeaponSprite
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2011-07-06 13:00:51 +00:00
|
|
|
int APowerInvisibility::AlterWeaponSprite (visstyle_t *vis)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-03-08 23:34:54 +00:00
|
|
|
int changed = Inventory == NULL ? false : Inventory->AlterWeaponSprite(vis);
|
2006-02-24 04:48:15 +00:00
|
|
|
// Blink if the powerup is wearing off
|
2007-01-14 08:58:07 +00:00
|
|
|
if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-17 20:54:07 +00:00
|
|
|
vis->RenderStyle = STYLE_Normal;
|
|
|
|
vis->alpha = OPAQUE;
|
2007-01-14 08:58:07 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (changed == 1)
|
|
|
|
{
|
|
|
|
// something else set the weapon sprite back to opaque but this item is still active.
|
2013-08-12 07:13:55 +00:00
|
|
|
fixed_t ts = (Strength/100) * (special1 + 1); if (ts > FRACUNIT) ts = FRACUNIT;
|
2009-09-17 20:54:07 +00:00
|
|
|
vis->alpha = clamp<fixed_t>((OPAQUE - ts), 0, OPAQUE);
|
2009-09-14 19:44:14 +00:00
|
|
|
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;
|
2014-05-13 19:16:06 +00:00
|
|
|
case (NAME_TranslucentStencil) :
|
|
|
|
vis->RenderStyle = STYLE_TranslucentStencil;
|
|
|
|
break;
|
|
|
|
case (NAME_AddStencil) :
|
|
|
|
vis->RenderStyle = STYLE_AddStencil;
|
|
|
|
break;
|
|
|
|
case (NAME_None) :
|
2009-09-14 19:44:14 +00:00
|
|
|
case (NAME_Cumulative):
|
|
|
|
case (NAME_Translucent):
|
|
|
|
default:
|
|
|
|
vis->RenderStyle = STYLE_Translucent;
|
|
|
|
break;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-06-30 22:10:51 +00:00
|
|
|
// Handling of Strife-like cumulative invisibility powerups, the weapon itself shouldn't become invisible
|
|
|
|
if ((vis->alpha < TRANSLUC25 && special1 > 0) || (vis->alpha == 0))
|
2007-01-14 08:58:07 +00:00
|
|
|
{
|
2013-08-12 07:13:55 +00:00
|
|
|
vis->alpha = clamp<fixed_t>((OPAQUE - (Strength/100)), 0, OPAQUE);
|
2009-09-21 13:15:36 +00:00
|
|
|
vis->colormap = SpecialColormaps[INVERSECOLORMAP].Colormap;
|
2007-01-14 08:58:07 +00:00
|
|
|
}
|
|
|
|
return -1; // This item is valid so another one shouldn't reset the translucency
|
|
|
|
}
|
|
|
|
|
2007-03-08 23:34:54 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2009-06-30 22:10:51 +00:00
|
|
|
// APowerInvisibility :: HandlePickup
|
2007-03-08 23:34:54 +00:00
|
|
|
//
|
2009-06-30 22:10:51 +00:00
|
|
|
// 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()?)
|
2007-03-08 23:34:54 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2009-06-30 22:10:51 +00:00
|
|
|
bool APowerInvisibility::HandlePickup (AInventory *item)
|
2007-03-08 23:34:54 +00:00
|
|
|
{
|
2009-06-30 22:10:51 +00:00
|
|
|
if (Mode == NAME_Cumulative && ((Strength * special1) < FRACUNIT) && item->GetClass() == GetClass())
|
2007-03-08 23:34:54 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2009-06-30 22:10:51 +00:00
|
|
|
special1++; // increases power
|
2007-03-08 23:34:54 +00:00
|
|
|
power->ItemFlags |= IF_PICKUPGOOD;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return Super::HandlePickup (item);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Ironfeet Powerup ----------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerIronFeet)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerIronFeet :: AbsorbDamage
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
void APowerIronFeet::AbsorbDamage (int damage, FName damageType, int &newdamage)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-01-28 04:59:04 +00:00
|
|
|
if (damageType == NAME_Drowning)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
newdamage = 0;
|
|
|
|
}
|
|
|
|
else if (Inventory != NULL)
|
|
|
|
{
|
|
|
|
Inventory->AbsorbDamage (damage, damageType, newdamage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-13 10:38:38 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerIronFeet :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerIronFeet::DoEffect ()
|
|
|
|
{
|
|
|
|
if (Owner->player != NULL)
|
|
|
|
{
|
|
|
|
Owner->player->mo->ResetAirSupply ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Strife Environment Suit Powerup -------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerMask)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerMask :: AbsorbDamage
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
void APowerMask::AbsorbDamage (int damage, FName damageType, int &newdamage)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
if (damageType == NAME_Fire)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
newdamage = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Super::AbsorbDamage (damage, damageType, newdamage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerMask :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerMask::DoEffect ()
|
|
|
|
{
|
|
|
|
Super::DoEffect ();
|
|
|
|
if (!(level.time & 0x3f))
|
|
|
|
{
|
|
|
|
S_Sound (Owner, CHAN_AUTO, "misc/mask", 1, ATTN_STATIC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Light-Amp Powerup ---------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerLightAmp)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerLightAmp :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerLightAmp::DoEffect ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Super::DoEffect ();
|
|
|
|
|
|
|
|
if (Owner->player != NULL && Owner->player->fixedcolormap < NUMCOLORMAPS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (EffectTics > BLINKTHRESHOLD || (EffectTics & 8))
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
Owner->player->fixedlightlevel = 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
Owner->player->fixedlightlevel = -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerLightAmp :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerLightAmp::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2007-01-12 15:24:10 +00:00
|
|
|
if (Owner != NULL && Owner->player != NULL && Owner->player->fixedcolormap < NUMCOLORMAPS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
Owner->player->fixedlightlevel = -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Torch Powerup -------------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerTorch)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerTorch :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerTorch::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << NewTorch << NewTorchDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerTorch :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerTorch::DoEffect ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
if (Owner == NULL || Owner->player == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EffectTics <= BLINKTHRESHOLD || Owner->player->fixedcolormap >= NUMCOLORMAPS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Super::DoEffect ();
|
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
else
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
APowerup::DoEffect ();
|
|
|
|
|
|
|
|
if (!(level.time & 16) && Owner->player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
if (NewTorch != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
if (Owner->player->fixedlightlevel + NewTorchDelta > 7
|
|
|
|
|| Owner->player->fixedlightlevel + NewTorchDelta < 0
|
|
|
|
|| NewTorch == Owner->player->fixedlightlevel)
|
2007-01-12 15:24:10 +00:00
|
|
|
{
|
|
|
|
NewTorch = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
Owner->player->fixedlightlevel += NewTorchDelta;
|
2007-01-12 15:24:10 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
NewTorch = (pr_torch() & 7) + 1;
|
2009-09-20 03:50:05 +00:00
|
|
|
NewTorchDelta = (NewTorch == Owner->player->fixedlightlevel) ?
|
|
|
|
0 : ((NewTorch > Owner->player->fixedlightlevel) ? 1 : -1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flight (aka Wings of Wrath) powerup ---------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerFlight)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFlight :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerFlight::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << HitCenterFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFlight :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerFlight::InitEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
Owner->flags2 |= MF2_FLY;
|
|
|
|
Owner->flags |= MF_NOGRAVITY;
|
|
|
|
if (Owner->z <= Owner->floorz)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
Owner->velz = 4*FRACUNIT; // thrust the player in the air a bit
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-06-30 20:57:51 +00:00
|
|
|
if (Owner->velz <= -35*FRACUNIT)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // stop falling scream
|
|
|
|
S_StopSound (Owner, CHAN_VOICE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFlight :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2007-01-12 15:24:10 +00:00
|
|
|
void APowerFlight::Tick ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// The Wings of Wrath only expire in multiplayer and non-hub games
|
2009-02-03 19:11:43 +00:00
|
|
|
if (!multiplayer && (level.flags2 & LEVEL2_INFINITE_FLIGHT))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-04-17 20:34:58 +00:00
|
|
|
assert(EffectTics < INT_MAX); // I can't see a game lasting nearly two years, but...
|
2006-02-24 04:48:15 +00:00
|
|
|
EffectTics++;
|
|
|
|
}
|
2007-01-12 15:24:10 +00:00
|
|
|
|
|
|
|
Super::Tick ();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Owner->flags |= MF_NOGRAVITY;
|
|
|
|
// Owner->flags2 |= MF2_FLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFlight :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerFlight::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner == NULL || Owner->player == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(Owner->player->cheats & CF_FLY))
|
|
|
|
{
|
|
|
|
if (Owner->z != Owner->floorz)
|
|
|
|
{
|
|
|
|
Owner->player->centering = true;
|
|
|
|
}
|
|
|
|
Owner->flags2 &= ~MF2_FLY;
|
|
|
|
Owner->flags &= ~MF_NOGRAVITY;
|
|
|
|
}
|
|
|
|
// BorderTopRefresh = screen->GetPageCount (); //make sure the sprite's cleared out
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFlight :: DrawPowerup
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool APowerFlight::DrawPowerup (int x, int y)
|
|
|
|
{
|
2010-08-10 19:22:43 +00:00
|
|
|
// If this item got a valid icon use that instead of the default spinning wings.
|
|
|
|
if (Icon.isValid())
|
|
|
|
{
|
|
|
|
return Super::DrawPowerup(x, y);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (EffectTics > BLINKTHRESHOLD || !(EffectTics & 16))
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID picnum = TexMan.CheckForTexture ("SPFLY0", FTexture::TEX_MiscPatch);
|
2006-02-24 04:48:15 +00:00
|
|
|
int frame = (level.time/3) & 15;
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!picnum.isValid())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Owner->flags & MF_NOGRAVITY)
|
|
|
|
{
|
|
|
|
if (HitCenterFrame && (frame != 15 && frame != 0))
|
|
|
|
{
|
|
|
|
screen->DrawTexture (TexMan[picnum+15], x, y,
|
|
|
|
DTA_HUDRules, HUD_Normal, TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen->DrawTexture (TexMan[picnum+frame], x, y,
|
|
|
|
DTA_HUDRules, HUD_Normal, TAG_DONE);
|
|
|
|
HitCenterFrame = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!HitCenterFrame && (frame != 15 && frame != 0))
|
|
|
|
{
|
|
|
|
screen->DrawTexture (TexMan[picnum+frame], x, y,
|
|
|
|
DTA_HUDRules, HUD_Normal, TAG_DONE);
|
|
|
|
HitCenterFrame = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen->DrawTexture (TexMan[picnum+15], x, y,
|
|
|
|
DTA_HUDRules, HUD_Normal, TAG_DONE);
|
|
|
|
HitCenterFrame = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Weapon Level 2 (aka Tome of Power) Powerup --------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerWeaponLevel2)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerWeaponLevel2 :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerWeaponLevel2::InitEffect ()
|
|
|
|
{
|
|
|
|
AWeapon *weapon, *sister;
|
|
|
|
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner->player == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weapon = Owner->player->ReadyWeapon;
|
|
|
|
|
|
|
|
if (weapon == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sister = weapon->SisterWeapon;
|
|
|
|
|
|
|
|
if (sister == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(sister->WeaponFlags & WIF_POWERED_UP))
|
|
|
|
return;
|
|
|
|
|
2008-07-05 10:17:10 +00:00
|
|
|
assert (sister->SisterWeapon == weapon);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
Owner->player->ReadyWeapon = sister;
|
|
|
|
|
|
|
|
if (weapon->GetReadyState() != sister->GetReadyState())
|
|
|
|
{
|
|
|
|
P_SetPsprite (Owner->player, ps_weapon, sister->GetReadyState());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerWeaponLevel2 :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerWeaponLevel2::EndEffect ()
|
|
|
|
{
|
|
|
|
player_t *player = Owner != NULL ? Owner->player : NULL;
|
|
|
|
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2007-04-29 08:44:32 +00:00
|
|
|
if (player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-04-29 08:44:32 +00:00
|
|
|
if (player->ReadyWeapon != NULL &&
|
|
|
|
player->ReadyWeapon->WeaponFlags & WIF_POWERED_UP)
|
|
|
|
{
|
|
|
|
player->ReadyWeapon->EndPowerup ();
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
if (player->PendingWeapon != NULL && player->PendingWeapon != WP_NOCHANGE &&
|
2007-04-29 08:44:32 +00:00
|
|
|
player->PendingWeapon->WeaponFlags & WIF_POWERED_UP &&
|
|
|
|
player->PendingWeapon->SisterWeapon != NULL)
|
|
|
|
{
|
|
|
|
player->PendingWeapon = player->PendingWeapon->SisterWeapon;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Player Speed Trail (used by the Speed Powerup) ----------------------------
|
|
|
|
|
|
|
|
class APlayerSpeedTrail : public AActor
|
|
|
|
{
|
2008-08-09 11:35:42 +00:00
|
|
|
DECLARE_CLASS (APlayerSpeedTrail, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void Tick ();
|
|
|
|
};
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APlayerSpeedTrail)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APlayerSpeedTrail :: Tick
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APlayerSpeedTrail::Tick ()
|
|
|
|
{
|
|
|
|
const int fade = OPAQUE*6/10/8;
|
|
|
|
if (alpha <= fade)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alpha -= fade;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Speed Powerup -------------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerSpeed)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-02-19 02:44:49 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerSpeed :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerSpeed::Serialize(FArchive &arc)
|
|
|
|
{
|
2013-02-19 08:10:33 +00:00
|
|
|
Super::Serialize (arc);
|
2013-02-19 02:44:49 +00:00
|
|
|
if (SaveVersion < 4146)
|
|
|
|
{
|
|
|
|
SpeedFlags = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arc << SpeedFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2007-05-12 11:14:09 +00:00
|
|
|
// APowerSpeed :: GetSpeedFactor
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2007-05-12 11:14:09 +00:00
|
|
|
fixed_t APowerSpeed ::GetSpeedFactor ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-02-19 02:44:49 +00:00
|
|
|
if (Inventory != NULL)
|
|
|
|
return FixedMul(Speed, Inventory->GetSpeedFactor());
|
|
|
|
else
|
|
|
|
return Speed;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerSpeed :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerSpeed::DoEffect ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Super::DoEffect ();
|
2007-10-05 08:04:38 +00:00
|
|
|
|
|
|
|
if (Owner == NULL || Owner->player == NULL)
|
|
|
|
return;
|
2007-01-12 15:24:10 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner->player->cheats & CF_PREDICTING)
|
|
|
|
return;
|
|
|
|
|
2013-02-19 02:44:49 +00:00
|
|
|
if (SpeedFlags & PSF_NOTRAIL)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-19 02:44:49 +00:00
|
|
|
if (level.time & 1)
|
2007-05-12 11:14:09 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-19 02:44:49 +00:00
|
|
|
// Check if another speed item is present to avoid multiple drawing of the speed trail.
|
|
|
|
// Only the last PowerSpeed without PSF_NOTRAIL set will actually draw the trail.
|
|
|
|
for (AInventory *item = Inventory; item != NULL; item = item->Inventory)
|
|
|
|
{
|
|
|
|
if (item->IsKindOf(RUNTIME_CLASS(APowerSpeed)) &&
|
|
|
|
!(static_cast<APowerSpeed *>(item)->SpeedFlags & PSF_NOTRAIL))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
if (P_AproxDistance (Owner->velx, Owner->vely) <= 12*FRACUNIT)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2006-07-16 09:10:45 +00:00
|
|
|
AActor *speedMo = Spawn<APlayerSpeedTrail> (Owner->x, Owner->y, Owner->z, NO_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (speedMo)
|
|
|
|
{
|
|
|
|
speedMo->angle = Owner->angle;
|
|
|
|
speedMo->Translation = Owner->Translation;
|
|
|
|
speedMo->target = Owner;
|
|
|
|
speedMo->sprite = Owner->sprite;
|
|
|
|
speedMo->frame = Owner->frame;
|
|
|
|
speedMo->floorclip = Owner->floorclip;
|
2007-01-09 16:32:44 +00:00
|
|
|
|
|
|
|
// [BC] Also get the scale from the owner.
|
|
|
|
speedMo->scaleX = Owner->scaleX;
|
|
|
|
speedMo->scaleY = Owner->scaleY;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner == players[consoleplayer].camera &&
|
|
|
|
!(Owner->player->cheats & CF_CHASECAM))
|
|
|
|
{
|
|
|
|
speedMo->renderflags |= RF_INVISIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Minotaur (aka Dark Servant) powerup ---------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerMinotaur)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Targeter powerup ---------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerTargeter)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void APowerTargeter::Travelled ()
|
|
|
|
{
|
|
|
|
InitEffect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void APowerTargeter::InitEffect ()
|
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if ((player = Owner->player) == NULL)
|
|
|
|
return;
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
FState *state = FindState("Targeter");
|
|
|
|
|
|
|
|
if (state != NULL)
|
|
|
|
{
|
|
|
|
P_SetPsprite (player, ps_targetcenter, state + 0);
|
|
|
|
P_SetPsprite (player, ps_targetleft, state + 1);
|
|
|
|
P_SetPsprite (player, ps_targetright, state + 2);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
player->psprites[ps_targetcenter].sx = (160-3)*FRACUNIT;
|
|
|
|
player->psprites[ps_targetcenter].sy =
|
|
|
|
player->psprites[ps_targetleft].sy =
|
|
|
|
player->psprites[ps_targetright].sy = (100-3)*FRACUNIT;
|
|
|
|
PositionAccuracy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void APowerTargeter::DoEffect ()
|
|
|
|
{
|
2007-01-12 15:24:10 +00:00
|
|
|
Super::DoEffect ();
|
|
|
|
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player = Owner->player;
|
|
|
|
|
|
|
|
PositionAccuracy ();
|
|
|
|
if (EffectTics < 5*TICRATE)
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
FState *state = FindState("Targeter");
|
|
|
|
|
|
|
|
if (state != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
if (EffectTics & 32)
|
|
|
|
{
|
|
|
|
P_SetPsprite (player, ps_targetright, NULL);
|
|
|
|
P_SetPsprite (player, ps_targetleft, state+1);
|
|
|
|
}
|
|
|
|
else if (EffectTics & 16)
|
|
|
|
{
|
|
|
|
P_SetPsprite (player, ps_targetright, state+2);
|
|
|
|
P_SetPsprite (player, ps_targetleft, NULL);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void APowerTargeter::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
|
|
|
{
|
|
|
|
P_SetPsprite (Owner->player, ps_targetcenter, NULL);
|
|
|
|
P_SetPsprite (Owner->player, ps_targetleft, NULL);
|
|
|
|
P_SetPsprite (Owner->player, ps_targetright, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void APowerTargeter::PositionAccuracy ()
|
|
|
|
{
|
|
|
|
player_t *player = Owner->player;
|
|
|
|
|
2007-10-05 08:04:38 +00:00
|
|
|
if (player != NULL)
|
|
|
|
{
|
2012-03-11 09:08:35 +00:00
|
|
|
player->psprites[ps_targetleft].sx = (160-3)*FRACUNIT - ((100 - player->mo->accuracy) << FRACBITS);
|
|
|
|
player->psprites[ps_targetright].sx = (160-3)*FRACUNIT + ((100 - player->mo->accuracy) << FRACBITS);
|
2007-10-05 08:04:38 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-13 12:41:15 +00:00
|
|
|
// Frightener Powerup --------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerFrightener)
|
2006-05-13 12:41:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFrightener :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerFrightener::InitEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2006-06-01 00:05:03 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
2006-05-13 12:41:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Owner->player->cheats |= CF_FRIGHTENING;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerFrightener :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerFrightener::EndEffect ()
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2006-06-01 00:05:03 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
2006-05-13 12:41:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Owner->player->cheats &= ~CF_FRIGHTENING;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Scanner powerup ----------------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APowerScanner)
|
2007-05-01 15:09:44 +00:00
|
|
|
|
|
|
|
// Time freezer powerup -----------------------------------------------------
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS( APowerTimeFreezer)
|
2007-05-01 15:09:44 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerTimeFreezer :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
void APowerTimeFreezer::InitEffect()
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
int freezemask;
|
2007-05-01 15:09:44 +00:00
|
|
|
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
if (Owner == NULL || Owner->player == NULL)
|
2007-10-05 08:04:38 +00:00
|
|
|
return;
|
|
|
|
|
2007-05-01 15:09:44 +00:00
|
|
|
// When this powerup is in effect, pause the music.
|
2012-04-27 01:40:50 +00:00
|
|
|
S_PauseSound(false, false);
|
2007-05-01 15:09:44 +00:00
|
|
|
|
|
|
|
// Give the player and his teammates the power to move when time is frozen.
|
2012-04-27 01:40:50 +00:00
|
|
|
freezemask = 1 << (Owner->player - players);
|
|
|
|
Owner->player->timefreezer |= freezemask;
|
|
|
|
for (int i = 0; i < MAXPLAYERS; i++)
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
if (playeringame[i] &&
|
|
|
|
players[i].mo != NULL &&
|
|
|
|
players[i].mo->IsTeammate(Owner)
|
2007-05-01 15:09:44 +00:00
|
|
|
)
|
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
players[i].timefreezer |= freezemask;
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-07 05:12:30 +00:00
|
|
|
// [RH] The effect ends one tic after the counter hits zero, so make
|
|
|
|
// sure we start at an odd count.
|
|
|
|
EffectTics += !(EffectTics & 1);
|
|
|
|
if ((EffectTics & 1) == 0)
|
|
|
|
{
|
|
|
|
EffectTics++;
|
|
|
|
}
|
|
|
|
// Make sure the effect starts and ends on an even tic.
|
|
|
|
if ((level.time & 1) == 0)
|
|
|
|
{
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_FROZEN;
|
2007-12-07 05:12:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EffectTics++;
|
|
|
|
}
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerTimeFreezer :: DoEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
void APowerTimeFreezer::DoEffect()
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2007-07-12 15:15:57 +00:00
|
|
|
Super::DoEffect();
|
2007-12-07 05:12:30 +00:00
|
|
|
// [RH] Do not change LEVEL_FROZEN on odd tics, or the Revenant's tracer
|
|
|
|
// will get thrown off.
|
2013-06-06 20:15:04 +00:00
|
|
|
// [ED850] Don't change it if the player is predicted either.
|
|
|
|
if (level.time & 1 || (Owner != NULL && Owner->player != NULL && Owner->player->cheats & CF_PREDICTING))
|
2007-12-07 05:12:30 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2007-12-08 22:29:59 +00:00
|
|
|
// [RH] The "blinking" can't check against EffectTics exactly or it will
|
|
|
|
// never happen, because InitEffect ensures that EffectTics will always
|
|
|
|
// be odd when level.time is even.
|
2007-05-01 15:09:44 +00:00
|
|
|
if ( EffectTics > 4*32
|
2007-12-08 22:29:59 +00:00
|
|
|
|| (( EffectTics > 3*32 && EffectTics <= 4*32 ) && ((EffectTics + 1) & 15) != 0 )
|
|
|
|
|| (( EffectTics > 2*32 && EffectTics <= 3*32 ) && ((EffectTics + 1) & 7) != 0 )
|
|
|
|
|| (( EffectTics > 32 && EffectTics <= 2*32 ) && ((EffectTics + 1) & 3) != 0 )
|
|
|
|
|| (( EffectTics > 0 && EffectTics <= 1*32 ) && ((EffectTics + 1) & 1) != 0 ))
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_FROZEN;
|
2007-05-01 15:09:44 +00:00
|
|
|
else
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 &= ~LEVEL2_FROZEN;
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerTimeFreezer :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
void APowerTimeFreezer::EndEffect()
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
int i;
|
2007-05-01 15:09:44 +00:00
|
|
|
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
// If there is an owner, remove the timefreeze flag corresponding to
|
|
|
|
// her from all players.
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
int freezemask = ~(1 << (Owner->player - players));
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
players[i].timefreezer &= freezemask;
|
|
|
|
}
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
// Are there any players who still have timefreezer bits set?
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
if (playeringame[i] && players[i].timefreezer != 0)
|
2007-05-01 15:09:44 +00:00
|
|
|
{
|
2012-04-27 01:40:50 +00:00
|
|
|
break;
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-27 01:40:50 +00:00
|
|
|
|
|
|
|
if (i == MAXPLAYERS)
|
|
|
|
{
|
|
|
|
// No, so allow other actors to move about freely once again.
|
|
|
|
level.flags2 &= ~LEVEL2_FROZEN;
|
|
|
|
|
|
|
|
// Also, turn the music back on.
|
|
|
|
S_ResumeSound(false);
|
|
|
|
}
|
2007-05-01 15:09:44 +00:00
|
|
|
}
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
// Damage powerup ------------------------------------------------------
|
|
|
|
|
2012-04-27 01:40:50 +00:00
|
|
|
IMPLEMENT_CLASS(APowerDamage)
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerDamage :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDamage::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
// Use sound channel 5 to avoid interference with other actions.
|
2008-06-15 02:25:09 +00:00
|
|
|
if (Owner != NULL) S_Sound(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerDamage :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDamage::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2007-05-10 22:22:38 +00:00
|
|
|
// Use sound channel 5 to avoid interference with other actions.
|
2008-06-15 02:25:09 +00:00
|
|
|
if (Owner != NULL) S_Sound(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2013-01-02 04:39:59 +00:00
|
|
|
// APowerDamage :: ModifyDamage
|
2007-05-10 22:22:38 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bool passive)
|
|
|
|
{
|
|
|
|
static const fixed_t def = 4*FRACUNIT;
|
|
|
|
if (!passive && damage > 0)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
const fixed_t *pdf = NULL;
|
|
|
|
DmgFactors *df = GetClass()->DamageFactors;
|
2008-10-07 18:21:03 +00:00
|
|
|
if (df != NULL && df->CountUsed() != 0)
|
2007-05-10 22:22:38 +00:00
|
|
|
{
|
2012-03-23 01:20:45 +00:00
|
|
|
pdf = df->CheckFactor(damageType);
|
2008-10-07 18:21:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pdf = &def;
|
|
|
|
}
|
|
|
|
if (pdf != NULL)
|
|
|
|
{
|
2007-05-10 22:22:38 +00:00
|
|
|
damage = newdamage = FixedMul(damage, *pdf);
|
|
|
|
if (*pdf > 0 && damage == 0) damage = newdamage = 1; // don't allow zero damage as result of an underflow
|
2008-06-15 02:25:09 +00:00
|
|
|
if (Owner != NULL && *pdf > FRACUNIT) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Inventory != NULL) Inventory->ModifyDamage(damage, damageType, newdamage, passive);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Quarter damage powerup ------------------------------------------------------
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
IMPLEMENT_CLASS(APowerProtection)
|
|
|
|
|
|
|
|
#define PROTECTION_FLAGS3 (MF3_NORADIUSDMG | MF3_DONTMORPH | MF3_DONTSQUASH | MF3_DONTBLAST | MF3_NOTELEOTHER)
|
|
|
|
#define PROTECTION_FLAGS5 (MF5_NOPAIN | MF5_DONTRIP)
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerProtection :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerProtection::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
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;
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerProtection :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerProtection::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2009-05-09 02:31:49 +00:00
|
|
|
if (Owner != NULL)
|
|
|
|
{
|
|
|
|
S_Sound(Owner, CHAN_AUTO, DeathSound, 1.0f, ATTN_NONE);
|
|
|
|
Owner->flags3 &= ~(flags3 & PROTECTION_FLAGS3);
|
|
|
|
Owner->flags5 &= ~(flags5 & PROTECTION_FLAGS5);
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerProtection :: AbsorbDamage
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage, bool passive)
|
|
|
|
{
|
|
|
|
static const fixed_t def = FRACUNIT/4;
|
|
|
|
if (passive && damage > 0)
|
|
|
|
{
|
2009-05-09 02:31:49 +00:00
|
|
|
const fixed_t *pdf = NULL;
|
2010-03-24 02:49:37 +00:00
|
|
|
DmgFactors *df = GetClass()->DamageFactors;
|
2008-10-07 18:21:03 +00:00
|
|
|
if (df != NULL && df->CountUsed() != 0)
|
2007-05-10 22:22:38 +00:00
|
|
|
{
|
2012-03-23 01:20:45 +00:00
|
|
|
pdf = df->CheckFactor(damageType);
|
2008-10-07 18:21:03 +00:00
|
|
|
}
|
|
|
|
else pdf = &def;
|
2007-05-10 22:22:38 +00:00
|
|
|
|
2008-10-07 18:21:03 +00:00
|
|
|
if (pdf != NULL)
|
|
|
|
{
|
2007-05-10 22:22:38 +00:00
|
|
|
damage = newdamage = FixedMul(damage, *pdf);
|
2009-05-09 02:31:49 +00:00
|
|
|
if (Owner != NULL && *pdf < FRACUNIT) S_Sound(Owner, CHAN_AUTO, ActiveSound, 1.0f, ATTN_NONE);
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-09 02:31:49 +00:00
|
|
|
if (Inventory != NULL)
|
|
|
|
{
|
|
|
|
Inventory->ModifyDamage(damage, damageType, newdamage, passive);
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Drain rune -------------------------------------------------------
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
IMPLEMENT_CLASS(APowerDrain)
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// ARuneDrain :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDrain::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2007-10-05 08:04:38 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
|
|
|
return;
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
// Give the player the power to drain life from opponents when he damages them.
|
|
|
|
Owner->player->cheats |= CF_DRAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// ARuneDrain :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDrain::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
// Nothing to do if there's no owner.
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
|
|
|
{
|
|
|
|
// Take away the drain power.
|
|
|
|
Owner->player->cheats &= ~CF_DRAIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Regeneration rune -------------------------------------------------------
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
IMPLEMENT_CLASS(APowerRegeneration)
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2012-05-11 04:05:55 +00:00
|
|
|
// APowerRegeneration :: DoEffect
|
2007-05-10 22:22:38 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-05-11 04:05:55 +00:00
|
|
|
void APowerRegeneration::DoEffect()
|
2007-05-10 22:22:38 +00:00
|
|
|
{
|
2012-05-11 04:05:55 +00:00
|
|
|
if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0)
|
2007-05-10 22:22:38 +00:00
|
|
|
{
|
2013-08-11 18:39:53 +00:00
|
|
|
if (P_GiveBody(Owner, Strength/FRACUNIT))
|
2012-05-11 04:05:55 +00:00
|
|
|
{
|
|
|
|
S_Sound(Owner, CHAN_ITEM, "*regenerate", 1, ATTN_NORM );
|
|
|
|
}
|
2007-05-10 22:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// High jump rune -------------------------------------------------------
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
IMPLEMENT_CLASS(APowerHighJump)
|
2007-05-10 22:22:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// ARuneHighJump :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerHighJump::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2007-10-05 08:04:38 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
|
|
|
return;
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
// Give the player the power to jump much higher.
|
|
|
|
Owner->player->cheats |= CF_HIGHJUMP;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// ARuneHighJump :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerHighJump::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2007-05-10 22:22:38 +00:00
|
|
|
// Nothing to do if there's no owner.
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
|
|
|
{
|
|
|
|
// Take away the high jump power.
|
|
|
|
Owner->player->cheats &= ~CF_HIGHJUMP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 01:16:39 +00:00
|
|
|
// Double firing speed rune ---------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS(APowerDoubleFiringSpeed)
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerDoubleFiringSpeed :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDoubleFiringSpeed::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2009-05-26 01:16:39 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Give the player the power to shoot twice as fast.
|
|
|
|
Owner->player->cheats |= CF_DOUBLEFIRINGSPEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerDoubleFiringSpeed :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerDoubleFiringSpeed::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
2009-05-26 01:16:39 +00:00
|
|
|
// Nothing to do if there's no owner.
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
|
|
|
{
|
|
|
|
// Take away the shooting twice as fast power.
|
|
|
|
Owner->player->cheats &= ~CF_DOUBLEFIRINGSPEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-08 08:53:42 +00:00
|
|
|
// Morph powerup ------------------------------------------------------
|
|
|
|
|
2009-05-09 02:31:49 +00:00
|
|
|
IMPLEMENT_CLASS(APowerMorph)
|
2008-04-08 08:53:42 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerMorph :: Serialize
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerMorph::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << PlayerClass << MorphStyle << MorphFlash << UnMorphFlash;
|
2008-05-22 19:35:38 +00:00
|
|
|
arc << Player;
|
2008-04-08 08:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerMorph :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerMorph::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2008-04-08 08:53:42 +00:00
|
|
|
if (Owner != NULL && Owner->player != NULL && PlayerClass != NAME_None)
|
|
|
|
{
|
|
|
|
player_t *realplayer = Owner->player; // Remember the identity of the player
|
2010-04-03 04:07:17 +00:00
|
|
|
PClassActor *morph_flash = PClass::FindActor(MorphFlash);
|
|
|
|
PClassActor *unmorph_flash = PClass::FindActor(UnMorphFlash);
|
2010-03-25 20:38:00 +00:00
|
|
|
PClassPlayerPawn *player_class = dyn_cast<PClassPlayerPawn>(PClass::FindClass (PlayerClass));
|
2008-04-12 15:31:18 +00:00
|
|
|
if (P_MorphPlayer(realplayer, realplayer, player_class, -1/*INDEFINITELY*/, MorphStyle, morph_flash, unmorph_flash))
|
2008-04-08 08:53:42 +00:00
|
|
|
{
|
|
|
|
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)
|
2008-05-22 19:35:38 +00:00
|
|
|
Player = realplayer; // Store the player identity (morphing clears the unmorphed actor's "player" field)
|
2008-04-08 08:53:42 +00:00
|
|
|
}
|
2008-04-12 15:31:18 +00:00
|
|
|
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)
|
|
|
|
}
|
2008-04-08 08:53:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerMorph :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerMorph::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
// Abort if owner already destroyed
|
|
|
|
if (Owner == NULL)
|
2008-04-08 08:53:42 +00:00
|
|
|
{
|
2008-05-22 19:35:38 +00:00
|
|
|
assert(Player == NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Abort if owner already unmorphed
|
|
|
|
if (Player == NULL)
|
|
|
|
{
|
|
|
|
return;
|
2008-04-08 08:53:42 +00:00
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
|
|
|
|
// Abort if owner is dead; their Die() method will
|
|
|
|
// take care of any required unmorphing on death.
|
|
|
|
if (Player->health <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unmorph if possible
|
2012-05-01 03:43:14 +00:00
|
|
|
if (!bNoCallUndoMorph)
|
|
|
|
{
|
|
|
|
int savedMorphTics = Player->morphTics;
|
|
|
|
P_UndoPlayerMorph (Player, Player);
|
2008-05-22 19:35:38 +00:00
|
|
|
|
2012-05-01 03:43:14 +00:00
|
|
|
// Abort if unmorph failed; in that case,
|
|
|
|
// set the usual retry timer and return.
|
|
|
|
if (Player != NULL && Player->morphTics)
|
|
|
|
{
|
|
|
|
// Transfer retry timeout
|
|
|
|
// to the powerup's timer.
|
|
|
|
EffectTics = Player->morphTics;
|
|
|
|
// Reload negative morph tics;
|
|
|
|
// use actual value; it may
|
|
|
|
// be in use for animation.
|
|
|
|
Player->morphTics = savedMorphTics;
|
|
|
|
// Try again some time later
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
// Unmorph suceeded
|
|
|
|
Player = NULL;
|
2008-04-08 08:53:42 +00:00
|
|
|
}
|
2009-06-07 16:38:19 +00:00
|
|
|
|
|
|
|
// Infinite Ammo Powerup -----------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS(APowerInfiniteAmmo)
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInfiniteAmmo :: InitEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInfiniteAmmo::InitEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::InitEffect();
|
|
|
|
|
2009-06-07 16:38:19 +00:00
|
|
|
if (Owner== NULL || Owner->player == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Give the player infinite ammo
|
|
|
|
Owner->player->cheats |= CF_INFINITEAMMO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// APowerInfiniteAmmo :: EndEffect
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void APowerInfiniteAmmo::EndEffect( )
|
|
|
|
{
|
2010-03-28 04:02:57 +00:00
|
|
|
Super::EndEffect();
|
|
|
|
|
2009-06-07 16:38:19 +00:00
|
|
|
// Nothing to do if there's no owner.
|
|
|
|
if (Owner != NULL && Owner->player != NULL)
|
|
|
|
{
|
|
|
|
// Take away the limitless ammo
|
|
|
|
Owner->player->cheats &= ~CF_INFINITEAMMO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|