Skip to content

Instantly share code, notes, and snippets.

@it-sova
Last active April 30, 2022 04:56
Show Gist options
  • Save it-sova/5e43e53ee20a01b3b5b5ab17efe2f711 to your computer and use it in GitHub Desktop.
Save it-sova/5e43e53ee20a01b3b5b5ab17efe2f711 to your computer and use it in GitHub Desktop.
uoem.ru -> Drink healpot
POTION_HEAL = 60;
// Output levels
types = {
healingPotion: {
type: 0x0F0E,
color: 0x0031,
cooldown: 5000,
}
}
output = {
"ERROR": {
"prefix": "P >",
"color": 0x008A,
},
"INFO": {
"prefix": "I >",
"color": 0x0003,
},
"OK": {
"prefix": "O >",
"color": 0x0044,
},
"WARNING": {
"prefix": "W >",
"color": 0x0085,
}
}
// Prints pased message above target/player/whatever
// If target is undefined, prints above player
// If level if undefined, INFO will be used
function overheadPrint(message, level, target) {
if (!target) {
target = Player.Serial();
}
if (!level || !output[level]) {
level = "INFO";
}
Orion.CharPrint(target, output[level]["color"], output[level]["prefix"] + " " + message);
}
function panicHeal() {
while (true) {
if (!Player.Dead()) {
// If we have some potions - proceed
potionCount = Orion.Count(types.healingPotion.type, types.healingPotion.color)
if (potionCount > 0) {
if (Player.Hits() < (Player.MaxHits() - (Player.MaxHits() / 100 * POTION_HEAL))) {
// Warn if 10 or less potions were found
if (potionCount <= 10) {
overheadPrint("There is !! " + potionCount + " !! heal potions left", "WARNING")
}
// Use potion
overheadPrint("Should use healpot!", "INFO")
potion = Orion.FindType(types.healingPotion.type, types.healingPotion.color);
if (potion.length > 0) {
Orion.UseType(types.healingPotion.type, types.healingPotion.color);
overheadPrint("Used healpot!", "OK")
Orion.Wait(types.healingPotion.cooldown);
}
}
} else {
// if no potions are present - let's wait, maybe we can get some from loot
if (Orion.Count(types.healingPotion.type, types.healingPotion.color) < 1) {
overheadPrint("No more potions left, waiting for 1 more minute", "ERROR")
for (i = 0; i <= 60; i++) {
Orion.Wait(1000);
}
}
}
}
Orion.Wait(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment