Greasy Fork is available in English.

Neverwinter gateway - Profession Automation

Automatically selects professions for empty slots

< 脚本Neverwinter gateway - Profession Automation的反馈

提问/评论

§
发表于:2015-03-11

Help with task asset hacking

Inside SelectItemFor function, can I somehow find out what task I am currently iterating on or do I have to pass it as an argument from parent function (i.e. createNextTask)?

I'd like to try to hack in some custom asset allocation / management based on task name...

Rotten_mind作者
§
发表于:2015-03-11

Please, explain better what you want script do.

Gateway select first asset automatically and next 1 - 3 are selected by script, look lines ~1500 - 1700, mailing assets away is easy solution...

/**
 * Selects the highest level asset for the i'th button in the list. Uses an iterative approach
 * in order to apply a sufficient delay after the asset is assigned
 *
 * @param {Array} The list of buttons to use to click and assign assets for
 * @param {int} i The current iteration number. Will select assets for the i'th button
 * @param {Deferred} jQuery Deferred object to resolve when all of the assets have been assigned
 */
function SelectItemFor(buttonListIn, i, def, prof) {
    buttonListIn[i].click();
    WaitForState("").done(function () {

        var $assets = $("div.modal-item-list a").has("img[src*='_Resource_'],img[src*='_Assets_'],img[src*='_Tools_'],img[src*='_Tool_'],img[src*='_Jewelersloupe_'],img[src*='_Bezelpusher_']"); //edited by RottenMind
        var $persons = $("div.modal-item-list a").has("img[src*='_Follower_']");
        var quality = [".Special", ".Gold", ".Silver", ".Bronze"];
        var ic, $it;

        var clicked = false;

        // Try to avoid using up higher rank assets needlessly
        if (prof.taskName === "Leadership") {
            var mercenarys = $('div.modal-item-list a.Bronze img[src*="Crafting_Follower_Leader_Generic_T1_01"]').parent().parent();
            var guards = $('div.modal-item-list a.Bronze img[src*="Crafting_Follower_Leader_Guard_T2_01"]').parent().parent();
            var footmen = $('div.modal-item-list a.Bronze img[src*="Crafting_Follower_Leader_Private_T2_01"]').parent().parent();

            if (mercenarys.length) {
                clicked = true;
                mercenarys[0].click();
            }
            else if (guards.length) {
                clicked = true;
                guards[0].click();
            }
            else if (footmen.length) {
                clicked = true;
                footmen[0].click();
            }
        }

        // check resources & assets for best quality, in descending order
        for (ic in quality) {
            $it = $assets.filter(quality[ic]);
            if ($it.length) {
                $it[0].click();
                clicked = true;
                break;
            }
        }

        // if no asset was selected, check for persons for best speed, in descending order
        if (!clicked) {
            for (ic in quality) {
                $it = $persons.filter(quality[ic]);
                if ($it.length) {
                    $it[0].click();
                    clicked = true;
                    break;
                }
            }
        }

        // if nothing was found at all, return immediately (skip other optional slots)
        if (!clicked) {
            $("button.close-button").trigger('click');
            console.log("Nothing more to click..");
            WaitForState("").done(function () {
                // Let main loop continue
                def.resolve();
            });
        }

        console.log("Clicked item");
        WaitForState("").done(function () {
            // Get the new set of select buttons created since the other ones are removed when the asset loads
            var buttonList = $('.taskdetails-assets:eq(1)').find("button");
            if (i < buttonList.length - 1) {
                SelectItemFor(buttonList, i + 1, def, prof);
            }
            else {
                // Let main loop continue
                def.resolve();
            }
        });
    });
}
§
发表于:2015-03-11

Well, the idea was to only get 3 Heroes and only use them to Destroy E. C., not to waste them on worthless tasks. In code, I can see how to test that the current profession is Leadership (via prof.taskName). However I'm not sure how to test if the current task is Destroy E. C...

Now I can see that I could either test this inside createNextTask and pass the result of the test as a new, additional parameter into SelectItemFor, or alternatively I could pass the task name as a new parameter into SelectItemFor and do the test there based on this new parameter. As I don't see too deeply into various data structures used, the question is if this could be avoided and the current task name could be somehow figured out directly inside SelectItemFor without introduction of new parameter.

§
发表于:2015-03-11
编辑于:2015-03-11

Do you have more assets than slots assigned for Leadership x2 ?
If not, your question doesn't make sense, because task starts always when previous ends and takes leaved assets.
3x Heroes is not enough because script takes always best assets (except white ones), so first takes 2 heroes, second 1 hero + another asset and third?
Maybe solution for you is: move Destroy E.C. to top of list - in this case they always take best assets...

In mod6 (in 5 days) Destroy Enemy Camp isn't best solution

§
发表于:2015-03-12

Sorry if my question wasn't clear, I am simply looking for a way how to find out current task inside SelectItemFor function. By current task, I mean current task, not current profession.

§
发表于:2015-03-12

The simplest solution is to create your own global variable.

Near line 280 define your variable


var loading_reset = false; // Enables a periodic reload if this is toggled on by the Auto Reload check box on the settings panel
var s_paused = false;	   // extend the paused setting to the Page Reloading function

var yourVariable;

Near line 1284 set your variable:


        if (task) {

            yourVariable = task;

            task = '/professions-tasks/' + prof.taskName + '/' + task.def.name;
            console.log('Task Found');
            unsafeWindow.location.hash = unsafeWindow.location.hash.replace(/\)\/.+/, ')' + task);

and use it anywhere you want

§
发表于:2015-03-12

Right, no point in passing it as a new argument into SelectItemFor, when it does not change during SelectItemFor's recurse. Awesome! Thx for tip.

发表回复

登录以发表回复。