- partially scriptified APowerSpeed.

This commit is contained in:
Christoph Oelckers 2017-01-15 20:58:52 +01:00
parent 7503937a84
commit 4837e1e770
4 changed files with 83 additions and 61 deletions

View file

@ -1250,63 +1250,6 @@ void APowerSpeed::Serialize(FSerializer &arc)
arc("speedflags", SpeedFlags);
}
//===========================================================================
//
// APowerSpeed :: DoEffect
//
//===========================================================================
void APowerSpeed::DoEffect ()
{
Super::DoEffect ();
if (Owner == NULL || Owner->player == NULL)
return;
if (Owner->player->cheats & CF_PREDICTING)
return;
if (SpeedFlags & PSF_NOTRAIL)
return;
if (level.time & 1)
return;
// 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;
}
}
if (Owner->Vel.LengthSquared() <= 12*12)
return;
AActor *speedMo = Spawn("PlayerSpeedTrail", Owner->Pos(), NO_REPLACE);
if (speedMo)
{
speedMo->Angles.Yaw = Owner->Angles.Yaw;
speedMo->Translation = Owner->Translation;
speedMo->target = Owner;
speedMo->sprite = Owner->sprite;
speedMo->frame = Owner->frame;
speedMo->Floorclip = Owner->Floorclip;
// [BC] Also get the scale from the owner.
speedMo->Scale = Owner->Scale;
if (Owner == players[consoleplayer].camera &&
!(Owner->player->cheats & CF_CHASECAM))
{
speedMo->renderflags |= RF_INVISIBLE;
}
}
}
// Morph powerup ------------------------------------------------------
IMPLEMENT_CLASS(APowerMorph, false, true)

View file

@ -152,8 +152,6 @@ class APowerSpeed : public APowerup
{
DECLARE_CLASS (APowerSpeed, APowerup)
protected:
virtual void DoEffect () override;
virtual void Serialize(FSerializer &arc) override;
public:
int SpeedFlags;

View file

@ -472,7 +472,7 @@ static const struct FFlagList { const PClass * const *Type; FFlagDef *Defs; int
{ &RUNTIME_CLASS_CASTLESS(AInventory), InventoryFlagDefs, countof(InventoryFlagDefs), 3 },
{ &RUNTIME_CLASS_CASTLESS(AWeapon), WeaponFlagDefs, countof(WeaponFlagDefs), 3 },
{ &RUNTIME_CLASS_CASTLESS(APlayerPawn), PlayerPawnFlagDefs, countof(PlayerPawnFlagDefs), 3 },
{ &RUNTIME_CLASS_CASTLESS(APowerSpeed), PowerSpeedFlagDefs, countof(PowerSpeedFlagDefs), 3 },
{ &RUNTIME_CLASS_CASTLESS(APowerSpeed), PowerSpeedFlagDefs, countof(PowerSpeedFlagDefs), 1 },
};
#define NUM_FLAG_LISTS (countof(FlagLists))

View file

@ -133,9 +133,18 @@ class PowerWeaponLevel2 : Powerup native
}
}
//===========================================================================
//
// Speed
//
//===========================================================================
class PowerSpeed : Powerup native
{
native int SpeedFlags;
const PSF_NOTRAIL = 1;
Default
{
@ -145,7 +154,67 @@ class PowerSpeed : Powerup native
+INVENTORY.NOTELEPORTFREEZE
}
override double GetSpeedFactor() { return Speed; }
override double GetSpeedFactor()
{
return Speed;
}
//===========================================================================
//
// APowerSpeed :: DoEffect
//
//===========================================================================
override void DoEffect ()
{
Super.DoEffect ();
if (Owner == NULL || Owner.player == NULL)
return;
if (Owner.player.cheats & CF_PREDICTING)
return;
if (SpeedFlags & PSF_NOTRAIL)
return;
if (level.time & 1)
return;
// 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 (Inventory item = Inv; item != NULL; item = item.Inv)
{
let sitem = PowerSpeed(item);
if (sitem != null && !(sitem.SpeedFlags & PSF_NOTRAIL))
{
return;
}
}
if (Owner.Vel.Length() <= 12)
return;
Actor speedMo = Spawn("PlayerSpeedTrail", Owner.Pos, NO_REPLACE);
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;
// [BC] Also get the scale from the owner.
speedMo.Scale = Owner.Scale;
if (Owner == players[consoleplayer].camera &&
!(Owner.player.cheats & CF_CHASECAM))
{
speedMo.bInvisible = true;
}
}
}
}
// Player Speed Trail (used by the Speed Powerup) ----------------------------
@ -170,6 +239,12 @@ class PlayerSpeedTrail : Actor
}
}
//===========================================================================
//
// Minotaur
//
//===========================================================================
class PowerMinotaur : Powerup
{
Default
@ -179,6 +254,12 @@ class PowerMinotaur : Powerup
}
}
//===========================================================================
//
// Targeter
//
//===========================================================================
class PowerTargeter : Powerup
{
Default