- added DavidPH's damage type specific damage color submission.

SVN r3220 (trunk)
This commit is contained in:
Christoph Oelckers 2011-06-06 22:23:43 +00:00
parent 5df9af462a
commit 2e4e5bdb28
7 changed files with 50 additions and 8 deletions

View File

@ -907,6 +907,7 @@ public:
SWORD PainChance;
int PainThreshold;
FNameNoInit DamageType;
FNameNoInit DamageTypeReceived;
fixed_t DamageFactor;
FState *SpawnState;

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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)

View File

@ -171,6 +171,7 @@ struct FPlayerColorSet
typedef TMap<FName, fixed_t> DmgFactors;
typedef TMap<FName, int> PainChanceList;
typedef TMap<FName, PalEntry> PainFlashList;
typedef TMap<int, FPlayerColorSet> 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;
};

View File

@ -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.

View File

@ -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);
}
}