Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //made by github.com/BlekDimon
- const movingAddonsObj = {
- heroMoveToPos: function(j, i) {
- if (hero.isBlockedSearchPath()) {
- return hero.blockedInfoSearchPath();
- }
- var l = map.nodes.getNode(hero.x, hero.y);
- var k = map.nodes.getNode(j, i);
- if (!l.hasSameGroup(k)) {
- map.nodes.clearAllNodes();
- l.setScore(0, map.hce8(k, l));
- k = map.nodeSetLoop(k, l, map.findStep);
- }
- map.nodes.clearAllNodes();
- l.setScore(0, map.hce(l, k));
- map.nodeSetLoop(l, k, map.mapStep);
- var m = k;
- road = [];
- while (m !== null && m.id != l.id) {
- road.push({ x: m.x, y: m.y });
- m = m.from;
- }
- if (m !== null) {
- road.push({ x: m.x, y: m.y });
- }
- if (road.length > 1 && g.playerCatcher.follow == null) {
- $("#target")
- .stop()
- .css({
- left: road[0].x * 32,
- top: road[0].y * 32,
- display: "block",
- opacity: 1,
- "z-index": 1
- })
- .fadeOut(1000);
- }
- },
- createPanel: function() {
- $("<div class='autoMovePanel'></div>")
- .css({
- position: "absolute",
- "z-index": "1003",
- top: `${localStorage.getItem("move-panel-y")}px` || "0",
- left: `${localStorage.getItem("move-panel-x")}px` || "0",
- "font-family": "Verdana",
- "font-size": "10px",
- width: "fit-content",
- height: "fit-content",
- "text-align": "center",
- background: "#3498db",
- border: "2px solid white"
- })
- .appendTo("body")
- .html(
- "<span style='display: block; margin: 5px; font-weight: 700'>Move to:</span>" +
- "<span style='margin: 0 0 0 5px; font-weight: 700'>x: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='move-to-x' type='number' required />" +
- "<span style='margin: 0 0 0 5px; font-weight: 700'>y: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='move-to-y' type='number' required />" +
- "<button style='display: block; background: #2ecc71; border: none; color: white; font-size: 11px; font-weight: 700; padding: 2.5px 7.5px; position absolute; transform: translate(100%);' class='confirm-move-to'>Move</button>" +
- "<span style='display: block; margin: 5px; font-weight: 700'>Run around:</span>" +
- "<span style='margin: 0 0 0 5px; font-weight: 700'>x1: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='run-to-x1' type='number' required />" +
- "<span style='margin: 0 0 0 5px; font-weight: 700'>y1: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='run-to-y1' type='number' required />" +
- "<br><span style='margin: 0 0 0 5px; font-weight: 700'>x2: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='run-to-x2' type='number' required />" +
- "<span style='margin: 0 0 0 5px; font-weight: 700'>y2: </span>" +
- "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='run-to-y2' type='number' required />" +
- "<button style='display: block; background: #2ecc71; border: none; color: white; font-size: 11px; font-weight: 700; padding: 2.5px 7.5px; position absolute; transform: translate(110%); margin-bottom: 5px' class='confirm-run-around'>Start</button>"
- )
- .draggable({
- contaiment: "window",
- start: function(event, ui) {
- g.lock.add("movingAddonsYeah");
- },
- stop: function(event, ui) {
- localStorage.setItem("move-panel-y", ui.position.top);
- localStorage.setItem("move-panel-x", ui.position.left);
- g.lock.remove("movingAddonsYeah");
- }
- });
- },
- runAround: false
- };
- movingAddonsObj.createPanel();
- document.querySelector(".confirm-move-to").addEventListener("click", () => {
- const x = document.querySelector(".move-to-x").value;
- const y = document.querySelector(".move-to-y").value;
- if (x != "" && y != "") {
- movingAddonsObj.heroMoveToPos(parseInt(x), parseInt(y));
- }
- });
- document
- .querySelector(".confirm-run-around")
- .addEventListener("click", function() {
- const x1 = document.querySelector(".run-to-x1").value;
- const y1 = document.querySelector(".run-to-y1").value;
- const x2 = document.querySelector(".run-to-x2").value;
- const y2 = document.querySelector(".run-to-y2").value;
- if (x1 != "" && y1 != "" && x2 != "" && y2 != "") {
- if (movingAddonsObj.runAround == false) {
- movingAddonsObj.runAround = true;
- this.innerHTML = "Stop";
- setTimeout(
- (returned = function() {
- if (hero.x == x1 && hero.y == y1) {
- movingAddonsObj.heroMoveToPos(
- parseInt(x2),
- parseInt(y2)
- );
- } else if (hero.x == x2 && hero.y == y2) {
- movingAddonsObj.heroMoveToPos(
- parseInt(x1),
- parseInt(y1)
- );
- }
- setTimeout(returned, 200);
- }),
- 200
- );
- } else {
- movingAddonsObj.runAround = false;
- returned = "";
- this.innerHTML = "Start";
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement