From cde450dd8a8735bc7444d795353b65ef15178659 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Apr 2017 16:51:11 +0200 Subject: [PATCH] - some enhancements for PowerReflection. --- src/namedef.h | 1 + src/p_interaction.cpp | 13 ++++++++++--- wadsrc/static/zscript/inventory/powerups.txt | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/namedef.h b/src/namedef.h index fec4093fd..bfbf26362 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -911,3 +911,4 @@ xx(Enum) xx(StaticArray) xx(DynArray) xx(Struct) +xx(ReflectType) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 7df05653e..59a22fa76 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1122,20 +1122,27 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da { int reflectdamage = 0; + bool reflecttype = false; for (auto p = target->player->mo->Inventory; p != nullptr; p = p->Inventory) { // This picks the reflection item with the maximum efficiency for the given damage type. if (p->IsKindOf(NAME_PowerReflection)) { - int mydamage = p->ApplyDamageFactor(mod, damage); - if (mydamage > reflectdamage) reflectdamage = mydamage; + double alwaysreflect = p->FloatVar(NAME_Strength); + int alwaysdamage = clamp(int(damage * alwaysreflect), 0, damage); + int mydamage = alwaysdamage + p->ApplyDamageFactor(mod, damage - alwaysdamage); + if (mydamage > reflectdamage) + { + reflectdamage = mydamage; + reflecttype = p->BoolVar(NAME_ReflectType); + } } } if (reflectdamage > 0) { // use the reflect item's damage factors to get the final value here. - P_DamageMobj(source, nullptr, target, reflectdamage, NAME_Reflection ); + P_DamageMobj(source, nullptr, target, reflectdamage, reflecttype? mod : NAME_Reflection ); // Reset means of death flag. MeansOfDeath = mod; diff --git a/wadsrc/static/zscript/inventory/powerups.txt b/wadsrc/static/zscript/inventory/powerups.txt index 045331672..8402588c5 100644 --- a/wadsrc/static/zscript/inventory/powerups.txt +++ b/wadsrc/static/zscript/inventory/powerups.txt @@ -1861,6 +1861,10 @@ class PowerInfiniteAmmo : Powerup class PowerReflection : Powerup { + // if 1, reflects the damage type as well. + bool ReflectType; + property ReflectType : ReflectType; + Default { Powerup.Duration -60;