All pastes #447097 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-18 20:41 UTC
rendered paste body
#define RETRIEVE_FREESLOTS 0
#define RETRIEVE_TOTALSLOTS 1
#define RETRIEVE_BAGCOUNT 2

objectdef oInventory inherits oBase
{

	;AutoSell, AutoDestroy, AutoBank, AutoMule, DestroyRarity, SellRarity, BankRarity, MuleRarity

	method BagStatusPulse()
	{	
		WoWEcho ${This.GetBagsInfo[2,"normal"]}
		if ${This.GetBagsInfo[0,"normal"].Equal[0]}
		{
			; disabled to not break bot
			;ActionNPC:MerchantRun
		}
		if ${This.GetBagsInfo[0,"quiver"].NotEqual[0]}||${This.GetBagsInfo[0,"ammo"].NotEqual[0]}
		{
			; disabled to not break bot
			;ActionNPC:MerchantRun
		}
	}
	member CheckInventory()
	{
		if ${This.GetBagsInfo[0,"normal"].Equal[0]}
		{
			return TRUE
		}
	}
	member CheckAmmo()
	{
		if ${This.GetBagsInfo[0,"ammo"].NotEqual[0]}
		{
			return TRUE
		}
	}
	member CheckQuiver()
	{
		if ${This.GetBagsInfo[0,"quiver"].Equal[0]}
		{
			return TRUE
		}
	}
	member CheckQuestItem(string strItemName)
	{
		if ${WoWScript[GetItemInfo("${strItemName}"),6].Equal["Quest"]}
		{
			return TRUE
		}
		return FALSE
	}

	member GetBagType(string strBagName)
	{
		if ${strBagName.Find[Quiver]}||${strBagName.Equal[Ancient Sinew Wrapped Lamina]}
			return "quiver"
		if ${strBagName.Find[Ammo Pouch]}||${strBagName.Find[Shot Pouch]}||${strBagName.Find[Ammo Sack]}||${strBagName.Find[Bandolier]}
			return "ammo"
		if ${strBagName.Equal[Spellfire Bag]}||${strBagName.Find[Enchant]}
			return "enchanting"
		if ${strBagName.Equal[Satchel of Cenarius]}||${strBagName.Find[Herb]}
			return "herbalism"
		if ${strBagName.Find[Toolbox]}
			return "engineering"
		if ${strBagName.Equal[Bag of Jewels]}||${strBagName.Equal[Gem Pouch]}
			return "jewelcrafting"
		if ${strBagName.Find[Mining]}
			return "mining"
		if ${strBagName.Equal[Ebon Shadowbag]}||${strBagName.Find[Felcloth]}||${strBagName.Find[Soul]}
			return "lock"	
		return "normal"
	}

	member GetBagsInfo(int intInfoType,string strBagType)
	{
		; intInfoType = what you want to retrieve - see defines
		; strBagType = the bag type you want to get info from

		variable int intBags = 0
		variable int intTotalSlots = 0
		variable int intFreeSlots = 0

		do
		{
			if ${strBagType.Equal["all"]}
			{
				intFreeSlots:Inc[${Me.Bag[${intBags}].EmptySlots}]
				intTotalSlots:Inc[${Me.Bag[${intBags}].Slots}]
			}
			elseif ${This.GetBagType[${Me.Bag[${intBags}].Name}].Equal["${strBagType}"]}
			{
				intFreeSlots:Inc[${Me.Bag[${intBags}].EmptySlots}]
				intTotalSlots:Inc[${Me.Bag[${intBags}].Slots}]
			}
		}
		while ${Me.Bag[${intBags:Inc}](exists)}
      	
		switch ${intInfoType}
		{
			case RETRIEVE_FREESLOTS
				return ${intFreeSlots}
				break
			case RETRIEVE_TOTALSLOTS
				return ${intTotalSlots}
				break
			case RETRIEVE_BAGCOUNT
				return ${intBags}
				break
		}
	}

	member GetTotalSlots(intBag)
	{
		variable int intTotalSlots = 0

		if ${Me.Bag[${intBag}](exists)}
		{
			intTotalSlots:Inc[${Me.Bag[${intBag}].Slots}]
		}
		return ${intTotalSlots}
	}
	member GetFreeSlots(intBag)
	{
		variable int intFreeSlots = 0

		if ${Me.Bag[${intBag}](exists)}
		{
			intFreeSlots:Inc[${Me.Bag[${intBag}].Slots}]
		}
		return ${intFreeSlots}
	}
	

	member GetItemRarity(string strItemName)
	{
		variable int intItemRarity
		intItemRarity:Set[${strItemName}.Rarity]
		return ${intItemRarity}
	}
	
	member ItemCount(string strItemName)
	{
		variable guidlist lstItemList
		variable int intTotalCount = 0
		variable int Index = 1

		lstItemList:Search[-items,-inventory,${strItemName}]
		if ${lstItemList.Count}
		{
			do
			{
				if ${Item[${lstItemList.GUID[${Index}]}].Name.Equal["${strItemName}"]}
				{
					intTotalCount:Inc[${Item[${lstItemList.GUID[${Index}]}].StackCount}]
				}
			}
			while ${Index:Inc}<=${lstItemList.Count}
		}
		return ${intTotalCount}
	}
}