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

📄 mbm_snagit.d2l

📁 转载其他网站的资料与大家分享
💻 D2L
📖 第 1 页 / 共 2 页
字号:
// ParseIt! Library
// by blue mind
// -----------------------------------------------------------------------------
// History :
//
// 1.53 : Added in the ability to use | in the inis
// 1.52 : Made the ini parsing one variable, and cleaned up code
// 1.51 : Added in <autoid> support
// 1.5c : Much easier to read logging
// 1.5a : Fixed a possible memory leak...
// 1.5 : Added in the ability to log items that are set not to be picked up
// 1.4 : Bug fixes, added in distance code, and hopefully made it work with pickit
// 1.3 : Added in belt management and ranged items
// 1.2 : Added in a better method to deal with the ini in memory from FryGuy
// 1.1a : Added in checking if items should be ided
// 1.1 : Completed snagit
// 1.0a : Added quote removal in the ini parsing
// 1.0 : Added the start of the code for SnagIt!
// 0.9a : Added better logging
// 0.9 : Added quality checking for unique items
// 0.8 : Added jewel checking method
// 0.7e : Fixed a ton of bugs
// 0.7d : Made the library universal to check mods of all items
// 0.7c : stupid bug in 0.7b
// 0.7b : removed the need to call getINI() from outside the script
// 0.7 : items logging
// 0.6 : standalone reusable library
//       beta 20+ required for normal/exceptional/elite detection
//       ini and mods parsing are working
// 0.5 : ini parsing added
// 0.4 : working and working fast already. anya support only
// 0.3- : didn't bother to keep a history log

/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
Do not edit anything past this point!
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

// ** Logging related
var logging=1;
var fLog="output/mephdata/"+me.name+"ItemLog.pwn";

// ** The INI
var INI = new Array();
var WhichINI="";
var idValid=false;

// ** SnagIt variables
var forcePots = true;
var dontLog = false;
var snagx=new Array();
var snagy=new Array();
var snagn=new Array();
var SkipType=new Array();
var snagrad=60;

// ** Mods parsing
var itemQual=["none","lowquality","normal","superior","magic","set","rare","unique","craft"];

/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
ShopIt! section:
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

function ShopIt(who)
{
	checkprint=0;

	var shopitem = getUnit(4,null,0);
	if (shopitem) do
	{
		var owner = shopitem.getParent();
		if (owner) if (owner.name==who)
		{
			writedesc = "";
			if(checkprint == 0)
			{
				print("Shopping at: " +who);
				//DumpItems("While shopping at " + who);
				checkprint++;
			}

			if (CheckItem(shopitem, "settings/bmShopIt.ini"))
			{
				if (logging >= 1)
					writedesc = GetDescription(shopitem);
				if (logging >= 2)
					writedesc += " | " + getAllStats(shopitem);
				// - paranoia
				var mygold=mbm_MyGold();
				if (shopitem && owner && ValidVendorName(owner.name) && shopitem.mode == 0) {
					shopitem.shop(npc,2);
					DoDel(1000);
					var numtries = 0;
					while(mygold == mbm_MyGold())
					{
						delay(500);
						numtries += 1;
						if (numtries > 10) break;
					}
				}

				if (logging >= 1)
				if (mygold == MyGold())
					LogItem(null, writedesc, "FAILED to buy a ", "MISSED | " + who); 
				else 
					LogItem(null, writedesc, "Just bought a ", "BOUGHT"); 
			}
			else if (logging >= 4)
				LogItem(shopitem, writedesc, "Just ignored a ", "IGNORED");
		}
	} while(shopitem && shopitem.getNext(null,0));
	if(checkprint == 0) print("Shopping at " +who +"failed!  Bugbugbugbugbug!");
	// - give my slow system a chance to collect it's marbles...
}

function ShopHer(who) {ShopIt(who);}
function ShopHim(who) {ShopIt(who);}

/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
SnagIt! section:
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

function SnagIt(which, radius)
{
	var reloop=true;
	var snagqual=5;
	var returnVal = true;

	if(WhichINI!=which) getINI(which);

	if (arguments.length < 2 || radius <= 0) {
		radius = snagrad;
	}
	while(reloop) {
		var snagitem = getUnit(4);
		reloop=false;
		if (snagitem) itemloop : do {
			if((snagitem.mode==3 || snagitem.mode==5) && snagitem.quality >= snagqual) {
				var itemType = ItemType(snagitem);
				for(m=0;m<=SkipType.length;m++) {
					if(SkipType[m]==itemType) {
						continue itemloop;
					}
				}
				for(var pk=0;pk<snagx.length;pk++)
				{
					if(snagx[pk]==snagitem.x &&
					   snagy[pk]==snagitem.y &&
					   snagn[pk]==snagitem.code) {
						continue itemloop;
					}
				}
				snagx.push(snagitem.x); snagy.push(snagitem.y); snagn.push(snagitem.code);

				// - skip potions if belt is full and ForcePotions == false
				if (itemType >= c_ItemType_HealingPotion && itemType <= c_ItemType_RejuvPotion)
				if (!PickupPotions())
					continue itemloop;

				// - check all potions in case set in ini file
				if(calcdistance(me.x, me.y, snagitem.x, snagitem.y) <= radius)
				//if(snagitem.code!="gld" && (snagitem.itemtype < 76 || snagitem.itemtype > 78))
				{

					if (CheckItem(snagitem, which))
					{
						reloop=true;

						if (snagitem.code == "gld")
						{
							if (GoldDisabled) continue itemloop;
							
							if (!(PickupGold(snagitem))) { continue itemloop; }
							// - since gold disappears once picked up, start
							//   from the beginning again
							snagitem = getUnit(4);
						}
						else {
							if (!PickUpItem(snagitem, writedesc)) {
								returnVal = false;
							}
						}
					}
					else if (loganyhow)
						LogItem(snagitem, writedesc, "Ignoring a ", "IGNORED");
				}
			}
		} while(snagitem && snagitem.getNext());
		if(snagqual==5) reloop=true;
		snagqual=0;
	}
	
	return returnVal;
}

function PickUpItem(pickitem, description)
{
	var gotIt=false
//	var byItem = false;
	var attemptnum = 0;
	var limit = 100;
	var tries = 4;
	var missReason = "";

	if (arguments.length < 2) description = "";
	clearcursor();

//	MoveTo(pickitem.x, pickitem.y);

	for (var i = 0; i < tries; i++) {
//		if (byItem = ) {
			if((pickitem.mode==c_UnitMode_Item_OnGround || pickitem.mode == c_UnitMode_Item_BeingDropped) && !(pickitem.getParent())) {
				while (pickitem.mode == c_UnitMode_Item_BeingDropped) { delay(10); }
				pickitem.interact();
				attemptnum = 0;
				while (pickitem.mode == c_UnitMode_Item_OnGround && attemptnum++ < limit) { delay(10); }
				if(pickitem.mode == c_UnitMode_Item_OnCursor || pickitem.mode == c_UnitMode_Item_BeingDropped) {
					missReason = "full";
					clearcursor();
					break;
				}
				else if(pickitem.mode==c_UnitMode_Item_OnGround) {
					clearcursor();
				}
				else { break; }
			}
//		}
	}

//	if (!byItem) {
//		if (missReason == "") {
//			missReason = "stuck:"+mbm_GetAreaName(me.area);
//		}
//		gotIt = false;
//	}
//	else 
	if (pickitem.mode == c_UnitMode_Item_OnGround || pickitem.mode == c_UnitMode_Item_OnCursor || pickitem.mode == c_UnitMode_Item_BeingDropped) {
		if (missReason == "") {
			missReason = "lag"+(me.version >= "0.25" ? ":"+me.ping : "");
		}
		gotIt = false;
	}
	else {
		gotIt = true;
	}

	if (gotIt) {
		if (idValid) {
			LogItem(pickitem, description, "Just picked up a ", "CHECKING");
		}
		else {
			LogItem(pickitem, description, "Just picked up a ", "PICKED-UP");
		}
	}
	else {
		LogItem(pickitem, description, "FAILED to pick up a ", "MISSED | "+ missReason);
	}
	clearcursor();
	return gotIt;
}

function PickupGold(golditem) {
	var myGold = me.getStat(c_UnitStat_Gold);

	if (mbm_InvGoldFull()) {
		//print("Your gold is not full!  Picking up " + golditem.getStat(14) + " gold!");
		return false;
	}
	if (calcdistance(me.x, me.y, golditem.x, golditem.y) > 30) {
	//	if (!GoToPoint(golditem.x, golditem.y)) return false;
		return false;
	}
	if(me.classid!=c_UnitClassID_Sorceress || !DoCast("Telekinesis", right_hand, golditem))
	{
		if (!MoveTo(golditem.x, golditem.y, true)) return false;
		if ((golditem.mode==c_UnitMode_Item_OnGround || golditem.mode==c_UnitMode_Item_BeingDropped) && !(golditem.getParent())) {
			golditem.interact();
		}
	}
	// - confirm that gold was picked up
	var attemptnum = 0;
	var limit = 100;
	while (myGold == me.getStat(c_UnitStat_Gold) && attemptnum++ < limit) delay(10);

⌨️ 快捷键说明

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