public WowInterface335a(IMemoryApi memoryApi) { Memory = memoryApi; OffsetList = new(); HookModules = new(); // lua variable names for the event hook string handlerName = BotUtils.FastRandomStringOnlyLetters(); string tableName = BotUtils.FastRandomStringOnlyLetters(); string eventHookOutput = BotUtils.FastRandomStringOnlyLetters(); // name of the frame used to capture wows events string eventHookFrameName = BotUtils.FastRandomStringOnlyLetters(); EventManager = new(LuaDoString, eventHookFrameName); // module to process wows events. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memoryApi.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { EventManager.OnEventPush(s); } }, null, memoryApi, Offsets, $"{eventHookOutput}='['function {handlerName}(self,a,...)table.insert({tableName},{{time(),a,{{...}}}})end if {eventHookFrameName}==nil then {tableName}={{}}{eventHookFrameName}=CreateFrame(\"FRAME\"){eventHookFrameName}:SetScript(\"OnEvent\",{handlerName})else for b,c in pairs({tableName})do {eventHookOutput}={eventHookOutput}..'{{'for d,e in pairs(c)do if type(e)==\"table\"then {eventHookOutput}={eventHookOutput}..'\"args\": ['for f,g in pairs(e)do {eventHookOutput}={eventHookOutput}..'\"'..g..'\"'if f<=table.getn(e)then {eventHookOutput}={eventHookOutput}..','end end {eventHookOutput}={eventHookOutput}..']}}'if b<table.getn({tableName})then {eventHookOutput}={eventHookOutput}..','end else if type(e)==\"string\"then {eventHookOutput}={eventHookOutput}..'\"event\": \"'..e..'\",'else {eventHookOutput}={eventHookOutput}..'\"time\": \"'..e..'\",'end end end end end {eventHookOutput}={eventHookOutput}..']'{tableName}={{}}", eventHookOutput )); string staticPopupsVarName = BotUtils.FastRandomStringOnlyLetters(); string oldPoupString = string.Empty; // module that monitors the STATIC_POPUP windows. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memoryApi.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { if (!oldPoupString.Equals(s, StringComparison.Ordinal)) { OnStaticPopup?.Invoke(s); oldPoupString = s; } } else { oldPoupString = string.Empty; } }, null, memoryApi, Offsets, $"{staticPopupsVarName}=\"\"for b=1,STATICPOPUP_NUMDIALOGS do local c=_G[\"StaticPopup\"..b]if c:IsShown()then {staticPopupsVarName}={staticPopupsVarName}..b..\":\"..c.which..\"; \"end end", staticPopupsVarName )); string battlegroundStatusVarName = BotUtils.FastRandomStringOnlyLetters(); string oldBattlegroundStatus = string.Empty; // module to monitor the battleground (and queue) status. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memoryApi.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { if (!oldBattlegroundStatus.Equals(s, StringComparison.Ordinal)) { OnBattlegroundStatus?.Invoke(s); oldBattlegroundStatus = s; } } else { oldBattlegroundStatus = string.Empty; } }, null, memoryApi, Offsets, $"{battlegroundStatusVarName}=\"\"for b=1,MAX_BATTLEFIELD_QUEUES do local c,d,e,f,g,h=GetBattlefieldStatus(b)local i=GetBattlefieldTimeWaited(b)/1000;{battlegroundStatusVarName}={battlegroundStatusVarName}..b..\":\"..tostring(c or\"unknown\")..\":\"..tostring(d or\"unknown\")..\":\"..tostring(e or\"unknown\")..\":\"..tostring(f or\"unknown\")..\":\"..tostring(g or\"unknown\")..\":\"..tostring(h or\"unknown\")..\":\"..tostring(i or\"unknown\")..\";\"end", battlegroundStatusVarName )); // module to detect small obstacles that we can jump over HookModules.Add(new TracelineJumpHookModule ( null, (x) => { IntPtr dataPtr = x.GetDataPointer(); if (dataPtr != IntPtr.Zero && Player != null) { Vector3 playerPosition = Player.Position; playerPosition.Z += 1.3f; Vector3 pos = BotUtils.MoveAhead(playerPosition, Player.Rotation, 0.25f); memoryApi.Write(dataPtr, (1.0f, playerPosition, pos)); } }, memoryApi, Offsets )); ObjectManager = new(memoryApi, Offsets); Hook = new(memoryApi, Offsets, ObjectManager); Hook.OnGameInfoPush += ObjectManager.HookManagerOnGameInfoPush; }
public WowInterface548(WowMemoryApi memory) { Memory = memory; HookModules = new(); // lua variable names for the event hook string handlerName = BotUtils.FastRandomStringOnlyLetters(); string tableName = BotUtils.FastRandomStringOnlyLetters(); string eventHookOutput = BotUtils.FastRandomStringOnlyLetters(); // name of the frame used to capture wows events string eventHookFrameName = BotUtils.FastRandomStringOnlyLetters(); EventManager = new(LuaDoString, eventHookFrameName); // module to process wows events. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memory.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { EventManager.OnEventPush(s); } }, null, memory, LuaEventHook.Get(eventHookFrameName, tableName, handlerName, eventHookOutput), eventHookOutput )); string staticPopupsVarName = BotUtils.FastRandomStringOnlyLetters(); string oldPoupString = string.Empty; // module that monitors the STATIC_POPUP windows. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memory.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { if (!oldPoupString.Equals(s, StringComparison.Ordinal)) { OnStaticPopup?.Invoke(s); oldPoupString = s; } } else { oldPoupString = string.Empty; } }, null, memory, $"{staticPopupsVarName}=\"\"for b=1,STATICPOPUP_NUMDIALOGS do local c=_G[\"StaticPopup\"..b]if c:IsShown()then {staticPopupsVarName}={staticPopupsVarName}..b..\":\"..c.which..\"; \"end end", staticPopupsVarName )); string battlegroundStatusVarName = BotUtils.FastRandomStringOnlyLetters(); string oldBattlegroundStatus = string.Empty; // module to monitor the battleground (and queue) status. HookModules.Add(new RunLuaHookModule ( (x) => { if (x != IntPtr.Zero && memory.ReadString(x, Encoding.UTF8, out string s) && !string.IsNullOrWhiteSpace(s)) { if (!oldBattlegroundStatus.Equals(s, StringComparison.Ordinal)) { OnBattlegroundStatus?.Invoke(s); oldBattlegroundStatus = s; } } else { oldBattlegroundStatus = string.Empty; } }, null, memory, $"{battlegroundStatusVarName}=\"\"for b=1,2 do local c,d,e,f,g,h=GetBattlefieldStatus(b)local i=GetBattlefieldTimeWaited(b)/1000;{battlegroundStatusVarName}={battlegroundStatusVarName}..b..\":\"..tostring(c or\"unknown\")..\":\"..tostring(d or\"unknown\")..\":\"..tostring(e or\"unknown\")..\":\"..tostring(f or\"unknown\")..\":\"..tostring(g or\"unknown\")..\":\"..tostring(h or\"unknown\")..\":\"..tostring(i or\"unknown\")..\";\"end", battlegroundStatusVarName )); // module to detect small obstacles that we can jump over HookModules.Add(new TracelineJumpHookModule ( null, (x) => { IntPtr dataPtr = x.GetDataPointer(); if (dataPtr != IntPtr.Zero && Player != null) { Vector3 playerPosition = Player.Position; playerPosition.Z += 1.3f; Vector3 pos = BotUtils.MoveAhead(playerPosition, Player.Rotation, 0.25f); memory.Write(dataPtr, (1.0f, playerPosition, pos)); } }, memory )); ObjectManager = new(memory); Hook = new(memory); Hook.OnGameInfoPush += ObjectManager.HookManagerOnGameInfoPush; }