Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[PROBLEM] Skrypt sprzedaje loot tylko z bp który jest otwarty, dlaczego ?


ThePein

Rekomendowane odpowiedzi

Opublikowano

Witam, Używam skryptu poniżej

i mam taki problem że jak char sprzedaje loot u rafzana to domyślnie jest ustawione żeby char zbierał itemki do Bp #3 i jeśli zapełni cały bp to otwiera kolejny i tu jest problem że jak otworzy następny i tam są powiedzmy 4 itemki to u rafzana sprzedaje tylko te 4 a poprzednich itemków z poprzedniego bp już nie sprzedaje, ktoś wie dlaczego ?

Daam plusy za pomoc 

 

 

\/

tutaj pierwszy skrypt

dofile("sLIB.lua")

Backpacks.stacks = "yellow backpack"
Backpacks.loot = "fur backpack"
Backpacks.gold = "red backpack"

stacksDP = 0
otherDP = 1

-- begin is the number you will start the hunt with
-- leave is the smallest number you will keep hunting with
Potion{name="health potion", begin=35, leave=15}
Potion{name="mana potion", begin=200, leave=60}

rafzan = true -- Do you want to sell loot to Rafzan

leaveMinutesBeforeSS = 60 -- Minutes before server save to leave the spawn. Remove to disable.
maxSessionLength = 6 * 60 + 30 -- Largest number of minutes to run the bot in one session. Remove to disable.
Stamina.leave = 16 -- Hours
Capacity.leave = 700
Capacity.dropFlasks = 150 -- Set to 0 to disable
--Capacity.dropGold = 50 -- Uncomment to enable


replyToMsgs = false
responses = {"?", "understand no", "china?", "talk china speak?", "what?", "you confusing", "me bad languages"}
maxResponsesPerPlayer = 3
sendIgnore = true -- After a player reaches the reply limit, do you want to pm them and say that they are ignored?

customHUD = true -- Do you want to use the built in HUD?

----------------------------------------------------------------------------------------------------
----------------------------------- END OF SETTINGS ------------------------------------------------
----------------------------------------------------------------------------------------------------

depositList = 
{
	{'spike shield', otherDP}, 
	{'ratana', otherDP}, 
	{'life preserver', otherDP}, 
	{'rat god doll', otherDP}, 
	{'leather harness', otherDP}, 
	{'spiky club', otherDP}, 
	{'bola', stacksDP}, 
	{'cheese cutter', stacksDP}, 
	{'cheesy figurine', stacksDP}, 
	{'earflap', stacksDP}
}

sellList = {'spike shield', 'ratana', 'life preserver', 'spiky club', 'leather harness'}

depotPos = {x=33018, y=32053, z=7}

registerEventListener(WALKER_SELECTLABEL, "handleLabel")

function handleLabel(labelName)
	if labelName == "CheckRafzan" and not rafzan then
		gotoLabel("EndRafzan")
	elseif labelName == "Rafzan" then
		Walker.Stop()
		NPC.speak({"hi", "trade"}, "Rafzan")
		wait(100, 200)
		NPC.sellItems(sellList)
		wait(100, 200)
		Walker.Start()
	else
		sLIB.handleLabel(labelName)
	end
end

if customHUD then
	startHUD()
end

sLIB.startModules()

tutaj drugi

\/

-- Library version 2.2

sLIB = {}
-- Split supplies into Runes, Potions and Food classes. Keep Supply as a super class
------------------------------------------------------------------------------------------------------------
--------------------------------------------- Supplies -----------------------------------------------------
------------------------------------------------------------------------------------------------------------
Supply = {}
Supply.__index = Supply
Supplies = {}
_Supplies = {}
Costs = 
{
	["health potion"] = 45,
	["strong health potion"] = 100,
	["great health potion"] = 190,
	["mana potion"] = 50,
	["strong mana potion"] = 80,
	["great mana potion"] = 120,
	["avalanche rune"] = 45,
	["great fireball rune"] = 45,
	["thunderstorm rune"] = 37,
	["brown mushroom"] = 10
}

function Supply:new(arg)
	local supply = {}
	setmetatable(supply, Supply)
	supply._name = arg.name:lower()
	supply._begin = arg.begin
	supply._leave = arg.leave
	supply._cost = arg.cost
	table.insert(_Supplies, supply)
	return supply
end

function Supply:name()
	return self._name
end

function Supply:begin()
	return self._begin
end

function Supply:leave()
	return self._leave or 0
end

function Supply:cost()
	return Costs[self:name()] or 0
end

function Supply:count()
	return Self.ItemCount(self:name())
end

function Supply:needRefill()
	return self:count() < self:leave()
end

function Supply:isStocked()
	return self:count() > 0.9 * self:begin()
end

function Supply:isFullyStocked()
	return self:count() >= self:begin()
end

function Supply:missingAmount()
	return math.max(self._begin - Self.ItemCount(self:name()), 0)
end

function Supply:missingCost()
	return self:missingAmount() * self:cost()
end

function Supply:buy()
	NPC.buyItem(self:name(), self:begin())
end

function Supplies.missingCost()
	local totalCost = 0
	for _, supply in ipairs(_Supplies) do
		totalCost = totalCost + supply:missingCost()
	end
	return totalCost
end

function Supplies.needRefill()
	local refill = false
	for _, supply in ipairs(_Supplies) do
		refill = refill or supply:needRefill()
	end
	return refill
end

function Supplies.isStocked(supplies)
	local supplies = supplies or _Supplies
	local stocked = true
	for _, supply in ipairs(supplies) do
		stocked = stocked and supply:isStocked()
	end
	return stocked
end

function Supplies.isFullyStocked(supplies)
	local supplies = supplies or _Supplies
	local stocked = true
	for _, supply in ipairs(supplies) do
		stocked = stocked and supply:isFullyStocked()
	end
	return stocked
end

function Supplies.buy(supplies)
	local supplies = supplies or _Supplies
	for _, supply in ipairs(supplies) do
		supply:buy()
	end
end

function Supplies.move()
	if Backpacks["supplies"] then
		Walker.Stop()
		local supplies = {"mana potion", "great mana potion", "strong mana potion", "health pothion", "strong health potion", "brown mushroom",
		                  "great health potion", "avalanche rune", "great fireball rune", "sudden death rune", "thunderstorm rune"}
		local mainBp = Container.GetFirst()
		local supBP = Container.New(Backpacks["supplies"]):Index()
		for spot = mainBp:ItemCount() - 1, 0, -1 do
			local item = mainBp:GetItemData(spot)
			if table.contains(supplies, Item.GetName(item.id)) then
				mainBp:MoveItemToContainer(spot, supBP, 19)
				wait(300, 400)
			end
		end
		Walker.Start()
	end
end

function Supplies.multiCheck(labelName)
	local check = true
	for label in labelName:gmatch("%a+") do
		if label == "Potions" then
			check = check and Supplies.isStocked(Potions)
		elseif label == "Food" then
			check = check and Supplies.isStocked(Foods)
		elseif label == "Runes" then
			check = check and Supplies.isStocked(Runes)
		elseif label == "Boots" then
			check = check and not SoftBoots:needRefill()
		end
	end
	return check
end

function Supplies.manaPotions()
	local count = 0
	for _, potion in ipairs(Potions) do
		if potion:name():lower():match("mana") then
			count = count + potion:count()
		end
	end
	return count
end
------------------------------------------------------------------------------------------------------------
--------------------------------------------- Potions ------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Potions = {}

function Potion(arg)
	table.insert(Potions, Supply:new(arg))
end

------------------------------------------------------------------------------------------------------------
---------------------------------------------- Runes -------------------------------------------------------
------------------------------------------------------------------------------------------------------------
RunesPerCast =
{
	["thunderstorm rune"] = 4,
	["great fireball rune"] = 4,
	["avalanche rune"] = 4,
	["sudden death rune"] = 3
}

Runes = {}

function Rune(arg)
	table.insert(Runes, Supply:new(arg))
end

function requiredBlanks()
	local req = 0
	for _, rune in ipairs(Runes) do
		if RunesPerCast[rune:name()] then
			req = req + math.ceil(rune:missingAmount()/RunesPerCast[rune:name()])
		end
	end
	return (makeRunes and math.max(req - Self.ItemCount("blank rune"), 0)) or 0
end
------------------------------------------------------------------------------------------------------------
---------------------------------------------- Food --------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Foods = {}

function Food(arg)
	table.insert(Foods, Supply:new(arg))
end


------------------------------------------------------------------------------------------------------------
---------------------------------------------- Rings -------------------------------------------------------
------------------------------------------------------------------------------------------------------------
_Ring = {}
_Ring.__index = _Ring
Rings = {}
Rings.__index = Rings
RingOptions = {"battle", "heal", "other"}

function _Ring:new(arg)
	local ring = {}
	setmetatable(ring, _Ring)
	ring._name = arg.name:lower()
	ring._begin = arg.begin or 0
	Rings[arg.use] = ring
	return ring
end

function _Ring:name()
	return self._name
end

function _Ring:begin()
	return self._begin
end

function Rings:choose()
	local prioQ = {}
	if battleRingLimit and monsterScores and Rings["battle"] and (Hunt.monsterScore(monsterScores, ringSearchRange) >= battleRingLimit or sLIB.healthPercent() < 0.4) then
		table.insert(prioQ, Item.GetID(Rings["battle"]:name()))
	end
	if Rings["heal"] and sLIB.manaPercent() < 0.9 and not Self.isInPz() then
		table.insert(prioQ, Item.GetID(Rings["heal"]:name()))
	end
	if Rings["other"] and not Self.isInPz() then
		table.insert(prioQ, Item.GetID(Rings["other"]:name()))
	end
	return prioQ
end

function Ring(arg)
	_Ring:new(arg)
end
------------------------------------------------------------------------------------------------------------
------------------------------------------- Soft Boots -----------------------------------------------------
------------------------------------------------------------------------------------------------------------
SoftBoots = {}
SoftBoots.__index = SoftBoots

function SoftBoots:ID()
	return 3549
end

function SoftBoots:wornID()
	return 6530
end

function SoftBoots:needRefill()
	return Self.ItemCount(SoftBoots:wornID()) > 0 and useSoftBoots
end

function SoftBoots:missingCost()
	if not SoftBoots:needRefill() or not useSoftBoots then
		return 0
	else
		return 10000
	end
end

------------------------------------------------------------------------------------------------------------
---------------------------------------------- NPCs --------------------------------------------------------
------------------------------------------------------------------------------------------------------------
NPC = {}

function NPC.speak(words, npc)
	for name, creature in Creature.iNpcs() do
		if name == npc then
			creature:Follow()
			wait(3000)
			break
		end
	end
	Self.SayToNpc(words, 75)
end

function NPC.buyItem(item, count)
	wait(1000)
	local maxTries = count / 50 + 2
	local tries = 0
	while(Self.ItemCount(item) < count and tries < maxTries) do
		Self.ShopBuyItemsUpTo(item, count)
		tries = tries + 1
		sLIB.wait()
	end
end

function NPC.sellItems(items)
	wait(1000)
	for _, item in ipairs(items) do
		if(Self.ItemCount(item) > 0) then
			Self.ShopSellAllItems(item)
		end
	end
end

function NPC.bank(money)
	NPC.speak("hi")
	if Self.Money() > 0 then
		NPC.speak({"deposit all", "yes"})
	end
	NPC.speak({"withdraw " .. money, "yes", "balance"})
end

local captains = 
{
	"Brodrosch",
	"Captain Bluebear",
	"Captain Breezelda",
	"Captain Chelop",
	"Captain Cookie",
	"Captain Dreadnought",
	"Captain Fearless",
	"Captain Greyhound",
	"Captain Haba",
	"Captain Jack",
	"Captain Kurt",
	"Captain Max",
	"Captain Seagull",
	"Captain Seahorse",
	"Captain Sinbeard",
	"Captain Tiberius",
	"Charles",
	"Dalbrect",
	"Ghost Captain",
	"Graubart",
	"Gurbasch",
	"Jack Fate",
	"Junkar",
	"Karith",
	"Maris",
	"Pemaret",
	"Petros",
	"Stone Temple Parrot",
	"Thorgrin"
}

function NPC.sail(dest)
	for name, creature in Creature.iNpcs() do
		if table.find(captains, name) then
			creature:Follow()
			wait(3000)
			break
		end
	end
	NPC.speak({"hi", "sail", dest, "yes"})
	wait(2000)
end

------------------------------------------------------------------------------------------------------------
---------------------------------------------- Depot -------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Depot = {}

function Depot.withdrawItems(...)

	local function getNonContainerSpot(container)
		for spot = 0, container:ItemCount() - 1 do
			local item = container:GetItemData(spot)
			if not Item.isContainer(item.id) then
				return spot
			end
		end
	end

	local function withdraw(itemID, toBP, amount)
		local to = Container.New(toBP)
		local remainingCount = amount
		
		while true do
			local from = Container:GetLast()
			
			for fromSpot = from:ItemCount() - 1, 1, -1 do
				local item = from:GetItemData(fromSpot)
				if item.id == itemID then
					local moveCount = math.min(remainingCount, item.count)
					from:MoveItemToContainer(fromSpot, to:Index(), getNonContainerSpot(to), moveCount)
					remainingCount = remainingCount - moveCount
					sLIB.wait()
					if remainingCount <= 0 then
						from:Close()
						sLIB.wait()
						return true
					end
				end
			end
				
			local lastSpot = from:ItemCount() - 1
			local lastID = from:GetItemData(lastSpot).id
			if Item.isContainer(lastID) then 
				from:UseItem(lastSpot, true)
				sLIB.wait()
			else
				from:Close()
				sLIB.wait()
				return false
			end
		end
	end
	
	setBotEnabled(false)
	local depot = Self.OpenDepot()
		
	for _, itemConfig in ipairs(arg) do
		local item = Item.GetItemIDFromDualInput(itemConfig[1])
		local fromDpSlot = itemConfig[2]
		local toBackpack = itemConfig[3]
		local amount = itemConfig[4] or 1
		if amount > 0 then
			depot:UseItem(fromDpSlot)
			sLIB.wait()
			withdraw(item, toBackpack, amount)
		end
	end
	
	depot:Close()
	setBotEnabled(true)
end

function Depot.withdrawSupplies()
	local withdrawList = {}
	for _, item in ipairs(_Supplies) do
		local amount = math.max(item:begin() - Self.ItemCount(item:name()), 0)
		table.insert(withdrawList, {item:name(), suppliesDP, Backpacks.supplies, amount})
	end
	Depot.withdrawItems(unpack(withdrawList))
end

function Depot.withdrawRings()
	local withdrawList = {}
	for _, option in ipairs(RingOptions) do
		if Rings[option] then
			local item = Rings[option]
			local amount = math.max(item:begin() - Self.ItemCount(item:name()), 0)
			table.insert(withdrawList, {item:name(), ringsDP, Backpacks.rings, amount})
		end
	end
	Depot.withdrawItems(unpack(withdrawList))
end

function Depot.reach()
	local depotIDs = {3497, 3498, 3499, 3500}
	local depots = {}
	sLIB.forWholeScreen( 
		function(pos)
			if table.find(depotIDs, Map.GetTopUseItem(pos.x, pos.y, pos.z).id) then
				table.insert(depots, pos)
			end
		end)
	
	sLIB.shuffleArray(depots)
	
	for _, depot in ipairs(depots) do
		if Self.DistanceFromPosition(depot.x, depot.y, depot.z) == 1 then
			return true
		end
	end

	for _, depot in ipairs(depots) do
		local oldPos = Self.Position()
		Self.UseItemFromGround(depot.x, depot.y, depot.z)
		wait(1000, 1300)
		if Self.DistanceFromPosition(oldPos.x, oldPos.y, oldPos.z) > 0 then
			wait(3000, 4000)
			if Self.DistanceFromPosition(depot.x, depot.y, depot.z) == 1 then
				return true
			end
		end
	end
	return false
end

function Depot.handle(depositList, withdrawList)
	Backpacks.reset()
	Depot.reach()
	if depositList then
		Self.DepositItems(unpack(depositList))
	end
	Depot.withdrawSupplies()
	Depot.withdrawRings()
	if withdrawList then
		Depot.withdrawItems(unpack(withdrawList))
	end
	if not bpResetter:IsActive() then
		bpResetter:Start()
	end
end

------------------------------------------------------------------------------------------------------------
---------------------------------------------- Hunt --------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Hunt = {}
local recalled = false
local logMsgs = false
Hunt.started = os.time(os.date("*t"))

function Hunt.enter()
	if Capacity.dropFlasks and not flaskDropper:IsActive() then
		flaskDropper:Start()
	end
	if Capacity.dropGold and not goldDropper:IsActive() then
		goldDropper:Start()
	end
	logMsgs = true
end

function Hunt.leave()
	if Capacity.dropFlasks and flaskDropper:IsActive() then
		flaskDropper:Stop()
	end
	if Capacity.dropGold and goldDropper:IsActive() then
		goldDropper:Stop()
	end
	logMsgs = false
end

function Hunt.checkLeave()
	local outOfCap = Capacity.leave and Self.Cap() < Capacity.leave
	local outOfStamina = Stamina.leave and Self.Stamina() < Stamina.leave * 60
	local outOfTime = (leaveMinutesBeforeSS and Hunt.timeToSS() < leaveMinutesBeforeSS) or (maxSessionLength and maxSessionLength < Hunt.sessionLength())
	return Supplies.needRefill() or outOfCap or outOfStamina or outOfTime or recalled
end

function Hunt.sessionLength()
	local now = os.time(os.date("*t"))
	return (os.difftime(now, Hunt.started) / 60)
end

function Hunt.timeToSS()
	local nowDate = os.date("*t")
	local now = os.time(nowDate)
	local ss = os.time{year = nowDate.year, month = nowDate.month, day = nowDate.day, hour = 10}
	return (os.difftime(ss, now) / 60) % (24*60)
end

function Hunt.monsterScore(scores, range)
	local score = 0
	for _, monster in ipairs(Self.GetTargets(range or 7)) do
		score = score + (scores[monster:Name():lower()] or 0)
	end
	return score
end

------------------------------------------------------------------------------------------------------------
----------------------------------------- Backpacks --------------------------------------------------------
------------------------------------------------------------------------------------------------------------

BackpackOptions = {"stacks", "loot", "gold", "supplies", "rings"}
Backpacks = {}

function Backpacks.reset()
	local tmp = isHunting
	isHunting = false
	Self.CloseContainers()
	Self.OpenMainBackpack(true):OpenChildren(
			{Backpacks.stacks, true},
			{Backpacks.loot, true},
			{Backpacks.gold, true},
			{Backpacks.supplies, true},
			{Backpacks.rings, true})
	isHunting = tmp
end

function Backpacks.all()
	local bps = {}
	for _, option in ipairs(BackpackOptions) do
		if Backpacks[option] then
			table.insert(bps, Backpacks[option])
		end
	end
	return bps
end

------------------------------------------------------------------------------------------------------------
---------------------------------------------- Misc --------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-- Standard wait between many actions
function sLIB.wait()
	wait(500, 900)
end

function sLIB.manaPercent()
	return Self.Mana() / Self.MaxMana()
end

function sLIB.healthPercent()
	return Self.Health() / Self.MaxHealth()
end

function sLIB.useGround(DIR)
	local pos = Self.Position()
	if(DIR == NORTH) then
		Self.UseItemFromGround(pos.x, pos.y-1, pos.z)
	elseif(DIR == SOUTH) then
		Self.UseItemFromGround(pos.x, pos.y+1, pos.z)
	elseif(DIR == EAST) then
		Self.UseItemFromGround(pos.x+1, pos.y, pos.z)
	elseif(DIR == WEST) then
		Self.UseItemFromGround(pos.x-1, pos.y, pos.z)
	end
end

function sLIB.door(DIR)
	local pos = Self.Position()
	if DIR == NORTH then
		Self.UseDoor(pos.x, pos.y-1, pos.z)
	elseif DIR == EAST then 
		Self.UseDoor(pos.x+1, pos.y, pos.z)
	elseif DIR == SOUTH then 
		Self.UseDoor(pos.x, pos.y+1, pos.z)
	elseif DIR == WEST then 
		Self.UseDoor(pos.x-1, pos.y, pos.z)
	end
end

-- Apply the function f to all positions on the screen
function sLIB.forWholeScreen(f)
	local myPos = Self.Position()
	for dx = -7, 7 do
		for dy = -5, 5 do
			pos = {x = myPos.x + dx, y = myPos.y + dy, z = myPos.z}
			f(pos)
		end
	end
end

function sLIB.getShovel()
	-- Light shovel
	if Self.ItemCount(5710) > 0 then
		return 5710
	-- Shovel
	elseif Self.ItemCount(3457) > 0 then
		return 3457
	end
	-- Secret service items
	for id = 9594, 9599 do
		if Self.ItemCount(id) > 0 then
			return id
		end
	end
end

function sLIB.levitate(vertical, dir)
	Self.Turn(dir)
	sLIB.wait()
	local z = Self.Position().z
	local tries = 0
	while Self.Position().z == z and tries < 5 do
		Self.Cast("exani hur " .. vertical)
		sLIB.wait()
	end
end

function sLIB.shuffleArray(a)
	for _ = 1, #a * 2 do
		local x = math.random(#a)
		local y = math.random(#a)
		a[x], a[y] = a[y], a[x]
	end
end
------------------------------------------------------------------------------------------------------------
--------------------------------------- Variables ----------------------------------------------------------
------------------------------------------------------------------------------------------------------------
local refillAttempts = 1
local isHunting = true
local minLvlLog = 10
Capacity = {}
Stamina = {}

------------------------------------------------------------------------------------------------------------
------------------------------------- Standard Labels ------------------------------------------------------
------------------------------------------------------------------------------------------------------------
function sLIB.handleLabel(labelName)
------------------------------------------------------------------------------------------------------------
	if labelName == "Depot" then
		Walker.Stop()
		isHunting = false
		Depot.handle(depositList, withdrawList)
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Start" then
		sLIB.startModules()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Startx" then
		sLIB.startModules()
		if depotPos and Self.DistanceFromPosition(depotPos.x, depotPos.y, depotPos.z) < 15 then
			gotoLabel("StartDepot")
		elseif trainerPos and Self.DistanceFromPosition(trainerPos.x, trainerPos.y, trainerPos.z) < 15 then
			gotoLabel("StartTrainer")
		else
			gotoLabel("Hunt")
		end
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Supplies" then
		Walker.ConditionalGoto(Supplies.isStocked() and not SoftBoots:needRefill(), "EndSupplies")
------------------------------------------------------------------------------------------------------------
	elseif labelName == "CheckMakeRunes" then
		Walker.ConditionalGoto(Supplies.isStocked(Runes) or not makeRunes, "EndMakeRunes")
------------------------------------------------------------------------------------------------------------
	elseif labelName == "MakeRunes1" and runeSpell then
		while sLIB.manaPercent() < 0.5 do 
			wait(900, 1100)
		end
		Self.Cast(runeSpell)
		wait(2000,2100)
------------------------------------------------------------------------------------------------------------
	elseif labelName == "MakeRunes2" and runeSpell then
		if Supplies.isFullyStocked(Runes) or Self.Soul() < 5 then
			gotoLabel("EndMakeRunes")
		elseif Self.ItemCount("blank rune") == 0 or Supplies.manaPotions() < 15 then
			gotoLabel("CheckMakeRunes")
		else
			gotoLabel("MakeRunes1")
		end
------------------------------------------------------------------------------------------------------------
	elseif labelName == "EndMakeRunes" then
		Supplies.move()
------------------------------------------------------------------------------------------------------------
	elseif labelName:match("mCheck") then
		Walker.ConditionalGoto(Supplies.multiCheck(labelName), labelName:gsub("mCheck", "End"))
------------------------------------------------------------------------------------------------------------
	elseif labelName == "EndSupplies" then
		if not Supplies.isStocked() and refillAttempts < 3 then
			refillAttempts = refillAttempts + 1
			gotoLabel("Supplies")
		elseif refillAttempts >= 3 then
			setBotEnabled(false)
			sLIB.print("Failed to acquire the necessary supplies too many times. Stopped the bot.")
		end
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Bank" then
		Walker.Stop()
		isHunting = false
		NPC.bank(Supplies.missingCost() + SoftBoots:missingCost() + (extraMoney or 0) + 10 * requiredBlanks())
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName:match("Sail") then
		Walker.Stop()
		isHunting = false
		NPC.sail(string.gsub(labelName, "Sail", ""))
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Aldo" then
		Walker.Stop()
		isHunting = false
		NPC.speak({"hi", "soft boots", "yes"})
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
	elseif labelName:match("Hunt") then
		Hunt.enter()
		refillAttempts = 1
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Leave" then
		Hunt.leave()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "CheckLeave" then
		Walker.ConditionalGoto(Hunt.checkLeave(), labelName:gsub("Check", ""))	
------------------------------------------------------------------------------------------------------------
	elseif labelName == "SellLoot" and sellList then
		Walker.Stop()
		isHunting = false
		NPC.speak({"hi", "trade"})
		NPC.sellItems(sellList)
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Runes" then
		Walker.Stop()
		isHunting = false
		NPC.speak({"hi", "trade"})
		Supplies.buy(Runes)
		sLIB.wait()
		Supplies.move()
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Potions" then
		Walker.Stop()
		isHunting = false
		NPC.speak({"hi", "deposit all", "yes", "trade"})
		Supplies.buy(Potions)
		sLIB.wait()
		Supplies.move()
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Food" then
		Walker.Stop()
		isHunting = false
		NPC.speak({"hi", "trade"})
		Supplies.buy(Foods)
		sLIB.wait()
		Supplies.move()
		isHunting = true
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "Blanks" and requiredBlanks() > 0 then
		Walker.Stop()
		NPC.speak({"hi", "trade"})
		NPC.buyItem("blank rune", requiredBlanks())
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DownNorth" then
		Walker.Stop()
		sLIB.levitate("down", NORTH)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DownEast" then
		Walker.Stop()
		sLIB.levitate("down", EAST)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DownSouth" then
		Walker.Stop()
		sLIB.levitate("down", SOUTH)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DownWest" then
		Walker.Stop()
		sLIB.levitate("down", WEST)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "UpNorth" then
		Walker.Stop()
		sLIB.levitate("up", NORTH)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "UpEast" then
		Walker.Stop()
		sLIB.levitate("up", EAST)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "UpSouth" then
		Walker.Stop()
		sLIB.levitate("up", SOUTH)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "UpWest" then
		Walker.Stop()
		sLIB.levitate("up", WEST)
		Walker.Start()
------------------------------------------------------------------------------------------------------------
	elseif labelName == "CheckLogout" then
		local outOfStamina = Stamina.leave and Self.Stamina() < Stamina.leave * 60
		local outOfTime = (leaveMinutesBeforeSS and Hunt.timeToSS() < leaveMinutesBeforeSS)  or (maxSessionLength and maxSessionLength < Hunt.sessionLength())
		Walker.ConditionalGoto(outOfStamina or outOfTime or recalled, "Logout")
------------------------------------------------------------------------------------------------------------
	elseif labelName == "CheckLogoutFacc" then
		local outOfStamina = Stamina.leave and Self.Stamina() < Stamina.leave * 60
		local outOfTime = (leaveMinutesBeforeSS and Hunt.timeToSS() < leaveMinutesBeforeSS)  or (maxSessionLength and maxSessionLength < Hunt.sessionLength())
		if outOfStamina or outOfTime or recalled then
			os.exit()
		end
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DoorNorth" then
		sLIB.door(NORTH)
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DoorEast" then
		sLIB.door(EAST)
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DoorSouth" then
		sLIB.door(SOUTH)
------------------------------------------------------------------------------------------------------------
	elseif labelName == "DoorWest" then
		sLIB.door(WEST)
------------------------------------------------------------------------------------------------------------
	elseif labelName == "LogoutEast" then
		Walker.Stop()
		sLIB.useGround(EAST)
		wait(4000)
		os.exit()
------------------------------------------------------------------------------------------------------------
	end
end

------------------------------------------------------------------------------------------------------------
----------------------------------------- Modules ----------------------------------------------------------
------------------------------------------------------------------------------------------------------------
function sLIB.startModules()
	if not bpResetter:IsActive() then
		bpResetter:Start()
	end
	if not lurer:IsActive() and attackLimit and monsterScores and attackLimit > 0 then 
		lurer:Start()
	end
	if not ringSwitcher:IsActive() and (Rings["heal"] or Rings["battle"]) then
		ringSwitcher:Start()
	end
	if not softSwitcher:IsActive()  and useSoftBoots then
		softSwitcher:Start()
	end
	if depotPos and Self.DistanceFromPosition(depotPos.x, depotPos.y, depotPos.z) > 20 then
		Hunt.enter()
	else
		Hunt.leave()
	end
end

flaskDropper = Module.New("Flask Dropper", function(Flasks)
	if(Self.TargetID() == 0 and Capacity.dropFlasks) then
		if Self.Flasks() > math.random(5,7) and Self.Cap() < Capacity.dropFlasks then
			delayWalker(300)
			Self.DropFlasks(Self.Position().x, Self.Position().y, Self.Position().z)
		end
	end
	Flasks:Delay(math.random(5000,6000))
end, false)

goldDropper = Module.New("Gold Dropper", function(Gold)
		if(Self.TargetID() == 0 and Backpacks.gold and Self.Cap() < Capacity.dropGold) then
			local gBP = Container.New(Backpacks.gold)
			local prevCount = gBP:CountItemsOfID(3031)
			for spot = gBP:ItemCount() - 1, 0, -1 do
				local item = gBP:GetItemData(spot)
				if item.id == 3031 and Self.Cap() < Capacity.dropGold then
					delayWalker(300)
					gBP:MoveItemToGround(spot, Self.Position().x, Self.Position().y, Self.Position().z)
				end
			end
			local newCount = gBP:CountItemsOfID(3031)
			if newCount < prevCount and customHUD then
				local change = prevCount - newCount
				_HUD.itemCounts[3031] = _HUD.itemCounts[3031] - change
				if _HUD.loot and _HUD.loot[3031] then
					_HUD.loot[3031][1] = _HUD.loot[3031][1] - change
				end
				if _HUD.maxCount and _HUD.maxCount[3031] then
					_HUD.maxCount[3031] = math.max(_HUD.maxCount[3031] - change, 0)
				end
				droppedValue = droppedValue - change
				lootedValue = lootedValue - change
			end
		end
	Gold:Delay(math.random(5000, 6000))
	end, false)
	
bpResetter = Module.New("Backpack Resetter", function(BpReset)
	local backpacks = Backpacks.all()
	if Self.TargetID() == 0 and #Container.GetAll() < #backpacks + 1 then
		delayWalker(1750 * (1 + #backpacks))
		Looter.Stop()
		Backpacks.reset()
		Looter.Start()
	end
	BpReset:Delay(math.random(4000, 6000))
end, false)

local killing = Self.TargetID() ~= 0
lurer = Module.New("Lurer", function(Lurer)
	if attackLimit and attackLimit > 0 and monsterScores then
		local score = Hunt.monsterScore(monsterScores, attackSearchRange)
		if score >= attackLimit and not killing then
			Targeting.StopIgnoring()
			killing = true
		elseif killWhenLooting and score > 0 and #Container.GetAll() > (#Backpacks.all() + 1) then
			Targeting.StopIgnoring()
			killing = true
		elseif score == 0 and killing then
			Targeting.StartIgnoring()
			killing = false
		end
	else
		Lurer:Stop()
	end
	Lurer:Delay(500)
end)

ringSwitcher = Module.New("Ring Switcher", function(Ring)
	local prioQ = Rings:choose()
	local dequip = true
	for _, ring in ipairs(prioQ) do
		if Self.Ring().id == getActiveRingID(ring) then
			dequip = false
			break
		elseif Self.ItemCount(ring) > 0 then
			Self.Equip(ring, "ring")
			dequip = false
			break
		end
	end
	if dequip then
		Self.Dequip("ring", Backpacks.rings)
	end
	Ring:Delay(500)
end, false)

softSwitcher = Module.New("SoftSwitcher", function(Softs)
	local boots = otherBoots
	if sLIB.manaPercent() < 0.9 and not Self.isInPz() and Self.Feet().id ~= 6530 then
		boots = 6529
	end
	if Self.Feet().id ~= Item.GetID(boots) and Self.ItemCount(boots) > 0 then
		Self.Equip(boots, "feet")
	end
	Softs:Delay(500)
end, false)

-- WIP
blocking = {2524}
trasher = Module.New("Thrasher", function(Thrasher)
	if Walker.IsStuck() and trashWeapon then
		setBotEnabled(false)
		sLIB.forWholeScreen(function(pos)
			Self.UseItemWithGround(antiTrash, pos.x, pos.y, pos.z)
			wait(300,400)
		end)
		setBotEnabled(true)
	end
	Thrasher:Delay(300)
end, false)
------------------------------------------------------------------------------------------------------------
------------------------------------ Proxies and Channels --------------------------------------------------
------------------------------------------------------------------------------------------------------------
msgOptions = {}

function handleMsg(c, msg)
	c:SendOrangeMessage(Self.Name(), msg)
	local msg = msg:lower()
	if msg == "+logout" or msg == "logout" or msg == "+leave" or msg == "leave" then
		recalled = true
		sLIB.print("The bot will now leave the spawn upon reaching the next checker and will then log out.")
	elseif  msg == "-logout" or msg == "-leave" then
		if recalled then
			sLIB.print("Revoked previous command to leave the spawn. However, the bot will still leave the spawn if another leaving condition is met.")
		end
		recalled = false
	elseif  msg:match("+dropflasks") then
		local dropAt =  tonumber(msg:match("+dropflasks (.+)"))
		if dropAt then
			Capacity.dropFlasks = dropAt
			sLIB.print("The bot is now dropping flasks at " .. dropAt .. " capacity.")
		else
			sLIB.print("Invalid number.")
		end
		if not flaskDropper:IsActive() then
			flaskDropper:Start()
		end
	elseif  msg == "-dropflasks" and flaskDropper:IsActive() then
		flaskDropper:Stop()
	elseif  msg:match("+dropgold") then
		local dropAt =  tonumber(msg:match("+dropgold (.+)"))
		if dropAt then
			Capacity.dropGold = dropAt
			sLIB.print("The bot is now dropping gold at " .. dropAt .. " capacity.")
		else
			sLIB.print("Invalid number.")
		end
		if not goldDropper:IsActive() then
			goldDropper:Start()
		end
	elseif  msg:match("-dropgold") then
		goldDropper:Stop()
		sLIB.print("Gold dropper stopped.")
	elseif  msg == "+help" or msg == "help" then
		sLIB.print("The following commands are available:")
		sLIB.print("+logout/-logout  --- +: Leave the spawn upon reaching the next checker and then go logout. -: Revoke a previous + command.")
		sLIB.print("+dropgold NUMBER/-dropgold --- Start/Stop the gold dropper or change the capacity at which it drops gold.")
		sLIB.print("+dropflasks NUMBER/-dropflasks  --- Start/Stop the flask dropper or change the capacity at which it drops flasks.")
		for i, _ in pairs(msgOptions) do
			sLIB.print(msgOptions[i][2])
		end
	elseif msgOptions[msg] then
		msgOptions[msg][1]()
	end
end

local channel = Channel.New("Console", handleMsg)

function sLIB.print(msg)
	channel:SendOrangeMessage("Control", msg)
end
sLIB.print("Type +help for a list of commands.")


local replyCount = {}

function localProxy(proxy, msgType, speaker, level, text)
	local maxResponsesPerPlayer = maxResponsesPerPlayer or 3
    if msgType == "say" and logMsgs  and speaker ~= Self.Name() and  tonumber(level) > 0 then
		channel:SendOrangeMessage(speaker .. " [" .. level .. "]", text)
    end
	if logMsgs and msgType == "say" and replyToMsgs and responses and speaker ~= Self.Name() and  tonumber(level) >= 0 then
		if replyCount[speaker] and replyCount[speaker] < maxResponsesPerPlayer then
			wait(700, 3200)
			Self.Say(responses[math.random(1, #responses)])
			replyCount[speaker] = replyCount[speaker] + 1
		elseif not replyCount[speaker] then
			wait(1100, 3200)
			Self.Say(responses[math.random(1, #responses)])
			replyCount[speaker] = 1
		elseif sendIgnore then
			wait(1100, 4200)
			Self.PrivateMessage(speaker, "ignored")
		end
	end
end
LocalSpeechProxy.OnReceive("Local Message Proxy", localProxy)
 
function privateProxy(proxy, speaker, level, text)
    if logMsgs and (not minLvlLog or tonumber(level) >= minLvlLog) then
        channel:SendYellowMessage(speaker .. " [" .. level .. "]", text)
    end
	if (not minLvlLog or tonumber(level) >= minLvlLog) and replyToMsgs and responses then
		if replyCount[speaker] and replyCount[speaker] < maxResponsesPerPlayer then
			wait(1100, 3300)
			Self.PrivateMessage(speaker, responses[math.random(1, #responses)])
			replyCount[speaker] = replyCount[speaker] + 1
		elseif not replyCount[speaker] then
			wait(1100, 3300)
			Self.PrivateMessage(speaker, responses[math.random(1, #responses)])
			replyCount[speaker] = 1
		elseif sendIgnore and replyCount[speaker] == maxResponsesPerPlayer then
			wait(1100, 3300)
			Self.PrivateMessage(speaker, "ignored")
			replyCount[speaker] = replyCount[speaker] + 1
		end
	end
end
PrivateMessageProxy.OnReceive("Private Message Proxy", privateProxy)

------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------- HUD -----------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------

_HUD = {}
_HUD.w = 50
_HUD.e = 50

function startHUD()
	local y = 50
	function incy()
		y = y + 15
	end

	headerColor = {r=240, g=240, b=240}
	descColor = {r=200, g=200, b=200}
	textColor = {r=150, g=150, b=150}

	_HUD.startTime = os.time()
	_HUD.elapsedSeconds = nil
	_HUD.startExp = Self.Experience()
	_HUD.itemCounts = {}
	_HUD.maxCount = {}
	HUD.New(_HUD.w+60, y, "shAdOwHUD", headerColor.r, headerColor.g, headerColor.
	incy()

	_HUD.module = Module.New("shAdOwHUD", function(hud)
		_HUD.updateTime()
		_HUD.updateLevel()
		_HUD.updatePing()
		_HUD.updateExp()
		if isHunting then
			_HUD.updateLoot()
			_HUD.updateWaste()
		end
		hud:Delay(1000)
	end, false)

	if customHUD then
		_HUD.module:Start()
	end
		
	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	HUD.New(_HUD.w, y, "Ping: ", descColor.r, descColor.g, descColor.
	_HUD.ping = HUD.New(_HUD.w + 145, y, "", textColor.r, textColor.g, textColor.
	incy()
	function _HUD.updatePing()
		_HUD.ping:SetText(Self.Ping() .. " ms")
	end

	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	HUD.New(_HUD.w, y, "Level: ", descColor.r, descColor.g, descColor.
	_HUD.level = HUD.New(_HUD.w + 145, y, "", textColor.r, textColor.g, textColor.
	incy()
	function _HUD.updateLevel()
		_HUD.level:SetText(Self.Level())
	end

	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	HUD.New(_HUD.w, y, "Session Length: ", descColor.r, descColor.g, descColor.
	_HUD.time = HUD.New(_HUD.w + 145, y, "", textColor.r, textColor.g, textColor.
	incy()
	function _HUD.updateTime()
		_HUD.elapsedSeconds = os.difftime(os.time(), _HUD.startTime)
		local seconds =  math.floor(_HUD.elapsedSeconds % 60)
		local minutes =  math.floor(_HUD.elapsedSeconds/60 % 60)
		local hours = math.floor(_HUD.elapsedSeconds/3600)
		_HUD.time:SetText(hours..":".. string.format("%02.f", minutes)..":".. string.format("%02.f", seconds))
	end

	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	incy()
	HUD.New(_HUD.w, y, "Exp/h: ",descColor.r, descColor.g, descColor.
	_HUD.exp = HUD.New(_HUD.w + 145, y, "", textColor.r, textColor.g, textColor.
	incy()
	function _HUD.updateExp()
		local expGained = Self.Experience() -  _HUD.startExp
		local exph = math.floor(expGained/_HUD.elapsedSeconds * 36)/10 -- Round to 1 decimal
		_HUD.exp:SetText(exph .. " k/h")
	end

	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	HUD.New(_HUD.w, y, "Profits: ", descColor.r, descColor.g, descColor.
	_HUD.profits = HUD.New(_HUD.w + 145, y, "", textColor.r, textColor.g, textColor.
	incy()

	------------------------------------------------------------------------------------------------------------------------------------
	------------------------------------------------------------------------------------------------------------------------------------

	local lootList = 
	{
		[Item.GetID("gold coin")] = {value=1, cost=0, weight=Item.GetWeight(Item.GetID("gold coin")), name="gold coin"},
		[Item.GetID("platinum coin")] = {value=100, cost=0, weight=Item.GetWeight(Item.GetID("platinum coin")), name="platinum coin"}
	}

	for _, data in ipairs(depositList) do
		local name = data[1]
		local id = Item.GetItemIDFromDualInput(name)
		local _value = customValues and customValues[name] or Item.GetValue(id)
		local _cost = customCosts and customCosts[name] or Item.GetCost(id)
		local _weight = Item.GetWeight(id)
		lootList[id] = {value=_value, cost=_cost, weight=_weight, name=Item.GetName(id)}
		_HUD.maxCount[id] = 0
	end

	local useList = {}
	
	for _, data in ipairs(_Supplies) do
		local name = data:name()
		local id = Item.GetItemIDFromDualInput(name)
		local _value = customValues and customValues[name] or Item.GetValue(id)
		local _cost = customCosts and customCosts[name] or Item.GetCost(id)
		local _weight = Item.GetWeight(id)
		useList[id] = {value=_value, cost=_cost, weight=_weight, name=Item.GetName(id)}
		_HUD.maxCount[id] = 0
	end

	local ringList = {}
	
	for _, option in ipairs(RingOptions) do
		if Rings[option] then
			local name = Rings[option]:name()
			local id = Item.GetItemIDFromDualInput(name)
			local _cost = customCosts and customCosts[name] or Item.GetCost(id)
			local _weight = Item.GetWeight(id)
			ringList[id] = {cost=_cost, weight=_weight, name=Item.GetName(id)}
			_HUD.maxCount[id] = 0
		end
	end
	
	function itemCount(id)
		local id = Item.GetItemIDFromDualInput(id)
		local count = Container.GetFirst():CountItemsOfID(id) or 0
		for _, option in ipairs(BackpackOptions) do
			if Backpacks[option] then
				count = count + Container.New(Backpacks[option]):CountItemsOfID(id)
			end
		end
		return count
	end

	for id, _ in pairs(lootList) do
		_HUD.itemCounts[id] = itemCount(id)
	end

	for id, _ in pairs(useList) do
		_HUD.itemCounts[id] = itemCount(id)
	end
	
	local ye = y + 20
	function incye()
		ye = ye + 15
	end
	HUD.New(_HUD.e+80, ye, "LOOT ",headerColor.r, headerColor.g, headerColor.
	incye()
	_HUD.loot = {}
	incye()
	local totalLootTitle = HUD.New(_HUD.e, ye + 15, "Looted: ", descColor.r, descColor.g, descColor.
	local totalLoot = HUD.New(_HUD.e+80, ye + 15, "", textColor.r, textColor.g, textColor.
	local droppedTitle = HUD.New(_HUD.e, ye + 30, "Dropped:", descColor.r, descColor.g,descColor.
	local dropped = HUD.New(_HUD.e+80, ye + 30, "", textColor.r, textColor.g, textColor.
	local offset = 0
	local woffset = 20
	lootedValue = 0
	droppedValue = 0
	local wastedCost = 0
	local imgOffset = 5

	function _HUD.updateLoot()
		local new = 0
		for id, data in pairs(lootList) do
			local oldCount = _HUD.itemCounts[id] or 0
			local newCount = itemCount(id) or 0
			local newlyLooted = newCount - oldCount
			if newlyLooted > 0 then
				 _HUD.itemCounts[id] = newCount
				if _HUD.loot[id] and (newlyLooted + _HUD.loot[id][1]) <= _HUD.maxCount[id] then
					lootedValue = lootedValue + newlyLooted * data.value
					_HUD.loot[id][1] = _HUD.loot[id][1] + newlyLooted
					_HUD.loot[id][4]:SetText(_HUD.loot[id][1] .." (".._HUD.loot[id][1]*data.value.." gp)")
				elseif not _HUD.loot[id] and _HUD.maxCount[id] and newlyLooted <= _HUD.maxCount[id] then
					lootedValue = lootedValue + newlyLooted * data.value
					_HUD.loot[id] = {}
					_HUD.loot[id][1] = newlyLooted
					_HUD.loot[id][2] = HUD.New(_HUD.e-25, ye+offset-imgOffset, id, textColor.r, textColor.g, textColor.
					_HUD.loot[id][2]:SetItemSize(10)
					_HUD.loot[id][3] = HUD.New(_HUD.e, ye+offset, Item.GetName(id), descColor.r, descColor.g, descColor.
					_HUD.loot[id][4] = HUD.New(_HUD.e+145, ye+offset, _HUD.loot[id][1] .." (".._HUD.loot[id][1]*data.value.." gp)", textColor.r, textColor.g, textColor.
					offset = offset + 15
					new = new + 1
				end
			elseif newlyLooted < 0 then
				_HUD.itemCounts[id] = newCount
				if _HUD.loot[id] and (newCount + _HUD.loot[id][1]) <= _HUD.maxCount[id] then
					lootedValue = lootedValue + newCount * data.value
					_HUD.loot[id][1] = _HUD.loot[id][1] + newCount
					_HUD.loot[id][4]:SetText(_HUD.loot[id][1] .." (".._HUD.loot[id][1]*data.value.." gp)")
				end
			end
		end
		totalLoot:SetText(lootedValue .. " gp")
		dropped:SetText(droppedValue.." gp")
		totalLoot:SetPosition(_HUD.e+80, ye + 15 + offset)
		totalLootTitle:SetPosition(_HUD.e, ye + 15 + offset)
		dropped:SetPosition(_HUD.e+80, ye + 30 + offset)
		droppedTitle:SetPosition(_HUD.e, ye + 30 + offset)
		if new > 0 then 
			for _, hud in pairs(_HUD.waste)  do
				hud[5] = hud[5] + new * 15
				hud[2]:SetPosition(_HUD.e-25, hud[5]-imgOffset)
				hud[3]:SetPosition(_HUD.e, hud[5])
				hud[4]:SetPosition(_HUD.e+145, hud[5])
			end
		end
	end

	local wasteTitle = HUD.New(_HUD.e+75, ye + 60 + offset, "WASTE ", headerColor.r, headerColor.g, headerColor.
	local totalWasteTitle = HUD.New(_HUD.e, ye + 75 + offset + woffset, "Wasted: ", descColor.r, descColor.g, descColor.
	local totalWaste = HUD.New(_HUD.e+80, ye + 75 + offset + woffset, "", textColor.r, textColor.g, textColor.
	_HUD.waste = {}

	local durations =
	{
		[SoftBoots:ID()] = 60 * 60 * 4,
		[Item.GetID("Sword Ring")] = 30 * 60,
		[Item.GetID("Club Ring")] = 30 * 60,
		[Item.GetID("Axe Ring")] = 30 * 60,
		[Item.GetID("Energy Ring")] = 10 * 60,
		[Item.GetID("Life Ring")] = 20 * 60,
		[Item.GetID("Ring of Healing")] = 7.5 * 60,
	}
	
	function _HUD.updateWaste()
		for id, data in pairs(useList) do
			local oldCount = _HUD.itemCounts[id] or 0
			local newCount = itemCount(id) or 0
			local newlyWasted = oldCount - newCount
			if newlyWasted > 0 then
				_HUD.itemCounts[id] = newCount
				if _HUD.waste[id] and newlyWasted < 5 then 
					wastedCost = wastedCost + newlyWasted * data.cost
					_HUD.waste[id][1] = _HUD.waste[id][1] + newlyWasted
					_HUD.waste[id][4]:SetText(_HUD.waste[id][1] .." (".._HUD.waste[id][1]*data.cost.." gp)")
				elseif not _HUD.loot[id] and newlyWasted < 5 then
					wastedCost = wastedCost + newlyWasted * data.cost
					_HUD.waste[id] = {}
					_HUD.waste[id][1] = newlyWasted
					_HUD.waste[id][2] = HUD.New(_HUD.e-25, ye+offset+woffset+60-imgOffset, id, textColor.r, textColor.g, textColor.
					_HUD.waste[id][2]:SetItemSize(10)
					_HUD.waste[id][3] = HUD.New(_HUD.e, ye+offset+woffset+60, Item.GetName(id), descColor.r, descColor.g, descColor.
					_HUD.waste[id][4] = HUD.New(_HUD.e+145, ye+offset+woffset+60, _HUD.waste[id][1] .." (".._HUD.waste[id][1]*data.cost.." gp)", textColor.r, textColor.g, textColor.
					_HUD.waste[id][5] = ye+offset+woffset+60
					woffset = woffset + 15
				end
			elseif newlyWasted < 0 then
				_HUD.itemCounts[id] = newCount
			end
		end
		
		if Self.Feet().id == SoftBoots:ID() then
			local id = SoftBoots:ID()
			local costPerS =  10000 / durations[id]
			wastedCost = wastedCost + costPerS
			if _HUD.waste[id] then
				_HUD.waste[id][1] = _HUD.waste[id][1] + 1
				local totalSeconds = _HUD.waste[id][1]
				local hours = math.floor(totalSeconds/3600)
				local minutes = math.floor(totalSeconds/60)%60
				local seconds = math.floor(totalSeconds)%60
				local timeS = hours..":"..minutes..":"..seconds
				_HUD.waste[id][4]:SetText(timeS .." ("..math.ceil(_HUD.waste[id][1]*costPerS).." gp)")
			else
				_HUD.waste[id] = {}
				_HUD.waste[id][1] = 1
				_HUD.waste[id][2] = HUD.New(_HUD.e, ye+offset+woffset+60-imgOffset, id, textColor.r, textColor.g, textColor.
				_HUD.waste[id][2]:SetItemSize(10)
				local totalSeconds = _HUD.waste[id][1]
				local hours = math.floor(totalSeconds/3600)
				local minutes = math.floor(totalSeconds/3600)%60
				local seconds = math.floor(totalSeconds/3600)%60
				local timeS = hours..":"..minutes..":"..seconds
				_HUD.waste[id][3] = HUD.New(_HUD.e+20, ye+offset+woffset+60, Item.GetName(id), descColor.r, descColor.g, descColor.
				_HUD.waste[id][4] = HUD.New(_HUD.e+145, ye+offset+woffset+60, timeS .." ("..math.ceil(_HUD.waste[id][1]*costPerS).." gp)", textColor.r, textColor.g, textColor.
				_HUD.waste[id][5] = ye+offset+woffset+60
				woffset = woffset + 15
			end
		end
		
		if Self.Ring().id ~= 0 then
			for id, r in pairs(ringList) do
				if Self.Ring().id == Item.GetRingActiveID(id) and durations[id] then
					local costPerS =  r.cost / durations[id]
					wastedCost = math.floor(wastedCost + costPerS)
					if _HUD.waste[id] then
						_HUD.waste[id][1] = _HUD.waste[id][1] + 1
						local totalSeconds = _HUD.waste[id][1]
						local hours = math.floor(totalSeconds/3600)
						local minutes = math.floor(totalSeconds/60)%60
						local seconds = math.floor(totalSeconds)%60
						local timeS = hours..":"..minutes..":"..seconds
						_HUD.waste[id][4]:SetText(timeS .." ("..math.ceil(_HUD.waste[id][1]*costPerS).." gp)")
					else
						_HUD.waste[id] = {}
						_HUD.waste[id][1] = 1
						_HUD.waste[id][2] = HUD.New(_HUD.e, ye+offset+woffset+60-imgOffset, id, textColor.r, textColor.g, textColor.
						_HUD.waste[id][2]:SetItemSize(10)
						local totalSeconds = _HUD.waste[id][1]
						local hours = math.floor(totalSeconds/3600)
						local minutes = math.floor(totalSeconds/3600)%60
						local seconds = math.floor(totalSeconds/3600)%60
						local timeS = hours..":"..minutes..":"..seconds
						_HUD.waste[id][3] = HUD.New(_HUD.e+25, ye+offset+woffset+60, Item.GetName(id), descColor.r, descColor.g, descColor.
						_HUD.waste[id][4] = HUD.New(_HUD.e+150, ye+offset+woffset+60, timeS .." ("..math.ceil(_HUD.waste[id][1]*costPerS).." gp)", textColor.r, textColor.g, textColor.
						_HUD.waste[id][5] = ye+offset+woffset+60
						woffset = woffset + 15
					end
				end
			end
		end
		
		_HUD.profits:SetText( math.floor((lootedValue-wastedCost)/_HUD.elapsedSeconds * 36)/10  .. " k/h")
		totalWaste:SetText(math.floor(wastedCost*10)/10 ..  " gp")
		wasteTitle:SetPosition(_HUD.e+75, ye + 60 + offset)
		totalWasteTitle:SetPosition(_HUD.e, ye + 75 + offset + woffset)
		totalWaste:SetPosition(_HUD.e+80, ye + 75 + offset + woffset)
	end

	function parseLoot(proxy, msg)
		local loot =  msg:match(": (.+)")
		local value = 0
		for lootItem in loot:gmatch("[^,]+") do
			for id, item in pairs(lootList) do
				local numLooted = lootItem:match("(.*) "..item.name)
				local num = tonumber(numLooted)
				if numLooted and (numLooted == "a" or numLooted == "an" or numLooted == " a" or numLooted == " an" or numLooted == "") then
					value = value + item.value
					if _HUD.maxCount[id] then
						_HUD.maxCount[id] = _HUD.maxCount[id] + 1
					else
						_HUD.maxCount[id] = 1
					end
				elseif numLooted and num then
					value = value + num  * item.value
					if _HUD.maxCount[id] then
						_HUD.maxCount[id] = _HUD.maxCount[id] + num
					else
						_HUD.maxCount[id] = num
					end
				end
			end
		end
		droppedValue = droppedValue + value
	end
	LootMessageProxy.OnReceive("Loot Parser", parseLoot)
end


------------------------------------------------------------------------------------------------------------
Looter.Start()
Targeting.Start()

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...