diff --git a/src/namedef.h b/src/namedef.h index fec4093fd0..bfbf263622 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 7df05653e5..59a22fa762 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 0453316726..8402588c57 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;