Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Bot na e2
- // @version 1.1
- // @description Bot bijący e2
- // @author chuj cie to
- // @match http://telawel.margonem.pl/
- // @match http://regros.margonem.pl/
- // @grant none
- // ==/UserScript==
- //box z inputem
- ! function() {
- var box = document.createElement("div");
- box.id = "elemencik";
- box.innerHTML = "<input type='text' id='mob_name'><br>Wpisz nazwę/y mobka/ów";
- document.body.appendChild(box);
- var style = document.createElement("style");
- style.innerHTML = "#elemencik{position: absolute; left: 0px; bottom: 0px; background: gold; border: 1px solid red; text-align: center; color: black; padding: 10px}";
- document.head.appendChild(style);
- //localStorage i wczytanie danych
- g.loadQueue.push({
- fun: function() {
- if (!localStorage.getItem("mob" + hero.id)) localStorage.setItem("mob" + hero.id, "Wprowadź nazwę moba/ów");
- document.querySelector("#mob_name").value = localStorage.getItem("mob" + hero.id);
- hero.idz = hero.searchPath;
- }
- });
- //zapis do local
- document.querySelector("#mob_name").addEventListener("keyup", function() {
- localStorage.setItem("mob" + hero.id, document.querySelector("#mob_name").value);
- })
- }()
- ! function(_p) {
- var id = 0,
- mox,
- moy,
- att = false,
- best1,
- best2 = 9999999,
- id2 = 0;
- function checkWt(a) {
- if (chceckFake(a.id) && checkType(a)) {
- return true;
- } else {
- return false;
- }
- }
- function chceckFake(a) {
- if (document.getElementById("npc" + a)) {
- function j(k) {
- var l = document.createElement("canvas");
- l.width = k.width, l.height = k.height;
- var m = l.getContext("2d");
- m.drawImage(k, 0, 0);
- var n = l.toDataURL("image/gif");
- return n.replace(/^data:image\/(png|jpg|gif);base64,/, "")
- }
- var b = new XMLSerializer().serializeToString(document.getElementById("npc" + a)),
- c = b.split("""),
- d = c[3],
- e = new Image,
- f = new Image;
- e.src = "http://" + document.location.hostname + "/obrazki/npc/" + g.npc[a].icon, f.src = d;
- var h = j(e),
- i = j(f);
- return !(h !== i)
- }
- }
- function checkType(a) {
- if ((a.type == 2 || a.type == 3) && document.querySelector("#mob_name").value.toLowerCase().indexOf(a.nick.toLowerCase()) > -1) {
- return true;
- } else {
- return false;
- }
- }
- parseInput = function(x, y, z) {
- _p(x, y, z);
- if (id == 0) {
- for (var x in g.npc) {
- var npc = g.npc[x];
- if (npc) {
- if (checkWt(npc)) {
- best1 = Math.sqrt(Math.pow(Math.abs(hero.x - npc.x), 2)) + Math.sqrt(Math.pow(Math.abs(hero.y - npc.y), 2));
- if (best1 < best2) {
- best2 = best1;
- mox = npc.x;
- moy = npc.y;
- id2 = npc.id;
- }
- }
- }
- }
- id = id2;
- } else if (g.npc[id]) {
- if (!g.battle) {
- if (Math.abs(hero.x - mox) > 1 || Math.abs(hero.y - moy) > 1) {
- hero.idz(mox, moy);
- } else if (!att) {
- _g("fight&a=attack&ff=1&id=-" + id);
- att = true;
- setTimeout(function() {
- att = false;
- }, 1000);
- }
- }
- } else {
- id = 0;
- id2 = 0;
- best2 = 9999999;
- }
- }
- }(parseInput);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement