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 = "645|560 645|560".split(" "); */
- var coords = "645|560 650|505 655|503 663|520 653|505 647|555 645|555 646|558 654|505 646|560 654|506 654|501 651|544 648|561 645|558 649|561 650|560 651|553 661|516 652|552 653|549 652|550 651|560 660|521 655|538 646|562 648|563 652|559 650|556 658|527 661|518 647|561 664|517 654|562 665|506 653|559 663|521 663|517 648|560 655|564 659|556 649|560 660|546 653|563 656|553 658|543 666|494 656|548 661|521 658|545 660|543 662|519 669|521 668|504 651|563 667|523 662|548 655|552 657|564 655|559 664|552 665|517 666|495 656|563 664|547 654|565 655|565 664|564 669|519 653|565 654|561 658|558 661|564 670|506 670|530 657|559 652|563 667|513 657|558 660|563 670|540 664|559 669|539 671|530 673|528 663|564 662|565 662|563 661|566 657|562 663|559 675|522 674|529 664|558 658|564 667|551 662|549 671|527 674|499 671|526 713|541 713|540 700|541 706|538 718|549 703|544 717|550 709|553 711|554 707|550 704|545 712|554 714|550 714|538 711|533 710|548 704|544 702|544 705|543 705|521 702|546 706|520 709|543 705|519 712|549 719|552 710|549 711|532 712|540 715|539 706|522 707|521 712|551 705|555 702|548 700|527 716|528 721|529 723|524 718|528 722|532 707|517 710|542 721|541 706|499 721|540 718|540 717|542 718|551 715|543 673|429 674|433 675|429 665|446 708|500 708|504 711|503 709|502 710|504 711|506 711|500 712|499 707|501 707|502 710|500 714|508 713|508 707|507 711|507 721|507 724|505 723|504 727|502 725|514 730|509 725|519 720|510 726|507 725|517 717|504 722|507 722|508 723|510 724|510 708|510 727|521 729|515 719|519 710|511 724|517 725|516 715|510 719|518 728|517 710|510 710|506 709|506 712|505 714|500 754|473 " .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", 1) || units("catapult", 10);
- fill("spy:20,light,axe,heavy,spear,sword,archer,catapult:20");
- 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 = ["8: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