Neverwinter gateway - Profession Automation

Automatically selects professions for empty slots

< 腳本Neverwinter gateway - Profession Automation的回應

提問/評論

§
發表於:2015-05-04

Maybe I found a bug in dailySCA()?

Hi there,


I'm not completely sure but I think the function dailySCA() could be buggy. I use the latest script version v1.10.06.06, which is the dot fix one. I read in the Tampermonkey wiki that GM_setValue() and GM_getValue() can hold only primitive datatypes of String, Integer or Boolean any other type may cause undefined behaviours, including crashes. In the Script under function dailySCA()

today = new Date();
thisday = today.getDay();

So in thisday is an Integer containing todays day of the week. Monday = 1 and so on.

dateforlastroll = GM_getValue("dateforlastrolls", 0);

Now dateforlastroll should contain a priorly saved day of the week or 0.

if (thisday !== dateforlastroll) {

In my Tests this condition was always true and that caused dailyroll = 0; again. I read that the !== operator checks for not equal value or not equal types. Could this cause the function to try SCA runs more often than it would be needed? Then the next if clause would always be true and another call of processSwordCoastDailies(); is made.

If I would like to save the time of the last processSwordCoastDailies(); would this modification do it?

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);
            GM_setValue("SCAHour", today.getHours());
            GM_setValue("SCAMin", today.getMinutes());
            GM_getValue("dailyswordcoast", 0);
        }

Or do I have to add something else for my new GM_Variables SCAHour and SCAMin?

What do you think? Am I completly wrong on this?

Rotten_mind作者
§
發表於:2015-05-04

Im more like concerned if "DAily SCA Roll" interferes character switch, but its still "Option" so script main functions are intact if option is not selected.

Not sure, but change week day during your test and look effects.

DAilyroll can be checked also from datamodel per character (not sure if each character data can be fetched without character switch).

There is allways possibility to missing "dots" or logic failure so it is good look after it.

This replaces current roll function. It looks if rolls are done so it will be allways at least two rounds, it reset "rolled count if all rolls are not succes" (gives 99% all roll done per day), small delay added to rolls price fetch.

 function processSwordCoastDailies(_charStartIndex, _rollStartIndex) {
    var _accountName = unsafeWindow.client.dataModel.model.loginInfo.publicaccountname;
    var _charIndex = (!_charStartIndex || parseInt(_charStartIndex) > (charSettings.length + 1) || parseInt(_charStartIndex) < 0) ? 0 : parseInt(_charStartIndex);
    var _fullCharName = settings["nw_charname" + _charIndex] + '@' + _accountName;
    var _rollIndex =  (!_rollStartIndex || parseInt(_rollStartIndex) >(charSettings.lenght + 1) || parseInt(_rollStartIndex) < 0) ? 0 : parseInt(_rollStartIndex);
    var _current_char =  settings["nw_charname" + _charIndex];
    var _hasLoginDaily = 0;
    var _hasRollDaily = 1;
    var _isLastChar = false;
    var _scaHashMatch = /\/adventures$/;
    if (!settings["paused"])
        PauseSettings("pause");

    // Switch to professions page to show task progression
    if (!_scaHashMatch.test(unsafeWindow.location.hash)) {
        return;
    } else if (unsafeWindow.location.hash != "#char(" + encodeURI(_fullCharName) + ")/adventures") {
        unsafeWindow.location.hash = "#char(" + encodeURI(_fullCharName) + ")/adventures";
    }

    if (settings["nw_charname" + (_charIndex + 1)] === undefined)
        _isLastChar = true;

    WaitForState("").done(function () {
        try {
            _hasLoginDaily = client.dataModel.model.gatewaygamedata.dailies.left.logins;
        } catch (e) {
            // TODO: Use callback function
            window.setTimeout(function () {
                processSwordCoastDailies(_charIndex, _rollIndex);
            }, delay.SHORT);
            return;
        }
        console.log("Checking SCA Dialy for", _fullCharName, "...",_charIndex, _rollIndex);
        _hasRollDaily = client.dataModel.model.gatewaygamedata.dailies.roll; // this looks if daily is done "1/0"
        if (_hasRollDaily !== 0) {
            // Do SCA daily dice roll if the button comes up
            WaitForState(".daily-dice-intro").done(function () {
                $(".daily-dice-intro button").trigger('click');
                WaitForState(".daily-awards-button").done(function () {
                    window.setTimeout(function() {
                        $(".daily-awards-button button").trigger('click');
                    },delay.SHORT);
                });
            });
            _rollIndex = -1;
        }
        if (_rollIndex === _charIndex && _isLastChar) {GM_setValue("dailyswordcoast", 4); GM_getValue("dailyswordcoast", 0); console.log(" all rolls done", _isLastChar, _rollIndex, _charIndex, _hasRollDaily, _current_char);}
        else if (_rollIndex !== _charIndex && _isLastChar){GM_setValue("dailyswordcoast", 0); GM_getValue("dailyswordcoast", 0);} console.log("some rolls are failed", _isLastChar, _rollIndex, _charIndex, _hasRollDaily);
        // If Dice roll dialog is non existant
        WaitForNotState(".modal-window.daily-dice").done(function () {
            if (_isLastChar) {
                window.setTimeout(function () {
                    PauseSettings("unpause");
                }, 3000);
            } else {
                window.setTimeout(function () {
                    processSwordCoastDailies(_charIndex + 1, _rollIndex + 1);
                }, 3000);
            }
        });
    });
}

發表回覆

登入以回復