- print('Complex Scripts Library (ver.15.03.29)')
- CS = {}
- SessionStart = os.time()
- SessionTime = 0
- h = 0
- m = 0
- local count = 0
- balance = 0
- --========FUNCTIONS====================--
- CS.PreCheck = function (lLabel1, cLabel1)
- leaveLabel2 = lLabel2 or "ContinueSupply"
- continueLabel2 = cLabel2 or "ToHunt"
- if(runes and runes2 and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.ItemCount(Item.GetID(runes2)) < maxRune2) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(runes and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(ammo and mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(ammo and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- elseif(hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
- end
- end
- CS.CheckBefore = function (lLabel1, cLabel1)
- leaveLabel1 = lLabel1 or "Resupply"
- continueLabel1 = cLabel1 or "ToHunt"
- if(runes and runes2 and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.ItemCount(Item.GetID(runes2)) < maxRune2) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(runes and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(ammo and mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(ammo and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- elseif(hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
- end
- end
- CS.Check = function (lLabel, cLabel)
- leaveLabel = lLabel or "Leave"
- continueLabel = cLabel or "Continue"
- if(runes and runes2 and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(runes)) <= minRune) or (Self.ItemCount(Item.GetID(runes2)) <= minRune2) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(runes and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(runes)) <= minRune) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(ammo and mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(hPots)) <= minHP) or (Self.ItemCount(Item.GetID(ammo)) <= minAmmo) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(ammo and mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(ammo)) <= minAmmo) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(mPots and hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(hPots)) <= minHP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(mPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- elseif(hPots) then
- Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) <= minHP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
- end
- end
- CS.Check = function (lLabel, cLabel)
- leaveLabel = lLabel or "goSell"
- continueLabel = cLabel or "skipSell"
- Walker.ConditionalGoto(sellItems, leaveLabel, continueLabel)
- end
- -- x och y = pos efter lever
- --CS.Lever(east, 32322, 12312, failLabel)
- CS.Lever = function (pos, x, y, failLabel)
- tmpPos = Self.Position()
- tries = 3
- if type(tonumber(pos[1])) == "number" then
- -- Move trash
- repeat
- Self.UseLever(pos[1], pos[2], pos[3])
- tries = tries - 1
- wait(700, 900)
- until (Self.Position().x == x and Self.Position().y == y) or tries <= 0
- wait(200)
- if(Self.Position().x == tmpPos.x and Self.Position().y == tmpPos.y and Self.Position().z == tmpPos.z) then
- Walker.Goto(failLabel)
- end
- elseif type(tonumber(pos)) == "string" then
- -- Move trash
- dir = direction(pos)
- repeat
- Self.UseLever(dir.x, dir.y, dir.z)
- tries = tries - 1
- wait(700, 900)
- until (Self.Position().x == x and Self.Position().y == y) or tries <= 0
- wait(200)
- if(Self.Position().x ~= x and Self.Position().y ~= y) then
- Walker.Goto(failLabel)
- end
- end
- end
- --CS.TradeLoop("medicine pouch", "Ottokar")
- CS.TradeLoop = function (itemName, npcName)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- end
- end
- antiPush(true)
- wait(1000, 1200)
- Self.Say("hi")
- wait(500, 750)
- repeat
- Self.SayToNpc({itemName, "yes"}, 65)
- until Self.ItemCount(Item.GetID(itemName)) == 0
- antiPush(false)
- end
- -- x och y = pos efter tp
- --CS.Teleport(SOUTH, 32322, 12322, "b4tp1")
- CS.Teleport = function (step, tpX, tpY, failLabel)
- Targeting.Stop()
- Self.Step(step)
- wait(1000, 1200)
- if Self.Position().x ~= tpX and Self.Position().y ~= tpY then
- print("fail")
- Walker.Goto(failLabel)
- end
- Targeting.Start()
- end
- --CS.Levitate(south, "up", 4, "b4lev1")
- CS.Levitate = function (turn, where, currentZpos, faillabel)
- Targeting.Stop()
- where2 = tostring(string.lower(where))
- if where2 == "up" then
- Self.Turn(turn)
- wait(500, 700)
- Self.Cast('exani hur "up')
- elseif where2 == "down" then
- Self.Turn(turn)
- wait(500, 700)
- Self.Cast('exani hur "down')
- end
- wait(1000, 1200)
- if currentZpos == Self.Position().z then
- Walker.Goto(faillabel)
- end
- Targeting.Start()
- end
- --CS.Withdraw(foodID, 100, 2)
- CS.Withdraw = function (item, count, dpPos)
- if item > 0 or item then
- item1 = 0
- if type(tonumber(item)) == "number" then
- item1 = item
- elseif type(tostring(item)) == "string" then
- item1 = Item.GetID(item)
- end
- wait(100,200)
- if(Self.ItemCount(item1) < count) then
- CS.ReachDepot()
- Self.WithdrawItems(dpPos, {item1, 0, count - Self.ItemCount(item1)})
- end
- end
- end
- --CS.Bank()
- CS.Bank = function ()
- antiPush(true)
- wTries = 3
- wRune = 0
- wRune2 = 0
- wMana = 0
- wFood = 0
- wAmmo = 0
- wHealth = 0
- wExtra = 0
- if (hPots) then
- if (Self.ItemCount(Item.GetID(hPots)) < maxHP) then
- wHealth = (maxHP - Self.ItemCount(Item.GetID(hPots))) * Item.GetCost(Item.GetID(hPots))
- end
- end
- if (runes) then
- if (Self.ItemCount(Item.GetID(runes)) < maxRune) then
- wRune = (maxRune - Self.ItemCount(Item.GetID(runes))) * Item.GetCost(Item.GetID(runes))
- end
- end
- if (runes2) then
- if (Self.ItemCount(Item.GetID(runes2)) < maxRune2) then
- wRune2 = (maxRune2 - Self.ItemCount(Item.GetID(runes2))) * Item.GetCost(Item.GetID(runes2))
- end
- end
- if (mPots) then
- if (Self.ItemCount(Item.GetID(mPots)) < maxMP) then
- wMana = (maxMP - Self.ItemCount(Item.GetID(mPots))) * Item.GetCost(Item.GetID(mPots))
- end
- end
- if (foods) then
- if (Self.ItemCount(Item.GetID(foods)) < maxFood) then
- wFood = (maxFood - Self.ItemCount(Item.GetID(foods))) * Item.GetCost(Item.GetID(foods))
- end
- end
- if (ammo) then
- if (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) then
- wAmmo = (maxAmmo - Self.ItemCount(Item.GetID(ammo))) * Item.GetCost(Item.GetID(ammo))
- end
- end
- if (extraCash) then
- wExtra = extraCash
- end
- Withdraw = wExtra + wMana + wHealth + wAmmo + wFood + wRune + wRune2
- wait(1000, 1200)
- Self.Say("hi")
- wait(300)
- Self.SayToNpc({"deposit all", "yes"}, 150)
- repeat
- wait(600, 900)
- Self.SayToNpc({"withdraw "..Withdraw, "yes"}, 150)
- wait(250, 450)
- Self.SayToNpc("balance")
- wait(200, 400)
- wTries = wTries - 1
- wait(200)
- if wTries <= 0 then
- break
- end
- until Self.Money() >= Withdraw
- wait(2000 + Self.Ping())
- if(Self.Money() < Withdraw) then
- Walker.Stop()
- wait(1000)
- print("Stopping Walker.. Money needed: "..Withdraw..". Money in bank: "..balance..".")
- end
- antiPush(false)
- end
- NpcMessageProxy.OnReceive("CS.NPCProxy", function(proxy, npcName, message)
- balance = string.match(message, "Your account balance is (.+) gold.")
- end)
- --CS.CheckTask()
- CS.CheckTask = function ()
- if((Self.GetCreatureKills(creature) + creatureKillCount) >= needToKill and doTask and (taskTimes < taskTimesDo)) then
- --go take task
- print("Going to take the task.")
- else
- Walker.Goto("SkipTask")
- end
- end
- --CS.CheckBoss()
- CS.CheckBoss = function ()
- Walker.ConditionalGoto(killBoss, "goBoss", "SkipBoss")
- end
- --CS.TakeTask()
- CS.TakeTask = function ()
- Creature:Follow('Grizzly Adams')
- wait(300)
- antiPush(true)
- Self.SayToNpc({"hi", "task", "task", "task", "promotion", "yes", "task", "task", "".. creature .."s", "yes" }, 120)
- Self.ResetCreatureKills(creature)
- creatureKillCount = 0
- if limitedTask then
- taskTimes = taskTimes + 1
- wait(300)
- if(taskTimes == taskTimesDo) then
- doTask = false
- end
- end
- antiPush(false)
- end
- --CS.TakeTask()
- CS.TakeTask2 = function ()
- Creature:Follow('Grizzly Adams')
- Self.SayToNpc({"hi", "task", "task", "task", "promotion", "yes", "task", "task", "".. creature .."s", "yes" }, 120)
- for i, name in ipairs(mList) do
- Self.ResetCreatureKills(name)
- end
- creatureKillCount = 0
- if limitedTask then
- taskTimes = taskTimes + 1
- wait(300)
- if(taskTimes == taskTimesDo) then
- doTask = false
- end
- end
- end
- --CS.BuyRunes()
- CS.BuyRunes = function (trade, npcName)
- if(runes or runes2) then
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- wait(300)
- end
- end
- antiPush(true)
- trade = trade or "trade"
- wait(1000, 1200)
- Self.SayToNpc("hi")
- wait(300)
- Self.SayToNpc(trade, 100)
- wait(1000)
- if (runes) then
- Self.ShopBuyItemsUpTo(runes, maxRune)
- end
- wait(500)
- if (runes2) then
- Self.ShopBuyItemsUpTo(runes2, maxRune2)
- end
- antiPush(false)
- end
- end
- --CS.BuyAmmo()
- CS.BuyAmmo = function (trade, npcName)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- wait(300)
- end
- end
- antiPush(true)
- trade = trade or "trade"
- wait(1000, 1200)
- Self.Say("hi")
- wait(300)
- Self.SayToNpc(trade)
- wait(500)
- if (ammo) then
- Self.ShopBuyItemsUpTo(ammo, maxAmmo)
- end
- antiPush(false)
- end
- -- Buy runes in same shop, CS.BuySupplies(true, "magic supplies", "Rock In A Hard Place")
- -- CS.BuySupplies()
- CS.BuySupplies = function (trade, npcName)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- wait(300)
- end
- end
- antiPush(true)
- trade = trade or "trade"
- wait(1000, 1200)
- Self.Say("hi")
- wait(300)
- Self.SayToNpc(trade, 100)
- wait(500)
- if (Self.Flasks() > 0) then
- -- Self.SayToNpc({"vial"}, 100)
- -- while (Self.Flasks() > 0) do
- -- Self.SayToNpc({"yes"}, 150)
- -- wait(250, 300)
- --end
- while (Self.Flasks() > 0) do
- if (Self.ItemCount(283) > 0) then
- Self.ShopSellAllItems(283)
- end
- if (Self.ItemCount(284) > 0) then
- Self.ShopSellAllItems(284)
- end
- if (Self.ItemCount(285) > 0) then
- Self.ShopSellAllItems(285)
- end
- wait(150, 300)
- end
- end
- wait(500)
- if (hPots) then
- Self.ShopBuyItemsUpTo(hPots, maxHP)
- end
- wait(500, 750)
- if (mPots) then
- Self.ShopBuyItemsUpTo(mPots, maxMP)
- end
- wait(500, 750)
- if (buyRunes) then
- if (runes) then
- Self.ShopBuyItemsUpTo(runes, maxRune)
- end
- wait(500)
- if (runes2) then
- Self.ShopBuyItemsUpTo(runes2, maxRune2)
- end
- end
- wait(500, 750)
- antiPush(false)
- end
- -- CS.BuyFood()
- CS.BuyFood = function (trade, npcName)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- end
- end
- antiPush(true)
- trade = trade or "trade"
- wait(1000, 1200)
- Self.Say("hi")
- wait(300)
- Self.SayToNpc(trade)
- wait(1000)
- Self.ShopBuyItemsUpTo(foods, maxFood)
- wait(1000)
- antiPush(false)
- end
- -- CS.Travel("thais", "ingvar", 32333, 32444, "b4boat1")
- CS.Travel = function (where, npcName, x, y, failLabel)
- tmpPos = Self.Position()
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- end
- end
- wait(1000, 1200)
- Self.Say("hi")
- wait(150, 300)
- Self.SayToNpc({where, "yes"}, 100)
- wait(300, 500)
- if (failLabel) then
- if(Self.Position().x ~= x and Self.Position().z ~= y) then
- Walker.Goto(failLabel)
- end
- end
- end
- -- CS.Talk({"trade", "bye"}, "ingvar")
- CS.Talk = function (conversation, npcName)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- end
- end
- wait(1000, 1200)
- Self.SayToNpc("hi")
- wait(150, 300)
- Self.SayToNpc(conversation, 150)
- wait(300, 500)
- end
- -- CS.Sell({283, 284, 285}, "creature products")
- CS.Sell = function (items, conversation, npcName)
- local item1 = 0
- if conversation then
- wait(200)
- for n, c in Creature.iNpcs() do
- if (n == npcName and c:isOnScreen()) then
- c:Follow()
- end
- end
- wait(2000, 2200)
- Self.SayToNpc("hi")
- wait(150, 300)
- Self.SayToNpc(conversation, 100)
- end
- antiPush(true)
- wait(300, 500)
- for _, ItemList in ipairs(items) do
- if (Self.ShopGetItemSaleCount(ItemList) > 0) then
- Self.ShopSellAllItems(ItemList)
- wait(100, 250)
- end
- wait(500, 700)
- end
- antiPush(false)
- end
- CS.SellFlask = function ()
- items = {283, 284, 285}
- wait(500)
- Self.SayToNpc("vials")
- wait(500)
- for _, IL in ipairs(items) do
- while Self.ItemCount(IL) > 0 do
- Self.SayToNpc("yes")
- wait(500, 700)
- end
- wait(200, 300)
- end
- end
- -- CS.CheckStamina()
- CS.CheckStamina = function ()
- if (staminaLogout) and (Self.Stamina() < 960) then
- Walker.Stop()
- print("Stopping Walker.. Low Stamina!")
- end
- end
- -- CS.OpenBackpacks(true)
- CS.OpenBackpacks = function (relog)
- Client.HideEquipment()
- tries = 3
- count = 0
- bps = {}
- if stackBP and lootBP and goldBP and suppliesBP and ammoBP then
- bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}, [4] = {suppliesBP, true}, [5] = {ammoBP, true}}
- count = 6
- elseif stackBP and lootBP and goldBP and suppliesBP then
- bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}, [4] = {suppliesBP, true}}
- count = 5
- elseif stackBP and lootBP and goldBP then
- bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}}
- count = 4
- elseif stackBP and lootBP and suppliesBP then
- bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {suppliesBP, true}}
- count = 4
- elseif lootBP and goldBP then
- bps = {[1] = {lootBP, true}, [2] = {goldBP, true}}
- count = 3
- elseif goldBP then
- bps = {[1] = {goldBP, true}}
- count = 2
- end
- if not(relog) then
- repeat
- Self.CloseContainers()
- wait(500)
- Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
- if(#Container.GetAll() == count) then
- print("Successfully opened backpacks")
- break
- else
- tries = tries - 1
- wait(200)
- if(tries <= 0) then
- print("Stopping Walker! Backpack settings are wrong!")
- Walker.Stop()
- break
- end
- print("Backpacks failed to open, trying again")
- end
- wait(500)
- until #Container.GetAll() == count or tries <= 0
- if(logoutTime and (tonumber(SessionTime) >= tonumber(logoutTime))) then
- print("Session ended after "..h..':'..m)
- Walker.Stop()
- wait(1000)
- screenshot(Self.Name()..'_session_end_'.. os.date("%H.%M"))
- end
- else
- print("Reconnected, resetting backpacks")
- setBotEnabled(false)
- repeat
- Self.CloseContainers()
- wait(500)
- Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
- if(#Container.GetAll() == count) then
- print("Successfully opened backpacks")
- setBotEnabled(true)
- break
- else
- tries = tries - 1
- wait(200)
- if(tries <= 0) then
- Targeting.Start()
- print("Stopping Walker! Backpack settings are wrong!")
- break
- end
- print("Backpacks failed to open, trying again")
- end
- wait(500)
- until #Container.GetAll() == count or tries <= 0
- end
- end
- CS.OpenBackpacks1 = function (relog)
- Client.HideEquipment()
- tries = 3
- count = 0
- bps1 = {}
- if suppliesBP then
- --table.insert(bps1, {suppliesBP, true})
- bps1[#bps1+1] = {suppliesBP, true}
- end
- if stackBP then
- -- table.insert(bps1, {stackBP, true})
- bps1[#bps1+1] = {stackBP, true}
- end
- if lootBP then
- -- table.insert(bps1, {lootBP, true})
- bps1[#bps1+1] = {lootBP, true}
- end
- if goldBP then
- -- table.insert(bps1, {goldBP, true})
- bps1[#bps1+1] = {goldBP, true}
- end
- if ammoBP then
- -- table.insert(bps1, {ammoBP, true})
- bps1[#bps1+1] = {ammoBP, true}
- end
- for _, s in ipairs(bps1) do
- print(s)
- end
- print(bps1)
- table.concat(bps1, ", ")
- count = #bps1+1
- if not(relog) then
- repeat
- Self.CloseContainers()
- wait(500)
- Self.OpenMainBackpack(true):OpenChildren(bps1)
- if(#Container.GetAll() == count) then
- print("Successfully opened backpacks")
- break
- else
- tries = tries - 1
- wait(200)
- if(tries <= 0) then
- print("Stopping Walker! Backpack settings are wrong!")
- Walker.Stop()
- break
- end
- print("Backpacks failed to open, trying again")
- end
- wait(500)
- until #Container.GetAll() == count or tries <= 0
- else
- print("Reconnected, resetting backpacks")
- setBotEnabled(false)
- repeat
- Self.CloseContainers()
- wait(500)
- Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
- if(#Container.GetAll() == count) then
- print("Successfully opened backpacks")
- setBotEnabled(true)
- break
- else
- tries = tries - 1
- wait(200)
- if(tries <= 0) then
- Targeting.Start()
- print("Stopping Walker! Backpack settings are wrong!")
- break
- end
- print("Backpacks failed to open, trying again")
- end
- wait(500)
- until #Container.GetAll() == count or tries <= 0
- end
- end
- CS.OpenDoor1 = function (pos, x, y, failLabel)
- Targeting.Stop()
- dir = direction(pos)
- if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
- wait(300, 700)
- Self.OpenDoor(dir.x, dir.y, dir.z)
- wait(300, 400)
- Self.Step(pos)
- wait(300, 400)
- end
- if not(Self.Position().x == x and Self.Position().y == y) then
- Walker.Goto(failLabel)
- end
- Targeting.Start()
- end
- -- CS.OpenDoor({x, y, z}, "key", 1234) -- key door
- -- CS.OpenDoor({x, y, z}, "level") -- level door
- -- CS.OpenDoor({x, y, z}) -- normal door
- -- CS.OpenDoor("north", "level") -- level door without coordinates
- CS.OpenDoor = function (pos, doorType, keyid)
- if type(tonumber(pos[1])) == "number" then
- if(doorType == "key") then
- if(keyid) then
- if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
- Self.OpenDoor(pos[1], pos[2], pos[3])
- wait(300, 500)
- end
- if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
- kSpot = getSpotById(keyid)
- repeat
- wait(500, 700)
- Container:UseItemWithGround(kSpot, pos[1], pos[2], pos[3])
- wait(1000, 2000)
- Self.OpenDoor(pos[1], pos[2], pos[3])
- until (Map.IsTileWalkable(pos[1], pos[2], pos[3]))
- end
- end
- elseif (doorType == "level") then
- if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
- repeat
- Self.OpenDoor(pos[1], pos[2], pos[3])
- wait(300, 700)
- until (Self.Position().x == pos[1] and Self.Position().y == pos[2])
- end
- else
- if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
- repeat
- Self.OpenDoor(pos[1], pos[2], pos[3])
- wait(300, 700)
- until (Map.IsTileWalkable(pos[1], pos[2], pos[3]))
- end
- end
- elseif type(tostring(pos)) == "string" then
- dir = direction(pos)
- if(doorType == "key") then
- if(keyid) then
- if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
- Self.OpenDoor(dir.x, dir.y, dir.z)
- wait(300, 500)
- end
- if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
- kSpot = getSpotById(keyid)
- repeat
- wait(500, 700)
- Container:UseItemWithGround(kSpot, dir.x, dir.y, dir.z)
- wait(1000, 2000)
- Self.OpenDoor(dir.x, dir.y, dir.z)
- until (Map.IsTileWalkable(dir.x, dir.y, dir.z))
- end
- end
- elseif (doorType == "level") then
- if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
- repeat
- Self.OpenDoor(dir.x, dir.y, dir.z)
- wait(300, 700)
- until (Self.Position().x == dir.x and Self.Position().y == dir.y)
- end
- else
- if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
- repeat
- Self.OpenDoor(dir.x, dir.y, dir.z)
- wait(300, 700)
- until (Map.IsTileWalkable(dir.x, dir.y, dir.z))
- end
- end
- end
- end
- -- Breakwall in dworcs?:D
- -- CS.BreakWall("NORTH", "Crowbar")
- CS.BreakWall = function (string, itemId)
- dir = direction(string)
- spot = getSpotById(itemId)
- repeat
- wait(500, 1000)
- Container:UseItemWithGround(spot, dir.x, dir.y, dir.z)
- until Map.IsTileWalkable(dir.x, dir.y, dir.z)
- end
- -- CS.UseItem(3215)
- CS.UseItem = function (itemId, tries1)
- spot = getSpotById(itemId)
- tries = tries1 or 2
- if(itemId > 0) then
- repeat
- wait(500, 1000)
- Container:UseItem(spot)
- tries = tries - 1
- until tries <= 0
- end
- end
- CS.PickUpFromGround = function (x,y,z, itemId)
- if(itemId) then
- repeat
- Map.PickupItem(x, y, z, "", 0)
- until Self.ItemCount(itemId) ~= 0
- else
- Map.PickupItem(x, y, z, "", 0)
- end
- end
- CS.PickUpFromGroundDir = function (string, itemId)
- dir = direction(string)
- if(itemId) then
- repeat
- Map.PickupItem(dir.x, dir.y, dir.z, "", 0)
- until Self.ItemCount(itemId) ~= 0
- else
- Map.PickupItem(dir.x, dir.y, dir.z, "", 0)
- end
- end
- CS.UseOnGround = function (pos, tries)
- tries = 3 or tries
- if type(tonumber(pos[1])) == "number" then
- repeat
- wait(500, 1000)
- Self.UseItemFromGround(pos[1], pos[2], pos[3])
- tries = tries - 1
- until tries <= 0
- elseif type(tostring(pos)) == "string" then
- dir = direction(pos)
- repeat
- wait(500, 1000)
- Self.UseItemFromGround(dir.x, dir.y, dir.z)
- tries = tries - 1
- until tries <= 0
- end
- end
- CS.ReachDepot = function (tries)
- local tries = tries or 3
- Walker.Stop()
- local DepotIDs = {3497, 3498, 3499, 3500}
- local DepotPos = {}
- for i = 1, #DepotIDs do
- local dps = CS.GetUseItems(DepotIDs[i])
- for j = 1, #dps do
- table.insert(DepotPos, dps[j])
- end
- end
- local function gotoDepot()
- local pos = Self.Position()
- print("Depots found: " .. tostring(#DepotPos))
- for i = 1, #DepotPos do
- location = DepotPos[i]
- Self.UseItemFromGround(location.x, location.y, location.z)
- wait(1000, 2000)
- if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
- wait(5000, 6000)
- if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
- Walker.Start()
- return true
- end
- else
- print("Something is blocking the path. Trying next depot.")
- end
- end
- return false
- end
- repeat
- reachedDP = gotoDepot()
- if reachedDP then
- return true
- end
- tries = tries - 1
- sleep(100)
- print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
- until tries <= 0
- return false
- end
- CS.GetUseItems = function (id)
- if type(id) == "string" then
- id = Item.GetID(id)
- end
- local pos = Self.Position()
- local store = {}
- for x = -7, 7 do
- for y = -5, 5 do
- if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
- itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
- table.insert(store, itemPos)
- end
- end
- end
- return store
- end
- local lvl = Self.Level()
- local Vocation =
- {
- Unknown = {Name = "Unknown", ID = 0},
- Rookie = {Name = "Rookie", ID = 1},
- Neutral = {Name = "N/A", ID = 2},
- Sorcerer = {Name = "Sorcerer", ID = 3},
- Druid = {Name = "Druid", ID = 4},
- Mage = {Name = "Mage", ID = 5},
- Knight = {Name = "Knight", ID = 6},
- Paladin = {Name = "Paladin", ID = 7}
- }
- local Hitpoints =
- {
- Knight = 5 * ((3 * lvl) - (2 * 8) + 29),
- Paladin = 5 * ((2 * lvl) - 8 + 29),
- Mage = 5 * (lvl + 29),
- Rookie = 5 * (lvl + 29)
- }
- local Manapoints =
- {
- Knight = 5 * lvl,
- Paladin = 5 * ((3 * lvl) - (2 * 8)),
- Mage = 5 * ((6 * lvl) - (5 * 8)),
- Rookie = 5 * lvl
- }
- local Druid =
- {
- Armor = {8041, 8038},
- Rod = {3066, 3070, 3069, 8083, 3065, 3067, 8084, 8082, 16117, 16118}
- }
- local Sorcerer =
- {
- Armor = {8039, 8062, 8040, 8037},
- Wand = {3074, 3075, 3072, 8093, 3073, 3071, 12603, 8092, 8094, 16096, 16115}
- }
- CS.Vocation = function ()
- if lvl == 8 then
- return Vocation.Neutral
- elseif (table.contains({ Hitpoints.Knight, Hitpoints.Knight - 10, Hitpoints.Knight - 20}, Self.MaxHealth())) then
- if (table.contains({ Manapoints.Knight }, Self.MaxMana())) then
- return Vocation.Knight.Name
- end
- elseif (table.contains({ Hitpoints.Paladin, Hitpoints.Paladin - 5, Hitpoints.Paladin - 10}, Self.MaxHealth())) then
- if (table.contains({ Manapoints.Paladin, Manapoints.Paladin - 10, Manapoints.Paladin - 20}, Manapoints.Paladin)) then
- return Vocation.Paladin.Name
- end
- elseif (table.contains({ Hitpoints.Mage }, Self.MaxHealth())) then
- if (table.contains({ Manapoints.Mage, Manapoints.Mage - 25, Manapoints.Mage - 50 }, Self.MaxMana())) then
- if table.contains(Druid.Armor, Self.Armor().id) or table.contains(Druid.Rod, Self.Weapon().id) then
- return Vocation.Druid.Name
- elseif table.contains(Sorcerer.Armor, Self.Armor().id) or table.contains(Sorcerer.Wand, Self.Weapon().id) then
- return Vocation.Sorcerer.Name
- else
- return Vocation.Mage.Name
- end
- end
- elseif (Hitpoints.Rookie == Self.MaxHealth()) then
- if (Manapoints.Rookie == Self.MaxMana()) then
- return Vocation.Rookie.Name
- end
- else
- return Vocation.Unknown.Name
- end
- end
- function getSpotById(id)
- cont = Container.GetFirst()
- for spot = 0, cont:ItemCount() do
- local item = cont:GetItemData(spot)
- if item.id == id then
- Spot = spot
- break
- end
- end
- return Spot
- end
- function direction(string)
- dir = tostring(string:lower())
- pos = {}
- pos.x = 0
- pos.y = 0
- pos.z = Self.Position().z
- if(dir == "north" ) then
- pos.x = Self.Position().x
- pos.y = Self.Position().y-1
- elseif(dir == "south" ) then
- pos.x = Self.Position().x
- pos.y = Self.Position().y+1
- elseif(dir == "west" ) then
- pos.x = Self.Position().x-1
- pos.y = Self.Position().y
- elseif(dir == "east" ) then
- pos.x = Self.Position().x+1
- pos.y = Self.Position().y
- elseif(dir == "center" ) then
- pos.x = Self.Position().x
- pos.y = Self.Position().y
- else
- print("Accepted Direction NORTH/SOUTH/WEST/EAST/CENTER")
- end
- return pos
- end
- function getMonsterCount(monsterList)
- local count = 0
- for i = CREATURES_LOW, CREATURES_HIGH do
- local creature = Creature.GetFromIndex(i)
- if (creature:isValid()) and creature:ID() ~= Self.ID() then
- if (creature:isOnScreen() and creature:isVisible() and creature:isAlive()) then
- local name = creature:Name()
- if(table.find(monsterList, name, true))then
- count = count + 1
- end
- end
- end
- end
- return count
- end
- function ManaPercent()
- return math.ceil((Self.Mana()/Self.MaxMana()*100))
- end
- function Comma_value(amount)
- local formatted = amount
- while true do
- formatted, k = string.format(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then
- break
- end
- end
- return formatted
- end
- function AddCommas(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then
- break
- end
- end
- return formatted
- end
- function transformMoney(moneyCur)
- if (tonumber(moneyCur) < 1000) then
- return moneyCur .. "gp"
- else
- return string.format("%.0f", moneyCur / 1000) .. "k"
- end
- end
- local antiPushPos = Self.Position()
- local antiPushMaxTries = 5 -- number or false
- local antiPushTriesLeft = antiPushMaxTries
- local antiPushModule = Module.New("antiPush", function()
- stepTo(antiPushPos)
- end,false)
- function stepTo(pos)
- local p = Self.Position()
- local dx = pos.x - p.x
- local dy = pos.y - p.y
- local d = ""
- if dy == -1 then
- d = "north"
- elseif dy == 1 then
- d = "south"
- end
- if dx == 1 then
- d = d .. "east"
- elseif dx == -1 then
- d = d .. "west"
- end
- if string.len(d) > 0 then
- antiPushModule:Delay(math.random(100,300))
- local notMoved = (Self.Step(d) == 0)
- if notMoved then
- if antiPushMaxTries then
- antiPushTriesLeft = antiPushTriesLeft - 1
- if antiPushTriesLeft == 0 then
- -- do something like an alarm if you want
- antiPushModule:Stop()
- end
- end
- else
- antiPushTriesLeft = antiPushMaxTries
- end
- antiPushModule:Delay(math.random(100,300))
- end
- end
- function antiPush(turnItOn)
- if turnItOn then
- antiPushTriesLeft = antiPushMaxTries
- antiPushPos = Self.Position()
- antiPushModule:Start()
- else
- antiPushModule:Stop()
- end
- end
- --========MODULES========================--
- Time = HUD.New(10, 30, '', 200, 200, 200)
- Module.New('Session_Time_Update', function(module)
- if (logoutTime) then
- -- Timer
- local TimeDifference = os.difftime(os.time(), SessionStart)
- h = string.format("%02.f", math.floor(TimeDifference/3600));
- m = string.format("%02.f", math.floor(TimeDifference/60 - (h*60)));
- SessionTime = string.format("%01.f", math.floor(TimeDifference/3600));
- logoutAfter = logoutTime - SessionTime
- Time:SetText(h ..':'.. m )
- end
- end)
- Module.New('Move_Supplies', function(module)
- local Supplies = {Item.GetID(mPots), Item.GetID(hPots), Item.GetID(runes), Item.GetID(runes2)}
- for _, c in Container.iContainers() do
- for spot, data in c:iItems() do
- if (table.contains(Supplies, data.id) and c:Index() ~= Container.New(suppliesBP):Index()) then
- c:MoveItemToContainer(spot, Container.New(suppliesBP):Index(), Container.New(suppliesBP):EmptySlots() - 1)
- module:Delay(300,600)
- end
- module:Delay(550, 800)
- end
- end
- module:Delay(300,600)
- end, false)
- Module.New('Move_Ammunition', function(module)
- local Ammunition = {Item.GetID(ammo)}
- for _, c in Container.iContainers() do
- for spot, data in c:iItems() do
- if (table.contains(Ammunition, data.id) and c:Index() ~= Container.New(ammoBP):Index()) then
- c:MoveItemToContainer(spot, Container.New(ammoBP):Index(), Container.New(ammoBP):EmptySlots() - 1)
- module:Delay(300,600)
- end
- module:Delay(550, 800)
- end
- end
- module:Delay(300,600)
- end, false)
- vialIDs = {283, 284, 285}
- Module.New('Drop_Vials', function(module)
- if Self.Cap() < 200 then
- for i = 1, #vialIDs do
- if Self.ItemCount(vialIDs[i]) > math.random(5, 10) then
- Self.DropFlasks(Self.Position().x-math.random(-1, 2), Self.Position().y-math.random(-1, 2), Self.Position().z)
- module:Delay(math.random(5000,9000))
- end
- end
- end
- end, false)
- local onLevel = 'yes'
- local onDeath = 'yes'
- cLevel = Self.Level()
- cName = Self.Name()
- Module.New('Screenshot', function(module)
- if cName ~= Self.Name() then
- cLevel = Self.Level()
- cName = Self.Name()
- end
- if onLevel == 'yes' then
- if cName == Self.Name() and Self.Level() > cLevel then
- wait(1000)
- screenshot(Self.Name()..'_Level_'..Self.Level())
- wait(1000)
- cLevel = Self.Level()
- cName = Self.Name()
- end
- end
- if cName == Self.Name() and onDeath == 'yes' then
- if Self.Health() <= Self.Health() * 0.05 then
- --wait(1000)
- screenshot(Self.Name()..'_Death_'..Self.Level())
- wait(1000)
- onDeath = 'no'
- end
- end
- module:Delay(200)
- end, false)
- lastTime = os.clock()
- Module.New('BP_Reconnect', function()
- if (os.difftime(os.clock(), lastTime) > 1) then
- if((#Container.GetAll() < count) and not Self.isInPz()) then
- screenshot(Self.Name()..'_reconnected_'.. os.date("%H.%M"))
- CS.OpenBackpacks(true)
- end
- end
- lastTime = os.clock()
- end, false)
- Module.New('Kill_HUD', function(module)
- if doTask then
- totalkills = Self.GetCreatureKills(creature) + creatureKillCount
- TotalKillHUD:SetText("You already hunted " .. totalkills .. "/".. needToKill .. " " .. creature.."s.")
- if limitedTask then
- TotalTimesHUD:SetText("" .. taskTimes .. "/" ..taskTimesDo.. "")
- else
- TotalTimesHUD:SetText("")
- end
- module:Delay(2000)
- else
- TotalKillHUD:SetText("")
- TotalTimesHUD:SetText("")
- end
- end, false)
- Balance = HUD.New(10, 20, '', 200, 200, 200)
- Module.New('Balance_HUD', function(module)
- if balance then
- Balance:SetText("Balance: "..transformMoney(balance))
- end
- end)
- --weaponID = 2323
- --ammoID =1234
- --ammoAmount = 5
- --monsterAmount = 3
- --mList = {"Shit"}
- Module.New('Trainer', function(module)
- local mob = Self.GetTargets(7)
- local count = 0
- for i =1, #mob do
- if table.contains(mList, mob[i]:Name()) then
- count = count + 1
- end
- end
- if ((Self.ItemCount(ammoID) < ammoAmount) or (count > monsterAmount)) then
- module:Delay(1000)
- Self.Equip(weaponID, "weapon")
- elseif ((Self.ItemCount(ammoID) > ammoAmount) and (count < monsterAmount)) then
- module:Delay(1000)
- Self.Equip(ammoID, "weapon", 100)
- end
- module:Delay(2000)
- end, false)
- Module.New('Concentrated_Blood', function (module)
- if Self.ItemCount(6558) > 0 then
- Self.UseItem(6558)
- end
- module:Delay(100,6000)
- end, false)
- --mLimit = 3
- --mList = {"Banshee", "Necromancer", "Lich", "Vampire", "Vampire Bride"}
- --eRingID = 3051
- Module.New("Ring_Equip", function (module)
- local curRing = Self.Ring().id
- local eneRing = getActiveRingID(eRingID)
- if (getMonsterCount(mList) >= mLimit and curRing ~= eneRing) then
- Self.Equip(eRingID, "ring")
- elseif (getMonsterCount(mList) < mLimit) then
- Self.Dequip("ring", 0)
- end
- module:Delay(500)
- end, false)
- -- useRing = true
- -- ringID = 2323 -- ring to be equiped
- Module.New("Ring_Loop", function (module)
- local curRing = Self.Ring().id
- local eRing = getActiveRingID(ringID)
- if (curRing ~= eRing and useRing) then
- Self.Equip(ringID, "ring")
- end
- module:Delay(500)
- end, false)
- --lMode = true
- --mLimit = 4
- --mList = {"Simbang"}
- Module.New("Lure", function(module)
- local mob = Self.GetTargets(10)
- local count = 0
- for i = 1, #mob do
- if table.find(mList, mob[i]:Name()) then
- count = count+1
- end
- end
- if lMode and (count >= mLimit) and not load then
- loadSettings(nTargeting, "Targeting")
- wait(300,400)
- loadSettings(nTargeting, "Spell Shooter")
- load = true
- elseif count == 0 and load then
- loadSettings(lTargeting, "Targeting")
- wait(300,400)
- loadSettings(lTargeting, "Spell Shooter")
- load = false
- end
- module:Delay(200)
- end, false)
- --lMode = true
- --mLimit = 4
- --mList = {"Simbang"}
- Module.New("Lure_1", function(module)
- local mob = Self.GetTargets(10)
- local count = 0
- for i = 1, #mob do
- if table.find(mList, mob[i]:Name()) then
- count = count+1
- end
- end
- if lMode and (count >= mLimit) and not load or Walker.IsStuck() then
- Targeting.Start()
- load = true
- elseif count == 0 and load then
- Targeting.Stop()
- load = false
- end
- module:Delay(200)
- end, false)
- rep = 0
- Module.New("Warlock_Hunter", function(module)
- for name, creature in Creature.iMonsters() do
- if creature:isTarget() and creature:isValid() and creature:Name() == "Warlock" or creature:Name() == "Infernalist" then
- Walker.Stop()
- x = creature:Position().x
- y = creature:Position().y
- z = creature:Position().z
- while creature:HealthPercent() > 0 and rep <= 6 do
- wait(400)
- countr = Self.ItemCount(Item.GetID(runes2))
- tries = 2
- repeat
- Self.UseItemWithGround(Item.GetID(runes2), x, y, z)
- wait(140)
- tries = tries - 1
- until tries <= 0
- wait(4500)
- rep = rep + 1
- end
- Walker.Start()
- rep = 0
- end
- end
- module:Delay(200)
- end, false)
- Module.New("Warlock_Hunter2", function(module)
- for name, creature in Creature.iMonsters() do
- if creature:isTarget() and creature:isValid() and creature:Name() == "Warlock" or creature:Name() == "Infernalist" then
- Walker.Stop()
- while creature:HealthPercent() > 0 and rep <= 6 do
- wait(4500)
- rep = rep + 1
- end
- Walker.Start()
- rep = 0
- end
- end
- module:Delay(200)
- end, false)
- local TempCreatureData = nil
- Module.New('Anti-Stealth', function(module)
- if Self.TargetID() == 0 then
- if TempCreatureData then
- if not TempCreatureData:isVisible() then
- if TempCreatureData:HealthPercent() > 0 then
- if(invisibleRune) then
- tries = 2
- Walker.Stop()
- repeat
- if Self.ItemCount(Item.GetID(invisibleRune)) > 0 then
- Self.UseItemWithGround(Item.GetID(invisibleRune), TempCreatureData:Position().x, TempCreatureData:Position().y, TempCreatureData:Position().z)
- end
- tries = tries - 1
- until tries < 1
- Walker.Start()
- end
- else
- TempCreatureData = nil
- end
- end
- end
- end
- end, false)
- Module.New('UpdateData', function (module)
- if Self.TargetID() ~= 0 then
- TempCreatureData = Creature(Self.TargetID())
- end
- module:Delay(200)
- end)
- Module.New("Mana_Restore", function(module)
- if (ManaPercent() < 90) and (#Self.GetTargets(5) == 0) and (Self.ItemCount(Item.GetID(mPots)) > 0) and (Self.isInPz() == false) and manaRestore then
- Walker.Stop()
- while (ManaPercent() < 95) and (#Self.GetTargets(5) == 0) and (Self.ItemCount(Item.GetID(mPots)) > 0) do
- Self.UseItemWithMe(Item.GetID(mPots))
- wait(700,800)
- end
- Walker.Start()
- end
- module:Delay(200)
- end, false)
- local bodyid = {6048, 17445} -- monster body id (fresh only, 5~10 seconds after death)
- local lootItems = { -- Sort item ids into backpack index/name
- [1] = {3029, 3035, 10282, 9058},
- [2] = {3369, 3370, 3392, 3079, 3436, 3081, 3098, 9302, 9606},
- [3] = {3031}
- }
- local tmp = {}
- Module.New("CorpseScanner", function(module)
- if loot then
- local pos = Self.Position()
- -- insert all fresh bodies position into a temporary table
- for x = -7, 7 do
- for y = -5, 5 do
- local body = Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id
- if table.contains(bodyid, body) then
- local identical = false
- for i = 1, #tmp do
- if tmp[i].x == pos.x + x and tmp[i].y == pos.y + y and tmp[i].id == body then
- identical = true
- end
- end
- if not (identical) then
- tmp[#tmp+1] = {x = pos.x + x, y = pos.y + y, z = pos.z, id = body}
- end
- end
- end
- end
- end
- module:Delay(1000, 1500)
- end)
- Module.New("CorpseHandler", function(module)
- if (#tmp > 0 and loot) then -- there is atleast one corpse on screen
- Cavebot.Stop()
- for i = #tmp, 1, -1 do -- reverse table for future removal
- local t = 0
- local indexes = #Container.GetAll()
- while indexes == #Container.GetAll() or t > 6 do
- t = t + 1
- Self.UseItemFromGround(tmp[i].x, tmp[i].y, tmp[i].z)
- wait(1000)
- end
- -- body should be open by now, start looting
- if #Container.GetAll() == indexes + 1 then
- local c = Container.GetLast()
- for spot = c:ItemCount() - 1, 0, -1 do -- reversed
- for index, group in pairs(lootItems) do
- if table.contains(group, c:GetItemData(spot).id) then
- c:MoveItemToContainer(spot, Container(index):Index(), Container(index):ItemCapacity()-1)
- wait(1000)
- end
- end
- end
- wait(7000)
- end
- table.remove(tmp, i)
- end
- Cavebot.Start()
- end
- module:Delay(1000, 1500)
- end)
- -- labelName = "Exit"
- -- amountToLeave = 10
- -- mList = {"Medusa", "Serpent Spawn"}
- Module('Anti-Lure', function(mod)
- local count = 0
- for name, creature in Creature.iMonsters() do
- if (table.contains(mList, name)) then
- count = count + 1
- end
- end
- if (count >= amountToLeave) then
- gotoLabel(labelName)
- end
- end, false)
- Module.New("Anti-Stalker", function (module)
- BattleMessageProxy.OnReceive('Anti Stalker', function(proxy, message)
- if message:find("You lose (.+) hitpoints due to an attack by a stalker.") and Self.TargetID() == 0 then
- Walker.Stop()
- print("Stalker detected!!")
- if(vocation == "Knight") then
- wait(200, 300)
- Self.Cast("exori")
- elseif (vocation == "Paladin") then
- wait(200, 300)
- Self.Cast("exevo mas san")
- elseif (vocation == "mage" or vocation == "druid" or vocation == "sorcerer") then
- if(invisibleRune) then
- tries = 2
- repeat
- wait(200, 300)
- if Self.ItemCount(Item.GetID(invisibleRune)) > 0 then
- Self.UseItemWithMe(Item.GetID(invisibleRune))
- end
- tries = tries - 1
- until tries <= 0
- end
- end
- Walker.Start()
- end
- end)
- module:Delay(1000)
- end, false)
- Module.New("Roots", function (module)
- rootsID = {21104, 21105}
- pos = Self.Position()
- for x = -7, 7 do
- for y = -5, 5 do
- local root = Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id
- if table.contains(rootsID, root) and #Self.GetTargets(5) < 1 and Self.TargetID() == 0 then
- Self.StopAttack()
- Cavebot.Stop()
- wait(1000)
- Self.UseItemFromGround(pos.x + x, pos.y + y, pos.z)
- wait(1000)
- Cavebot.Start()
- end
- end
- end
- end, false)
- --Lottery Module
- Module.New('Lottery', function (module)
- if Self.ItemCount(5957) > 0 then
- Self.UseItem(5957)
- end
- module:Delay(100,6000)
- end, false)
- Module.New("Dwarven_Ring", function (mod)
- local curRing = Self.Ring().id
- local eRing = getActiveRingID(3097)
- if (curRing ~= eRing) then
- Self.Equip(3097, "ring")
- end
- mod:Delay(1000, 2000)
- end, false)
- ------------SERVERSAVE MODULE-------------
- serverSave = "10:00"
- --SERVER_SAVE_TEXT = HUD(10, 5, 'Next Server Save', 200, 200, 200)
- --SERVER_SAVE_VALUE = HUD(140, 5, '00:00:00', 255, 255, 255)
- Time_Now = os.date("*t")
- Server_Save_Hour, Server_Save_Minutes = serverSave:match("(.+):(.+)")
- Server_Save = ((Server_Save_Hour + 0) * 3600) + ((Server_Save_Minutes + 0) * 60)
- if Server_Save <= ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec) then
- Server_Save_TimeLeft = (Server_Save + 24 * 3600) - ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
- else
- Server_Save_TimeLeft = Server_Save - ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
- end
- Module.New("Update_SS", function ( mod )
- Time_Now = os.date("*t")
- if Server_Save <= ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec) then
- Server_Save_TimeLeft = os.difftime((Server_Save + 24 * 3600), (Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
- else
- Server_Save_TimeLeft = os.difftime(Server_Save,(Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
- end
- nHours = string.format("%02.f", math.floor(Server_Save_TimeLeft/3600))
- nMins = string.format("%02.f", math.floor((Server_Save_TimeLeft - (nHours * 3600)) / 60))
- nSecs = string.format("%02.f", math.floor(Server_Save_TimeLeft - (nHours * 3600) - (nMins * 60)))
- --SERVER_SAVE_VALUE:SetText(nHours..':'..nMins..':'..nSecs)
- end, false)
- Stuck = {}
- --Stuck.x = 32323
- --Stuck.label = "CheckStuck"
- Module.New("Stuck", function (mod)
- if(Self.DistanceFromPosition(Stuck.x, Stuck.y, Stuck.z) < 10) then
- Targeting.Stop()
- Looter.Stop()
- wait(1000)
- Walker.Goto(Stuck.label)
- end
- mod:Delay(1000)
- end, false)
- --=======================================--
- --========TASK CHANNEL===================--
- sit = 0
- CS.OnTaskSpeak = function (c, msg)
- c:SendYellowMessage(Self.Name(), msg)
- if sit == 0 then
- if type(tonumber(msg)) == "number" then
- c:SendOrangeMessage('Tasker','Okay, so you have killed ' .. msg .. " " .. creature ..'s.')
- creatureKillCount = msg
- Self.ResetCreatureKills(creature)
- if limitedTask then
- c:SendOrangeMessage('Tasker','How many times have you made the task?')
- sit = 1
- else
- sit = 2
- c:SendOrangeMessage('Tasker','Happy hunting :)! You can change these number whenever you want, just type /change.')
- end
- else
- c:SendOrangeMessage('Tasker','You must fill in a number!')
- sit = 0
- end
- elseif sit == 1 and limitedTask then
- if type(tonumber(msg)) == "number" then
- c:SendOrangeMessage('Tasker','Okay, so you have made the task ' .. msg .. ' times.')
- taskTimes = tonumber(msg)
- if(tonumber(msg) >= taskTimesDo) then
- c:SendOrangeMessage('Tasker','You can only do this task ' .. taskTimesDo ..' times. Tasker inactivated')
- c:Close()
- doTask = false
- else
- sit = 2
- c:SendOrangeMessage('Tasker','Happy hunting :)! You can change these number whenever you want, just type /change.')
- end
- else
- c:SendOrangeMessage('Tasker','You must fill in a number!')
- sit = 1
- end
- elseif sit == 2 then
- if(msg == "/change") then
- sit = 0
- c:SendOrangeMessage('Tasker','How many '.. creature ..'s have you killed?')
- else
- c:SendOrangeMessage('Tasker','The only available command is /change.')
- end
- elseif sit == 3 then
- --
- end
- end
- CS.OnTaskClose = function (c)
- print('Closing Chat..')
- end
- --=======================================--
- --===========HUD=========================--
- xHUD = {}
- function xHUD.New(x, y, value, r, g, b, shadow)
- local HUDshadow
- if (shadow == nil) then shadow = false end
- local c = {}
- setmetatable(c, HUD)
- if (type(value) == 'number') then
- c._pointer = HUDCreateItemImage(x, y, value, r, g)
- else
- if shadow == true then
- HUDshadow = xHUD.New(x+1, y+1, value, 0, 0, 0, false)
- end
- c._pointer = HUDCreateText(x, y, value, r, g, b)
- end
- return c, HUDshadow
- end
- --=======================================--