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 = "504|617 505|617".split(" "); */
- var coords = "533|568 534|568 534|569 540|570 540|569 535|554 526|567 528|570 512|561 461|566 460|567 463|562 475|572 460|563 458|574 463|574 465|575 466|537 465|537 467|529 464|531 467|568 471|531 467|539 468|539 465|545 467|534 466|542 470|537 468|532 470|521 466|522 435|566 468|518 473|559 429|571 433|564 448|558 428|573 445|562 536|567 538|572 537|573 538|570 537|571 537|570 526|577 533|570 531|569 535|570 535|569 533|567 539|568 536|565 538|567 537|567 533|572 535|567 534|567 536|570 536|566 475|573 439|563 535|568 456|576 440|567 468|508 456|574 534|550 538|569 541|574 542|571 535|551 544|571 548|558 551|558 547|558 548|565 550|567 547|562 511|559 514|564 513|559 472|532 512|563 513|560 514|559 470|530 464|572 448|577 463|563 466|572 517|568 538|574 538|565 536|552 533|557 547|566 546|564 540|553 550|558 540|557 538|577 538|573 515|565 537|561 548|561 547|563 509|567 545|570 547|570 548|564 511|561 512|560 511|560 530|572 529|572 526|568 534|577 534|576 532|577 533|575 534|557 470|516 534|565 443|529 460|502 476|563 549|564 510|559 430|505 441|509 440|510 443|512 436|521 436|522 443|509 437|522 442|510 434|520 435|514 433|506 433|507 445|509 446|508 428|530 ".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", 5);
- units("ram", 1) || units("catapult", 1);
- fill("light,axe,spear,sword, heavy");
- if (left > 0)
- UI.ErrorMessage('Za maĹa pula wojsk, aby atak skĹadaĹ siÄ z ' + perc * 100 + '% ludnoĹci\r\nbrakuje ' + left + ' mieszkaĹcĂłw', 5000);
- } else {
- UI.ErrorMessage('Nie moĹźna wybraÄ wioski, aby atak wchodziĹ w podanych ramach czasowych', 5000);
- }
- }
- }
- } catch (err) {
- var message = "WystÄ piĹ nieoczekiwany bĹÄ d. SprawdĹş 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 = ["19-19"];
- var intervals = ["07:00-10:00"];
- var distance = Math.hypot(coords.split("|")[0] - v.x, coords.split("|")[1] - v.y);
- var destination = new Date(distance * 1714000 + 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