Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name AutoHeal z potek
- // @version 1.0
- // @match http://husaria.margonem.com
- // @grant none
- // @author adi wilk
- // ==/UserScript==
- (Engine => {
- const useItem = item => {
- const {
- name,
- id
- } = item;
- //window.log(`Uleczono potką ${name}.`);
- window._g(`moveitem&st=1&id=${id}`, () => {
- setTimeout(autoHeal, 100);
- });
- }
- const getMaxHealVal = items => {
- if (items.length > 0) {
- return items.reduce((first, second) => first._cachedStats.leczy >= second._cachedStats.leczy ? first : second)
- }
- }
- const autoHeal = () => {
- const {
- hp,
- maxhp,
- lvl
- } = Engine.hero.d.warrior_stats;
- if (hp < maxhp && !Engine.dead) {
- const items = Engine.items.fetchLocationItems("g")
- .filter(item => item._cachedStats.hasOwnProperty("leczy"))
- .filter(item => item._cachedStats.leczy <= maxhp - hp)
- .filter(item => !item._cachedStats.hasOwnProperty("lvl") || (item._cachedStats.hasOwnProperty("lvl") && item._cachedStats.lvl <= lvl))
- .filter(item => !item._cachedStats.hasOwnProperty("timelimit") || (item._cachedStats.hasOwnProperty("timelimit") && !item._cachedStats.timelimit.includes(",")));
- const item = getMaxHealVal(items);
- if (item !== undefined) useItem(item);
- }
- }
- window.API.addCallbackToEvent("close_battle", autoHeal);
- })(window.Engine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement