mirror of
https://github.com/brues-code/nampower.git
synced 2026-10-10 15:40:02 +00:00
add more item/spell dbc functions, improve flexibility of spell lua functions
This commit is contained in:
+37
-51
@@ -36,6 +36,7 @@
|
||||
#include "scripts.hpp"
|
||||
#include "spellchannel.hpp"
|
||||
#include "helper.hpp"
|
||||
#include "items.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -99,23 +100,10 @@ namespace Nampower {
|
||||
std::unique_ptr<hadesmem::PatchDetour<SpellGoT>> gSpellGoDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gSpellTargetUnitDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gSpellStopCastingDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gCastSpellByNameNoQueueDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gQueueSpellByNameDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> qQueueScriptDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gIsSpellInRangeDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gIsSpellUsableDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetCurrentCastingInfoDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetSpellIdForNameDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetSpellNameAndRankForIdDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetSpellSlotAndTypeForNameDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gChannelStopCastingNextTickDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<OnSpriteRightClickT>> gOnSpriteRightClickDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<Spell_C_HandleSpriteClickT>> gSpell_C_HandleSpriteClickDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<Spell_C_TargetSpellT>> gSpell_C_TargetSpellDetour;
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetNampowerVersionDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<LuaScriptT>> gGetItemLevelDetour;
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<PacketHandlerT>> gSpellCooldownDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<PacketHandlerT>> gSpellDelayedDetour;
|
||||
std::unique_ptr<hadesmem::PatchDetour<PacketHandlerT>> gCastResultHandlerDetour;
|
||||
@@ -130,6 +118,10 @@ namespace Nampower {
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<CGPlayer_C_OnAttackIconPressedT>> gCGPlayer_C_OnAttackIconPressedDetour;
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<InvalidFunctionPtrCheckT>> gInvalidFunctionPtrCheckDetour;
|
||||
|
||||
std::unique_ptr<hadesmem::PatchDetour<GetSpellSlotFromLuaT>> gGetSpellSlotFromLuaDetour;
|
||||
|
||||
uint32_t GetTime() {
|
||||
return static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch()).count()) - gStartTime;
|
||||
@@ -543,6 +535,10 @@ namespace Nampower {
|
||||
return iSceneEnd(ptr);
|
||||
}
|
||||
|
||||
void InvalidFunctionPtrCheckHook(hadesmem::PatchDetourBase *detour, uint32_t param_1) {
|
||||
// remove original call to allow registering lua functions at any address range
|
||||
}
|
||||
|
||||
void updateFromCvar(const char *cvar, const char *value) {
|
||||
if (strcmp(cvar, "NP_QueueCastTimeSpells") == 0) {
|
||||
gUserSettings.queueCastTimeSpells = atoi(value) != 0;
|
||||
@@ -1116,29 +1112,13 @@ namespace Nampower {
|
||||
&Script_SpellStopCastingHook);
|
||||
gSpell_C_TargetSpellDetour = createHook<Spell_C_TargetSpellT>(process, Offsets::Spell_C_TargetSpell,
|
||||
&Spell_C_TargetSpellHook);
|
||||
gCastSpellByNameNoQueueDetour = createHook<LuaScriptT>(process, Offsets::Script_CastSpellByNameNoQueue,
|
||||
Script_CastSpellByNameNoQueue);
|
||||
gQueueSpellByNameDetour = createHook<LuaScriptT>(process, Offsets::Script_QueueSpellByName,
|
||||
Script_QueueSpellByName);
|
||||
qQueueScriptDetour = createHook<LuaScriptT>(process, Offsets::Script_QueueScript, Script_QueueScript);
|
||||
gIsSpellInRangeDetour = createHook<LuaScriptT>(process, Offsets::Script_IsSpellInRange, Script_IsSpellInRange);
|
||||
gIsSpellUsableDetour = createHook<LuaScriptT>(process, Offsets::Script_IsSpellUsable, Script_IsSpellUsable);
|
||||
gGetCurrentCastingInfoDetour = createHook<LuaScriptT>(process, Offsets::Script_GetCurrentCastingInfo,
|
||||
Script_GetCurrentCastingInfo);
|
||||
gGetSpellIdForNameDetour = createHook<LuaScriptT>(process, Offsets::Script_GetSpellIdForName,
|
||||
Script_GetSpellIdForName);
|
||||
gGetSpellNameAndRankForIdDetour = createHook<LuaScriptT>(process, Offsets::Script_GetSpellNameAndRankForId,
|
||||
Script_GetSpellNameAndRankForId);
|
||||
gGetSpellSlotAndTypeForNameDetour = createHook<LuaScriptT>(process, Offsets::Script_GetSpellSlotTypeIdForName,
|
||||
Script_GetSpellSlotTypeIdForName);
|
||||
gOnSpriteRightClickDetour = createHook<OnSpriteRightClickT>(process, Offsets::OnSpriteRightClick,
|
||||
OnSpriteRightClickHook);
|
||||
gChannelStopCastingNextTickDetour = createHook<LuaScriptT>(process, Offsets::Script_ChannelStopCastingNextTick,
|
||||
Script_ChannelStopCastingNextTick);
|
||||
gGetNampowerVersionDetour = createHook<LuaScriptT>(process, Offsets::Script_GetNampowerVersion,
|
||||
Script_GetNampowerVersion);
|
||||
gGetItemLevelDetour = createHook<LuaScriptT>(process, Offsets::Script_GetItemLevel, Script_GetItemLevel);
|
||||
gIEndSceneDetour = createHook<ISceneEndT>(process, Offsets::ISceneEndPtr, &ISceneEndHook);
|
||||
gInvalidFunctionPtrCheckDetour = createHook<InvalidFunctionPtrCheckT>(process, Offsets::InvalidFunctionPtrCheck,
|
||||
&InvalidFunctionPtrCheckHook);
|
||||
gGetSpellSlotFromLuaDetour = createHook<GetSpellSlotFromLuaT>(process, Offsets::GetSpellSlotFromLua,
|
||||
&GetSpellSlotFromLuaHook);
|
||||
|
||||
// gCGPlayer_C_OnAttackIconPressedDetour = createHook<CGPlayer_C_OnAttackIconPressedT>(process,
|
||||
// Offsets::CGPlayer_C_OnAttackIconPressed,
|
||||
@@ -1169,46 +1149,52 @@ namespace Nampower {
|
||||
// register our own lua functions
|
||||
DEBUG_LOG("Registering Custom Lua functions");
|
||||
char queueSpellByName[] = "QueueSpellByName";
|
||||
RegisterLuaFunction(queueSpellByName, reinterpret_cast<uintptr_t *>(Offsets::Script_QueueSpellByName));
|
||||
RegisterLuaFunction(queueSpellByName, reinterpret_cast<uintptr_t *>(Script_QueueSpellByName));
|
||||
|
||||
char castSpellByNameNoQueue[] = "CastSpellByNameNoQueue";
|
||||
RegisterLuaFunction(castSpellByNameNoQueue,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_CastSpellByNameNoQueue));
|
||||
RegisterLuaFunction(castSpellByNameNoQueue, reinterpret_cast<uintptr_t *>(Script_CastSpellByNameNoQueue));
|
||||
|
||||
char queueScript[] = "QueueScript";
|
||||
RegisterLuaFunction(queueScript, reinterpret_cast<uintptr_t *>(Offsets::Script_QueueScript));
|
||||
RegisterLuaFunction(queueScript, reinterpret_cast<uintptr_t *>(Script_QueueScript));
|
||||
|
||||
char isSpellInRange[] = "IsSpellInRange";
|
||||
RegisterLuaFunction(isSpellInRange, reinterpret_cast<uintptr_t *>(Offsets::Script_IsSpellInRange));
|
||||
RegisterLuaFunction(isSpellInRange, reinterpret_cast<uintptr_t *>(Script_IsSpellInRange));
|
||||
|
||||
char isSpellUsable[] = "IsSpellUsable";
|
||||
RegisterLuaFunction(isSpellUsable, reinterpret_cast<uintptr_t *>(Offsets::Script_IsSpellUsable));
|
||||
RegisterLuaFunction(isSpellUsable, reinterpret_cast<uintptr_t *>(Script_IsSpellUsable));
|
||||
|
||||
char getCurrentCastingInfo[] = "GetCurrentCastingInfo";
|
||||
RegisterLuaFunction(getCurrentCastingInfo,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_GetCurrentCastingInfo));
|
||||
RegisterLuaFunction(getCurrentCastingInfo, reinterpret_cast<uintptr_t *>(Script_GetCurrentCastingInfo));
|
||||
|
||||
char getSpellIdForName[] = "GetSpellIdForName";
|
||||
RegisterLuaFunction(getSpellIdForName,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_GetSpellIdForName));
|
||||
RegisterLuaFunction(getSpellIdForName, reinterpret_cast<uintptr_t *>(Script_GetSpellIdForName));
|
||||
|
||||
char getSpellNameAndRankForId[] = "GetSpellNameAndRankForId";
|
||||
RegisterLuaFunction(getSpellNameAndRankForId,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_GetSpellNameAndRankForId));
|
||||
RegisterLuaFunction(getSpellNameAndRankForId, reinterpret_cast<uintptr_t *>(Script_GetSpellNameAndRankForId));
|
||||
|
||||
char getSpellSlotTypeIdForName[] = "GetSpellSlotTypeIdForName";
|
||||
RegisterLuaFunction(getSpellSlotTypeIdForName,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_GetSpellSlotTypeIdForName));
|
||||
RegisterLuaFunction(getSpellSlotTypeIdForName, reinterpret_cast<uintptr_t *>(Script_GetSpellSlotTypeIdForName));
|
||||
|
||||
char channelStopCastingNextTick[] = "ChannelStopCastingNextTick";
|
||||
RegisterLuaFunction(channelStopCastingNextTick,
|
||||
reinterpret_cast<uintptr_t *>(Offsets::Script_ChannelStopCastingNextTick));
|
||||
RegisterLuaFunction(channelStopCastingNextTick, reinterpret_cast<uintptr_t *>(Script_ChannelStopCastingNextTick));
|
||||
|
||||
char getNampowerVersion[] = "GetNampowerVersion";
|
||||
RegisterLuaFunction(getNampowerVersion, reinterpret_cast<uintptr_t *>(Offsets::Script_GetNampowerVersion));
|
||||
RegisterLuaFunction(getNampowerVersion, reinterpret_cast<uintptr_t *>(Script_GetNampowerVersion));
|
||||
|
||||
char getItemILevel[] = "GetItemLevel";
|
||||
RegisterLuaFunction(getItemILevel, reinterpret_cast<uintptr_t *>(Offsets::Script_GetItemLevel));
|
||||
RegisterLuaFunction(getItemILevel, reinterpret_cast<uintptr_t *>(Script_GetItemLevel));
|
||||
|
||||
char getItemStats[] = "GetItemStats";
|
||||
RegisterLuaFunction(getItemStats, reinterpret_cast<uintptr_t *>(Script_GetItemStats));
|
||||
|
||||
char getSpellRec[] = "GetSpellRec";
|
||||
RegisterLuaFunction(getSpellRec, reinterpret_cast<uintptr_t *>(Script_GetSpellRec));
|
||||
|
||||
char getItemStatsField[] = "GetItemStatsField";
|
||||
RegisterLuaFunction(getItemStatsField, reinterpret_cast<uintptr_t *>(Script_GetItemStatsField));
|
||||
|
||||
char getSpellRecField[] = "GetSpellRecField";
|
||||
RegisterLuaFunction(getSpellRecField, reinterpret_cast<uintptr_t *>(Script_GetSpellRecField));
|
||||
}
|
||||
|
||||
std::once_flag loadFlag;
|
||||
|
||||
Reference in New Issue
Block a user