Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD
- DotNET: Added `RequestFunctionHook`, `ReturnFunctionHook`.
- 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.

##### New Plugins
- Store: Enables getting and setting store data.
Expand Down
3 changes: 2 additions & 1 deletion Plugins/Tweaks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ add_plugin(Tweaks
"RangedWeaponsUseOnHitCastSpellItemProperties.cpp"
"CastAllOnHitCastSpellItemProperties.cpp"
"SetAreaCallsSetPosition.cpp"
"EquipUnequipEventTweaks.cpp")
"EquipUnequipEventTweaks.cpp"
"CutsceneModeNoTURD.cpp")
47 changes: 47 additions & 0 deletions Plugins/Tweaks/CutsceneModeNoTURD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "nwnx.hpp"

#include "API/CNWSModule.hpp"
#include "API/CNWSPlayer.hpp"
#include "API/CNWSVirtualMachineCommands.hpp"


namespace Tweaks {

using namespace NWNXLib;
using namespace NWNXLib::API;

static bool s_CutsceneModeNoTURD;

void CutsceneModeNoTURD() __attribute__((constructor));
void CutsceneModeNoTURD()
{
if (!Config::Get<bool>("CUTSCENE_MODE_NO_TURD", false))
return;

LOG_INFO("SetCutsceneMode() will not drop a TURD.");

static Hooks::Hook s_ExecuteCommandSetCutsceneModeHook = Hooks::HookFunction(&CNWSVirtualMachineCommands::ExecuteCommandSetCutsceneMode,
+[](CNWSVirtualMachineCommands *thisPtr, int32_t nCommandId, int32_t nParameters) -> int32_t
{
s_CutsceneModeNoTURD = true;
auto retVal = s_ExecuteCommandSetCutsceneModeHook->CallOriginal<int32_t>(thisPtr, nCommandId, nParameters);
s_CutsceneModeNoTURD = false;
return retVal;
}, Hooks::Order::Early);

static Hooks::Hook s_DropTURDHook = Hooks::HookFunction(&CNWSPlayer::DropTURD,
+[](CNWSPlayer *pPlayer) -> void
{
if (!s_CutsceneModeNoTURD)
s_DropTURDHook->CallOriginal<void>(pPlayer);
}, Hooks::Order::Earliest);

static Hooks::Hook s_CleanMyTURDsHook = Hooks::HookFunction(&CNWSPlayer::CleanMyTURDs,
+[](CNWSPlayer *pPlayer) -> void
{
if (!s_CutsceneModeNoTURD)
s_CleanMyTURDsHook->CallOriginal<void>(pPlayer);
}, Hooks::Order::Earliest);
}

}
1 change: 1 addition & 0 deletions Plugins/Tweaks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Tweaks stuff. See below.
| `NWNX_TWEAKS_SETAREA_CALLS_SETPOSITION` | true or false | If enabled, a creature getting added to an area will fire the `NWNX_ON_MATERIALCHANGE_*` and `NWNX_ON_CREATURE_TILE_CHANGE_*` events. |
| `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. |

## Environment variable values

Expand Down