diff --git a/CHANGELOG.md b/CHANGELOG.md index 8266c5d4ee3..0817997c59b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD - Events: Added events `NWNX_ON_SET_EXPERIENCE_{BEFORE|AFTER}` which fire when the XP of a player changes. - NoStack: Added `NWNX_NOSTACK_IGNORE_SUPERNATURAL_INNATE` to ignore effects created by the Feat, Race and SkillRanks plugins when stacking. - Tweaks: added `NWNX_TWEAKS_CUTSCENE_MODE_NO_TURD` to not drop a TURD when SetCutsceneMode() is called. +- Tweaks: added `NWNX_TWEAKS_CAN_USE_ITEMS_WHILE_POLYMORPHED` to allow all items to be used while polymorphed. ##### New Plugins - Store: Enables getting and setting store data. diff --git a/Plugins/Tweaks/CMakeLists.txt b/Plugins/Tweaks/CMakeLists.txt index 8bbacdedabc..49139ff4ff3 100644 --- a/Plugins/Tweaks/CMakeLists.txt +++ b/Plugins/Tweaks/CMakeLists.txt @@ -38,4 +38,5 @@ add_plugin(Tweaks "CastAllOnHitCastSpellItemProperties.cpp" "SetAreaCallsSetPosition.cpp" "EquipUnequipEventTweaks.cpp" - "CutsceneModeNoTURD.cpp") + "CutsceneModeNoTURD.cpp" + "CanUseItemsWhilePolymorphed.cpp") diff --git a/Plugins/Tweaks/CanUseItemsWhilePolymorphed.cpp b/Plugins/Tweaks/CanUseItemsWhilePolymorphed.cpp new file mode 100644 index 00000000000..c2610367b82 --- /dev/null +++ b/Plugins/Tweaks/CanUseItemsWhilePolymorphed.cpp @@ -0,0 +1,40 @@ +#include "nwnx.hpp" + +#include "API/CNWSCreature.hpp" + +namespace Tweaks { + +using namespace NWNXLib; +using namespace NWNXLib::API; + +void CanUseItemsWhilePolymorphed() __attribute__((constructor)); +void CanUseItemsWhilePolymorphed() +{ + if (!Config::Get("CAN_USE_ITEMS_WHILE_POLYMORPHED", false)) return; + + LOG_INFO("Allow all items to be used while polymorphed."); + + static Hooks::Hook s_CanUseItemHook = Hooks::HookFunction(&CNWSCreature::CanUseItem, + +[](CNWSCreature* thisPtr, CNWSItem* pItem, BOOL bIgnoreIdentifiedFlag) -> BOOL + { + bool isPolymorphed = thisPtr->m_bIsPolymorphed; + thisPtr->m_bIsPolymorphed = false; + BOOL retVal = s_CanUseItemHook->CallOriginal(thisPtr, pItem, bIgnoreIdentifiedFlag); + thisPtr->m_bIsPolymorphed = isPolymorphed; + return retVal; + }, Hooks::Order::Early); + + static Hooks::Hook s_UseItemHook = Hooks::HookFunction(&CNWSCreature::UseItem, + +[](CNWSCreature* thisPtr, OBJECT_ID oidItem, uint8_t nActivePropertyIndex, uint8_t nSubPropertyIndex, + OBJECT_ID oidTarget, Vector vTargetPosition, OBJECT_ID oidArea, BOOL bUseCharges = true) -> BOOL + { + bool isPolymorphed = thisPtr->m_bIsPolymorphed; + thisPtr->m_bIsPolymorphed = false; + BOOL retVal = s_UseItemHook->CallOriginal(thisPtr, oidItem, nActivePropertyIndex, nSubPropertyIndex, + oidTarget, vTargetPosition, oidArea, bUseCharges); + thisPtr->m_bIsPolymorphed = isPolymorphed; + return retVal; + }, Hooks::Order::Early); +} + +} diff --git a/Plugins/Tweaks/README.md b/Plugins/Tweaks/README.md index 74e458acb14..be420c620e6 100644 --- a/Plugins/Tweaks/README.md +++ b/Plugins/Tweaks/README.md @@ -1,6 +1,6 @@ @addtogroup tweaks Tweaks @page tweaks Readme -@ingroup tweaks +@ingroup tweaks Tweaks stuff. See below. @@ -14,7 +14,7 @@ Tweaks stuff. See below. | `NWNX_TWEAKS_DISABLE_QUICKSAVE` | true or false | Disables DM quicksave. | | `NWNX_TWEAKS_COMPARE_VARIABLES_WHEN_MERGING` | true or false | When trying to merge items, local variables are also considered. | | `NWNX_TWEAKS_PARRY_ALL_ATTACKS` | true or false | Removes the number of parried attacks per round limit. | -| `NWNX_TWEAKS_SNEAK_ATTACK_IGNORE_CRIT_IMMUNITY` | true or false | Allow sneakattacks on creatures that are immune to critical hits. | +| `NWNX_TWEAKS_SNEAK_ATTACK_IGNORE_CRIT_IMMUNITY` | true or false | Allow sneakattacks on creatures that are immune to critical hits. | | `NWNX_TWEAKS_PRESERVE_DEPLETED_ITEMS` | true or false | Items that run out of charges are not destroyed. | | `NWNX_TWEAKS_HIDE_PLAYERS_ON_CHAR_LIST` | between 1 and 3 | See [here](https://github.com/nwnxee/unified/tree/master/Plugins/Tweaks#nwnx_tweaks_hide_players_on_char_list). | | `NWNX_TWEAKS_DISABLE_MONK_ABILITIES_WHEN_POLYMORPHED` | true or false | Disables monk abilities (ac, speed, etc) when polymorphed. | @@ -50,6 +50,7 @@ Tweaks stuff. See below. | `NWNX_TWEAKS_FIRE_EQUIP_EVENTS_FOR_ALL_CREATURES` | true or false | The module OnPlayerEquipItem and OnPlayerUnEquipItem events are fired for all creatures | | `NWNX_TWEAKS_DONT_DELAY_EQUIP_EVENT` | true or false | Fixes Unequip/Equip events being out of sync if an item is equipped/unequipped multiple times per server tick | | `NWNX_TWEAKS_CUTSCENE_MODE_NO_TURD` | true or false | SetCutsceneMode() will not cause a TURD to be dropped. | +| `NWNX_TWEAKS_CAN_USE_ITEMS_WHILE_POLYMORPHED` | true or false | Allow all items to be used while polymorphed. | ## Environment variable values @@ -88,7 +89,7 @@ Values between 1 and 3 are valid. Any of those values will adjust the item cost ### NWNX_TWEAKS_HIDE_HARDCODED_ITEM_VFX -Add the numbers of the VFX you want to hide. For example to hide all Elemental Damage Bonus, Holy Avenger and OnHitVorpal visual effects you'd set the environment variable to 318 (2 + 4 + 8 + 16 + 32 + 256) +Add the numbers of the VFX you want to hide. For example to hide all Elemental Damage Bonus, Holy Avenger and OnHitVorpal visual effects you'd set the environment variable to 318 (2 + 4 + 8 + 16 + 32 + 256) Specific VFX values in order of priority: