diff --git a/src/info.cpp b/src/info.cpp index c15bf0a94..a1dd4723e 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -562,7 +562,6 @@ DamageTypeDefinition *DamageTypeDefinition::Get(FName const type) bool DamageTypeDefinition::IgnoreArmor(FName const type) { - if (type == NAME_Drowning) return true; DamageTypeDefinition *dtd = Get(type); if (dtd) return dtd->NoArmor; return false; @@ -609,12 +608,11 @@ int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const type, Dm { fixed_t const *pdf = factors->CheckKey(NAME_None); + DamageTypeDefinition *dtd = Get(type); // Here we are looking for modifications to untyped damage // If the calling actor defines untyped damage factor, that is contained in "pdf". if (pdf) // normal damage available { - DamageTypeDefinition *dtd = Get(type); - if (dtd) { if (dtd->ReplaceFactor) return FixedMul(damage, dtd->DefaultFactor); // use default instead of untyped factor @@ -622,6 +620,10 @@ int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const type, Dm } return FixedMul(damage, *pdf); // there was no default, so actor default is used } + else if (dtd) + { + return FixedMul(damage, dtd->DefaultFactor); // implicit untyped factor 1.0 does not need to be applied/replaced explicitly + } } return damage; } diff --git a/src/info.h b/src/info.h index 7fcdeca9b..ff59a4656 100644 --- a/src/info.h +++ b/src/info.h @@ -201,7 +201,7 @@ public: void Apply(FName const type); void Clear() { - DefaultFactor = (fixed_t)1; + DefaultFactor = FRACUNIT; ReplaceFactor = false; NoArmor = false; } diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 1b820f9bb..a15c18e16 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -1202,7 +1202,7 @@ static void ParseDamageDefinition(FScanner &sc) if (sc.Compare("FACTOR")) { sc.MustGetFloat(); - dtd.DefaultFactor = (fixed_t)sc.Float; + dtd.DefaultFactor = FLOAT2FIXED(sc.Float); if (!dtd.DefaultFactor) dtd.ReplaceFactor = true; // Multiply by 0 yields 0: FixedMul(damage, FixedMul(factor, 0)) is more wasteful than FixedMul(factor, 0) } else if (sc.Compare("REPLACEFACTOR")) diff --git a/wadsrc/static/actors/shared/damagetypes.txt b/wadsrc/static/actors/shared/damagetypes.txt new file mode 100644 index 000000000..7ba83564d --- /dev/null +++ b/wadsrc/static/actors/shared/damagetypes.txt @@ -0,0 +1,4 @@ +damagetype Drowning +{ + NoArmor +} diff --git a/wadsrc/static/decorate.txt b/wadsrc/static/decorate.txt index 465ce3287..ae4b6f851 100644 --- a/wadsrc/static/decorate.txt +++ b/wadsrc/static/decorate.txt @@ -29,6 +29,7 @@ #include "actors/shared/sectoraction.txt" #include "actors/shared/action.txt" #include "actors/shared/dog.txt" +#include "actors/shared/damagetypes.txt" #include "actors/doom/doomplayer.txt" #include "actors/doom/possessed.txt"