From 5b63fd067573f16808c810c1bcd5fc98dc3a02e4 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 16 Jul 2010 03:46:20 +0000 Subject: [PATCH] - Added an optional parameter to DamageScreenColor to scale the amount of damage for pain flash calculations. This can range from 0.0 to 1.0. SVN r2435 (trunk) --- src/g_shared/shared_sbar.cpp | 17 ++++++++++------- src/p_user.cpp | 4 ++++ src/thingdef/thingdef_properties.cpp | 11 ++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 8c0473832..ef48d211a 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1507,15 +1507,18 @@ void DBaseStatusBar::BlendView (float blend[4]) AddBlend (0.8431f, 0.7333f, 0.2706f, cnt > 128 ? 0.5f : cnt / 255.f, blend); } - cnt = DamageToAlpha[MIN (113, CPlayer->damagecount)]; - - if (cnt) + if (CPlayer->mo->DamageFade.a != 0) { - if (cnt > 228) - cnt = 228; + cnt = DamageToAlpha[MIN (113, CPlayer->damagecount * CPlayer->mo->DamageFade.a / 255)]; + + if (cnt) + { + if (cnt > 228) + cnt = 228; - APlayerPawn *mo = players[consoleplayer].mo; - AddBlend (mo->DamageFade.r / 255.f, mo->DamageFade.g / 255.f, mo->DamageFade.b / 255.f, cnt / 255.f, blend); + APlayerPawn *mo = CPlayer->mo; + AddBlend (mo->DamageFade.r / 255.f, mo->DamageFade.g / 255.f, mo->DamageFade.b / 255.f, cnt / 255.f, blend); + } } // Unlike Doom, I did not have any utility source to look at to find the diff --git a/src/p_user.cpp b/src/p_user.cpp index a350babab..65909b3d3 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -426,6 +426,10 @@ void APlayerPawn::Serialize (FArchive &arc) << MorphWeapon << DamageFade << PlayerFlags; + if (SaveVersion < 2435) + { + DamageFade.a = 255; + } } //=========================================================================== diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index f58eb6500..db620c5c7 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2094,10 +2094,19 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, crouchsprite, S, PlayerPawn) //========================================================================== // //========================================================================== -DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, C, PlayerPawn) +DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cf, PlayerPawn) { PROP_COLOR_PARM(c, 0); defaults->DamageFade = c; + if (PROP_PARM_COUNT < 3) // Because colors count as 2 parms + { + defaults->DamageFade.a = 255; + } + else + { + PROP_FLOAT_PARM(a, 2); + defaults->DamageFade.a = BYTE(255 * clamp(a, 0.f, 1.f)); + } } //==========================================================================