From 2e4e5bdb28de5ce9c71b50ccb72d471d30a572ee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Jun 2011 22:23:43 +0000 Subject: [PATCH] - added DavidPH's damage type specific damage color submission. SVN r3220 (trunk) --- src/actor.h | 1 + src/dobjtype.cpp | 2 ++ src/g_shared/shared_sbar.cpp | 17 +++++++++++++---- src/info.cpp | 13 +++++++++++++ src/info.h | 3 +++ src/p_interaction.cpp | 1 + src/thingdef/thingdef_properties.cpp | 21 +++++++++++++++++---- 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/actor.h b/src/actor.h index c41403004..05a7c0965 100644 --- a/src/actor.h +++ b/src/actor.h @@ -907,6 +907,7 @@ public: SWORD PainChance; int PainThreshold; FNameNoInit DamageType; + FNameNoInit DamageTypeReceived; fixed_t DamageFactor; FState *SpawnState; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 232e91f30..32df6a537 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -336,6 +336,7 @@ PClass *PClass::CreateDerivedClass (FName name, unsigned int size) info->StateList = NULL; info->DamageFactors = NULL; info->PainChances = NULL; + info->PainFlashes = NULL; info->ColorSets = NULL; m_RuntimeActors.Push (type); } @@ -430,6 +431,7 @@ void PClass::InitializeActorInfo () info->StateList = NULL; info->DamageFactors = NULL; info->PainChances = NULL; + info->PainFlashes = NULL; info->ColorSets = NULL; m_RuntimeActors.Push (this); } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 3091d63e3..b1dff41b9 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1546,17 +1546,26 @@ void DBaseStatusBar::BlendView (float blend[4]) BPART(gameinfo.pickupcolor)/255.f, cnt > 128 ? 0.5f : cnt / 255.f, blend); } - if (CPlayer->mo->DamageFade.a != 0) + PainFlashList * pfl = CPlayer->mo->GetClass()->ActorInfo->PainFlashes; + PalEntry painFlash = CPlayer->mo->DamageFade; + + if (pfl) { - cnt = DamageToAlpha[MIN (113, CPlayer->damagecount * CPlayer->mo->DamageFade.a / 255)]; + PalEntry * color = pfl->CheckKey(CPlayer->mo->DamageTypeReceived); + + if (color) painFlash = *color; + } + + if (painFlash.a != 0) + { + cnt = DamageToAlpha[MIN (113, CPlayer->damagecount * painFlash.a / 255)]; if (cnt) { if (cnt > 228) cnt = 228; - APlayerPawn *mo = CPlayer->mo; - AddBlend (mo->DamageFade.r / 255.f, mo->DamageFade.g / 255.f, mo->DamageFade.b / 255.f, cnt / 255.f, blend); + AddBlend (painFlash.r / 255.f, painFlash.g / 255.f, painFlash.b / 255.f, cnt / 255.f, blend); } } diff --git a/src/info.cpp b/src/info.cpp index 32aa92a91..21e756369 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -313,6 +313,19 @@ void FActorInfo::SetPainChance(FName type, int chance) // //========================================================================== +void FActorInfo::SetPainFlash(FName type, PalEntry color) +{ + if (PainFlashes == NULL) + PainFlashes = new PainFlashList; + + PainFlashes->Insert(type, color); +} + +//========================================================================== +// +// +//========================================================================== + void FActorInfo::SetColorSet(int index, const FPlayerColorSet *set) { if (set != NULL) diff --git a/src/info.h b/src/info.h index 9480f5f59..c2d4f4cc2 100644 --- a/src/info.h +++ b/src/info.h @@ -171,6 +171,7 @@ struct FPlayerColorSet typedef TMap DmgFactors; typedef TMap PainChanceList; +typedef TMap PainFlashList; typedef TMap FPlayerColorSetMap; struct FActorInfo @@ -183,6 +184,7 @@ struct FActorInfo void RegisterIDs (); void SetDamageFactor(FName type, fixed_t factor); void SetPainChance(FName type, int chance); + void SetPainFlash(FName type, PalEntry color); void SetColorSet(int index, const FPlayerColorSet *set); FState *FindState (int numnames, FName *names, bool exact=false) const; @@ -206,6 +208,7 @@ struct FActorInfo FStateLabels *StateList; DmgFactors *DamageFactors; PainChanceList *PainChances; + PainFlashList *PainFlashes; FPlayerColorSetMap *ColorSets; }; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 82ee2f221..0306f866a 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1210,6 +1210,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage // // the damage has been dealt; now deal with the consequences // + target->DamageTypeReceived = mod; // If the damaging player has the power of drain, give the player 50% of the damage // done in health. diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index e7601ba74..d871c1b5b 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2128,18 +2128,31 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, crouchsprite, S, PlayerPawn) //========================================================================== // //========================================================================== -DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cf, PlayerPawn) +DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn) { PROP_COLOR_PARM(c, 0); - defaults->DamageFade = c; + + PalEntry color = c; + if (PROP_PARM_COUNT < 3) // Because colors count as 2 parms { - defaults->DamageFade.a = 255; + color.a = 255; + defaults->DamageFade = color; + } + else if (PROP_PARM_COUNT < 4) + { + PROP_FLOAT_PARM(a, 2); + + color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + defaults->DamageFade = color; } else { PROP_FLOAT_PARM(a, 2); - defaults->DamageFade.a = BYTE(255 * clamp(a, 0.f, 1.f)); + PROP_STRING_PARM(type, 3); + + color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + info->SetPainFlash(type, color); } }