From e90b86acce759fcecbe576e3054b4b83f4592441 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 Jan 2011 11:16:46 +0000 Subject: [PATCH] - added 'player.flechettetype' property so that the appropriate flechette type can be set per player class. - bumped savegame version for flechette type changes. SVN r3085 (trunk) --- src/d_player.h | 1 + src/g_game.cpp | 26 +++++++---- src/g_hexen/a_flechette.cpp | 51 ++++++++++----------- src/p_user.cpp | 3 +- src/thingdef/thingdef_properties.cpp | 13 +++++- src/version.h | 2 +- wadsrc/static/actors/hexen/clericplayer.txt | 1 + wadsrc/static/actors/hexen/mageplayer.txt | 1 + wadsrc/static/actors/shared/player.txt | 1 + 9 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 6f414e1ff..74a3b8a24 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -137,6 +137,7 @@ public: int SpawnMask; FNameNoInit MorphWeapon; fixed_t AttackZOffset; // attack height, relative to player center + const PClass *FlechetteType; // [CW] Fades for when you are being damaged. PalEntry DamageFade; diff --git a/src/g_game.cpp b/src/g_game.cpp index 1d735ee03..1c2a6e516 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -455,6 +455,8 @@ CCMD (drop) } } +const PClass *GetFlechetteType(AActor *other); + CCMD (useflechette) { // Select from one of arti_poisonbag1-3, whichever the player has static const ENamedName bagnames[3] = @@ -463,22 +465,26 @@ CCMD (useflechette) NAME_ArtiPoisonBag2, NAME_ArtiPoisonBag3 }; - int i, j; if (who == NULL) return; - if (who->IsKindOf (PClass::FindClass (NAME_ClericPlayer))) - i = 0; - else if (who->IsKindOf (PClass::FindClass (NAME_MagePlayer))) - i = 1; - else - i = 2; - - for (j = 0; j < 3; ++j) + const PClass *type = GetFlechetteType(who); + if (type != NULL) { AInventory *item; - if ( (item = who->FindInventory (bagnames[(i+j)%3])) ) + if ( (item = who->FindInventory (type) )) + { + SendItemUse = item; + return; + } + } + + // The default flechette could not be found. Try all 3 types then. + for (int j = 0; j < 3; ++j) + { + AInventory *item; + if ( (item = who->FindInventory (bagnames[j])) ) { SendItemUse = item; break; diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index ea72cb208..b99ec9793 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -141,6 +141,27 @@ bool AArtiPoisonBag3::Use (bool pickup) return false; } +//============================================================================ +// +// GetFlechetteType +// +//============================================================================ + +const PClass *GetFlechetteType(AActor *other) +{ + const PClass *spawntype = NULL; + if (other->IsKindOf(RUNTIME_CLASS(APlayerPawn))) + { + spawntype = static_cast(other)->FlechetteType; + } + if (spawntype == NULL) + { + // default fallback if nothing valid defined. + spawntype = RUNTIME_CLASS(AArtiPoisonBag3); + } + return spawntype; +} + //============================================================================ // // AArtiPoisonBag :: HandlePickup @@ -155,21 +176,7 @@ bool AArtiPoisonBag::HandlePickup (AInventory *item) return Super::HandlePickup (item); } - bool matched; - - if (Owner->IsKindOf (PClass::FindClass(NAME_ClericPlayer))) - { - matched = (GetClass() == RUNTIME_CLASS(AArtiPoisonBag1)); - } - else if (Owner->IsKindOf (PClass::FindClass(NAME_MagePlayer))) - { - matched = (GetClass() == RUNTIME_CLASS(AArtiPoisonBag2)); - } - else - { - matched = (GetClass() == RUNTIME_CLASS(AArtiPoisonBag3)); - } - if (matched) + if (GetClass() == GetFlechetteType(Owner)) { if (Amount < MaxAmount) { @@ -204,20 +211,8 @@ AInventory *AArtiPoisonBag::CreateCopy (AActor *other) } AInventory *copy; - const PClass *spawntype; - if (other->IsKindOf (PClass::FindClass(NAME_ClericPlayer))) - { - spawntype = RUNTIME_CLASS(AArtiPoisonBag1); - } - else if (other->IsKindOf (PClass::FindClass(NAME_MagePlayer))) - { - spawntype = RUNTIME_CLASS(AArtiPoisonBag2); - } - else - { - spawntype = RUNTIME_CLASS(AArtiPoisonBag3); - } + const PClass *spawntype = GetFlechetteType(other); copy = static_cast(Spawn (spawntype, 0, 0, 0, NO_REPLACE)); copy->Amount = Amount; copy->MaxAmount = MaxAmount; diff --git a/src/p_user.cpp b/src/p_user.cpp index 831d65dd5..d18a31b6a 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -432,7 +432,8 @@ void APlayerPawn::Serialize (FArchive &arc) << InvSel << MorphWeapon << DamageFade - << PlayerFlags; + << PlayerFlags + << FlechetteType; } //=========================================================================== diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index ad7bde72d..f7221c435 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -601,11 +601,11 @@ DEFINE_PROPERTY(renderstyle, S, Actor) { PROP_STRING_PARM(str, 0); static const char * renderstyles[]={ - "NONE","NORMAL","FUZZY","SOULTRANS","OPTFUZZY","STENCIL","TRANSLUCENT", "ADD", "SHADED", "SHADOW", NULL}; + "NONE","NORMAL","FUZZY","SOULTRANS","OPTFUZZY","STENCIL","TRANSLUCENT", "ADD","SHADED", NULL}; static const int renderstyle_values[]={ STYLE_None, STYLE_Normal, STYLE_Fuzzy, STYLE_SoulTrans, STYLE_OptFuzzy, - STYLE_TranslucentStencil, STYLE_Translucent, STYLE_Add, STYLE_Shaded, STYLE_Shadow}; + STYLE_TranslucentStencil, STYLE_Translucent, STYLE_Add, STYLE_Shaded}; // make this work for old style decorations, too. if (!strnicmp(str, "style_", 6)) str+=6; @@ -2070,6 +2070,15 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, morphweapon, S, PlayerPawn) defaults->MorphWeapon = FName(z); } +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY_PREFIX(player, flechettetype, S, PlayerPawn) +{ + PROP_STRING_PARM(str, 0); + defaults->FlechetteType = FindClassTentative(str, "ArtiPoisonBag"); +} + //========================================================================== // //========================================================================== diff --git a/src/version.h b/src/version.h index 32cd44b39..bc6abfa29 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 3030 +#define MINSAVEVER 3085 #if SVN_REVISION_NUMBER < MINSAVEVER // If we don't know the current revision write something very high to ensure that diff --git a/wadsrc/static/actors/hexen/clericplayer.txt b/wadsrc/static/actors/hexen/clericplayer.txt index 73276e981..6e1658594 100644 --- a/wadsrc/static/actors/hexen/clericplayer.txt +++ b/wadsrc/static/actors/hexen/clericplayer.txt @@ -28,6 +28,7 @@ ACTOR ClericPlayer : PlayerPawn Player.WeaponSlot 2, CWeapStaff Player.WeaponSlot 3, CWeapFlame Player.WeaponSlot 4, CWeapWraithverge + Player.FlechetteType "ArtiPoisonBag1" Player.ColorRange 146, 163 Player.Colorset 0, "Blue", 146, 163, 161 diff --git a/wadsrc/static/actors/hexen/mageplayer.txt b/wadsrc/static/actors/hexen/mageplayer.txt index d843b00a9..1690cbf72 100644 --- a/wadsrc/static/actors/hexen/mageplayer.txt +++ b/wadsrc/static/actors/hexen/mageplayer.txt @@ -30,6 +30,7 @@ ACTOR MagePlayer : PlayerPawn Player.WeaponSlot 2, MWeapFrost Player.WeaponSlot 3, MWeapLightning Player.WeaponSlot 4, MWeapBloodscourge + Player.FlechetteType "ArtiPoisonBag2" Player.ColorRange 146, 163 Player.Colorset 0, "Blue", 146, 163, 161 diff --git a/wadsrc/static/actors/shared/player.txt b/wadsrc/static/actors/shared/player.txt index 194e58048..2752412e7 100644 --- a/wadsrc/static/actors/shared/player.txt +++ b/wadsrc/static/actors/shared/player.txt @@ -28,6 +28,7 @@ Actor PlayerPawn : Actor native Player.SoundClass "player" Player.DamageScreenColor "ff 00 00" Player.MugShotMaxHealth 0 + Player.FlechetteType "ArtiPoisonBag3" } Actor PlayerChunk : PlayerPawn native