Scavenge script approved :)

Discussion in 'Scripts & independent tools' started by dabookman, Mar 17, 2019.

Share This Page

  1. dabookman

    dabookman Community Manager Staff Member Community Manager

    Joined:
    Oct 8, 2010
    Messages:
    753
    Likes Received:
    46
    Aparrently the script here didn't work so no point in it remaing :)
     
  2. chelover

    chelover New Member

    Joined:
    Jan 29, 2019
    Messages:
    5
    Likes Received:
    0
    how it works?) screenshots
     
  3. Monkey17

    Monkey17 New Member

    Joined:
    Mar 17, 2019
    Messages:
    1
    Likes Received:
    0
    I'm glad I'm not the only person who has no idea what this does.
     
  4. Executioner

    Executioner New Member

    Joined:
    Jul 9, 2015
    Messages:
    10
    Likes Received:
    0
    Have added to the quick bar but no idea how it works and cant work it out
     
  5. chelover

    chelover New Member

    Joined:
    Jan 29, 2019
    Messages:
    5
    Likes Received:
    0
    aslo, Use the script in the Rally point - Scavenging page! no idea
    threw and that's all, where to the description, we're all java programmers ))))
     
  6. TW.PLAYER

    TW.PLAYER Member

    Joined:
    Jan 22, 2012
    Messages:
    164
    Likes Received:
    2
  7. Foxtrot

    Foxtrot Active Member

    Joined:
    Mar 20, 2016
    Messages:
    493
    Likes Received:
    58
    is this script legal over here? if so have you tried using this script? ^
     
    Last edited: Mar 17, 2019
  8. TW.PLAYER

    TW.PLAYER Member

    Joined:
    Jan 22, 2012
    Messages:
    164
    Likes Received:
    2
    The script here does not work and we need some scriptors on here or from Inno please.
     
    Foxtrot likes this.
  9. TW.PLAYER

    TW.PLAYER Member

    Joined:
    Jan 22, 2012
    Messages:
    164
    Likes Received:
    2
    cheesasaurus Please come back to TW and sort this mess out. :)
     
  10. chelover

    chelover New Member

    Joined:
    Jan 29, 2019
    Messages:
    5
    Likes Received:
    0
    cheesasaurus was last seen:

    Apr 3, 2016

    come back,
    wait )) :D
     
  11. np12

    np12 Member

    Joined:
    Oct 31, 2015
    Messages:
    44
    Likes Received:
    16
    Looool so u gave us a broken one and banned the working one
     
    Foxtrot likes this.
  12. 9optimus999

    9optimus999 New Member

    Joined:
    Mar 18, 2019
    Messages:
    1
    Likes Received:
    0
    It doesnt work? - says its banned?
     
  13. TW.PLAYER

    TW.PLAYER Member

    Joined:
    Jan 22, 2012
    Messages:
    164
    Likes Received:
    2
    Even the staff are leaving the game. lol :D:D:D
     
  14. Executioner

    Executioner New Member

    Joined:
    Jul 9, 2015
    Messages:
    10
    Likes Received:
    0
    Thought I’d heck if this has been resolved yet but nope no luck
     
  15. Shinko To Kuma

    Shinko To Kuma New Member

    Joined:
    Mar 19, 2019
    Messages:
    3
    Likes Received:
    3
    Since I heard my scavenging script got deemed illegal here despite having permission on .net, .us, .nl, .de, .es, and .beta, I figured I'd check what's wrong with this one by request of someone I know from .net

    First off all, this script is using part of my code, idk where you got it, or why you aren't using half of it then banning my version, but that doesn't matter. I'm here to help people to use it.

    This is how your array looks after the math you got up top:

    upload_2019-3-19_1-10-20.png

    A simple console log would have shown you're doing something wrong in your math.

    It also doesn't limit the runtime you have at all so you get crazy runtimes on big villages.

    Here is the SAME SCRIPT WITH SOME ADDED VARIABLES AND MATH. This is not the version that is blocked for no apparent reason from.net, since that one is way more powerfull than this. If you ban this idk what to tell you, it doesn't do anything yours doesn't do besides calculations. For anyone using it, adjust "var hours=6;" to how long you want your troops to be gone. It will prioritise sending to the more efficient scavenging options if you don't have enough troops to fill all of them.

    Code:
    javascript:
    // Sophie "Shinko to kuma"
    //declaring variables
    var hours = 6;
    var scavengeInfo = JSON.parse($('html').find('script:contains("ScavengeScreen")').html().match(/\{.*\:\{.*\:.*\}\}/g)[0]);
    var duration_factor = scavengeInfo[1].duration_factor;
    var duration_exponent = scavengeInfo[1].duration_exponent;
    var duration_initial_seconds = scavengeInfo[1].duration_initial_seconds;
    var lackadaisicalLooters = document.getElementsByClassName("title")[0].innerHTML;
    var humbleHaulers = document.getElementsByClassName("title")[1].innerHTML;
    var cleverCollectors = document.getElementsByClassName("title")[2].innerHTML;
    var greatGatherers = document.getElementsByClassName("title")[3].innerHTML;
    
    //finding values
    spears = $('.units-entry-all[data-unit=spear]').text().match(/\((\d+)\)/)[1];
    swords = $('.units-entry-all[data-unit=sword]').text().match(/\((\d+)\)/)[1];
    axes = $('.units-entry-all[data-unit=axe]').text().match(/\((\d+)\)/)[1];
    lightC = $('.units-entry-all[data-unit=light]').text().match(/\((\d+)\)/)[1];
    heavyC = $('.units-entry-all[data-unit=heavy]').text().match(/\((\d+)\)/)[1];
    if ($('.units-entry-all[data-unit=archer]').text() != "") {
        archer = $('.units-entry-all[data-unit=archer]').text().match(/\((\d+)\)/)[1]
    } else archer = 0;
    
    if ($('.units-entry-all[data-unit=marcher]').text() != "") {
        marcher = $('.units-entry-all[data-unit=marcher]').text().match(/\((\d+)\)/)[1]
    } else marcher = 0;
    
    totalLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 + heavyC * 50 + archer * 10 + marcher * 50;
    totalSpSwLoot = spears * 25 + swords * 15;
    possibleLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 + heavyC * 50 + archer * 10 + marcher * 50;
    spearRatio = spears / (spears * 25 + swords * 15);
    swordRatio = swords / (spears * 25 + swords * 15);
    
    time = hours * 3600;
    haul = ((time / duration_factor - duration_initial_seconds) ** (1 / (duration_exponent)) / 100) ** (1 / 2);
    haul1 = haul / 0.1;
    haul2 = haul / 0.25;
    haul3 = haul / 0.5;
    haul4 = haul / 0.75;
    totalHaul = haul1 + haul2 + haul3 + haul4;
    
    var scavengeOptions = {};
    scavengeOptions[greatGatherers] = [
        {
            type: 'spear',
            count: (haul4 * (spears / possibleLoot))
        },
        {
            type: 'sword',
            count: (haul4 * (swords / possibleLoot))
        },
        {
            type: 'axe',
            count: (haul4 * (axes / possibleLoot))
        },
        {
            type: 'light',
            count: (haul4 * (lightC / possibleLoot))
        },
        {
            type: 'heavy',
            count: (haul4 * (heavyC / possibleLoot))
        },
        {
            type: 'archer',
            count: (haul4 * (archer / possibleLoot))
        },
        {
            type: 'marcher',
            count: (haul4 * (marcher / possibleLoot))
        },
    ];
    scavengeOptions[cleverCollectors] = [
        {
            type: 'spear',
            count: (haul3 * (spears / possibleLoot))
        },
        {
            type: 'sword',
            count: (haul3 * (swords / possibleLoot))
        },
        {
            type: 'axe',
            count: (haul3 * (axes / possibleLoot))
        },
        {
            type: 'light',
            count: (haul3 * (lightC / possibleLoot))
        },
        {
            type: 'heavy',
            count: (haul3 * (heavyC / possibleLoot))
        },
        {
            type: 'archer',
            count: (haul3 * (archer / possibleLoot))
        },
        {
            type: 'marcher',
            count: (haul3 * (marcher / possibleLoot))
        },
    ];
    scavengeOptions[humbleHaulers] = [
        {
            type: 'spear',
            count: (haul2 * (spears / possibleLoot))
        },
        {
            type: 'sword',
            count: (haul2 * (swords / possibleLoot))
        },
        {
            type: 'axe',
            count: (haul2 * (axes / possibleLoot))
        },
        {
            type: 'light',
            count: (haul2 * (lightC / possibleLoot))
        },
        {
            type: 'heavy',
            count: (haul2 * (heavyC / possibleLoot))
        },
        {
            type: 'archer',
            count: (haul2 * (archer / possibleLoot))
        },
        {
            type: 'marcher',
            count: (haul2 * (marcher / possibleLoot))
        },
    ];
    scavengeOptions[lackadaisicalLooters] = [
        {
            type: 'spear',
            count: (haul1 * (spears / possibleLoot))
        },
        {
            type: 'sword',
            count: (haul1 * (swords / possibleLoot))
        },
        {
            type: 'axe',
            count: (haul1 * (axes / possibleLoot))
        },
        {
            type: 'light',
            count: (haul1 * (lightC / possibleLoot))
        },
        {
            type: 'heavy',
            count: (haul1 * (heavyC / possibleLoot))
        },
        {
            type: 'archer',
            count: (haul1 * (archer / possibleLoot))
        },
        {
            type: 'marcher',
            count: (haul1 * (marcher / possibleLoot))
        },
    ];
    
    
    var unitsCapacity = {
        'spear': 25, 'sword': 15, 'archer': 10, 'axe': 10,
        'heavy': 50, 'light': 80, 'marcher': 50, 'knight': 100
    }
    checkCorrectPage();
    run();
    function run() {
        let btn = null;
        for (const option in scavengeOptions) {
            btn = findNextButton(option);
            if (btn) {
                fillInTroops(option, getAvailableUnits(), btn);
                break;
            }
        }
    }
    function fillInTroops(option, availableUnits, button) {
        scavengeOptions[option].forEach(units => {
            const type = units.type;
            const count = units.count;
            let requiredCapacity = availableUnits[type] < count ? availableUnits[type] : count;
            $(`input.unitsInput[name='${type}']`).val(requiredCapacity).trigger("change");
            $(button).focus();
        });
    }
    function findNextButton(option) {
        let btn = $(`.scavenge-option:contains("${option}")`).find('a:contains("Start")');
        if (btn.length > 0 && !$(btn).hasClass('btn-disabled')) return btn;
    }
    function getAvailableUnits() {
        let availableUnits = {};
        $('.units-entry-all').each((i, e) => {
            const unitName = $(e).attr("data-unit");
            const count = $(e).text().replace(/[()]/, '');
            availableUnits[unitName] = parseInt(count);
        });
        return availableUnits;
    }
    function checkCorrectPage() {
        const doc = document;
        if (window.frames.length > 0 && window.main != null) doc = window.main.document;
        const url = doc.URL;
        if (url.indexOf('screen=place&mode=scavenge') == -1) alert('Use the script in the Rally point - Scavenging page!');
    }
     
    Last edited: Mar 19, 2019
    Dark Donkey and Foxtrot like this.
  16. np12

    np12 Member

    Joined:
    Oct 31, 2015
    Messages:
    44
    Likes Received:
    16
    Its auto banned because your script is hosted on dropbox
     
  17. Dark Donkey

    Dark Donkey <img src="http://i1318.photobucket.com/albums/t655

    Joined:
    Feb 11, 2011
    Messages:
    2
    Likes Received:
    2
    It works for me.It would be nice to have better control of the time and units you send though.Thanks Sophie :)
     
    Executioner likes this.
  18. Shinko To Kuma

    Shinko To Kuma New Member

    Joined:
    Mar 19, 2019
    Messages:
    3
    Likes Received:
    3
    According to a TW .net mod my version has been legal for two days now here.

    I’ll post a condensed version that will work from quickbar, which will allow you to enable/disable trooptypes, and adjust runtime.

    https://pastebin.com/jkfgya2t

    putting a trooptype to disable will keep it home, enable will use it. script tries prioritising spear and sword to reach your desired runtime.

    If a .uk mod would like to upload the full version with UI I’ll give the link but I cba to make a support ticket for every single server. its legal on 7 versions
     
    Last edited: Mar 19, 2019
    Foxtrot likes this.
  19. Executioner

    Executioner New Member

    Joined:
    Jul 9, 2015
    Messages:
    10
    Likes Received:
    0
    Altho i have axe and lc enabled it will not add the number of troops i need i have to do it manually
     
  20. chelover

    chelover New Member

    Joined:
    Jan 29, 2019
    Messages:
    5
    Likes Received:
    0
    thanks, my hero, where should I send my money???)