From bd601a1bc832de1340faf19d2cb5e1398815fb10 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 19 Feb 2013 02:44:49 +0000 Subject: [PATCH] - Added NOTRAIL flag for PowerSpeed. SVN r4146 (trunk) --- src/g_shared/a_artifacts.cpp | 40 ++++++++++++++++++++--- src/g_shared/a_artifacts.h | 5 +++ src/thingdef/thingdef_data.cpp | 7 ++++ wadsrc/static/actors/shared/inventory.txt | 2 +- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 4f44cfc20..dc45634df 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1156,6 +1156,24 @@ void APlayerSpeedTrail::Tick () IMPLEMENT_CLASS (APowerSpeed) +//=========================================================================== +// +// APowerSpeed :: Serialize +// +//=========================================================================== + +void APowerSpeed::Serialize(FArchive &arc) +{ + if (SaveVersion < 4146) + { + SpeedFlags = 0; + } + else + { + arc << SpeedFlags; + } +} + //=========================================================================== // // APowerSpeed :: GetSpeedFactor @@ -1164,8 +1182,10 @@ IMPLEMENT_CLASS (APowerSpeed) fixed_t APowerSpeed ::GetSpeedFactor () { - if (Inventory != NULL) return FixedMul(Speed, Inventory->GetSpeedFactor()); - else return Speed; + if (Inventory != NULL) + return FixedMul(Speed, Inventory->GetSpeedFactor()); + else + return Speed; } //=========================================================================== @@ -1184,12 +1204,22 @@ void APowerSpeed::DoEffect () 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. - if (Inventory != NULL && Inventory->GetSpeedFactor() > FRACUNIT) - 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(item)->SpeedFlags & PSF_NOTRAIL)) + { + return; + } + } if (P_AproxDistance (Owner->velx, Owner->vely) <= 12*FRACUNIT) return; diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index f8a806956..b8c66bb40 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -143,9 +143,14 @@ class APowerSpeed : public APowerup DECLARE_CLASS (APowerSpeed, APowerup) protected: void DoEffect (); + void Serialize(FArchive &arc); fixed_t GetSpeedFactor(); +public: + int SpeedFlags; }; +#define PSF_NOTRAIL 1 + class APowerMinotaur : public APowerup { DECLARE_CLASS (APowerMinotaur, APowerup) diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 1d828d647..68a17241b 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -338,12 +338,19 @@ static FFlagDef PlayerPawnFlags[] = DEFINE_FLAG(PPF, CANSUPERMORPH, APlayerPawn, PlayerFlags), }; +static FFlagDef PowerSpeedFlags[] = +{ + // PowerSpeed flags + DEFINE_FLAG(PSF, NOTRAIL, APowerSpeed, SpeedFlags), +}; + static const struct FFlagList { const PClass *Type; FFlagDef *Defs; int NumDefs; } FlagLists[] = { { RUNTIME_CLASS(AActor), ActorFlags, countof(ActorFlags) }, { RUNTIME_CLASS(AInventory), InventoryFlags, countof(InventoryFlags) }, { RUNTIME_CLASS(AWeapon), WeaponFlags, countof(WeaponFlags) }, { RUNTIME_CLASS(APlayerPawn), PlayerPawnFlags,countof(PlayerPawnFlags) }, + { RUNTIME_CLASS(APowerSpeed), PowerSpeedFlags,countof(PowerSpeedFlags) }, }; #define NUM_FLAG_LISTS (countof(FlagLists)) diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index 7ed28e22d..0632195c6 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -226,7 +226,7 @@ ACTOR PowerWeaponLevel2 : Powerup native Inventory.Icon "SPINBK0" } -ACTOR PowerSpeed: Powerup native +ACTOR PowerSpeed : Powerup native { Powerup.Duration -45 Speed 1.5