Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Bot
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match http://wilds.io/
- // @grant none
- // ==/UserScript==
- queuedRespawn = false;
- function log(msg)
- {
- console.log(msg);
- }
- function d(a, b)
- {
- let x = b.x-a.x;
- let y = b.y-a.y;
- return { x, y };
- }
- function goTowards(hero, target)
- {
- let {x, y} = d(hero, target);
- if ( Math.random() < (1/10) )
- {
- x = (Math.random()-0.5) * 1000;
- y = (Math.random()-0.5) * 1000;
- console.log('unstuck');
- }
- CLIENT.Game.setMoving(COMMON.FLAG_RIGHT, x>0);
- CLIENT.Game.setMoving(COMMON.FLAG_LEFT, x<0);
- CLIENT.Game.setMoving(COMMON.FLAG_DOWN, y>0);
- CLIENT.Game.setMoving(COMMON.FLAG_UP, y<0);
- }
- function rotateTowards(hero, villain)
- {
- let {x, y} = d(hero, villain);
- CLIENT.Game.pointerX = x * 10000;
- CLIENT.Game.pointerY = y * 10000;
- CLIENT.Game.desiredDirection = Utils.lookAt(hero.x, hero.y-24, villain.x, villain.y-24);
- }
- function attack()
- {
- CLIENT.Game.send("useSkill", { key: "one" });
- }
- function distance(a, b)
- {
- let dx = a.x-b.x;
- let dy = a.y-b.y;
- return Math.sqrt(dx*dx + dy*dy);
- }
- function turn()
- {
- if ( ! CLIENT.Game.entities )
- return;
- let hero = CLIENT.Game.player;
- let enemies = CLIENT.Game.entities.children.filter(e => e instanceof CLIENT.Citizen && e.team != CLIENT.Game.player.team );
- enemies.sort(enemy => distance(CLIENT.Game.player, enemy));
- let closestEnemy = enemies[0];
- let villain = closestEnemy;
- let goTo = { x: CLIENT.Game.modeData.innerWidth/2, y: CLIENT.Game.modeData.innerHeight/2 }; // lub villain
- goTowards(hero, goTo);
- rotateTowards(hero, villain);
- attack();
- if ( hero.dead && ! queuedRespawn )
- {
- queuedRespawn = true;
- setTimeout( tryRespawn, 5000 );
- }
- if ( Math.random() < (1/100) )
- {
- console.log('dash');
- CLIENT.Game.dash(COMMON.FLAG_UP);
- }
- }
- function tryRespawn()
- {
- console.log("try respawn");
- queuedRespawn = false;
- app.game.send("respawn", true);
- }
- function go()
- {
- // Don't rotate to cursor
- CLIENT.Game.Desktop.pointermove = () => {};
- setInterval(turn, 100);
- }
- go();
- (function() {
- 'use strict';
- let hero = CLIENT.Game.player;
- let villain = CLIENT.Game.entities.children.find(e => e instanceof CLIENT.Citizen);
- // Your code here...
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement