Greasy Fork is available in English.

Neverwinter gateway - Profession Automation

Automatically selects professions for empty slots

< Opinie na Neverwinter gateway - Profession Automation

Pytanie/komentarz

§
Napisano: 07-01-2015

Dont use high level assets in extra slots?

Hello. Using the script, the script seems to give preference to using all the high level assets first (even for the extra slots), then moves down to the next highest, etc.

In previous scripts, the system used the highest asset first, then filled the extra slots with the lower level assets. Is there a way to restore it to that?

In order to avoid this, I'm currently running the script without the train assets box checked, so it just uses one asset. Not the fastest, but its better than wasting tons of time converting level 1's to level 3's.

§
Napisano: 07-01-2015

For me it works fine,

search text below from script body and just switch,

or do "Menu item" for it,

what use "Default if nothing selected", ;),

---------------------------------------------------

/**
* 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_']");
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:contains('Mercenary')");
var guards = $("div.modal-item-list a.Bronze:contains('Guard')");
var footmen = $("div.modal-item-list a.Bronze:contains('Footman')");

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").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 = $("h3:contains('Optional Assets:')").closest("div").find("button");
if(i < buttonList.length - 1) {
SelectItemFor(buttonList, i+1, def, prof);
}
else {
// Let main loop continue
def.resolve();
}
});
});
}

/* ################# original
function SelectItemFor(buttonListIn, i, def, prof) {
buttonListIn[i].click();
WaitForState("").done(function() {
var specialItems = $("div.modal-item-list a.Special");
var goldItems = $("div.modal-item-list a.Gold");
var silverItems = $("div.modal-item-list a.Silver");
var bronzeItems = $("div.modal-item-list a.Bronze");
var clicked = false;

// Try to avoid using up higher rank assets needlessly
if (prof.taskName === "Leadership") {
var mercenarys = $("div.modal-item-list a.Bronze:contains('Mercenary')");
var guards = $("div.modal-item-list a.Bronze:contains('Guard')");
var footmen = $("div.modal-item-list a.Bronze:contains('Footman')");

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(); }
}
// TODO: add remaining professions in the same way for bronze tier assets.

if (!clicked) {
// Click the highest slot
if (specialItems.length) { specialItems[0].click(); }
else if (goldItems.length) { goldItems[0].click(); }
else if (silverItems.length) { silverItems[0].click(); }
else if (bronzeItems.length) { bronzeItems[0].click(); }
else { $("button.close-button").click(); }
}

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 = $("h3:contains('Optional Assets:')").closest("div").find("button");
if (i < buttonList.length - 1) {
SelectItemFor(buttonList, i+1, def, prof);
}
else {
// Let main loop continue
def.resolve();
}
});
});
}
*/

------------------------------------------------

§
Napisano: 28-04-2015

Hi, it is a older post, but i have fixed the '(leadership) asset level problem' with a function:

/* * Try to select best Leader-Asset * 20150412 BarbaPapa */

function SelBestLeader() {

var optasset = ["Generic", "Guard", "Private", "Manatarms", "Sergeant", "Lietenant"]; var baseid = "#modal_content"; var assetname = ""; var level = 0; var levelold = 0; var laction = ""; var err = 1; var container = $(baseid).has( "a" );; // loop through <a> $(container).find("a").each(function( i, ela) { // loop through current <img> $(ela).find("img").each(function( x, elimg) { // loop through assetlevel $.each(optasset, function(index, value){ if( $(elimg).is( "[src*='"+value+"']" )) { //console.log("matching: "+value); //higher level ?? if( index >= levelold) { laction = $(ela); //fetch displayed assetname assetname = $(ela).find("div.icon-info").html(); //console.log("curr Level: "+index); console.log("Found higher Asset: "+assetname); //save new level levelold = index; // disable error err = 0; } } }); }); }); if(err === 0){ console.log( "Best asset Level : " +levelold+" "+assetname); //console.log( "Click Link : " ,laction); return laction; } return false;

}

Call the function in

SelectItemFor(buttonListIn, i, def, prof)


// Try to avoid using up higher rank assets needlessly
// 20150412 BarbaPapa
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();
    
    var clickasset = SelBestLeader();
    // will only execute if clickasset is defined.
    try {
        if(clickasset) {
            clicked = true;
            clickasset.click();
            }
        } catch(e) {
            console.log("Error, no Assets defined");
        }
    
    /*
    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();
    }
    */
}

Works fine for me

§
Napisano: 28-04-2015

Nice, did not test it yet, but must look. I just sell unused leadership assets or put them in mail...

If those work maybe they can be used as "function" so you can select option you want use...

Here is another snippet for SCA runs, SCA completion can be checked from account datamodel only per character so only way to see if it completed is run it... this shuold work but need recheck...

/**
 * Created by RM on 29.4.2015.
 * Runs daily SCA -rolls in GAteway Bot
 */
function dailySCA() {
    if (settings["dailySCA"]) {
        var char, today, thisday, thishour, dailyroll, dateforlastroll;
        char = settings["charcount"];
        today = new Date();
        thisday = today.getDate();
        thishour = today.getHours();
        dailyroll = GM_getValue("dailyswordcoast", 0);
        dateforlastroll = GM_getValue("dateforlastrolls", 0);
        //console.log(thisday, dateforlastroll, dailyroll, chardelay, thishour);
        if (thisday > dateforlastroll) {
            GM_setValue("dateforlastrolls", thisday);
            dailyroll = 0;
        }
        if (dailyroll < (4 || undefined) && chardelay > 10000 * char && (thishour >= 14 || thishour >= 23)) {
            unsafeWindow.location.hash = unsafeWindow.location.hash.replace(/\)\/.+/, ')' + "/adventures");
            processSwordCoastDailies();
            dailyroll++;
            GM_setValue("dailyswordcoast", dailyroll);
        }
    }
}

//added SCA completion counter, runs per day, replaces current panel.

   $("#prinfopane").empty().append("<h3 class='promo-image copy-top prh3'>Professions Robot<br />Next task for " + settings["nw_charname" + charcurrent] + "<br /><span data-timer='" + chardate + "' data-timer-length='2'></span><br />Diamonds: " + curdiamonds.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " #SCA[" + GM_getValue("dailyswordcoast", 0) + "]times." + "</h3>");

Odpowiedz

Zaloguj się, by odpowiedzieć.