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

📄 mbm_snagit.d2l

📁 转载其他网站的资料与大家分享
💻 D2L
📖 第 1 页 / 共 2 页
字号:
	if (myGold == me.getStat(c_UnitStat_Gold)) {
		print("Gold pickup timed out after " + attemptnum*10 + " ms.  Moving on...");
	}
	else { 
		print("Picked up " + (me.getStat(c_UnitStat_Gold)-myGold) + " gold in " + attemptnum*10 + " ms!");
	}
	return true;
}


/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
SnagIt! belt management section:
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */
/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
Taken from Sherpya's common library's
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

function PickupPotions()
{
	if(forcePots) return true;
	count = 0;
	start = getUnit(4);
	if (start) do
	{
		var owner = start.getParent();
		var itemType = ItemType(start);
		if (owner && owner.name && owner.name == me.name)
		if (start.mode == c_UnitMode_Object_Opened && ((itemType >= c_ItemType_HealingPotion && itemType <=c_ItemType_RejuvPotion) || itemType == c_ItemType_Scroll))
				count++;
	} while (start.getNext());
	if(FindBelt()>count) return true;
	return false;
}

var beltscap = {
	"lbl":   8, // Sash
	"vbl":   8, // Light Belt
	"mbl":   12, // Belt
	"tbl":   12  // Heavy Belt
}

/* Returns the belt capability in rows */
function BeltCapability(belt) // RWG
{
	if (beltscap[belt.code])
		return beltscap[belt.code]

	return 16;
}

function ItemType(item)
{
	return item.getBaseStat(c_ItemBaseStat_Type);
}

/* Find the item of equiped belt */
function FindBelt()
{
	// - due to bug with getItem(), we must loop til we find a belt...
	var belt = getUnit(4, null, 208);
	if (belt) do
	{
		if (ItemType(belt) == c_ItemType_Belt) break;
		//DumpItems("Invalid item returned from getItem(null,208):code="+ belt.code+":name"+belt.name+":mode"+belt.mode+":itemloc="+belt.itemloc+":coords="+belt.x+","+belt.y+":size="+belt.xsize+","+belt.ysize);
	} while (belt && belt.getNext(null, 208));

	if (!belt || ItemType(belt) != c_ItemType_Belt) return 4; // RWG
	return BeltCapability(belt); // RWG
}

/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
ParseIt! section:
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

function ParseIt(which, cx, cy, DoLog)
{
	var parseitem = getUnit(4, null,0);
	if (parseitem) do
	{
		var owner = parseitem.getParent();
		if (owner)
			if (owner.name==me.name)
			{
				if ((parseitem.x == cx) && (parseitem.y == cy) && (parseitem.itemloc == 0))
				{
					KeepIt=CheckItem(parseitem, which);

					if(KeepIt && DoLog >= 1)
						LogItem(parseitem, writedesc, "Keeping a ", "KEPT");
					else if (parseitem.getFlag(c_ItemFlag_Identified) && DoLog>=1 && logging >= 3)
						LogItem(parseitem, writedesc, (SellCrapItems ? "Selling" : "Dropping") + " a ", "DROPPED");
					return KeepIt;
				}
			}
	} while(parseitem && parseitem.getNext(null,0));
	return false;
}

/* 骀骀骀骀骀骀骀骀骀骀骀骀骀骀
SnagIt! and ParseIt! item parsing section:
骀骀骀骀骀骀骀骀骀骀骀骀骀骀 */

function CheckItem(item, which)
{
	if(WhichINI!=which) getINI(which);

	lloop : for(i=0;i<INI[which].length;i++)
	{
		nKeys=INI[which][i].length;
		idValid=false;
		writedesc=false;
		dontLog=false;
		loganyhow=false;
		var OrSkip=new Array();
		for(j=1;j<nKeys;j++)
		{
			type=INI[which][i][j][0];
			key=INI[which][i][j][1];
			val=INI[which][i][j][2];

			if(type=="|")
			{
				if(!OrCase(val,item,OrSkip))
					continue lloop;
			}
			else
			{
				if(!KeyCase(type,key,val,item)) {
					continue lloop;
				}
			}
		}
		
		if (loganyhow) return false;
		debugprint("!!Keeping an item from section: " +INI[which][i][0],0);
		return true;
	}
	return false;
}

function OrCase(string,item,OrSkip)
{
	LastOne=true;
	divider=string.indexOf("|");
	lastloop : while(LastOne)
	{
		debugprint(string,0);
		if(divider==-1) LastOne=false;
		if(LastOne)
		{
			cursub=string.substring(0,divider);
			string=string.substring(divider+1);
		} else cursub=string;
		var TypeTable=["=",">","<","!"];
		for (oi=0;oi<TypeTable.length;oi++)
		{
			nEndOfKey = cursub.indexOf(TypeTable[oi]);
			if (nEndOfKey!=-1)
			{
				KeyName=cursub.substring(0,nEndOfKey);
				KeyValue=StripQuotes(cursub.substring(nEndOfKey+1));
				typeval=oi;
				break;
			}
		}
		debugprint("Argument: "+TypeTable[typeval]+" -- Entering KeyName: "+KeyName+" -- and KeyValue: "+KeyValue,0);
		if(KeyCase(TypeTable[typeval],KeyName,KeyValue,item))
		{
			for (oi=0;oi<OrSkip.length;oi++)
			{
				if(OrSkip[oi][0]==TypeTable[typeval] && OrSkip[oi][1]==KeyName && OrSkip[oi][2]==KeyValue) continue lastloop;
			}
			OrSkip.push(TypeTable[typeval],KeyName,KeyValue);
			return true;
		}
		divider=string.indexOf("|");
	}
	return false;
}

function KeyCase(type,key,val,item)
{
	switch(key)
	{
		case "description":	//Printed value for snagit
		case "show":	//Place holder, in case someone uses the old command
			writedesc=val;
			return true;
		case "pickup":	//If set to 0, it will log it but not pick it up
			if (val==0) loganyhow=true;
			return true;
		case "iditem":	//If set to 1, will id the item if it is in your inventory
			if (val==1) idValid=true;
			return true;
		case "log":	//If set to 0, the item will be picked up, but not logged
			if (val==0) dontLog=true;
			return true;
		case "type":	//I have to set this up still
			print("The option of picking up certain item types is not currently supported by SnagIt!");
			return false;
		case "mod":	//Specific mod names, like cruel
			if(item.fname.toLowerCase().indexOf(val) == -1) return false;
			return true;
		case "isethereal":	//Ethereal check
			if (val==1 && item.getFlag(c_ItemFlag_Etheral) == 0) return false;
			if (val==0 && item.getFlag(c_ItemFlag_Etheral)) return false;
			return true;
		case "hassockets":	//Socket check
			if (val==1 && !item.getFlag(c_ItemFlag_Socketed)) return false;
			if (val==0 && item.getFlag(c_ItemFlag_Socketed)) return false;
			return true;
		case "identified":	//Identified check
			if (val==0 && item.getFlag(c_ItemFlag_Identified)) return false;
			if (val==1 && item.getFlag(c_ItemFlag_Identified) == 0) return false;
			return true;
		case "item":	//Item type, item code, or an items name
		case "code":	//Item type, item code, or an items name
			return CodeCase(type,val,item);
		case "qual":	//Item quality, Such as magic or unique.  Number or name accepted.
		case "level":	//Item quality, Such as magic or unique.  Number or name accepted.
			return QualCase(type,val,item);
		case "classlevel":	//Normal, elite, or exceptional.  Number or name accepted.
			return ClassCase(type,val,item);
		case "ilvl":	//The items ilvl.
			return ilvlCase(type,val,item);
		case "eval-pu":
			return item.eval(val);
		case "eval-id":
			if (item.getFlag(0x10) == 0) return false; // not ID'd
			return item.eval(val);
		default:	//Specific mod values, in numeric form.
			return TypeCase(type,val,key,item);
	}
	return false;
}

function CodeCase(type,val,item)
{
	switch(type)
	{
		case "=":
			if ((val!=item.code) && (val!=item.name.toLowerCase()) && (val!=String(ItemType(item)))) return false;
			return true;
		case ">":
			if (parseInt(val)<ItemType(item)) return false;
			return true;
		case "<":
			if (parseInt(val)>ItemType(item)) return false;
			return true;
		case "!":
			if ((val==item.code) || (val==item.name.toLowerCase()) || (val==String(ItemType(item)))) return false;
			return true;
	}
	return false;
}

function ilvlCase(type,val,item)
{
	switch(type)
	{
		case "=":
			if (item.ilvl != parseInt(val)) return false;
			return true;
		case ">":
			if (item.ilvl < parseInt(val)) return false;
			return true;
		case "<":
			if (item.ilvl > parseInt(val)) return false;
			return true;
		case "!":
			if (item.ilvl == parseInt(val)) return false;
			return true;
	}
	return false;
}

function TypeCase(type,val,key,item)
{
	if(isNaN(parseInt(key,10)) || isNaN(parseInt(val,10))) {
		if (key != "pickupradius" && key != "fillbelt" && key != "loglevel")
			print("

⌨️ 快捷键说明

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