Matenia 628 Posted December 15, 2017 Share Posted December 15, 2017 (edited) Hey @Droidz, currently, I'm trying to execute my own code instead of letting wRobot finish the quest (very last step - select item and complete quest). I've been doing it like this: EventsLua.AttachEventLua((LuaEventsId) Enum.Parse(typeof(LuaEventsId), "QUEST_COMPLETE"), QuestCompleteHandler); private static void QuestCompleteHandler(object context) { PluginLog.Log("About to complete quest - INTERCEPT!"); SelectQuestItem(); } private static void SelectQuestItem() { //my logic to turn in quest Lua.LuaDoString($@" QuestRewardItem{index}:Click(); QuestFrameCompleteQuestButton:Click(); "); } However, it seems wRobot will still be faster in turning in the quest and although I can correctly log which is the best item to choose, wRobot will select another item and finish the quest. If I run this code in wRotation and manually open the quest dialog, it works 100%. How can I stop the quester from turning it at that point? I've tried using Products.InPause = true and pausing the bot before selecting the quest item myself, but it doesn't seem to work. Edited December 16, 2017 by Matenia BetterSister 1 Link to comment https://wrobot.eu/forums/topic/8011-stop-quest-turn-in-and-inject-my-own-code/ Share on other sites More sharing options...
Droidz 2738 Posted December 16, 2017 Share Posted December 16, 2017 Hello, try to use ingame lua event like: f = CreateFrame('Frame') f:RegisterAllEvents() f:SetScript('OnEvent', function() if event and tostring(event) == 'QUEST_COMPLETE' then QuestRewardItem{index}:Click(); QuestFrameCompleteQuestButton:Click(); end end ) (use random name for "f" and "'Frame'") Link to comment https://wrobot.eu/forums/topic/8011-stop-quest-turn-in-and-inject-my-own-code/#findComment-36708 Share on other sites More sharing options...
Matenia 628 Posted December 16, 2017 Author Share Posted December 16, 2017 16 minutes ago, Droidz said: Hello, try to use ingame lua event like: f = CreateFrame('Frame') f:RegisterAllEvents() f:SetScript('OnEvent', function() if event and tostring(event) == 'QUEST_COMPLETE' then QuestRewardItem{index}:Click(); QuestFrameCompleteQuestButton:Click(); end end ) (use random name for "f" and "'Frame'") This does not work, because I rely in C# to parse item code from quest items. I will try to hook QuestFrameCompleteQuestButton.Click and see if I can prevent the original click by wRobot (does wRobot use memory writing or Lua to achieve this?). Link to comment https://wrobot.eu/forums/topic/8011-stop-quest-turn-in-and-inject-my-own-code/#findComment-36709 Share on other sites More sharing options...
Droidz 2738 Posted December 16, 2017 Share Posted December 16, 2017 WRobot use lua to turnin quest. You can try code like: ulong lastTarget = 0; wManager.Events.InteractEvents.OnInteractPulse += (target, cancelable) => { try { if (lastTarget == target) return; var o = ObjectManager.GetObjectByGuid(target); if (o.IsValid && o.Type == WoWObjectType.Unit) { var unit = new WoWUnit(o.GetBaseAddress); if (unit.IsValid && unit.NpcMarker == NpcMarker.YellowQuestion) { lastTarget = target; Interact.InteractGameObject(target); // your turnin code here } } } catch { } }; } or ulong lastTarget = 0; wManager.Events.InteractEvents.OnInteractPulse += (target, cancelable) => { try { if (lastTarget == target) return; if (!Logging.Status.StartsWith("Quester > TurnIn")) return; var o = ObjectManager.GetObjectByGuid(target); if (o.IsValid && o.Type == WoWObjectType.Unit) { var unit = new WoWUnit(o.GetBaseAddress); if (unit.IsValid) { lastTarget = target; cancelable.Cancel = true; Interact.InteractGameObject(target); // your turnin code here } } } catch { } }; Matenia 1 Link to comment https://wrobot.eu/forums/topic/8011-stop-quest-turn-in-and-inject-my-own-code/#findComment-36710 Share on other sites More sharing options...
Matenia 628 Posted December 16, 2017 Author Share Posted December 16, 2017 (edited) How does wRobot turn in a quest using Lua? Can you give me an example, please? I wrote a hook in Lua to prevent wRobot from turning in fast. The problem is, it works perfectly if I "click" on the button (by mouse) ingame or call QuestFrameCompleteButton:Click() but it doesn't work when Quest product. Even calling QuestFrameCompleteQuestButton:Disable() - the bot will STILL turn the quest in. Edit: I found out wRobot uses GetQuestReward, so it's possible to hook it using this: _GetQuestReward = GetQuestReward; function GetQuestReward(index, force) if(force) then return _GetQuestReward(index); else C_Timer.After(1000, function() DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 1000ms'); return _GetQuestReward(index); end); end end Lua.LuaDoString(@" local C_Timer = CreateFrame(""Frame"", ""C_Timer"", UIParent); C_Timer:Show(); C_Timer.schedule = {}; C_Timer:SetScript(""OnUpdate"", function(self, elapsed) self = C_Timer; elapsed = 1/GetFramerate(); for timestamp, callback in pairs(self.schedule) do if tonumber(timestamp) <= GetTime() then callback(); self.schedule[timestamp] = nil; end end end); C_Timer.After = function(duration, callback) C_Timer.schedule[tonumber(GetTime() + (duration / 1000))] = callback; end _OriginalQuestCompleteOnClick = QuestFrameCompleteQuestButton:GetScript(""OnClick""); --_OriginalQuestCompleteClick = QuestFrameCompleteQuestButton.Click; function hook_QuestComplete(self, button, arg2, arg3) self = this; if (button == ""FORCE"") then DEFAULT_CHAT_FRAME:AddMessage('Forcing quest acceptance!'); --_OriginalQuestCompleteClick(self, button); _OriginalQuestCompleteOnClick(self, button); else C_Timer.After(1000, function() DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 1000ms'); --_OriginalQuestCompleteClick(self, button); _OriginalQuestCompleteOnClick(self, button); end); end end QuestFrameCompleteQuestButton:SetScript(""OnClick"", hook_QuestComplete); --QuestFrameCompleteQuestButton.Click = hookQuestComplete; DEFAULT_CHAT_FRAME:AddMessage('Quest hook initiated'); "); Edited December 16, 2017 by Matenia Link to comment https://wrobot.eu/forums/topic/8011-stop-quest-turn-in-and-inject-my-own-code/#findComment-36712 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now