⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 barbarian.d2l

📁 转载其他网站的资料与大家分享
💻 D2L
字号:
/*******************************************************************************
*                                                                              *
*                                The Multi MF                                  *
*                                   v1.25a                                     *
*                                                                              *
* ---------------------------------------------------------------------------- *
* Copyright (C) 2003 Jan Onno Tuinenga (Scavenger) - tha_scavenger@hotmail.com *
* ---------------------------------------------------------------------------- *
*                                                                              *
* This program is free software; you can redistribute it and/or modify         *
* it under the terms of the GNU General Public License as published by         *
* the Free Software Foundation; either version 2 of the License, or            *
* (at your option) any later version.                                          *
*                                                                              *
* This program is distributed in the hope that it will be useful,              *
* but WITHOUT ANY WARRANTY; without even the implied warranty of               *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                *
* GNU General Public License for more details.                                 *
*                                                                              *
********************************************************************************/

/////////////////////////////////////////////////////////////////////
//                                                                 //
//                           WARNING!                              //
//                                                                 //
//      ONLY CHANGE THIS FILE IF YOU KNOW WHAT YOU ARE DOING       //
//                                                                 //
/////////////////////////////////////////////////////////////////////

include("vec_coord.d2l");

var character = new Object;
character["protect_skills"] = null;
character["protect_timer"] = 0;
character["primary_skill"] = "";
character["primary_skill_time"] = 0
character["secondary_skill"] = "";
character["backup_skill"] = "";
character["merc"] = null;


function CharIsSupported(quest)
{
	switch(quest) {
		case "countess":
			return false;
		case "andy":
			return false;
		case "meph":
			return false;
		case "pindle":
			return true;
		case "zombies":
			return true;
		case "shenk":
			return true;
		case "baal":
			return false;
		default:
			return false;
	}
}

function CheckChar()
{
	// check bo
}

function CharPrecast()
{
	if (me.getSkill("Battle Orders")) {
		Sc_SetSkill("Battle Orders", right_hand);
		me.useSkill(right_hand);
		delay(120);
		while(me.mode == 10) { 
			delay(40); 
		}
	}
}

function CharPindleAttack(pindle)
{
	CharAttack(pindle);
	
	return true;
}

function CharZombieAttack()
{
	MoveTo(10059,13246);
	
	while(1) {
		e = FindEnemy("Prowling Dead");
		
		if (e)
			CharAttack(e);
		else
			break;
		delay(50);
	}
	
	return true;
}

function CharShenkAttack()
{
	//ChooseSkills(e);
	
	while(1) {
		CheckSelf();
		
		// find and kill enemies
		e = FindShenkEnemy();
		
		if (e) {
			CharAttack(e);
		}
		else {
			e = getUnit(1, Lang.NPC.Shenk);
			if (!e) {
				DebugWrite(" * ERROR: Shenk not detected");
				return false;
			}
			if (e.hp > 0) {
				CharAttack(e);
			}
			if (e.hp > 0) {
				DebugWrite(" * ERROR: Couldn't kill shenk");
				Abort();
			}
			
			MoveTo(e, 3);
			break;
		}
		
		delay(50);
	}
	
	return true;
}

function CharClearThroneRoom()
{
	while(1) {
		if (!CharThroneAttack()) {
			Error("CharThroneAttack failed");
			return false;
		}

		path = mlFindPath(mlWARPNONE, me.x, me.y, 15095, 5030, 4, mlREDUCEWALK);
		if (!path) {
			DebugWrite("Failed to find path to snagit spot");
			Abort();
		}
		mlWalkThePath(path, true);
		PickItOn();
		path = mlFindPath(mlWARPNONE, me.x, me.y, 15095, 5060, 4, mlREDUCEWALK);
		if (!path) {
			DebugWrite("Failed to find path to snagit spot");
			Abort();
		}
		mlWalkThePath(path, true);
		PickItOn();
		
		if (rnd(0,3) >= 2) {
			path = mlFindPath(mlWARPNONE, me.x, me.y, 15117, 5071, 4, mlREDUCEWALK);
			if (!path) {
				DebugWrite("Failed to find path to wait spot");
				Abort();
			}
			mlWalkThePath(path, true);
		}
		else {
			path = mlFindPath(mlWARPNONE, me.x, me.y, 15074, 5071, 4, mlREDUCEWALK);
			if (!path) {
				DebugWrite("Failed to find path to wait spot");
				Abort();
			}
			mlWalkThePath(path, true);
		}
			
		while(me.hp < globals["heal_hp"] && GetHealthPot()) { 
			me.overhead("Healing/recovering mana");
			CharDefend();
			if (!CheckSelf()) {
				delay(500);
				Sc_TownHeal(true, true);
			}
			delay(250);
		}
		
		while(!FindThroneEnemy() && getUnit(1, Lang.NPC.Baal)) {
			me.overhead("Waiting for enemies");
			if (!CheckSelf()) {
				delay(500);
				Sc_TownHeal(true, true);
			}
			delay(250);
		}
		
		if (!getUnit(1, Lang.NPC.Baal)) {
			me.overhead("Baal is leaving. Going after him");
			if (!CheckSelf()) {
				delay(500);
				Sc_TownHeal(true, true);
			}
			break;
		}
		
		// check enchants
		var e = getUnit(1);
		do {
			if (e && e.hp > 0 && e.mode != 12 && ValidEnemy(e)) {
				var p = e.getParent();
				if (!p || p.name != me.name) {
					CheckEnchants(e);
				}
			}
		}while(e && e.getNext());
		
		CharPrecast();
	}
	
	return true;
}

function CharThroneAttack()
{
	path = mlFindPath(mlWARPNONE, me.x, me.y, 15095, 5045, 4, mlREDUCEWALK);
	if (!path) {
		DebugWrite("Failed to find path to throne center");
		Abort();
	}
	mlWalkThePath(path, true);
		
	var enemy = FindThroneEnemy();
	while(enemy) {
		DebugWrite("ThroneAttack: " + enemy);
		CharAttack(enemy);
		delay(50);
		enemy = FindThroneEnemy();
	}
	
	DebugWrite("ThroneAttack done");
	return true;
}


function CharAttack(e)
{
	ChooseSkills(e);
	
	if (!e) {
		DebugWrite("Warning: No enemy in CharAttack");
		return;
	}

	while(e.hp > 0) {
		Attack(e);
		CheckSelf();
	}
}

function ChooseSkills(e)
{
	if (!e) {
		DebugWrite("Warning: No enemy in ChooseSkills");
		return false;
	}
	
	character["primary_skill"] = "Whirlwind";
	character["secondary_skill"] = "Concentrate";	
	character["backup_skill"] = "Berserk";
		
	return true;
}

function Attack(e)
{
	if (!e || e.hp <= 0)
		return false;

	DebugWrite("Attacking " + e.name);
	
	pos = new coord(me);
	if (e.getStat(36) > 99) { // phys immune. use backup skill
		while(pos.dist(e) > 5) {
			pos.set(me);
			if (!MoveTo(e, 4))
				return false;
		}
		return MeleeAttack(character["backup_skill"], e);
	}
	else {	
		if (character["primary_skill"] == "Whirlwind" && me.mp > Math.ceil(24 + (0.5 * me.getSkill("Whirlwind")))) {
			while(pos.dist(e) > 10) {
				pos.set(me);
				DebugWrite("Moving closer for ww attack to " + e.name + " dist: " + pos.dist(e));
				if (!MoveTo(e, 8))
					return false;
			}
			return WWAttack(character["primary_skill"], e);
		}
		else if(character["primary_skill"] == "Frenzy") {
			while(pos.dist(e) > 5) {
				pos.set(me);
				DebugWrite("Moving closer for melee attack to " + e.name + " dist: " + pos.dist(e));
				if (!MoveTo(e, 4))
					return false;
			}
			return MeleeAttack(character["primary_skill"], e);
		}
		else {
			while(pos.dist(e) > 5) {
				pos.set(me);
				DebugWrite("Moving closer for secondary melee attack to " + e.name + " dist: " + pos.dist(e));
				if (!MoveTo(e, 4))
					return false;
			}
			return MeleeAttack(character["backup_skill"], e);
		}
	}
	
	DebugWrite("Attack failed");
	
	return false;	
}

function MeleeAttack(skill, e)
{
	if (!e || e.hp <= 0)
		return false;
	
	DebugWrite("Melee attack");
	
	pos = new coord(me);
	if(pos.dist(e) > 3) {
		MoveTo(e,3);
	}
	
	Sc_SetSkill(skill, left_hand);
		
	last_hp = e.hp;
	miss_counter = 0;
	pos = new coord();
	while(e.hp > 0) {
		pos.set(me);
		if (pos.dist(e) > 4)
			MoveTo(e, 3);
			
		last_hp = e.hp;
		e.useSkill(left_hand);
		delay(50);
		while(me.mode == 7 || me.mode == 8) {
			delay(50);
		}
		if (e.hp >= last_hp) {
			miss_counter++;
			if (miss_counter > 3) {
				return false;
			}
		}
		else
			miss_counter = 0;
			
		CheckSelf();
	}
	
	return true;
}

function WWAttack(skill, e)
{	
	if (!e || e.hp <= 0)
		return false;
	
	DebugWrite("WW Attack");
	
	Sc_SetSkill(skill, left_hand);
		
	pos = new coord(me);
	
	last_hp = e.hp;
	miss_counter = 0;
	
	while(e.hp > 0) {
		if (me.mp < Math.ceil(24 + (0.5 * me.getSkill(character["primary_skill"]))))
			return MeleeAttack(character["secondary_skill"], e);
			
		pos.set(me);
		dir = pos.dir(e);
		
		// prevent 0,0 vector
		if (dir.x == 0 && dir.y == 0)
			dir.x = 1;
		
		dist = pos.dist(e);
		pos.move(dir, dist + 6);

		last_hp = e.hp;

		me.useSkillAt(pos.x, pos.y, left_hand);
		delay(100);
		while(me.mode == 18) {
			delay(100);
		}
		
		if (e.hp >= last_hp) {
			miss_counter++;
			if (miss_counter > 3) {
				return false;
			}
		}
		else
			miss_counter = 0;
			
		CheckSelf();
	}
	
	return true;
}

function WalkAttack(x, y, e)
{	
	if (!e || e.hp <= 0)
		return;
	
	DebugWrite("WW Walk Attack");
	
	if (e.getStat(36) > 99) {
		Sc_SetSkill("Berserk", left_hand);
					
		var pos = new coord(me);
		if (pos.dist(e) > 4) {
			e.move();
			delay(500);
		}
		e.useSkill(left_hand);
	}
	else {
		Sc_SetSkill("Whirlwind", left_hand);
		
		var pos = new coord(me);
		pos.set(me);
		var dir = pos.dir(e);
		var dist = pos.dist(e);
		pos.move(dir, dist + 3);
		
		me.useSkillAt(pos.x, pos.y, left_hand);
		delay(100);
		while(me.mode == 18) {
			delay(100);
		}
	}
}

function CharWalkCallBack(dest_x, dest_y)
{
	e = FindEnemyOnPath(dest_x, dest_y);
	
	while(e) {
		CharAttack(e);
		e = FindEnemyOnPath(dest_x, dest_y);
	}
	
	return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -