Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name AutoHeal NI
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description try to take over the world!
- // @author MiensnyTrzaski
- // @match https://*.margonem.com/*
- // @grant none
- // ==/UserScript==
- const getBestItem=(diff,time=500)=>new Promise(res=>
- setTimeout(()=>
- res(Object.values(Engine.heroEquipment.getInvItems())
- .filter(a=>a._cachedStats.hasOwnProperty("leczy"))
- .filter(a=>a._cachedStats.leczy<=diff)
- .sort((first,second)=>second._cachedStats.leczy-first._cachedStats.leczy)[0])
- ,time))
- const healHero=async ()=>{
- let heroHP=Engine.hero.d.warrior_stats.hp;
- let bestHealItem=await getBestItem(Engine.hero.d.warrior_stats.maxhp-heroHP);
- while(bestHealItem){
- Engine.heroEquipment.sendUseRequest(bestHealItem);
- heroHP+=parseInt(bestHealItem._cachedStats.leczy);
- bestHealItem=await getBestItem(Engine.hero.d.warrior_stats.maxhp-heroHP);
- }
- }
- const main=(battleLog, warriorsInfo)=>{
- if(battleLog.some(a=>a.includes("winner")) && !Engine.dead && Engine.hero.d.warrior_stats.maxhp!==Engine.hero.d.warrior_stats.hp){
- healHero();
- }
- }
- (oldFun=>{
- Engine.communication.dispatcher.on_f=a=>{
- if(a.hasOwnProperty('m')){
- main(a.m,Object.values(a.w));
- }
- oldFun(a);
- };
- })(Engine.communication.dispatcher.on_f);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement