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 = "425|544 422|544 426|544 428|546 426|546 433|546 432|544 422|532 445|537 421|545 425|539 426|551 427|553 415|551 449|543 425|538 431|545 429|557 421|565 396|573 426|556 431|549 429|554 425|551 433|555 423|563 427|563 427|558 421|564 421|573 420|574 401|575 422|564 424|569 379|563 378|558 391|534 400|580 377|555 401|576 404|576 404|578 407|571 403|578 384|569 404|577 399|577 402|579 395|575 405|576 437|551 386|538 396|577 394|587 396|536 382|539 400|585 404|574 427|541 400|573 379|570 387|552 394|535 393|534 394|536 409|575 381|545 393|528 377|570 434|545 389|541 399|571 427|544 386|540 393|529 465|598 445|585 454|544 423|542 425|546 417|581 434|544 431|540 404|580 399|576 400|575 403|574 402|569 426|542 427|539 430|549 419|577 402|578 406|579 385|545 384|545 387|543 383|599 414|612 428|544 431|542 430|539 430|550 401|565 422|543 424|542 427|548 421|549 431|543 425|545 407|580 406|578 390|535 381|569 405|555 404|559 403|559 416|556 496|635 424|539 495|638 411|554 409|554 407|555 395|564 495|639 493|641 410|556 416|561 499|641 412|566 496|634 434|539 426|537 430|537 427|537 ".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