From 26dbec2aae2ad8bdfb068e3b98fb45d67e21eab3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Apr 2012 15:29:47 +0000 Subject: [PATCH] - added FDARI*s damagetype fix SVN r3533 (trunk) --- src/info.cpp | 8 +++++--- src/info.h | 2 +- src/thingdef/thingdef_parse.cpp | 2 +- wadsrc/static/actors/shared/damagetypes.txt | 4 ++++ wadsrc/static/decorate.txt | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 wadsrc/static/actors/shared/damagetypes.txt diff --git a/src/info.cpp b/src/info.cpp index c15bf0a947..a1dd4723ef 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 7fcdeca9bb..ff59a46564 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 1b820f9bb4..a15c18e164 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 0000000000..7ba83564d6 --- /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 465ce3287d..ae4b6f8517 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"