// ===================================================================== // Configurable Sorceress Mephisto Script with Randomization var version = "1.01c"; // Last Updated: 2:13 PM 2/4/2003 // Designed for JED // Authors: Avarice and Aennor #include "include/getbody.jed" #include "include/items.jed" #include "include/npcs.jed" #include "include/gold.jed" #include "include/pickit.jed" #include "include/moves.jed" #include "include/enchantments.jed" #include "include/SmartSleep.jed" #include "include/colorlog.jed" #include "include/actwarp.jed" Print(CBrown + "Loading settings for " + COrange + Player.Name + CBrown + "."); // Do not change these var defenses = new Array(); var defensestotal = 0; var skipthese = new Array(); var skiptotal = 0; var meph_attack_seq = new Array(); var mephattacktotal = 0; var currentSpell = ""; //////////////////////////////////////////////////////////////////////// /// Configurable Parameters /// //////////////////////////////////////////////////////////////////////// /// heal_life - Anything below this will go to Malah for healing /// /// heal_mana - Anything below this will go to Malah for healing /// /// health_chicken - If you have less life than this you will either/// /// use a potion if you have one, or if not exit /// /// health_bugout - If you have less life than this you will exit /// /// no questions asked /// /// health_potion - If you have less life than this you will /// /// use a potion if you have one /// /// mana_check - If this is set to true you will use a potion or /// /// exit if your mana falls below mana_chicken /// /// mana_chicken - If you have less mana than this you will either /// /// use a potion if you have one, or if not exit /// /// MephAttack - This is the attack sequence to use when fighting /// /// Mephisto /// /// Example: /// /// MephAttack("skill name", repetitions, optimum range, delay); /// /// MephAttack("Nova", 5, 10, 400); /// /// meph_repeat_after - Set this to the number of the attack /// /// seq to repeat after until Pindle is dead /// /// DefensiveSpell - This is the sequence of spells to cast before /// /// fighting Mephisto /// /// Example: /// /// DefensiveSpell("skill name",repetitions,optimum range,delay); /// /// DefensiveSpell("Energy Shield", 1, 0, 700); /// /// reposition - Set this to true if you want to ensure you are /// /// close enough to hit the monster with your attacks /// /// do_dodge - Set this to true if you want to dodge the extremely /// /// painful iceball-o-doom /// /// use_merc - Set this to true if you want to have your merc w/you /// /// merc_heal - Use potions on merc /// /// merc_chicken - If the merc has less life than this you will try/// /// to drop a potion on him/her /// /// buy_potions - If you want to buy potions from Ormus set to true /// /// err_on_potion_fail - Set to true it will exit the script if /// /// buying potions fails (safety). Set false /// /// to ignore the error /// /// want to fill your belt with if they drop /// /// repair_level - Set this to a decimal value 0 - 1 to set the /// /// percentage of durability at which you will repair/// /// Example: var repair_level = .3 /// /// This means you'd repair items that have <30% durability /// /// UseWeaponSwitch - set this to true/false depending on whether /// /// you want to use MF weapon switching /// /// MFweapon - Set this to the name of the weapon you want to use /// /// as you MF weapon /// /// MYweapon - Set this to the name of the weapon you use normally /// /// WeaponSwitchHealth - Set this to the percentage of health to /// /// switch to your MF weapon /// //////////////////////////////////////////////////////////////////////// var heal_life = 600; var heal_mana = 700; var health_chicken = 200; var health_bugout = 150; var health_potion = 400; var mana_check = false; var mana_chicken = 5; MephAttack("Frozen Orb", 1, 10, 750); MephAttack("Static Field", 6, 10, 500); MephAttack("Frozen Orb", 1, 10, 750); var meph_repeat_after = 2; DefensiveSpell("Energy Shield", 1, 0, 700); DefensiveSpell("Thunder Storm", 1, 0, 700); var reposition = true; var do_dodge = true; var use_merc = false; var merc_heal = true; var merc_chicken = 50; // Buy potions before run? Meph drops no full Rejuvs. var buy_potions = true; // set the below value to "false" if you don't want to exit if potion buy fails var err_on_potion_fail = true; var repair_level = .3; var UseWeaponSwitch = false; var MFweapon = "Blade of Ali Baba"; var MYweapon = "Chromatic Ire"; var WeaponSwitchHealth = 10; //////////////////////////////////////////////////////////////////////// /// End Configurable Parameters /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// General Parameters /// /// Do not edit anything below here /// //////////////////////////////////////////////////////////////////////// var meph = 0; var dodging = false; //////////////////////////////////////////////////////////////////////////////// // Path Coordinates //////////////////////////////////////////////////////////////////////////////// var town_path = new Array(5); town_path[0] = new coord(5118, 5168); town_path[1] = new coord(5133, 5155); town_path[2] = new coord(5133, 5125); town_path[3] = new coord(5133, 5100); town_path[4] = new coord(5150, 5088); town_path[5] = new coord(5150, 5075); town_path[6] = new coord(5158, 5050); var resur_path = new Array(3); resur_path[0] = new coord(5110, 5092); resur_path[1] = new coord(5075, 5092); resur_path[2] = new coord(5040, 5092); var repair_path = new Array(5); repair_path[0] = new coord(5150, 5088); repair_path[1] = new coord(5180, 5088); repair_path[2] = new coord(5210, 5088); repair_path[3] = new coord(5222, 5065); repair_path[4] = new coord(5222, 5040); var meph_path = new Array(7); meph_path[0] = new coord(17685, 8027); meph_path[1] = new coord(17655, 8040); meph_path[2] = new coord(17650, 8069); meph_path[3] = new coord(17620, 8069); meph_path[4] = new coord(17598, 8051); meph_path[5] = new coord(17575, 8062); meph_path[6] = new coord(17564, 8069); //////////////////////////////////////////////////////////////////////////////// // Main Function //////////////////////////////////////////////////////////////////////////////// function JSMain() { Sleep(Randomize(3000, 1000)); SetEventHandler("onDeath", "DeathEventFunc"); if(!CheckHand()) { ELog("Item in hand cannot be stashed!"); Sleep(2000); Disconnect(); return; } Print(CYellow + "AA_MephSorc" + CBrown + ", a script by " + CGreen + "Avarice" + CBrown + " and " + CRed + "Aennor" + CBrown + "."); Print(CBrown + "Version: " + CGold + version); Print(""); Sleep(100); // Use the Force Luke (enable on-screen display) UseTheForce(); if (UseWeaponSwitch) SetWeapon(MYweapon); // Make sure we are a Sorceress if(!Player.Class == 1) { ELog("You must be a sorceress to use this script!"); Sleep(2000); Disconnect(); return; } // If we died and can't get the body then panic if (!PickupBody()) { ELog("Cannot retrieve body!"); Sleep(2000); Disconnect(); return; } ClearInventoryPotions("Greater Healing Potion"); ClearInventoryPotions("Strong Healing Potion"); ClearInventoryPotions("Healing Potion"); SetupGlobalBeltPotions(); if (Act3Run()) { Disconnect(); return; } else { ELog("The Mephisto run failed."); Sleep(1000); Disconnect(); return; } } //////////////////////////////////////////////////////////////////////////////// // Main Run Functions //////////////////////////////////////////////////////////////////////////////// function Act3Run() { // See if we are in Act 3 if (Player.Act != 3) { PRed("Not in Act 3, moving there."); if (!ActWarp(3)) return false; PGreen("Now in Act 3, proceeding."); for(igototown = town_path.length - 1; igototown > 0; igototown--){ if (!Move(town_path[igototown])) return false; } } PBrown("The Mephisto run is starting."); if (!TownPrep()) return false; if (!DoWaypoint("durance of hate level 2")) return false; if (!MephRun()) return false; return true; } function TempMephRun() { meph = GetMephisto(); SetEventHandler("onRecvPacket", "OrbPacketParser"); while (0 == 0) { Sleep(1000); RepositionForAttack(meph, 10); } } //////////////////////////////////////////////////////////////////////////////// // Town Preparation //////////////////////////////////////////////////////////////////////////////// function TownPrep() { if (!Move(town_path[0])) return false; if (!Move(town_path[1])) return false; if (!Move(town_path[2])) return false; if (!Move(town_path[3])) return false; if (buy_potions && !RefillHealingPotions()) return false; if ((Player.Health < heal_life) || (Player.Mana < heal_mana) || NeedToIdentify()) { Sleep(500); if (!TalkToOrmus(heal_life, heal_mana)) return false; if (NeedToIdentify()) IdentifyInventoryItems(); // ID anything set to check } if (Merc.IsDead && use_merc) { if (!Move(resur_path[0])) return false; if (!Move(resur_path[1])) return false; if (!Move(resur_path[2])) return false; Sleep(1000); if (!TalkToAsheara()) return false; if (!Move(resur_path[2])) return false; if (!Move(resur_path[1])) return false; if (!Move(resur_path[0])) return false; } if (!Move(town_path[4])) return false; if (CheckForRepair(.3)) { if (!Move(repair_path[0])) return false; if (!Move(repair_path[1])) return false; if (!Move(repair_path[2])) return false; if (!Move(repair_path[3])) return false; if (!Move(repair_path[4])) return false; Sleep(500); if (!TalkToHratli()) return false; if (!Move(repair_path[4])) return false; if (!Move(repair_path[3])) return false; if (!Move(repair_path[2])) return false; if (!Move(repair_path[1])) return false; if (!Move(repair_path[0])) return false; if (!Move(town_path[4])) return false; } if (!Move(town_path[5])) return false; HandleGold(); StashInventory(); // Stash anything on our pick list that's in inv if (!Move(town_path[6])) return false; return true; } //////////////////////////////////////////////////////////////////////////////// // Meph Run //////////////////////////////////////////////////////////////////////////////// function MephRun() { SetEventHandler("onHealth", "HealthEventFunc"); if(mana_check) SetEventHandler("onMana", "ManaEventFunc"); if(!Merc.IsDead && merc_heal) SetEventHandler("onMercHealth", "MercHealthEventFunc"); SmartSleep(Randomize(1500, 500)); HandleDefenses(); if (!FindDungeonPath()) return false; if(!DoStairs("down")) return false; SmartSleep(400); HandleDefenses(); RestToRegenMana(); if (!PortToMeph()) return false; if (do_dodge) SetEventHandler("onRecvPacket", "OrbPacketParser"); for (mTry=0; mTry < 5 && !meph; mTry++) { meph = GetMephisto(); SmartSleep(100); } if (!meph) { ELog("Mephisto not found."); return false; } PickitEnable(); AttackSequence(meph_attack_seq, meph, meph_repeat_after); Stats("increment Mephisto"); PBrown("Mephisto has been destroyed."); if (UseWeaponSwitch) SetWeapon(MYweapon); if (do_dodge) RemoveEventHandler("onRecvPacket", "OrbPacketParser"); Sleep(100); PickitDisable(); PickIt(); SmartSleep(500); RemoveEventHandler("onHealth", "HealthEventFunc"); if(mana_check) RemoveEventHandler("onMana", "ManaEventFunc"); if(!Merc.IsDead && merc_heal) RemoveEventHandler("onMercHealth", "MercHealthEventFunc"); return true; } function FindDungeonPath() { failcount = 0; while (!TeleMovePath(788, 791)) { failcount++; if (failcount > 3) return false; } return true; } function PortToMeph() { failcount = 0; for (impath=0; impath < meph_path.length; impath++){ while (!TeleMove(meph_path[impath])) { failcount++; if (failcount > 2) return false; } } return true; } function GetMephisto() { EntityList = Entity.GetEntities(); for(i = 0; i < EntityList.length; i++){ monster = EntityList[i]; if(monster.Class == 1 && monster.MonsterType == 1 && monster.Type==242 ){ PBrown("Mephisto found."); return monster; } } return false; } //////////////////////////////////////////////////////////////////////////////// // Attack Functions //////////////////////////////////////////////////////////////////////////////// function AttackSequence(attack_seq, mon, repeat_after) { RandomizeMe = false; Sleep(100); for (i = 0; i < repeat_after && i < attack_seq.length; i++) { if (reposition && !dodging && i > 0) RepositionForAttack(mon, attack_seq[i].range); // Store current attack currentSpell = attack_seq[i].skill; Player.SetRightSkill(attack_seq[i].skill); for (n=0; n < attack_seq[i].repeat && !mon.Dead && !Player.Dead; n++) { Player.UseRightSkill(mon.Location.x, mon.Location.y); SmartSleep(Randomize(attack_seq[i].delay,50)); } } while (!mon.Dead && !Player.Dead) { for (i = repeat_after; i < attack_seq.length && !mon.Dead && !Player.Dead; i++) { if (reposition && !dodging) RepositionForAttack(mon, attack_seq[i].range); // Store current attack currentSpell = attack_seq[i].skill Player.SetRightSkill(attack_seq[i].skill); for (n=0; n <= Randomize(attack_seq[i].repeat, 1) && !mon.Dead && !Player.Dead; n++) { if (UseWeaponSwitch && mon.Health < WeaponSwitchHealth) SetWeapon(MFweapon); Player.UseRightSkill(mon.Location.x, mon.Location.y); SmartSleep(Randomize(attack_seq[i].delay,50)); } } } } function RepositionForAttack(monster, maxrange) { if (dodging) return; MonX = monster.Location.x; MonY = monster.Location.y; PlayX = Player.Location.x; PlayY = Player.Location.y; reprange = Math.floor(Math.sqrt(2 * Math.pow((maxrange / 2),2))); deltaX = Math.abs(PlayX - MonX); deltaY = Math.abs(PlayY - MonY); distance = Math.floor(Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY,2))); if (distance > maxrange || distance < 4) { PBrown("Repositioning..."); if (PlayX > MonX) newX = MonX + reprange; else newX = MonX - reprange; if (PlayY > MonY) newY = MonY + reprange; else newY = MonY - reprange; if (!dodging) TeleMove(new coord(newX, newY)); } } function OrbPacketParser() { // Look for Mephisto's "Frost Orb o'death" if((arguments[0] == 76 && arguments[1] == 1 && arguments[8] == 20) && !meph.Dead && !dodging) { dodging = true; PYellow("Dodging..."); MonDX = meph.Location.x; MonDY = meph.Location.y; PlayDX = Player.Location.x; PlayDY = Player.Location.y; deltaDX = Math.abs(PlayDX - MonDX); deltaDY = Math.abs(PlayDY - MonDY); if (PlayDX > MonDX) NewDX = MonDX - 10; else NewDX = MonDX + 10; if (PlayDY > MonDY) NewDY = MonDY - 10; else NewDY = MonDY + 10; TeleMove(new coord(NewDX, NewDY)); TeleMove(new coord(PlayDX, PlayDY)); dodging = false; Player.SetRightSkill(currentSpell); } } //////////////////////////////////////////////////////////////////////////////// // Spell Functions/Array Setups //////////////////////////////////////////////////////////////////////////////// function HandleDefenses() { for (HDi = 0; HDi < defenses.length; HDi++) { SmartSleep(500); Player.SetRightSkill(defenses[HDi].skill); SmartSleep(Randomize(600, 100)); Player.UseRightSkill(Player.Location.x, Player.Location.y); SmartSleep(Randomize(defenses[HDi].delay, 200)); } } function spell(s, p, r, d) { this.skill = s; this.repeat = p; this.range = r; this.delay = d; } function DefensiveSpell(s, p, r, d) { defenses[defensestotal++] = new spell(s, p, r, d); } function MephAttack(s, p, r, d) { meph_attack_seq[mephattacktotal++] = new spell(s, p, r, d); } //////////////////////////////////////////////////////////////////////////////// // Misc Functions //////////////////////////////////////////////////////////////////////////////// function RestToRegenMana() { if (Player.Mana < heal_mana) PBrown("Resting to regen Mana."); while (Player.Mana < heal_mana) SmartSleep(500); } function RefillHealingPotions() { RHPrefill = RefillBeltAmount(); if (RHPrefill > 0) { PBrown("Refilling potions in belt."); EL = Entity.GetEntities("ormus"); if (!EL.length) { ELog("Could not find Ormus to buy potions."); if (err_on_potion_fail) return false; else return true; } ormus = EL[0]; ormus.Approach(); Sleep(500); while (Player.IsRunning || Player.IsWalking) { Sleep(50); } ormus.Interact(); Sleep(1000); ormus.Trade(); Sleep(1000); RHPpot = 0; RHPIL = Items.GetItems(); for (RHPi=0; RHPi < RHPIL.length; RHPi++) { if (((RHPIL[RHPi].Name == "Greater Healing Potion") || (RHPIL[RHPi].Name == "Strong Healing Potion") || (RHPIL[RHPi].Name == "Healing Potion")) && RHPIL[RHPi].ActionID == Items.MSG_INSTORE) { RHPpot = RHPIL[RHPi]; Sleep(100); break; } Sleep(100); } if (!RHPpot) { ELog("I could not find a potion for sale."); ormus.Cancel(); if (err_on_potion_fail) return false; else return true; } for (RHPi=0; RHPi < RHPrefill; RHPi++) { Command("send 32" + Hex(ormus.ID) + "000000" + RHPpot.ID + "0000000001000000"); Sleep(1000); } ormus.Cancel(); Sleep(500); return true; } return true; } //////////////////////////////////////////////////////////////////////////////// // Event Handler Functions //////////////////////////////////////////////////////////////////////////////// function HealthEventFunc(health) { if (health < health_bugout) { Stats("increment chickens"); ELog("I'm outta here."); Disconnect(); return; } if (health < health_chicken) { if (!UseGlobalBeltPotion()) { Stats("increment chickens"); Disconnect(); return; } } } function ManaEventFunc(mana) { if(mana < mana_chicken && mana_check) { if (potionType != "Full Rejuv Potion" && potionType != "Rejuv Potion") { Stats("increment chickens"); Disconnect(); return; } if (!UseGlobalBeltPotion()) { Stats("increment chickens"); Disconnect(); return; } } } function MercHealthEventFunc(health) { if(health < merc_chicken && !Merc.IsDead) { MercUseGlobalBeltPotion(); } } function DeathEventFunc() { ELog("Ow. That hurt."); Stats("increment deaths"); Disconnect(); } //////////////////////////////////////////////////////////////////////////////// // TheForce Functions //////////////////////////////////////////////////////////////////////////////// function UseTheForce() { SetSuccessString = "" Stats("setscript AA_MephSorc"); Stats("add Total"); Stats("add Deaths"); Stats("add Chickens"); Stats("add Mephisto"); Stats("setsuccess Mephisto"); Stats("show"); }