mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- added DavidPH's damage type specific damage color submission.
SVN r3220 (trunk)
This commit is contained in:
parent
5df9af462a
commit
2e4e5bdb28
7 changed files with 50 additions and 8 deletions
|
@ -907,6 +907,7 @@ public:
|
||||||
SWORD PainChance;
|
SWORD PainChance;
|
||||||
int PainThreshold;
|
int PainThreshold;
|
||||||
FNameNoInit DamageType;
|
FNameNoInit DamageType;
|
||||||
|
FNameNoInit DamageTypeReceived;
|
||||||
fixed_t DamageFactor;
|
fixed_t DamageFactor;
|
||||||
|
|
||||||
FState *SpawnState;
|
FState *SpawnState;
|
||||||
|
|
|
@ -336,6 +336,7 @@ PClass *PClass::CreateDerivedClass (FName name, unsigned int size)
|
||||||
info->StateList = NULL;
|
info->StateList = NULL;
|
||||||
info->DamageFactors = NULL;
|
info->DamageFactors = NULL;
|
||||||
info->PainChances = NULL;
|
info->PainChances = NULL;
|
||||||
|
info->PainFlashes = NULL;
|
||||||
info->ColorSets = NULL;
|
info->ColorSets = NULL;
|
||||||
m_RuntimeActors.Push (type);
|
m_RuntimeActors.Push (type);
|
||||||
}
|
}
|
||||||
|
@ -430,6 +431,7 @@ void PClass::InitializeActorInfo ()
|
||||||
info->StateList = NULL;
|
info->StateList = NULL;
|
||||||
info->DamageFactors = NULL;
|
info->DamageFactors = NULL;
|
||||||
info->PainChances = NULL;
|
info->PainChances = NULL;
|
||||||
|
info->PainFlashes = NULL;
|
||||||
info->ColorSets = NULL;
|
info->ColorSets = NULL;
|
||||||
m_RuntimeActors.Push (this);
|
m_RuntimeActors.Push (this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1546,17 +1546,26 @@ void DBaseStatusBar::BlendView (float blend[4])
|
||||||
BPART(gameinfo.pickupcolor)/255.f, cnt > 128 ? 0.5f : cnt / 255.f, blend);
|
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)
|
||||||
{
|
{
|
||||||
if (cnt > 228)
|
if (cnt > 228)
|
||||||
cnt = 228;
|
cnt = 228;
|
||||||
|
|
||||||
APlayerPawn *mo = CPlayer->mo;
|
AddBlend (painFlash.r / 255.f, painFlash.g / 255.f, painFlash.b / 255.f, cnt / 255.f, blend);
|
||||||
AddBlend (mo->DamageFade.r / 255.f, mo->DamageFade.g / 255.f, mo->DamageFade.b / 255.f, cnt / 255.f, blend);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/info.cpp
13
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)
|
void FActorInfo::SetColorSet(int index, const FPlayerColorSet *set)
|
||||||
{
|
{
|
||||||
if (set != NULL)
|
if (set != NULL)
|
||||||
|
|
|
@ -171,6 +171,7 @@ struct FPlayerColorSet
|
||||||
|
|
||||||
typedef TMap<FName, fixed_t> DmgFactors;
|
typedef TMap<FName, fixed_t> DmgFactors;
|
||||||
typedef TMap<FName, int> PainChanceList;
|
typedef TMap<FName, int> PainChanceList;
|
||||||
|
typedef TMap<FName, PalEntry> PainFlashList;
|
||||||
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
||||||
|
|
||||||
struct FActorInfo
|
struct FActorInfo
|
||||||
|
@ -183,6 +184,7 @@ struct FActorInfo
|
||||||
void RegisterIDs ();
|
void RegisterIDs ();
|
||||||
void SetDamageFactor(FName type, fixed_t factor);
|
void SetDamageFactor(FName type, fixed_t factor);
|
||||||
void SetPainChance(FName type, int chance);
|
void SetPainChance(FName type, int chance);
|
||||||
|
void SetPainFlash(FName type, PalEntry color);
|
||||||
void SetColorSet(int index, const FPlayerColorSet *set);
|
void SetColorSet(int index, const FPlayerColorSet *set);
|
||||||
|
|
||||||
FState *FindState (int numnames, FName *names, bool exact=false) const;
|
FState *FindState (int numnames, FName *names, bool exact=false) const;
|
||||||
|
@ -206,6 +208,7 @@ struct FActorInfo
|
||||||
FStateLabels *StateList;
|
FStateLabels *StateList;
|
||||||
DmgFactors *DamageFactors;
|
DmgFactors *DamageFactors;
|
||||||
PainChanceList *PainChances;
|
PainChanceList *PainChances;
|
||||||
|
PainFlashList *PainFlashes;
|
||||||
FPlayerColorSetMap *ColorSets;
|
FPlayerColorSetMap *ColorSets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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
|
// If the damaging player has the power of drain, give the player 50% of the damage
|
||||||
// done in health.
|
// done in health.
|
||||||
|
|
|
@ -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);
|
PROP_COLOR_PARM(c, 0);
|
||||||
defaults->DamageFade = c;
|
|
||||||
|
PalEntry color = c;
|
||||||
|
|
||||||
if (PROP_PARM_COUNT < 3) // Because colors count as 2 parms
|
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
|
else
|
||||||
{
|
{
|
||||||
PROP_FLOAT_PARM(a, 2);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue