diff --git a/CHANGELOG.md b/CHANGELOG.md index d8ffed76f6..28d8276a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ https://github.com/nwnxee/unified/compare/build8193.37.13...HEAD ### Added - Tweaks: added `NWNX_TWEAKS_RESIST_ENERGY_STACKS_WITH_EPIC_ENERGY_RESISTANCE` to make Resist Energy feats stack with Epic Energy Resistance. - Tweaks: added `NWNX_TWEAKS_UNHARDCODE_SPECIAL_ABILITY_TARGET_TYPE` to allow special abilities to be used on target types other than creatures. +- Tweaks: added `NWNX_TWEAKS_CON_DOES_NOT_AFFECT_HP` to prevent constitution from affecting creature HP. ##### New Plugins - N/A diff --git a/Plugins/Tweaks/CMakeLists.txt b/Plugins/Tweaks/CMakeLists.txt index 58329dc87c..b72e8705af 100644 --- a/Plugins/Tweaks/CMakeLists.txt +++ b/Plugins/Tweaks/CMakeLists.txt @@ -40,4 +40,5 @@ add_plugin(Tweaks "CutsceneModeNoTURD.cpp" "CanUseItemsWhilePolymorphed.cpp" "ResistEnergyStacksWithEpicEnergyResistance.cpp" - "UnhardcodeSpecialAbilityTargetType.cpp") + "UnhardcodeSpecialAbilityTargetType.cpp" + "ConDoesNotAffectHP.cpp") diff --git a/Plugins/Tweaks/ConDoesNotAffectHP.cpp b/Plugins/Tweaks/ConDoesNotAffectHP.cpp new file mode 100644 index 0000000000..f1fc792fdd --- /dev/null +++ b/Plugins/Tweaks/ConDoesNotAffectHP.cpp @@ -0,0 +1,28 @@ +#include "nwnx.hpp" + +#include "API/CNWSCreature.hpp" + +namespace Tweaks { + +using namespace NWNXLib; +using namespace NWNXLib::API; + +void ConDoesNotAffectHP() __attribute__((constructor)); +void ConDoesNotAffectHP() +{ + if (!Config::Get("CON_DOES_NOT_AFFECT_HP", false)) return; + + LOG_INFO("Constitution does not affect creature HP."); + + static Hooks::Hook s_CNWSCreatureGetMaxHitPointsHook = Hooks::HookFunction( + Functions::_ZN12CNWSCreature15GetMaxHitPointsEi, + +[](CNWSCreature *pThis, BOOL bIncludeToughness) -> int16_t + { + int16_t maxHP = s_CNWSCreatureGetMaxHitPointsHook->CallOriginal(pThis, bIncludeToughness); + + return maxHP - pThis->m_pStats->GetLevel() * pThis->m_pStats->m_nConstitutionModifier; + }, + Hooks::Order::Late); +} + +} diff --git a/Plugins/Tweaks/README.md b/Plugins/Tweaks/README.md index c5aa23e478..abcdf63419 100644 --- a/Plugins/Tweaks/README.md +++ b/Plugins/Tweaks/README.md @@ -52,6 +52,7 @@ Tweaks stuff. See below. | `NWNX_TWEAKS_CAN_USE_ITEMS_WHILE_POLYMORPHED` | true or false | Allow all items to be used while polymorphed. | | `NWNX_TWEAKS_RESIST_ENERGY_STACKS_WITH_EPIC_ENERGY_RESISTANCE` | true or false | Resist Energy feats stack with Epic Energy Resistance. | | `NWNX_TWEAKS_UNHARDCODE_SPECIAL_ABILITY_TARGET_TYPE` | true or false | Allows special abilities to be used on target types other than creatures. | +| `NWNX_TWEAKS_CON_DOES_NOT_AFFECT_HP` | true or false | Constitution does not affect creature HP. | ## Environment variable values