mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
- Fixed: Armor did not use damagefactor "Normal" as a fallback factor.
SVN r3469 (trunk)
This commit is contained in:
parent
bff5a9b8d8
commit
9fcc6ebc89
5 changed files with 29 additions and 10 deletions
|
@ -171,13 +171,13 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
|
||||||
if ((damage > 0) && (ArmorType != NAME_None)) // BasicArmor is not going to have any damage factor, so skip it.
|
if ((damage > 0) && (ArmorType != NAME_None)) // BasicArmor is not going to have any damage factor, so skip it.
|
||||||
{
|
{
|
||||||
// This code is taken and adapted from APowerProtection::ModifyDamage().
|
// This code is taken and adapted from APowerProtection::ModifyDamage().
|
||||||
// The differences include not checking for the NAME_None key (doesn't seem appropriate here),
|
// The differences include not using a default value, and of course the way
|
||||||
// not using a default value, and of course the way the damage factor info is obtained.
|
// the damage factor info is obtained.
|
||||||
const fixed_t *pdf = NULL;
|
const fixed_t *pdf = NULL;
|
||||||
DmgFactors *df = PClass::FindClass(ArmorType)->ActorInfo->DamageFactors;
|
DmgFactors *df = PClass::FindClass(ArmorType)->ActorInfo->DamageFactors;
|
||||||
if (df != NULL && df->CountUsed() != 0)
|
if (df != NULL && df->CountUsed() != 0)
|
||||||
{
|
{
|
||||||
pdf = df->CheckKey(damageType);
|
pdf = df->CheckFactor(damageType);
|
||||||
if (pdf != NULL)
|
if (pdf != NULL)
|
||||||
{
|
{
|
||||||
damage = newdamage = FixedMul(damage, *pdf);
|
damage = newdamage = FixedMul(damage, *pdf);
|
||||||
|
|
|
@ -1511,8 +1511,7 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo
|
||||||
DmgFactors * df = GetClass()->ActorInfo->DamageFactors;
|
DmgFactors * df = GetClass()->ActorInfo->DamageFactors;
|
||||||
if (df != NULL && df->CountUsed() != 0)
|
if (df != NULL && df->CountUsed() != 0)
|
||||||
{
|
{
|
||||||
pdf = df->CheckKey(damageType);
|
pdf = df->CheckFactor(damageType);
|
||||||
if (pdf== NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1592,8 +1591,7 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage
|
||||||
DmgFactors *df = GetClass()->ActorInfo->DamageFactors;
|
DmgFactors *df = GetClass()->ActorInfo->DamageFactors;
|
||||||
if (df != NULL && df->CountUsed() != 0)
|
if (df != NULL && df->CountUsed() != 0)
|
||||||
{
|
{
|
||||||
pdf = df->CheckKey(damageType);
|
pdf = df->CheckFactor(damageType);
|
||||||
if (pdf == NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None);
|
|
||||||
}
|
}
|
||||||
else pdf = &def;
|
else pdf = &def;
|
||||||
|
|
||||||
|
|
19
src/info.cpp
19
src/info.cpp
|
@ -344,6 +344,25 @@ void FActorInfo::SetColorSet(int index, const FPlayerColorSet *set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// DmgFactors :: CheckFactor
|
||||||
|
//
|
||||||
|
// Checks for the existance of a certain damage type. If that type does not
|
||||||
|
// exist, the damage factor for type 'None' will be returned, if present.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
fixed_t *DmgFactors::CheckFactor(FName type)
|
||||||
|
{
|
||||||
|
fixed_t *pdf = CheckKey(type);
|
||||||
|
if (pdf == NULL && type != NAME_None)
|
||||||
|
{
|
||||||
|
pdf = CheckKey(NAME_None);
|
||||||
|
}
|
||||||
|
return pdf;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
|
@ -177,7 +177,10 @@ struct FPlayerColorSet
|
||||||
ExtraRange Extra[6];
|
ExtraRange Extra[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TMap<FName, fixed_t> DmgFactors;
|
struct DmgFactors : public TMap<FName, fixed_t>
|
||||||
|
{
|
||||||
|
fixed_t *CheckFactor(FName type);
|
||||||
|
};
|
||||||
typedef TMap<FName, int> PainChanceList;
|
typedef TMap<FName, int> PainChanceList;
|
||||||
typedef TMap<FName, PalEntry> PainFlashList;
|
typedef TMap<FName, PalEntry> PainFlashList;
|
||||||
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
||||||
|
|
|
@ -1000,8 +1000,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
|
||||||
DmgFactors *df = target->GetClass()->ActorInfo->DamageFactors;
|
DmgFactors *df = target->GetClass()->ActorInfo->DamageFactors;
|
||||||
if (df != NULL)
|
if (df != NULL)
|
||||||
{
|
{
|
||||||
fixed_t *pdf = df->CheckKey(mod);
|
fixed_t *pdf = df->CheckFactor(mod);
|
||||||
if (pdf== NULL && mod != NAME_None) pdf = df->CheckKey(NAME_None);
|
|
||||||
if (pdf != NULL)
|
if (pdf != NULL)
|
||||||
{
|
{
|
||||||
damage = FixedMul(damage, *pdf);
|
damage = FixedMul(damage, *pdf);
|
||||||
|
|
Loading…
Reference in a new issue