Guest User

Melvor Idle Auto Eat Just Enough

a guest
May 24th, 2020
215
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //author: Lamb #3856
  2. //tries to eat just enough to survive the next attack
  3. //doesn't warn you if your max HP/DR is too low for an attack
  4.  
  5. function readAttack() {
  6.     let htmlAttack = document.getElementById("combat-enemy-attack-speed-desc").textContent.slice(6, -1);
  7.  
  8.     if (htmlAttack === " Speed") {
  9.         incomingAttack = "Attack";
  10.         incomingDamage = combatData.enemy.maximumStrengthRoll;
  11.     } else {
  12.         incomingAttack = enemySpecialAttacks.find(o => o.name === htmlAttack);
  13.         incomingDamage = (incomingAttack.setDamage) ? incomingAttack.setDamage * numberMultiplier : combatData.enemy.maximumStrengthRoll;
  14.     }
  15. }
  16.  
  17. function autoEatJustEnough() {
  18.     let hpMax = skillLevel[CONSTANTS.skill.Hitpoints] * numberMultiplier;
  19.     let maxHitBase;
  20.     let maxHit;
  21.  
  22.     if (incomingAttack === "Attack") {
  23.         maxHitBase = incomingDamage;
  24.     } else {
  25.         maxHitBase = incomingDamage * ((combatData.player.stunned) ? incomingAttack.stunDamageMultiplier : 1);
  26.     }
  27.    
  28.     maxHit = Math.ceil(maxHitBase / 100 * (100 - damageReduction))
  29.         + ((combatData.player.isBurning) ? Math.floor(hpMax * 0.02) : 0)
  30.         + ((combatData.enemy.reflectMelee && attackStyle <= 2) ? combatData.enemy.reflectMelee * numberMultiplier : 0)
  31.         + ((combatData.enemy.reflectMagic && attackStyle >= 6) ? combatData.enemy.reflectMagic * numberMultiplier : 0)
  32.         + ((combatData.enemy.reflectMelee && (attackStyle >= 3 || attackStyle <= 5)) ? combatData.enemy.reflectRanged * numberMultiplier : 0)
  33.  
  34.     while (combatData.player.hitpoints <= maxHit && combatData.player.hitpoints < hpMax) {
  35.         //console.log(maxHit, combatData.player.hitpoints);
  36.         eatFood();
  37.     }
  38. }
  39.  
  40. if (typeof readAttackLoop !== 'undefined') { clearInterval(readAttackLoop); }
  41. readAttackLoop = setInterval( () => { readAttack(); }, 500)
  42.  
  43. if (typeof autoEatJustEnoughLoop !== 'undefined') { clearInterval(autoEatJustEnoughLoop); }
  44. autoEatJustEnoughLoop = setInterval( () => { autoEatJustEnough(); }, 100)
RAW Paste Data