message: ObjectEvents.cpp to support OBJECT_USE BEFORE/AFTER
  This was a patch created by Daz in NWNX discord chat.  It creates these two events:
  NWNX_ON_OBJECT_USE_BEFORE and NWNX_ON_OBJECT_USE_AFTER
  This is when a player 'uses' a plc (placeable).  I've tested and seems to be working well.
diff: @@ -9,9 +9,11 @@ using namespace NWNXLib::API::Constants;
  static NWNXLib::Hooks::Hook s_AddLockObjectActionHook;
  static NWNXLib::Hooks::Hook s_AddUnlockObjectActionHook;
  +static NWNXLib::Hooks::Hook s_AddUseObjectActionHook;
  static int32_t AddLockObjectActionHook(CNWSObject*, ObjectID);
  static int32_t AddUnlockObjectActionHook(CNWSObject*, ObjectID, ObjectID, int32_t);
  +static int32_t AddUseObjectActionHook(CNWSObject*, ObjectID);
  void ObjectEvents() __attribute__((constructor));
  void ObjectEvents()
  @@ -25,6 +27,11 @@ void ObjectEvents()
  s_AddUnlockObjectActionHook = Hooks::HookFunction(API::Functions::_ZN10CNWSObject21AddUnlockObjectActionEjji,
  (void*)&AddUnlockObjectActionHook, Hooks::Order::Early);
  });
  +
  + InitOnFirstSubscribe("NWNX_ON_OBJECT_USE_.*", []() {
  + s_AddUseObjectActionHook = Hooks::HookFunction(API::Functions::_ZN10CNWSObject18AddUseObjectActionEj,
  + (void*)&AddUseObjectActionHook, Hooks::Order::Early);
  + });
  }
  int32_t AddLockObjectActionHook(CNWSObject *thisPtr, ObjectID oidDoor)
  @@ -79,4 +86,28 @@ int32_t AddUnlockObjectActionHook(CNWSObject *thisPtr, ObjectID oidDoor, ObjectI
  return retVal;
  }
  +int32_t AddUseObjectActionHook(CNWSObject *thisPtr, ObjectID oidObjectToUse)
  +{
  + int32_t retVal;
  +
  + auto PushAndSignal = [&](const std::string& ev) -> bool {
  + PushEventData("OBJECT", Utils::ObjectIDToString(oidObjectToUse));
  + return SignalEvent(ev, thisPtr->m_idSelf);
  + };
  +
  + if (PushAndSignal("NWNX_ON_OBJECT_USE_BEFORE"))
  + {
  + retVal = s_AddUseObjectActionHook->CallOriginal<int32_t>(thisPtr, oidObjectToUse);
  + }
  + else
  + {
  + retVal = false;
  + }
  +
  + PushEventData("ACTION_RESULT", std::to_string(retVal));
  + PushAndSignal("NWNX_ON_OBJECT_USE_AFTER");
  +
  + return retVal;
  +}
  +
  }
  