SHARE
TWEET

Untitled

a guest Aug 18th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript: /* @name: Rooftochten @author: Warre @description: Stuur je rooftochten snel en slim */
  2.  
  3. /* Instellingen */
  4. // Maximale looptijd van de rooftochten voor elk soort dorp uitgedrukt in uren
  5. var runtimes = {
  6.     'off' : 1,
  7.     'def': 1
  8. };
  9.  
  10. // De eenheden die gebruikt mogen worden om te versturen met de nodige informatie (haul = hoe veel gs een eenheid kan dragen, type = off / def)
  11. var    units = {
  12.     'spear': {'haul': 25, 'type': 'def'},
  13.     'axe': {'haul': 10, 'type': 'off'},
  14.     'marcher': {'haul': 50, 'type': 'off'},
  15.     'heavy': {'haul': 50, 'type': 'deff'}
  16.  
  17. };
  18. /* Einde Instellingen */
  19.  
  20. var $content = $('#scavenge_screen');
  21. if ($content.length > 0) {
  22.         var $btns = $content.find('.btn-default').not('.btn-disabled, .unlock-button');
  23.         var    haul = 0;
  24.         var type = {'off': 0, 'def': 0};
  25.  
  26.         for (var prop in units) {
  27.             var amount = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  28.  
  29.             haul = haul + parseInt(amount * units[prop].haul);
  30.             type[units[prop].type] = type[units[prop].type] + amount;
  31.         }
  32.  
  33.         if ($btns.length > 0 && haul > 0) {
  34.             var $btn = $btns.last();
  35.             var current = $btn.closest('.scavenge-option').find('.title').text().trim();
  36.             var scavengeObject = JSON.parse($('html').find('script:contains("ScavengeScreen")').html().match(/\{.*\:\{.*\:.*\}\}/g)[1]);
  37.             var scavengeIndex = {'Flegmatische  Fielt': '1', 'Bescheiden Bandieten': '2', 'Slimme Speurders': '3', 'Reuze Rovers': '4'};
  38.             var scavangeInfo = scavengeObject[scavengeIndex[current]];
  39.             var troop_type = (type.off > type.def) ? 'off' : 'def';
  40.             var runtime = runtimes[troop_type] * 60 * 60;
  41.             var loot = Math.pow(Math.pow(((runtime / scavangeInfo.duration_factor) - scavangeInfo.duration_initial_seconds), (1 / scavangeInfo.duration_exponent)) / 100, 1/2) / scavangeInfo.loot_factor;
  42.             var send = 0;
  43.  
  44.             for (var prop in units) {
  45.                 var ui = $('.unitsInput[name="' + prop + '"]');
  46.                 var needed = Math.round(loot / units[prop].haul);
  47.                 var max = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  48.  
  49.                 if (needed > max) {
  50.                     ui.val(max).trigger('change');
  51.                     loot = loot - (max * units[prop].haul);
  52.                     send = send + max;
  53.                 } else {
  54.                     ui.val(needed).trigger('change');
  55.                     send = send + needed;
  56.                     break;
  57.                 }
  58.             }
  59.  
  60.             if (send >= 10) {
  61.                 $btn.trigger('click');
  62.             } else {
  63.                 $('.arrowRight, .groupRight').trigger('click');
  64.             }
  65.         } else {
  66.             $('.arrowRight, .groupRight').trigger('click');
  67.         }
  68. } else {
  69.     location.href = game_data.link_base_pure + 'place&mode=scavenge';
  70. }
  71. void(0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top