📄 mbm_sorc.d2l
字号:
// Version 0.5
/*骀骀骀骀骀骀骀骀骀骀骀骀骀骀
System Variables
骀骀骀骀骀骀骀骀骀骀骀骀骀骀*/
var scriptclass=1;
var timedspell=new Array();
var numtimed=0;
var currenttimed=1;
var potname="blah";
var lastcoldorb2=0;
var lastcoldorb3=0;
var diddodge=false;
var needdodge=false;
var healstate=1;
var dc=0;
var attackpos=new Array();
attackpos.push({x:17554,y:8071});
attackpos.push({x:17554,y:8063});
attackpos.push({x:17559,y:8066});
attackpos.push({x:17562,y:8078});
attackpos.push({x:17562,y:8069});
attackpos.push({x:17562,y:8060});
attackpos.push({x:17566,y:8069});
attackpos.push({x:17570,y:8078});
attackpos.push({x:17570,y:8069});
attackpos.push({x:17570,y:8060});
attackpos.push({x:17573,y:8069});
attackpos.push({x:17575,y:8073});
attackpos.push({x:17575,y:8065});
// New attack position array
var newattackpos=new Array();
newattackpos.push({x:17552,y:8063,maxy:8063});
newattackpos.push({x:17550,y:8066,maxy:8066});
newattackpos.push({x:17552,y:8069,maxy:8069});
newattackpos.push({x:17555,y:8061,maxy:8073});
newattackpos.push({x:17562,y:8056,maxy:8077});
newattackpos.push({x:17565,y:8056,maxy:8077});
newattackpos.push({x:17568,y:8056,maxy:8077});
newattackpos.push({x:17571,y:8056,maxy:8077});
newattackpos.push({x:17574,y:8056,maxy:8077});
newattackpos.push({x:17577,y:8060,maxy:8075});
var Center = {x:17566, y:8069};
var numspells=spelllist.length;
var attackposdiv = 3; // Subdivision of attack positions
var merc;
var StartWeapon = weaponSwitch(1);
var MFWeapon = !StartWeapon;
/*骀骀骀骀骀骀骀骀骀骀骀骀骀骀
Set up Skills for Attack
骀骀骀骀骀骀骀骀骀骀骀骀骀骀*/
function mbm_SorcSetSkills()
{
// Check timed attack spells
numspells = spelllist.length;
if (numspells <= 0) mbm_abortmessage("Number of spells set to 0!!!");
for (n = 0; n < numspells; n++)
{
mbm_print("Spell #" + n + " is: " + spelllist[n]);
}
for (s = 0; s < numspells; s++)
{
mbm_print("me.getSkill("+spelllist[s]+")="+me.getSkill(spelllist[s]));
if (!me.getSkill(spelllist[s])) {
print("Not using " + spelllist[s] + ", you don't have this skill");
} else {
mbm_print("Spell " + spelllist[s] + " verified");
var istimed = sorcchecktiming(spelllist[s]);
if (istimed)
{
mbm_print("Spell " + spelllist[s] + " is timed!");
numtimed++;
timedspell[numtimed] = spelllist[s];
}
else mbm_print("Spell " + spelllist[s] + " is untimed! Not a valid spell!");
}
}
if (numtimed == 0) mbm_abortmessage("No timed attack spells defined!");
mbm_print("Number of timed spells: " + numtimed);
for (t = 1; t <= numtimed; t++)
{
mbm_print("Timed spell #" + t + " is: " + timedspell[t] + ", Skill level: " + me.getSkill((timedspell[t])));
}
// Check precasts
if (esp && !me.getSkill(ENERGYSHIELD)) {
esp = false;
}
if (asp != "none") {
if (!me.getSkill(asp)) {
asp = "none";
}
}
if (tsp && !me.getSkill(THUNDERSTORM)) {
tsp = false;
}
if (UseMerc && EnchantMerc && !me.getSkill(ENCHANT)) {
EnchantMerc = false;
}
// Check static field
if (UseStatic && !me.getSkill(STATICFIELD)) {
UseStatic = false;
print("Warning: static field not detected");
} else {
//print("Static skill: " + me.getSkill(STATICFIELD));
//print("Static range: " + (3.3 + 0.6 * me.getSkill(STATICFIELD)));
if (StaticRange == 0)
StaticRange = Math.floor((3.3 + 0.6 * me.getSkill(STATICFIELD)) * 1.4);
//print("Static range: " + StaticRange);
}
// Check untimed attack
if (UseUntimed) {
for (i = 0; i < UntimedList.length; i++) {
spell = UntimedList[i];
if (!sorccheckuntimedattack(spell)) {
print(spell + " is not a valid untimed attack. Disabled.");
} else if (!me.getSkill(spell)) {
print("Warning: " + spell + " not detected, disabled");
} else {
mbm_print("Using untimed attack: " + spell);
UntimedSpell.push(spell);
}
}
if (UntimedSpell.length == 0) {
print("No valid timed attacks, disabling");
UseUntimed = false;
}
}
// Check teleport
if (!me.getSkill(TELEPORT)) {
print("Teleport not detected!");
print("This script REQUIRES teleport to run. Sorry.");
delay(5000);
mbm_abortmessage("No teleport skill, can't run");
}
}
function sorcchecktiming(spellname)
{
if (spellname == FROZENORB) return(true);
else if (spellname == BLIZZARD) return(true);
else if (spellname == FIREWALL) return(true);
else if (spellname == METEOR) return(true);
else if (spellname == HYDRA) return(true);
else return (false);
}
function sorccheckuntimedattack(spellname)
{
if (sorcchecktiming(spellname)) return false;
else switch (spellname) {
case FROSTNOVA:
case CHARGEDBOLT:
case ICEBOLT:
case ICEBLAST:
case GLACIALSPIKE:
case FIREBOLT:
case FIREBALL:
case NOVA:
case TELEKINESIS:
return true;
default: break;
}
return false;
}
function mbm_SpellRange(spellname)
{
switch (spellname) {
case NOVA:
case FROSTNOVA:
return NovaRange;
default:
return NormUntimedRange;
}
}
/*骀骀骀骀骀骀骀骀骀骀骀骀骀骀
Sorceress Precasts
骀骀骀骀骀骀骀骀骀骀骀骀骀骀*/
function sorcprecast()
{
if (esp) mbm_Cast(ENERGYSHIELD);
if (asp != "none") mbm_Cast(asp);
if (tsp) mbm_Cast(THUNDERSTORM);
}
function mbm_SetSkill(spell, hand, del)
{
if (!del) del = 80;
if (me.getSkill(hand) != spell) {
me.setSkill(spell, hand);
for (var x = 0; x < 200; x++) {
delay(del/2);
if (me.getSkill(hand) == spell)
break;
// me.setSkill(spell, hand);
}
if (me.getSkill(hand) != spell) {
print("skill in " + hand + " is " + me.getSkill(hand) + " not " + spell);
return false;
}
// Delay two frames
delay(del);
}
// mbm_print("set skill to " + spell);
return true;
}
function mbm_PostCastDelay(mode, interdelay)
{
if (!interdelay) interdelay = 20;
// Delay
delay(interdelay);
// Wait for mode 10
// for (var x = 0; x < 60; x++) {
// delay(10);
// if (me.state == mode)
// break;
// }
if (me.state != mode)
return false;
// Delay
delay(interdelay);
// Wait for end of mode 10
for (var x = 0; x < 60; x++) {
delay(10);
if (me.state != mode)
break;
}
if (me.state == mode)
return false;
// Delay
if (me.ping > 400)
delay(200);
else
delay(interdelay * 2);
return true;
}
function mbm_FastCast(spell)
{
if (!mbm_SetSkill(spell, right_hand, 20)) {
bug("Casting of " + spell + " failed, couldn't switch to");
return false;
}
if (PrintCast)
print("Casting " + spell);
else
mbm_print("Casting " + spell);
me.useSkill(right_hand);
mbm_PostCastDelay(c_UnitMode_Player_Casting, 0);
}
function mbm_Cast(spell, hand, at, nopostdelay)
{
if (hand == undefined) {
hand = right_hand;
}
if (!mbm_SetSkill(spell, hand)) {
bug("Casting of " + spell + " failed, couldn't switch to");
return false;
}
if (PrintCast)
print("Casting " + spell);
else
mbm_print("Casting " + spell);
if (arguments.length <= 2 || !at) {
me.useSkill(hand);
} else {
at.useSkill(hand);
}
if (arguments.length <= 3 || !nopostdelay) {
if (!mbm_PostCastDelay(c_UnitMode_Player_Casting)) {
bug("Casting of " + spell + " failed: it fizzled, maybe because I not ready, me.state=" + me.state);
return false;
}
}
return true;
}
function sorccheckprecasts()
{
if (esp && (me.getState(c_UnitState_EnergyShield) == 0))
{
// Check for very low mana
if (me.mp < 50) {
print("warning: very low mana, waiting to recast energy shield");
} else {
// print("Re-casting Energy Shield");
mbm_Cast(ENERGYSHIELD);
delay(40);
}
}
if (asp != "none") {
if (asp == FROZENARMOR && !me.getState(c_UnitState_FrozenArmor)) {
// print("Re-casting Frozen Armor");
mbm_Cast(FROZENARMOR);
delay(40);
} else if (asp == SHIVERARMOR && !me.getState(c_UnitState_ShiverArmor)) {
// print("Re-casting Shiver Armor");
mbm_Cast(SHIVERARMOR);
delay(40);
} else if (asp == CHILLINGARMOR && !me.getState(c_UnitState_ChillingArmor)) {
// print("Re-casting Chilling Armor");
mbm_Cast(CHILLINGARMOR);
delay(40);
}
}
if (tsp && !me.getState(c_UnitState_ThunderStorm))
{
// print("Re-casting Thunder Storm");
mbm_Cast(THUNDERSTORM, right_hand, null, true);
delay(40);
}
if (UseMerc && EnchantMerc)
{
merc = getUnit(1, mercname);
if (merc) {
if (merc.hp > 0 && !merc.getState(c_UnitState_Enchant))
{
// print("Casting enchant on merc");
mbm_Cast(ENCHANT, right_hand, merc);
delay(40);
}
}
}
}
function mbm_Recharge()
{
if (RechargePct > 100) RechargePct = 100;
if (mbm_MyMana() < RechargePct) {
print("Recharging mana...");
i = 4;
do {
// Check for hydras
var hydra = getUnit(1, HYDRA);
if (hydra) do {
if (hydra.getParent() != me)
if (calcdistance(me.x, me.y, hydra.x, hydra.y) < 4)
mbm_abortmessage("Hydra found my healing spot");
} while (hydra.getNext());
delay(250);
me.overhead("(" + Math.floor(i++ / 4) + ") Mana: " + mbm_MyMana() + "%");
} while (mbm_MyMana() < 99 && i <= 200);
} else {
// print("me.mana: " + me.mp + ". Max mana: " + mymaxmana + ". Not waiting.");
}
}
/*骀骀骀骀骀骀骀骀骀骀骀骀骀骀
Sorceress Attack
骀骀骀骀骀骀骀骀骀骀骀骀骀骀*/
function mbm_HideAndRecharge()
{
teleporttoentrace();
mbm_Recharge();
sorccheckprecasts();
teleporttomeph();
if (!checkfortarget(MEPHISTO)) {
mbm_abortmessage(name + " not detected!");
}
}
function mbm_LoadDuranceThreeMap()
{
var line;
var fp;
var y, x, z, tx, ty;
var now = new Date().getTime();
fp = fileOpen("libs/mbm/durance.map.d2l", 0);
if (!fp) {
bug("Error opening durance map");
return;
}
DuranceMap = new Array(DuranceMapHeight);
for (y = 0; y < DuranceMapHeight; y++) {
line = fp.readLine();
DuranceMap[y] = new Array(DuranceMapWidth);
for (x = 0; x < DuranceMapWidth; x++) {
DuranceMap[y][x] = (line.charAt(x) == 'X');
}
}
fp.close();
/*
DuranceMap = new Array(DuranceMapHeight);
for (y = 0; y < DuranceMapHeight; y++) {
DuranceMap[y] = new Array(DuranceMapWidth);
for (x = 0; x < DuranceMapWidth; x++)
DuranceMap[y][x] = false;
}
*/
// Find the near room collision info
var room = getRoom();
if (room) do {
if (room.x >= 3524 || room.y == 1600 || room.y == 1624) continue;
// print("room id " + room.number + ", xy = " + room.x + "," + room.y);
if (!room.getStat(c_RoomStat_nSizeGameX)) continue;
maxx = room.getStat(c_RoomStat_nSizeGameY);
maxy = room.getStat(c_RoomStat_nSizeGameX);
basex = room.x * 5 - DuranceMinX;
basey = room.y * 5 - DuranceMinY;
for (y = 0; y < maxy; y++) {
for (x = 0; x < maxx; x++) {
z = room.getCollision(x, y);
// if (z & 1 || z & 0x400)
if ( z & 0x400 )
for (ty = y - 1; ty <= y + 1; ty++) {
for (tx = x - 1; tx <= x + 1; tx++) {
DuranceMap[basey + ty][basex + tx] = true;
}
}
}
}
} while (room.getNext());
var then = new Date().getTime();
mbm_print("Durance Three mapped in " + (then - now));
/*
fp = fileOpen("testdump.txt", 1);
var line ="";
for (y = 0; y < DuranceMapHeight; y++) {
for (x = 0; x < DuranceMapWidth; x++) {
line += (DuranceMap[y][x] ? "X" : ".");
}
fp.writeLine(line);
line = "";
}
fp.close();
*/
}
function mbm_CalcAttackPos()
{
attackpos = new Array();
for (var i = 0; i < newattackpos.length; i++) {
var newpos = newattackpos[i];
for (var y = newpos.y; y < newpos.maxy; y += attackposdiv) {
attackpos.push({x:newpos.x, y:y});
}
attackpos.push({x:newpos.x, y:newpos.maxy});
}
// FIXME: hack hack hack hack hack
// if (StaticRange < 8)
mbm_print("Generated attack position subdivision grid with " + attackpos.length + " points");
}
function mbm_SorcAttack()
{
if (!checkfortarget(MEPHISTO))
mbm_abortmessage(name + " not detected! If you use a non-English Diablo 2 check your language settings.");
//if (debuglevel > 1) reportimmunities(MEPHISTO);
//checkimmunities(MEPHISTO);
// Calculate new attack position array
mbm_CalcAttackPos();
//if (usestatic && (maxstatic > 0) && (me.setSkill("Static Field",right_hand)))
// sorccaststatic();
// mbm_print("Beginning main attack spell sequence");
mbm_EventLoop();
/*
mbm_InitEvents();
while (target.hp > 0)
{
if (!mbm_SorcEventTurn())
ev_Idle();
if (HideWhenManaLow && target.hp > 0x18) {
if (mbm_MyMana() < HideThreshold) {
mbm_HideAndRecharge();
}
}
}
*/
print("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -