Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:
- var gd = game_data;
- /* CONFIG: ustawiÄ na 0.00 na Ĺwiatach bez ograniczonego fejkowania */
- var perc = 0.01;
- var v = gd.village;
- var u = {
- "spear": 1,
- "sword": 1,
- "axe": 1,
- "archer": 1,
- "spy": 2,
- "light": 4,
- "marcher": 5,
- "heavy": 6,
- "ram": 5,
- "catapult": 8,
- "knight": 10,
- "snob": 100
- }
- var left;
- try {
- if (document.URL.indexOf('try=confirm') != -1 && document.URL.indexOf('target=') == -1);
- else if (document.URL.indexOf('screen=place') == -1 || (document.URL.indexOf('mode') != -1 && document.URL.indexOf('mode=command') == -1)) {
- location = gd.link_base_pure + "place&mode=command";
- } else {
- if ($('.jump_link')[0] !== undefined) {
- location = $('#village_switch_right')[0].href;
- } else {
- var ul = $('.unit_link');
- for (var i = 0; i < ul.length; i++)
- $('#unit_input_' + $(ul[i]).attr('data-unit'))[0].value = "";
- /* CONFIG: wpisz koordynaty do losowania */
- /* np. var coords = "532|538 535|537".split(" "); */
- var coords = "529|532 536|533 528|539 536|538 537|538 536|540 535|540 535|540 535|541 534|542 532|541 535|544 532|549 530|557 526|556 524|554 517|561 518|559 518|558 513|553 547|547 552|549 557|546 557|545 555|542 549|538 562|539 556|535 561|550 561|549 561|548 562|549 568|549 569|549 568|548 567|548 566|548 565|555 576|553 585|537 585|539 585|540 587|540 588|540 589|539 589|538 585|532 587|530 588|530 581|535 578|534 578|536 577|537 577|538 580|538 580|539 581|540 580|541" .split(" ");
- var selected = [];
- for (var i = 0; i < coords.length; ++i)
- if (isSelected(coords[i]))
- selected.push(coords[i]);
- if (selected.length != 0) {
- left = Math.floor(v.points * perc);
- var index = Math.round(Math.random() * (selected.length - 1));
- $(".target-input-field")[0].value = selected[index];
- /* CONFIG: wybĂłr wojsk */
- units("spy", 1);
- units("ram", 10) || units("catapult", 1);
- fill("spy:8,light,axe,heavy,spear,sword,archer");
- if (left > 0)
- UI.ErrorMessage('Masz za malo wojska, aby wyslac atak. Do ' + perc * 100 + '% ludnosci\r\nbrakuje ' + left + ' mieszkancow', 5000);
- } else {
- UI.ErrorMessage('Nie mozna wybrac wioski, aby atak wchodzil w podanych ramach czasowych', 5000);
- }
- }
- }
- } catch (err) {
- var message = "Wystapil nieoczekiwany blad. Sprawdz czy skrypt jest poprawnie skonfigurowany!";
- console.log(err.message);
- UI.ErrorMessage(message, 5000);
- }
- function isSelected(coords) {
- /* CONFIG: ustaw ramy czasowe, ktĂłre ci odpowiadajÄ */
- var days = ["1-31"];
- var intervals = ["7:00-23:59"];
- var distance = Math.hypot(coords.split("|")[0] - v.x, coords.split("|")[1] - v.y);
- var destination = new Date(distance * 1800000 + gd.time_generated);
- var isInInterval = (intervals, value, predicate) => {
- for (var i = 0; i < intervals.length; i++)
- if (predicate(value, intervals[i]))
- return true;
- return false;
- };
- if (!isInInterval(days, destination, (v, i) => {
- v = v.getDate();
- i = i.split('-');
- return parseInt(i[0]) <= v && v <= parseInt(i[1]);
- })) return false;
- if (isInInterval(intervals, destination, (v, i) => {
- var parseTimer = timer => parseInt(timer[0]) * 60 + parseInt(timer[1]);
- v = parseTimer([v.getHours(), v.getMinutes()]);
- i = i.split("-");
- return parseTimer(i[0].split(':')) <= v && v <= parseTimer(i[1].split(':'));
- })) return true;
- return false;
- }
- function tryUnits(name, value) {
- var mv = $('a#units_entry_all_' + name)[0].innerText.match(/\d+/)[0];
- var sv = $('#unit_input_' + name)[0].value;
- return mv - sv - value >= 0;
- }
- function units(name, value) {
- var mv = $('a#units_entry_all_' + name)[0].innerText.match(/\d+/)[0];
- var sv = $('#unit_input_' + name)[0].value;
- sv = sv == "" ? 0 : parseInt(sv);
- mv -= sv;
- if (value > mv)
- value = mv;
- left -= u[name] * value;
- $('#unit_input_' + name)[0].value = sv + value;
- return value > 0;
- }
- function fill(names) {
- if (left <= 0) return;
- names = names.split(',');
- var name, quantity;
- for (var i = 0; i < names.length; ++i) {
- name = names[i];
- quantity = NaN;
- if (name.indexOf(':') != -1) {
- quantity = parseInt(name.split(':')[1]);
- name = name.split(':')[0];
- }
- units(name, Math.ceil((isNaN(quantity) ? left : (quantity * u[name] >= left ? left : quantity * u[name])) / u[name]));
- if (left <= 0) return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement