Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Suggestion] allow custom scripts into reward item

  • Version: All
  • Product: Quester
  • Type: Suggestion
  • Status: Added

Hello @Droidz,

my team and i are trying to writing a custom script to over ride Quest item choose rewards, and would love if you could add a option a option to use custom script on the quest reward frame.

The only way I could find to take over the item selection would be to write a full override of the turn-in on every single quest, which would be alot of work. It would be ideal if the reward item field could take lua that can run when the gossip menu is open and the custom lua simply returns the reward item number. this will allow code that can determine the item based on stats, then return the preferred reward item number. After that let the rest of wrobots turn-in code do its thing

 

This is a big feature and would make quester product even better. and more afkable.

User Feedback

Recommended Comments

Hello, wait next update, I added even:

wManager.Events.OthersEvents.OnSelectQuestRewardItem += delegate(CancelEventArgs cancelable)
{

};

if you cancel event WRobot will not select reward item.

Matenia

Elite user

This is great. Now I don't have to use a Lua hook anymore. 

Otherwise you can use a Lua hook to create a race condition between your selection code and ANY code turning in the quest:
 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using DatabaseManager.Enums;
using robotManager.Events;
using robotManager.FiniteStateMachine;
using robotManager.Helpful;
using robotManager.Products;
using wManager;
using wManager.Wow.Bot.Tasks;
using wManager.Wow.Class;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

public class QuestRewardSelector
{
    public static string TooltipName = "QuestItemCompareTooltip";
    
    public static void Start()
    {
        TooltipName = LuaVariableSettings.CurrentSetting.QuestToolTipName;
        RegisterHook();
        CreateTooltip();
        EventsLua.AttachEventLua((LuaEventsId) Enum.Parse(typeof(LuaEventsId), "QUEST_COMPLETE"), QuestCompleteHandler);
    }

    public static void Stop()
    {
        
    }

    public static void CreateTooltip()
    {
        Lua.LuaDoString($@"
        if not {TooltipName} then
            {TooltipName} = CreateFrame('GameTooltip', '{TooltipName}', nil, 'GameTooltipTemplate'); 
            {TooltipName}:SetOwner(UIParent, 'ANCHOR_NONE');
        end
        ");
    }

    public static void RegisterHook()
    {
        Lua.LuaDoString($@"
            if (not {LuaVariableSettings.CurrentSetting.QuestHookName}) then
                _OriginalQuestCompleteOnClick = QuestFrameCompleteQuestButton:GetScript(""OnClick"");
                function hook_QuestComplete(self, button, arg2, arg3)
                    self = this;
                    if (button == ""FORCE"") then
                        --DEFAULT_CHAT_FRAME:AddMessage('Forcing quest acceptance!');
                        _OriginalQuestCompleteOnClick(self, button);
                    else       
                        C_Timer.After(2500, function()
                            --DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 2500ms');
                            _OriginalQuestCompleteOnClick(self, button);
                        end);    
                    end
                end
                QuestFrameCompleteQuestButton:SetScript(""OnClick"", hook_QuestComplete);

                _GetQuestReward = GetQuestReward;
                function GetQuestReward(index, force)
                    if(force) then
                        return _GetQuestReward(index);
                    else
                        C_Timer.After(2500, function()
                            --DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 2500ms');
                            return _GetQuestReward(index);
                        end);
                    end
                end

                --DEFAULT_CHAT_FRAME:AddMessage('Quest hook initiated');
                {LuaVariableSettings.CurrentSetting.QuestHookName} = true;
            end
        ");
    }

    private static void QuestCompleteHandler(object context)
    {
        Lua.LuaDoString("QuestFrameCompleteQuestButton:Disable();");
        PluginLog.Log("About to complete quest - INTERCEPT!");
        SelectQuestItem();
        Lua.LuaDoString("QuestFrameCompleteQuestButton:Enable();");
        //fallback
        Lua.LuaDoString($"_GetQuestReward(1);");
    }

    private static void SelectQuestItem()
    {
        try
        {
            int questRewards = Lua.LuaDoString<int>("return GetNumQuestChoices()");
            if (questRewards == 0)
            {
                return;
            }

            Dictionary<ParsedItem, int> itemRewards = new Dictionary<ParsedItem, int>();
            for (int i = 1; i <= questRewards; i++)
            {
                Lua.LuaDoString($@"
                        {TooltipName}:Hide();
                        {TooltipName}:SetOwner(UIParent, 'ANCHOR_NONE');
                        {TooltipName}:ClearLines();
                        {TooltipName}:SetQuestItem(""choice"", {i});
                 ");

                ParsedItem item = ItemParser.ParseCurrentTooltip(TooltipName, true);
                if (item.isUsable)
                {
                    itemRewards.Add(item, i);
                }
            }

            ItemComparator comparator = new ItemComparator(StatWeights.ForClass(ObjectManager.Me.WowClass));
            ParsedItem bestItem = comparator.FindBestItem(itemRewards.Keys.ToList());

            int index = itemRewards[bestItem];
            PluginLog.Log("Found best item " + bestItem.name + " as reward number: " + index);
            Lua.LuaDoString($@"
                --QuestFrameCompleteQuestButton:Enable();
                _GetQuestReward({index});
            ");
            Thread.Sleep(1000);
        }
        catch (Exception e)
        {
            Logging.WriteError("" + e);
        }
    }

    private static async void SelectQuestItemAsync()
    {
        await Task.Run(() =>
        {
            SelectQuestItem();
        });
    }
}

 

TheSmokie

Banned

My Team got the code working and gonna add it to Project X with a big bug fixes with in a week.

TheSmokie

Banned

@Droidz Can you add the same function for picking up quests?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.