mirror of
https://github.com/brues-code/nampower.git
synced 2026-09-28 17:56:02 +00:00
refactor event flags, improve/fix bugs with SetLocalRaidTarget
This commit is contained in:
@@ -99,20 +99,22 @@ SET NP_TargetingQueueWindowMs "1000"
|
||||
|
||||
- `NP_PreventMountingWhenBuffCapped` - Whether to prevent mounting when you have 32 buffs (buff capped) and are not already mounted. This prevents the issue where you mount but cannot dismount because the mount aura fails to apply due to the buff cap. When blocked, displays an error message. 0 to disable, 1 to enable. Default is 1.
|
||||
|
||||
- `NP_EnableAuraCastEvents` - Whether to enable AURA_CAST_ON_SELF and AURA_CAST_ON_OTHER events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableAuraCastEvents` - Deprecated compatibility toggle for AURA_CAST_ON_SELF and AURA_CAST_ON_OTHER. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableAutoAttackEvents` - Whether to enable AUTO_ATTACK_SELF and AUTO_ATTACK_OTHER events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableAutoAttackEvents` - Deprecated compatibility toggle for AUTO_ATTACK_SELF and AUTO_ATTACK_OTHER. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableSpellStartEvents` - Whether to enable SPELL_START_SELF and SPELL_START_OTHER events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableSpellStartEvents` - Deprecated compatibility toggle for SPELL_START_SELF and SPELL_START_OTHER. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableSpellGoEvents` - Whether to enable SPELL_GO_SELF and SPELL_GO_OTHER events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableSpellGoEvents` - Deprecated compatibility toggle for SPELL_GO_SELF and SPELL_GO_OTHER. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableSpellHealEvents` - Whether to enable SPELL_HEAL_BY_SELF, SPELL_HEAL_BY_OTHER, and SPELL_HEAL_ON_SELF events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableSpellHealEvents` - Deprecated compatibility toggle for SPELL_HEAL_BY_SELF, SPELL_HEAL_BY_OTHER, and SPELL_HEAL_ON_SELF. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableSpellEnergizeEvents` - Whether to enable SPELL_ENERGIZE_BY_SELF, SPELL_ENERGIZE_BY_OTHER, and SPELL_ENERGIZE_ON_SELF events. 0 to disable, 1 to enable. Default is 0.
|
||||
- `NP_EnableSpellEnergizeEvents` - Deprecated compatibility toggle for SPELL_ENERGIZE_BY_SELF, SPELL_ENERGIZE_BY_OTHER, and SPELL_ENERGIZE_ON_SELF. In version 4.5.0 and later can just register the event to enable them. 0 to disable, 1 to enable. Default is 0.
|
||||
|
||||
- `NP_EnableEnhancedTooltips` - Whether to enable nampower's tooltip additions such as spell proc chance, ICD, and item cooldown text. 0 to disable, 1 to enable. Default is 1.
|
||||
|
||||
- `NP_EnableLocalSetRaidTarget` - Whether `SetRaidTarget` should fall back to the local-only raid marker table update when you are not in a party or raid. 0 to disable, 1 to enable. Default is 1.
|
||||
|
||||
- `NP_EnableUnitEventsPet` - Whether to fire unit state events for the `pet` and `partypet1`–`partypet4` unit tokens. 0 to disable, 1 to enable. Default is 1.
|
||||
|
||||
- `NP_EnableUnitEventsParty` - Whether to fire unit state events for the `party1`–`party4` unit tokens. 0 to disable, 1 to enable. Default is 1.
|
||||
@@ -233,12 +235,12 @@ Available events:
|
||||
- SPELL_GO_SELF and SPELL_GO_OTHER - Triggered by the server to indicate a spell completed casting.
|
||||
- SPELL_DAMAGE_EVENT_SELF and SPELL_DAMAGE_EVENT_OTHER - Combat damage events
|
||||
- Buff/Debuff Events (BUFF_ADDED_SELF, BUFF_REMOVED_SELF, BUFF_UPDATE_DURATION_SELF, etc.)
|
||||
- AURA_CAST_ON_SELF and AURA_CAST_ON_OTHER - Aura application events (fires once per aura effect per target; "Self" fires when the aura lands on the active player, including self-cast with no explicit target; includes aura metadata + amplitude/misc + aura cap bitfield for buff/debuff slots). Handles single-target and multi-target (AOE) spells. Some auras don't have spell effects and won't trigger this; use BUFF/DEBUFF gains for those. Set `NP_EnableAuraCastEvents=1` to enable. See EVENTS.md for details on multi-target behavior and known limitations.
|
||||
- AUTO_ATTACK_SELF and AUTO_ATTACK_OTHER - Auto attack round events (fires when auto attack hits are processed; includes damage, hit info, victim state, absorb/resist/block amounts). Set `NP_EnableAutoAttackEvents=1` to enable. See EVENTS.md for details.
|
||||
- SPELL_HEAL_BY_SELF, SPELL_HEAL_BY_OTHER, and SPELL_HEAL_ON_SELF - Spell healing events (fires when spell heals are processed; includes target, caster, spell ID, amount, critical flag, and periodic flag). Set `NP_EnableSpellHealEvents=1` to enable. See EVENTS.md for details.
|
||||
- SPELL_ENERGIZE_BY_SELF, SPELL_ENERGIZE_BY_OTHER, and SPELL_ENERGIZE_ON_SELF - Spell energize events (fires when power is restored via spells; includes target, caster, spell ID, power type, amount, and periodic flag). Set `NP_EnableSpellEnergizeEvents=1` to enable. See EVENTS.md for details.
|
||||
- AURA_CAST_ON_SELF and AURA_CAST_ON_OTHER - Aura application events (fires once per aura effect per target; "Self" fires when the aura lands on the active player, including self-cast with no explicit target; includes aura metadata + amplitude/misc + aura cap bitfield for buff/debuff slots). Handles single-target and multi-target (AOE) spells. Some auras don't have spell effects and won't trigger this; use BUFF/DEBUFF gains for those. Register the event to enable it. `NP_EnableAuraCastEvents` remains as a deprecated compatibility toggle. See EVENTS.md for details on multi-target behavior and known limitations.
|
||||
- AUTO_ATTACK_SELF and AUTO_ATTACK_OTHER - Auto attack round events (fires when auto attack hits are processed; includes damage, hit info, victim state, absorb/resist/block amounts). Register the event to enable it. `NP_EnableAutoAttackEvents` remains as a deprecated compatibility toggle. See EVENTS.md for details.
|
||||
- SPELL_HEAL_BY_SELF, SPELL_HEAL_BY_OTHER, and SPELL_HEAL_ON_SELF - Spell healing events (fires when spell heals are processed; includes target, caster, spell ID, amount, critical flag, and periodic flag). Register the event to enable it. `NP_EnableSpellHealEvents` remains as a deprecated compatibility toggle. See EVENTS.md for details.
|
||||
- SPELL_ENERGIZE_BY_SELF, SPELL_ENERGIZE_BY_OTHER, and SPELL_ENERGIZE_ON_SELF - Spell energize events (fires when power is restored via spells; includes target, caster, spell ID, power type, amount, and periodic flag). Register the event to enable it. `NP_EnableSpellEnergizeEvents` remains as a deprecated compatibility toggle. See EVENTS.md for details.
|
||||
- UNIT_DIED - Fires when a unit dies
|
||||
- KEY_DOWN and KEY_UP - Keyboard key events from `CSimpleTop::OnKeyDown` / `CSimpleTop::OnKeyUp` (see [EVENTS.md](EVENTS.md#key_down-and-key_up) for full argument and key-code details)
|
||||
- KEY_DOWN and KEY_UP - Keyboard key events from `CSimpleTop::OnKeyDown` / `CSimpleTop::OnKeyUp` (see [EVENTS.md](EVENTS.md#key_down-and-key_up) for full argument and key-code details). Register the event to enable it.
|
||||
|
||||
## Bug Reporting
|
||||
If you encounter any bugs please report them in the issues tab. Please include the nampower_debug.txt file in the same directory as your WoW.exe to help me diagnose the issue. If you are able to reproduce the bug please include the steps to reproduce it. In a future version once bugs are ironed out I'll make logging optional.
|
||||
|
||||
+15193
-15023
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,58 @@ namespace Nampower {
|
||||
lua_rawgetiT lua_rawgeti = reinterpret_cast<lua_rawgetiT>(Offsets::lua_rawgeti);
|
||||
luaL_unrefT luaL_unref = reinterpret_cast<luaL_unrefT>(Offsets::luaL_unref);
|
||||
|
||||
bool IsValidAsciiString(const char *str) {
|
||||
if (str == nullptr || IsBadReadPtr(str, 1) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 256; ++i) {
|
||||
if (IsBadReadPtr(str + i, 1) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto const ch = static_cast<unsigned char>(str[i]);
|
||||
if (ch == '\0') {
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
if (ch < 32 || ch > 126) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string GetAddonOrFrameName(void *frame) {
|
||||
auto addonOrFrameName = std::string{"<unnamed>"};
|
||||
auto const framescriptObj = reinterpret_cast<uintptr_t *>(frame);
|
||||
|
||||
if (framescriptObj == nullptr) {
|
||||
return addonOrFrameName;
|
||||
}
|
||||
|
||||
if (IsBadReadPtr(framescriptObj, sizeof(uintptr_t) * 76) == 0) {
|
||||
auto const addonNamePtr = framescriptObj + 74;
|
||||
|
||||
if (addonNamePtr != nullptr && addonNamePtr[1] != 0) {
|
||||
auto const namePtr = reinterpret_cast<const char *>(addonNamePtr[1]);
|
||||
if (namePtr != nullptr && IsBadReadPtr(namePtr, 1) == 0) {
|
||||
addonOrFrameName = std::string(namePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsBadReadPtr(framescriptObj, sizeof(uintptr_t) * 39) == 0 && framescriptObj[38] != 0) {
|
||||
auto const frameName = reinterpret_cast<char *>(framescriptObj[38]);
|
||||
if (frameName != nullptr && IsValidAsciiString(frameName)) {
|
||||
addonOrFrameName = std::string(frameName);
|
||||
}
|
||||
}
|
||||
|
||||
return addonOrFrameName;
|
||||
}
|
||||
|
||||
|
||||
int32_t GetSpellSlotAndTypeForName(const char *spellName, uint32_t *spellType) {
|
||||
auto const normalize = [](const char *name) -> std::string {
|
||||
|
||||
@@ -77,6 +77,8 @@ namespace Nampower {
|
||||
char *ConvertGuidToString(uint64_t guid);
|
||||
void FreeGuidString(char *str);
|
||||
void PushGuidString(uintptr_t *luaState, uint64_t guid);
|
||||
bool IsValidAsciiString(const char *str);
|
||||
std::string GetAddonOrFrameName(void *frame);
|
||||
bool IsReadableMemory(const void *ptr, size_t size);
|
||||
bool SafeReadMemory(const void *address, void *out, size_t size);
|
||||
|
||||
|
||||
+87
-2
@@ -54,13 +54,13 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <windows.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -108,6 +108,7 @@ namespace Nampower {
|
||||
std::unique_ptr<hadesmem::PatchDetour<LoadScriptFunctionsT> > gLoadScriptFunctionsDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<FrameScript_CreateEventsT> > gCreateEventsDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<FramescriptSetEventCountT> > gSetEventCountDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<FrameScript_Object_RegisterScriptEventT> > gRegisterScriptEventDetour;
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<SetCVarT> > gSetCVarDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<CGSpellBook_CastSpellT> > gCGSpellBook_CastSpellDetour;
|
||||
@@ -168,6 +169,7 @@ namespace Nampower {
|
||||
std::unique_ptr<hadesmem::PatchDetour<CSimpleTop_OnKeyUpT> > gCSimpleTop_OnKeyUpDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<GetGUIDFromNameT> > gGetGUIDFromNameDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT> > gCastSpellByNameDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT> > gSetRaidTargetDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<SendUnitSignalT> > gSendUnitSignalDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<CGPetInfo_SetPetT> > gCGPetInfo_SetPetDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<TogglePetSlotAutocastT> > gTogglePetSlotAutocastDetour;
|
||||
@@ -191,6 +193,13 @@ namespace Nampower {
|
||||
|
||||
void FrameScript_CreateEventsHook(hadesmem::PatchDetourBase *detour, int param_1, uint32_t maxEventId);
|
||||
|
||||
uint32_t FrameScript_Object_RegisterScriptEventHook(hadesmem::PatchDetourBase *detour, void *thisPtr,
|
||||
void *dummy_edx, char *eventName);
|
||||
|
||||
bool CSimpleTop_OnKeyDownHook(hadesmem::PatchDetourBase *detour, EVENT_DATA_KEY *keyData, int param_2);
|
||||
|
||||
bool CSimpleTop_OnKeyUpHook(hadesmem::PatchDetourBase *detour, EVENT_DATA_KEY *keyData, int param_2);
|
||||
|
||||
void Framescript_SetEventCountHook(hadesmem::PatchDetourBase *detour, void *thisPtr, void *dummy_edx,
|
||||
uint32_t count);
|
||||
|
||||
@@ -222,7 +231,6 @@ namespace Nampower {
|
||||
auto function = (LuaCallT) Offsets::lua_call;
|
||||
function(code, "Unused");
|
||||
}
|
||||
|
||||
uintptr_t *GetLuaStatePtr() {
|
||||
typedef uintptr_t *(__fastcall *GETCONTEXT)(void);
|
||||
static auto p_GetContext = reinterpret_cast<GETCONTEXT>(Offsets::lua_state_ptr);
|
||||
@@ -750,6 +758,9 @@ namespace Nampower {
|
||||
} else if (strcmp(cvar, "NP_EnableEnhancedTooltips") == 0) {
|
||||
gUserSettings.enableEnhancedTooltips = atoi(value) != 0;
|
||||
DEBUG_LOG("Set NP_EnableEnhancedTooltips to " << gUserSettings.enableEnhancedTooltips);
|
||||
} else if (strcmp(cvar, "NP_EnableLocalSetRaidTarget") == 0) {
|
||||
gUserSettings.enableLocalSetRaidTarget = atoi(value) != 0;
|
||||
DEBUG_LOG("Set NP_EnableLocalSetRaidTarget to " << gUserSettings.enableLocalSetRaidTarget);
|
||||
} else if (strcmp(cvar, "NP_MinBufferTimeMs") == 0) {
|
||||
gUserSettings.minBufferTimeMs = atoi(value);
|
||||
DEBUG_LOG("Set NP_MinBufferTimeMs and current buffer to " << gUserSettings.minBufferTimeMs);
|
||||
@@ -1363,6 +1374,16 @@ namespace Nampower {
|
||||
0, // unk2
|
||||
0); // unk3
|
||||
|
||||
char NP_EnableLocalSetRaidTarget[] = "NP_EnableLocalSetRaidTarget";
|
||||
CVarRegister(NP_EnableLocalSetRaidTarget, // name
|
||||
nullptr, // help
|
||||
0, // unk1
|
||||
gUserSettings.enableLocalSetRaidTarget ? defaultTrue : defaultFalse, // default value address
|
||||
nullptr, // callback
|
||||
1, // category
|
||||
0, // unk2
|
||||
0); // unk3
|
||||
|
||||
// update from cvars
|
||||
loadUserVar("NP_QueueCastTimeSpells");
|
||||
loadUserVar("NP_QueueInstantSpells");
|
||||
@@ -1378,6 +1399,7 @@ namespace Nampower {
|
||||
loadUserVar("NP_QuickcastOnDoubleCast");
|
||||
loadUserVar("NP_ReplaceMatchingNonGcdCategory");
|
||||
loadUserVar("NP_OptimizeBufferUsingPacketTimings");
|
||||
loadUserVar("NP_EnableLocalSetRaidTarget");
|
||||
|
||||
loadUserVar("NP_PreventRightClickTargetChange");
|
||||
|
||||
@@ -1418,6 +1440,7 @@ namespace Nampower {
|
||||
|
||||
loadUserVar("NP_NameplateDistance");
|
||||
loadUserVar("NP_ChatBubbleDistance");
|
||||
loadUserVar("EnableLocalSetRaidTarget");
|
||||
loadUserVar("NP_ChatBubblesBattleground");
|
||||
|
||||
gBufferTimeMs = gUserSettings.minBufferTimeMs;
|
||||
@@ -1562,6 +1585,8 @@ namespace Nampower {
|
||||
&GetGUIDFromNameHook);
|
||||
gCastSpellByNameDetour = createHook<LuaScriptT>(process, Offsets::Script_CastSpellByName,
|
||||
&Script_CastSpellByNameHook);
|
||||
gSetRaidTargetDetour = createHook<LuaScriptT>(process, Offsets::Script_SetRaidTarget,
|
||||
&Script_SetRaidTargetHook);
|
||||
gSpellTargetUnitDetour = createHook<LuaScriptT>(process, Offsets::Script_SpellTargetUnit,
|
||||
&Script_SpellTargetUnitHook);
|
||||
gSpellStopCastingDetour = createHook<LuaScriptT>(process, Offsets::Script_SpellStopCasting,
|
||||
@@ -1630,6 +1655,8 @@ namespace Nampower {
|
||||
&Glue_LoadScriptFunctionsHook);
|
||||
gCreateEventsDetour = createHook<FrameScript_CreateEventsT>(process, Offsets::FrameScript_CreateEvents,
|
||||
&FrameScript_CreateEventsHook);
|
||||
gRegisterScriptEventDetour = createHook<FrameScript_Object_RegisterScriptEventT>(
|
||||
process, Offsets::FrameScript_Object_RegisterScriptEvent, &FrameScript_Object_RegisterScriptEventHook);
|
||||
gSetEventCountDetour = createHook<FramescriptSetEventCountT>(process, Offsets::Framescript_SetEventCount,
|
||||
&Framescript_SetEventCountHook);
|
||||
ApplyOnChatMessagePatch();
|
||||
@@ -1844,6 +1871,64 @@ namespace Nampower {
|
||||
}
|
||||
}
|
||||
|
||||
void EnableEvents(void *thisPtr, const char *eventName) {
|
||||
if (!eventName || !*eventName) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto const addonOrFrameName = GetAddonOrFrameName(thisPtr);
|
||||
|
||||
if (_stricmp(eventName, "AURA_CAST_ON_SELF") == 0 || _stricmp(eventName, "AURA_CAST_ON_OTHER") == 0) {
|
||||
if (!gUserSettings.enableAuraCastEvents) {
|
||||
gUserSettings.enableAuraCastEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "AUTO_ATTACK_SELF") == 0 || _stricmp(eventName, "AUTO_ATTACK_OTHER") == 0) {
|
||||
if (!gUserSettings.enableAutoAttackEvents) {
|
||||
gUserSettings.enableAutoAttackEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "SPELL_START_SELF") == 0 || _stricmp(eventName, "SPELL_START_OTHER") == 0) {
|
||||
if (!gUserSettings.enableSpellStartEvents) {
|
||||
gUserSettings.enableSpellStartEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "SPELL_GO_SELF") == 0 || _stricmp(eventName, "SPELL_GO_OTHER") == 0) {
|
||||
if (!gUserSettings.enableSpellGoEvents) {
|
||||
gUserSettings.enableSpellGoEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "SPELL_HEAL_BY_SELF") == 0 ||
|
||||
_stricmp(eventName, "SPELL_HEAL_BY_OTHER") == 0 ||
|
||||
_stricmp(eventName, "SPELL_HEAL_ON_SELF") == 0) {
|
||||
if (!gUserSettings.enableSpellHealEvents) {
|
||||
gUserSettings.enableSpellHealEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "SPELL_ENERGIZE_BY_SELF") == 0 ||
|
||||
_stricmp(eventName, "SPELL_ENERGIZE_BY_OTHER") == 0 ||
|
||||
_stricmp(eventName, "SPELL_ENERGIZE_ON_SELF") == 0) {
|
||||
if (!gUserSettings.enableSpellEnergizeEvents) {
|
||||
gUserSettings.enableSpellEnergizeEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
} else if (_stricmp(eventName, "KEY_DOWN") == 0 || _stricmp(eventName, "KEY_UP") == 0) {
|
||||
if (!gUserSettings.enableKeyPressEvents) {
|
||||
gUserSettings.enableKeyPressEvents = true;
|
||||
DEBUG_LOG("RegisterScriptEvent enabled " << eventName << " for " << addonOrFrameName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t FrameScript_Object_RegisterScriptEventHook(hadesmem::PatchDetourBase *detour, void *thisPtr,
|
||||
void *dummy_edx, char *eventName) {
|
||||
auto const registerScriptEvent = detour->GetTrampolineT<FrameScript_Object_RegisterScriptEventT>();
|
||||
auto const result = registerScriptEvent(thisPtr, dummy_edx, eventName);
|
||||
EnableEvents(thisPtr, eventName);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Framescript_SetEventCountHook(hadesmem::PatchDetourBase *detour, void *thisPtr, void *dummy_edx,
|
||||
uint32_t count) {
|
||||
auto const setEventCount = detour->GetTrampolineT<FramescriptSetEventCountT>();
|
||||
|
||||
@@ -128,6 +128,7 @@ namespace Nampower {
|
||||
|
||||
using LoadScriptFunctionsT = void (__stdcall *)();
|
||||
using FrameScript_RegisterFunctionT = void (__fastcall *)(char *name, uintptr_t *func);
|
||||
using FrameScript_Object_RegisterScriptEventT = uint32_t (__fastcall *)(void *thisPtr, void *dummy_edx, char *param_1);
|
||||
using FrameScript_CreateEventsT = void (__fastcall *)(int param_1, uint32_t maxEventId);
|
||||
using FramescriptSetEventCountT = void (__fastcall *)(void *thisPtr, void *dummy_edx, uint32_t count);
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Nampower {
|
||||
|
||||
void EmitKeyEvent(uint32_t eventCode, EVENT_DATA_KEY *keyData) {
|
||||
// don't trigger events until player exists as event won't be registered
|
||||
if (keyData == nullptr || game::ClntObjMgrGetActivePlayerGuid() == 0) {
|
||||
if (!gUserSettings.enableKeyPressEvents || keyData == nullptr || game::ClntObjMgrGetActivePlayerGuid() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,4 @@ namespace Nampower {
|
||||
|
||||
uint32_t Script_IsAuraHidden(uintptr_t *luaState);
|
||||
uint32_t Script_CombatLogFlush(uintptr_t *luaState);
|
||||
bool CSimpleTop_OnKeyDownHook(hadesmem::PatchDetourBase *detour, EVENT_DATA_KEY *keyData, int param_2);
|
||||
bool CSimpleTop_OnKeyUpHook(hadesmem::PatchDetourBase *detour, EVENT_DATA_KEY *keyData, int param_2);
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@ enum class Offsets : std::uint32_t {
|
||||
Player_LoadScriptFunctions = 0x00490250,
|
||||
Glue_LoadScriptFunctions = 0x0046ABB0,
|
||||
FrameScript_RegisterFunction = 0x00704120,
|
||||
FrameScript_Object_RegisterScriptEvent = 0x00702140,
|
||||
FrameScript_CreateEvents = 0X00703D90,
|
||||
Framescript_SetEventCount = 0X007053B0,
|
||||
Framescript_EventObject_Data = 0x00CEEF68,
|
||||
@@ -171,6 +172,7 @@ enum class Offsets : std::uint32_t {
|
||||
GetGUIDFromName = 0X00515970,
|
||||
Script_CastSpell = 0x004B42F0,
|
||||
Script_CastSpellByName = 0x004B4AB0,
|
||||
Script_SetRaidTarget = 0x004BBEC0,
|
||||
Script_SpellTargetUnit = 0x006E6D90,
|
||||
Script_SetCVar = 0x00488C10,
|
||||
Script_RunScript = 0x0048B980,
|
||||
@@ -286,6 +288,9 @@ enum class Offsets : std::uint32_t {
|
||||
XMLNode_GetAttributeByName = 0x006f2cf0,
|
||||
|
||||
CGRaidInfo_m_raidtargets = 0xB71368,
|
||||
CGRaidInfo_m_numRaidMembers = 0x00B713E0,
|
||||
CGGameUI_IsPartyMember = 0x004E7F70,
|
||||
CGPartyInfo_NumMembers = 0x004E86D0,
|
||||
|
||||
CGPetInfo_SetPet = 0x004bc7e0,
|
||||
TogglePetSlotAutocast = 0x004bcbb0,
|
||||
|
||||
@@ -43,8 +43,11 @@ struct UserSettings {
|
||||
bool enableSpellGoEvents = false;
|
||||
bool enableSpellHealEvents = false;
|
||||
bool enableSpellEnergizeEvents = false;
|
||||
bool enableKeyPressEvents = false;
|
||||
|
||||
bool preventMountingWhenBuffCapped = true;
|
||||
bool enableEnhancedTooltips = true;
|
||||
bool enableLocalSetRaidTarget = true;
|
||||
|
||||
uint32_t spellQueueWindowMs = 500;
|
||||
uint32_t onSwingBufferCooldownMs = 500;
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace Nampower {
|
||||
}
|
||||
|
||||
const char *unitStr = lua_tostring(luaState, 1);
|
||||
uint32_t raidTargetIndex = static_cast<uint32_t>(lua_tonumber(luaState, 2));
|
||||
int32_t raidTargetIndex = static_cast<int32_t>(lua_tonumber(luaState, 2)) - 1;
|
||||
|
||||
uint64_t targetGuid = GetUnitGuidFromString(unitStr);
|
||||
if (targetGuid == 0) {
|
||||
@@ -291,7 +291,7 @@ namespace Nampower {
|
||||
}
|
||||
}
|
||||
|
||||
if (raidTargetIndex > 8) {
|
||||
if (raidTargetIndex >= 8) {
|
||||
lua_error(luaState, "SetLocalRaidTargetIndex: raidTargetIndex must be in range 0-8");
|
||||
return 0;
|
||||
}
|
||||
@@ -303,7 +303,23 @@ namespace Nampower {
|
||||
|
||||
auto raidTargets =
|
||||
reinterpret_cast<uint64_t *>(static_cast<uint32_t>(Offsets::CGRaidInfo_m_raidtargets));
|
||||
|
||||
// if raidTargetIndex is valid and already has the targetGuid, do nothing
|
||||
if (raidTargetIndex >= 0 && raidTargets[raidTargetIndex] == targetGuid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Clear out previous mark for this guid if there was one
|
||||
for (uint32_t i = 0; i < 8; ++i) {
|
||||
if (i == static_cast<uint32_t>(raidTargetIndex) || raidTargets[i] != targetGuid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
raidTargets[i] = 0;
|
||||
}
|
||||
|
||||
auto const previousTargetGuid = raidTargets[raidTargetIndex];
|
||||
// Update the nameplate for the previous guid for the mark we are going to use
|
||||
if (previousTargetGuid != 0) {
|
||||
raidTargets[raidTargetIndex] = 0;
|
||||
|
||||
@@ -313,13 +329,37 @@ namespace Nampower {
|
||||
}
|
||||
}
|
||||
|
||||
raidTargets[raidTargetIndex] = targetGuid;
|
||||
// Store new mark if >= 0, -1 means clear
|
||||
if (raidTargetIndex >= 0) {
|
||||
raidTargets[raidTargetIndex] = targetGuid;
|
||||
}
|
||||
|
||||
// Update the nameplate for the new guid for the mark we are going to use
|
||||
namePlateUpdateRaidTarget(targetUnit);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t Script_SetRaidTargetHook(hadesmem::PatchDetourBase *detour, uintptr_t *luaState) {
|
||||
auto activePlayerGuid = game::ClntObjMgrGetActivePlayerGuid();
|
||||
auto const numRaidMembers =
|
||||
*reinterpret_cast<uint32_t *>(static_cast<uint32_t>(Offsets::CGRaidInfo_m_numRaidMembers));
|
||||
|
||||
using CGPartyInfo_NumMembersT = int (__fastcall *)();
|
||||
auto const numPartyMembers =
|
||||
reinterpret_cast<CGPartyInfo_NumMembersT>(static_cast<uint32_t>(Offsets::CGPartyInfo_NumMembers));
|
||||
auto const partyMemberCount = numPartyMembers ? numPartyMembers() : 0;
|
||||
|
||||
// if not in party or raid use local version
|
||||
if (gUserSettings.enableLocalSetRaidTarget &&
|
||||
(activePlayerGuid == 0 || (numRaidMembers == 0 && partyMemberCount == 0))) {
|
||||
return Script_SetLocalRaidTargetIndex(luaState);
|
||||
}
|
||||
|
||||
auto const original = detour->GetTrampolineT<LuaScriptT>();
|
||||
return original(luaState);
|
||||
}
|
||||
|
||||
uint32_t Script_GetUnitGUID(uintptr_t *luaState) {
|
||||
luaState = GetLuaStatePtr();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Nampower {
|
||||
uint32_t Script_GetUnitField(uintptr_t *luaState);
|
||||
uint32_t Script_SetMouseoverUnit(uintptr_t *luaState);
|
||||
uint32_t Script_SetLocalRaidTargetIndex(uintptr_t *luaState);
|
||||
uint32_t Script_SetRaidTargetHook(hadesmem::PatchDetourBase *detour, uintptr_t *luaState);
|
||||
uint32_t Script_GetUnitGUID(uintptr_t *luaState);
|
||||
|
||||
uint32_t CSimpleFrame_GetNameHook(hadesmem::PatchDetourBase *detour, uintptr_t *luaState);
|
||||
|
||||
Reference in New Issue
Block a user