Created
September 4, 2021 02:09
-
-
Save DanielCoulbourne/e77c498ca13162e0a81c38560feab5d7 to your computer and use it in GitHub Desktop.
Melvor Idle Auto-Combat Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let eat = () => { document.getElementById('combat-footer-minibar-eat-btn').click(); console.log('Eating Food! - Current HP:' + getCurrentHP())} | |
let loot = () => { document.getElementById('combat-btn-loot-all').click(); console.log('Looting!')} | |
let jump = () => { loot(); document.getElementById('combat-slayer-task-jump').click(); console.log('Switching Task! - New Task: ' + getAssignment())} | |
let run = () => { document.getElementById('combat-btn-run').click(); alert('Ran away. Re-stock your food.')} | |
let foodValue = 110 | |
let getCurrentHP = () => parseInt(document.getElementById('combat-player-hitpoints-current-1').innerText) | |
let getFoodQuantity = () => parseInt(document.getElementById('combat-food-current-qty-1').innerText) | |
let getMaxHP = () => parseInt(document.getElementById('combat-player-hitpoints-max-1').innerText) | |
let getHealthDiff = () => getMaxHP() - getCurrentHP() | |
let getLootStatus = () => document.getElementById('combat-loot-text').innerText | |
let getCurrentEnemy = () => document.getElementById('combat-enemy-name').innerText | |
let getAssignment = () => document.getElementById('combat-slayer-task-name').innerText | |
let getAssignedEnemy = () => getAssignment().split(' x ')[1] | |
let fightingWrongEnemy = () => (getCurrentEnemy() !== getAssignedEnemy()) | |
let eatIfNecessary = () => { | |
if (getHealthDiff() >= foodValue) eat() | |
if (getFoodQuantity() <= 10) run() | |
} | |
let lootIfNecessary = () => { | |
if (getLootStatus() === "Loot to Collect ( 16 / 16 )") loot() | |
} | |
let jumpIfNecessary = () => { | |
if (fightingWrongEnemy() && getCurrentEnemy() !== '-') { | |
console.log('Fighting Wrong Enemy: ' + getCurrentEnemy() + '. Should be fighting ' + getAssignedEnemy()) | |
jump() | |
} | |
} | |
let fight = () => { | |
eatIfNecessary() | |
lootIfNecessary() | |
jumpIfNecessary() | |
} | |
window.eatingInterval = null | |
let startFighting = () => {window.eatingInterval = setInterval(fight, 1000)} | |
let stopFighting = () => clearInterval(window.eatingInterval) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment