Facebook
From cslib, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 222
  1. print('Complex Scripts Library (ver.15.03.29)')
  2. CS = {}
  3. SessionStart = os.time()
  4. SessionTime = 0
  5. h = 0
  6. m = 0
  7. local count = 0
  8. balance = 0
  9. --========FUNCTIONS====================--
  10. CS.PreCheck = function (lLabel1, cLabel1)
  11.     leaveLabel2 = lLabel2 or "ContinueSupply"
  12.     continueLabel2 = cLabel2 or "ToHunt"
  13.     if(runes and runes2 and mPots) then
  14.         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)
  15.     elseif(runes and mPots) then
  16.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
  17.     elseif(ammo and mPots and hPots) then
  18.         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)
  19.     elseif(ammo and mPots) then
  20.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
  21.     elseif(mPots and hPots) then
  22.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
  23.     elseif(mPots) then
  24.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
  25.     elseif(hPots) then
  26.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel2, continueLabel2)
  27.     end
  28. end
  29.  
  30. CS.CheckBefore = function (lLabel1, cLabel1)
  31.     leaveLabel1 = lLabel1 or "Resupply"
  32.     continueLabel1 = cLabel1 or "ToHunt"
  33.     if(runes and runes2 and mPots) then
  34.         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)
  35.     elseif(runes and mPots) then
  36.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(runes)) < maxRune) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
  37.     elseif(ammo and mPots and hPots) then
  38.         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)
  39.     elseif(ammo and mPots) then
  40.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
  41.     elseif(mPots and hPots) then
  42.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
  43.     elseif(mPots) then
  44.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) < maxMP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
  45.     elseif(hPots) then
  46.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) < maxHP) or (Self.Cap() < minCap), leaveLabel1, continueLabel1)
  47.     end
  48. end
  49.  
  50. CS.Check = function (lLabel, cLabel)
  51.     leaveLabel = lLabel or "Leave"
  52.     continueLabel = cLabel or "Continue"
  53.     if(runes and runes2 and mPots) then
  54.         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)
  55.     elseif(runes and mPots) then
  56.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(runes)) <= minRune) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
  57.     elseif(ammo and mPots and hPots) then
  58.         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)
  59.     elseif(ammo and mPots) then
  60.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(ammo)) <= minAmmo) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
  61.     elseif(mPots and hPots) then
  62.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.ItemCount(Item.GetID(hPots)) <= minHP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
  63.     elseif(mPots) then
  64.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(mPots)) <= minMP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
  65.     elseif(hPots) then
  66.         Walker.ConditionalGoto((Self.ItemCount(Item.GetID(hPots)) <= minHP) or (Self.Cap() <= minCap), leaveLabel, continueLabel)
  67.     end
  68. end
  69.  
  70. CS.Check = function (lLabel, cLabel)
  71.     leaveLabel = lLabel or "goSell"
  72.     continueLabel = cLabel or "skipSell"
  73.     Walker.ConditionalGoto(sellItems, leaveLabel, continueLabel)
  74. end
  75.  
  76. -- x och y = pos efter lever
  77. --CS.Lever(east, 32322, 12312, failLabel)
  78. CS.Lever = function (pos, x, y, failLabel)
  79.     tmpPos = Self.Position()
  80.     tries = 3
  81.     if type(tonumber(pos[1])) == "number" then
  82.         -- Move trash
  83.         repeat
  84.             Self.UseLever(pos[1], pos[2], pos[3])
  85.             tries = tries - 1
  86.             wait(700, 900)
  87.         until (Self.Position().x == x and Self.Position().y == y) or tries <= 0
  88.         wait(200)
  89.         if(Self.Position().x == tmpPos.x and Self.Position().y == tmpPos.y and Self.Position().z == tmpPos.z) then
  90.             Walker.Goto(failLabel)
  91.         end
  92.     elseif type(tonumber(pos)) == "string" then
  93.         -- Move trash
  94.         dir = direction(pos)
  95.         repeat
  96.             Self.UseLever(dir.x, dir.y, dir.z)
  97.             tries = tries - 1
  98.             wait(700, 900)
  99.         until (Self.Position().x == x and Self.Position().y == y) or tries <= 0
  100.         wait(200)
  101.         if(Self.Position().x ~= x and Self.Position().y ~= y) then
  102.             Walker.Goto(failLabel)
  103.         end
  104.     end
  105. end
  106.  
  107. --CS.TradeLoop("medicine pouch", "Ottokar")
  108. CS.TradeLoop = function (itemName, npcName)
  109.     for n, c in Creature.iNpcs() do
  110.         if (n == npcName and c:isOnScreen()) then
  111.             c:Follow()
  112.         end
  113.     end
  114.     antiPush(true)
  115.     wait(1000, 1200)
  116.     Self.Say("hi")
  117.     wait(500, 750)
  118.     repeat
  119.         Self.SayToNpc({itemName, "yes"}, 65)
  120.     until Self.ItemCount(Item.GetID(itemName)) == 0
  121.     antiPush(false)
  122. end
  123.  
  124. -- x och y = pos efter tp
  125. --CS.Teleport(SOUTH, 32322, 12322, "b4tp1")
  126. CS.Teleport = function (step, tpX, tpY, failLabel)
  127.     Targeting.Stop()
  128.     Self.Step(step)
  129.     wait(1000, 1200)
  130.     if Self.Position().x ~= tpX and Self.Position().y ~= tpY then
  131.         print("fail")
  132.         Walker.Goto(failLabel)
  133.     end
  134.     Targeting.Start()
  135. end
  136.  
  137. --CS.Levitate(south, "up", 4, "b4lev1")
  138. CS.Levitate = function (turn, where, currentZpos, faillabel)
  139.     Targeting.Stop()
  140.     where2 = tostring(string.lower(where))
  141.     if where2 == "up" then
  142.         Self.Turn(turn)
  143.         wait(500, 700)
  144.         Self.Cast('exani hur "up')
  145.     elseif where2 == "down" then
  146.         Self.Turn(turn)
  147.         wait(500, 700)
  148.         Self.Cast('exani hur "down')
  149.     end
  150.     wait(1000, 1200)
  151.     if currentZpos == Self.Position().z then
  152.         Walker.Goto(faillabel)
  153.     end
  154.     Targeting.Start()
  155. end
  156.  
  157. --CS.Withdraw(foodID, 100, 2)
  158. CS.Withdraw = function (item, count, dpPos)
  159.     if item > 0 or item then
  160.         item1 = 0
  161.         if type(tonumber(item)) == "number" then
  162.             item1 = item
  163.         elseif type(tostring(item)) == "string" then
  164.             item1 = Item.GetID(item)
  165.         end
  166.         wait(100,200)
  167.         if(Self.ItemCount(item1) < count) then
  168.             CS.ReachDepot()
  169.             Self.WithdrawItems(dpPos, {item1, 0, count - Self.ItemCount(item1)})
  170.         end
  171.     end
  172. end
  173.  
  174. --CS.Bank()
  175. CS.Bank = function ()
  176.     antiPush(true)
  177.     wTries = 3
  178.     wRune = 0
  179.     wRune2 = 0
  180.     wMana = 0
  181.     wFood = 0
  182.     wAmmo = 0
  183.     wHealth = 0
  184.     wExtra = 0
  185.     if (hPots) then
  186.         if (Self.ItemCount(Item.GetID(hPots)) < maxHP) then
  187.             wHealth = (maxHP - Self.ItemCount(Item.GetID(hPots))) * Item.GetCost(Item.GetID(hPots))
  188.         end
  189.     end
  190.     if (runes) then
  191.         if (Self.ItemCount(Item.GetID(runes)) < maxRune) then
  192.             wRune = (maxRune - Self.ItemCount(Item.GetID(runes))) * Item.GetCost(Item.GetID(runes))
  193.         end
  194.     end
  195.     if (runes2) then
  196.         if (Self.ItemCount(Item.GetID(runes2)) < maxRune2) then
  197.             wRune2 = (maxRune2 - Self.ItemCount(Item.GetID(runes2))) * Item.GetCost(Item.GetID(runes2))
  198.         end
  199.     end
  200.     if (mPots) then
  201.         if (Self.ItemCount(Item.GetID(mPots)) < maxMP) then
  202.             wMana = (maxMP - Self.ItemCount(Item.GetID(mPots))) * Item.GetCost(Item.GetID(mPots))
  203.         end
  204.     end
  205.     if (foods) then
  206.         if (Self.ItemCount(Item.GetID(foods)) < maxFood) then
  207.             wFood = (maxFood - Self.ItemCount(Item.GetID(foods))) * Item.GetCost(Item.GetID(foods))
  208.         end
  209.     end
  210.     if (ammo) then
  211.         if (Self.ItemCount(Item.GetID(ammo)) < maxAmmo) then
  212.             wAmmo = (maxAmmo - Self.ItemCount(Item.GetID(ammo))) * Item.GetCost(Item.GetID(ammo))
  213.         end
  214.     end
  215.     if (extraCash) then
  216.         wExtra = extraCash
  217.     end
  218.     Withdraw = wExtra + wMana + wHealth + wAmmo + wFood + wRune + wRune2
  219.     wait(1000, 1200)
  220.     Self.Say("hi")
  221.     wait(300)
  222.     Self.SayToNpc({"deposit all", "yes"}, 150)
  223.     repeat
  224.         wait(600, 900)  
  225.         Self.SayToNpc({"withdraw "..Withdraw, "yes"}, 150)
  226.         wait(250, 450)  
  227.         Self.SayToNpc("balance")
  228.         wait(200, 400)
  229.         wTries = wTries - 1
  230.         wait(200)
  231.         if wTries <= 0 then
  232.             break
  233.         end
  234.     until Self.Money() >= Withdraw
  235.     wait(2000 + Self.Ping())
  236.     if(Self.Money() < Withdraw) then
  237.         Walker.Stop()
  238.         wait(1000)
  239.         print("Stopping Walker.. Money needed: "..Withdraw..". Money in bank: "..balance..".")
  240.     end
  241.     antiPush(false)
  242. end
  243.  
  244. NpcMessageProxy.OnReceive("CS.NPCProxy", function(proxy, npcName, message)
  245.     balance = string.match(message, "Your account balance is (.+) gold.")
  246. end)
  247.  
  248. --CS.CheckTask()
  249. CS.CheckTask = function ()
  250.     if((Self.GetCreatureKills(creature) + creatureKillCount) >= needToKill and doTask and (taskTimes < taskTimesDo)) then
  251.         --go take task
  252.         print("Going to take the task.")
  253.     else
  254.         Walker.Goto("SkipTask")
  255.     end
  256. end
  257.  
  258. --CS.CheckBoss()
  259. CS.CheckBoss = function ()
  260.     Walker.ConditionalGoto(killBoss, "goBoss", "SkipBoss")
  261. end
  262.  
  263. --CS.TakeTask()
  264. CS.TakeTask = function ()
  265.     Creature:Follow('Grizzly Adams')
  266.     wait(300)
  267.     antiPush(true)
  268.     Self.SayToNpc({"hi", "task", "task", "task", "promotion", "yes", "task", "task", "".. creature .."s", "yes" }, 120)
  269.     Self.ResetCreatureKills(creature)
  270.     creatureKillCount = 0
  271.     if limitedTask then
  272.         taskTimes = taskTimes + 1
  273.         wait(300)
  274.         if(taskTimes == taskTimesDo) then
  275.             doTask = false
  276.         end
  277.     end
  278.     antiPush(false)
  279. end
  280.  
  281. --CS.TakeTask()
  282. CS.TakeTask2 = function ()
  283.     Creature:Follow('Grizzly Adams')
  284.     Self.SayToNpc({"hi", "task", "task", "task", "promotion", "yes", "task", "task", "".. creature .."s", "yes" }, 120)
  285.     for i, name in ipairs(mList) do
  286.         Self.ResetCreatureKills(name)
  287.     end
  288.     creatureKillCount = 0
  289.     if limitedTask then
  290.         taskTimes = taskTimes + 1
  291.         wait(300)
  292.         if(taskTimes == taskTimesDo) then
  293.             doTask = false
  294.         end
  295.     end
  296. end
  297.  
  298. --CS.BuyRunes()
  299. CS.BuyRunes = function (trade, npcName)
  300.     if(runes or runes2) then
  301.         for n, c in Creature.iNpcs() do
  302.             if (n == npcName and c:isOnScreen()) then
  303.                 c:Follow()
  304.                 wait(300)
  305.             end
  306.         end
  307.         antiPush(true)
  308.         trade = trade or "trade"
  309.         wait(1000, 1200)
  310.         Self.SayToNpc("hi")
  311.         wait(300)
  312.         Self.SayToNpc(trade, 100)
  313.         wait(1000)
  314.         if (runes) then
  315.             Self.ShopBuyItemsUpTo(runes, maxRune)
  316.         end
  317.         wait(500)
  318.         if (runes2) then
  319.             Self.ShopBuyItemsUpTo(runes2, maxRune2)
  320.         end
  321.         antiPush(false)
  322.     end
  323. end
  324.  
  325. --CS.BuyAmmo()
  326. CS.BuyAmmo = function (trade, npcName)
  327.    
  328.     for n, c in Creature.iNpcs() do
  329.         if (n == npcName and c:isOnScreen()) then
  330.             c:Follow()
  331.             wait(300)
  332.         end
  333.     end
  334.     antiPush(true)
  335.     trade = trade or "trade"
  336.     wait(1000, 1200)
  337.     Self.Say("hi")  
  338.     wait(300)
  339.     Self.SayToNpc(trade)
  340.     wait(500)
  341.     if (ammo) then
  342.         Self.ShopBuyItemsUpTo(ammo, maxAmmo)
  343.     end
  344.     antiPush(false)
  345. end
  346.  
  347. -- Buy runes in same shop, CS.BuySupplies(true, "magic supplies", "Rock In A Hard Place")
  348. -- CS.BuySupplies()
  349. CS.BuySupplies = function (trade, npcName)
  350.     for n, c in Creature.iNpcs() do
  351.         if (n == npcName and c:isOnScreen()) then
  352.             c:Follow()
  353.             wait(300)
  354.         end
  355.     end
  356.     antiPush(true)
  357.     trade = trade or "trade"
  358.     wait(1000, 1200)
  359.     Self.Say("hi")
  360.     wait(300)
  361.     Self.SayToNpc(trade, 100)
  362.     wait(500)
  363.     if (Self.Flasks() > 0) then
  364.        -- Self.SayToNpc({"vial"}, 100)
  365.        -- while (Self.Flasks() > 0) do
  366.          --   Self.SayToNpc({"yes"}, 150)
  367.            -- wait(250, 300)
  368.         --end
  369.         while (Self.Flasks() > 0) do
  370.                 if (Self.ItemCount(283) > 0) then
  371.                     Self.ShopSellAllItems(283)
  372.                 end
  373.                 if (Self.ItemCount(284) > 0) then
  374.                     Self.ShopSellAllItems(284)
  375.                 end
  376.                 if (Self.ItemCount(285) > 0) then
  377.                     Self.ShopSellAllItems(285)
  378.                 end
  379.                 wait(150, 300)
  380.             end      
  381.     end
  382.     wait(500)
  383.     if (hPots) then
  384.         Self.ShopBuyItemsUpTo(hPots, maxHP)
  385.     end
  386.     wait(500, 750)
  387.     if (mPots) then
  388.         Self.ShopBuyItemsUpTo(mPots, maxMP)
  389.     end
  390.     wait(500, 750)
  391.     if (buyRunes) then
  392.         if (runes) then
  393.         Self.ShopBuyItemsUpTo(runes, maxRune)
  394.         end
  395.         wait(500)
  396.         if (runes2) then
  397.             Self.ShopBuyItemsUpTo(runes2, maxRune2)
  398.         end
  399.     end
  400.     wait(500, 750)
  401.     antiPush(false)
  402. end
  403.  
  404. -- CS.BuyFood()
  405. CS.BuyFood = function (trade, npcName)
  406.     for n, c in Creature.iNpcs() do
  407.         if (n == npcName and c:isOnScreen()) then
  408.             c:Follow()
  409.         end
  410.     end
  411.     antiPush(true)
  412.     trade = trade or "trade"
  413.     wait(1000, 1200)
  414.     Self.Say("hi")  
  415.     wait(300)
  416.     Self.SayToNpc(trade)
  417.     wait(1000)      
  418.     Self.ShopBuyItemsUpTo(foods, maxFood)
  419.     wait(1000)
  420.     antiPush(false)
  421. end
  422.  
  423. -- CS.Travel("thais", "ingvar", 32333, 32444, "b4boat1")
  424. CS.Travel = function (where, npcName, x, y, failLabel)
  425.     tmpPos = Self.Position()
  426.     for n, c in Creature.iNpcs() do
  427.         if (n == npcName and c:isOnScreen()) then
  428.             c:Follow()
  429.         end
  430.     end
  431.     wait(1000, 1200)
  432.     Self.Say("hi")
  433.     wait(150, 300)
  434.     Self.SayToNpc({where, "yes"}, 100)
  435.     wait(300, 500)
  436.     if (failLabel) then
  437.         if(Self.Position().x ~= x and Self.Position().z ~= y) then
  438.             Walker.Goto(failLabel)
  439.         end
  440.     end
  441. end
  442.  
  443. -- CS.Talk({"trade", "bye"}, "ingvar")
  444. CS.Talk = function (conversation, npcName)
  445.     for n, c in Creature.iNpcs() do
  446.         if (n == npcName and c:isOnScreen()) then
  447.             c:Follow()          
  448.         end
  449.     end
  450.     wait(1000, 1200)
  451.     Self.SayToNpc("hi")
  452.     wait(150, 300)
  453.     Self.SayToNpc(conversation, 150)
  454.     wait(300, 500)
  455. end
  456.  
  457. -- CS.Sell({283, 284, 285}, "creature products")
  458. CS.Sell = function (items, conversation, npcName)
  459.     local item1 = 0
  460.     if conversation then
  461.         wait(200)
  462.         for n, c in Creature.iNpcs() do
  463.             if (n == npcName and c:isOnScreen()) then
  464.                 c:Follow()
  465.             end
  466.         end
  467.         wait(2000, 2200)
  468.         Self.SayToNpc("hi")
  469.         wait(150, 300)
  470.         Self.SayToNpc(conversation, 100)
  471.     end
  472.     antiPush(true)
  473.     wait(300, 500)
  474.     for _, ItemList in ipairs(items) do
  475.         if (Self.ShopGetItemSaleCount(ItemList) > 0) then
  476.             Self.ShopSellAllItems(ItemList)
  477.             wait(100, 250)
  478.         end
  479.         wait(500, 700)
  480.     end
  481.     antiPush(false)
  482. end
  483.  
  484. CS.SellFlask = function ()
  485.     items = {283, 284, 285}
  486.     wait(500)
  487.     Self.SayToNpc("vials")
  488.     wait(500)
  489.     for _, IL in ipairs(items) do
  490.         while Self.ItemCount(IL) > 0 do
  491.             Self.SayToNpc("yes")
  492.             wait(500, 700)
  493.         end
  494.         wait(200, 300)
  495.     end
  496. end
  497.  
  498. -- CS.CheckStamina()
  499. CS.CheckStamina = function ()
  500.     if (staminaLogout) and (Self.Stamina() < 960) then
  501.         Walker.Stop()
  502.         print("Stopping Walker.. Low Stamina!")
  503.     end
  504. end
  505.  
  506. -- CS.OpenBackpacks(true)
  507. CS.OpenBackpacks = function (relog)
  508.     Client.HideEquipment()
  509.     tries = 3
  510.     count = 0
  511.     bps = {}
  512.     if stackBP and lootBP and goldBP and suppliesBP and ammoBP then
  513.         bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}, [4] = {suppliesBP, true}, [5] = {ammoBP, true}}
  514.         count = 6
  515.     elseif stackBP and lootBP and goldBP and suppliesBP then
  516.         bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}, [4] = {suppliesBP, true}}
  517.         count = 5
  518.     elseif stackBP and lootBP and goldBP then
  519.         bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {goldBP, true}}
  520.         count = 4  
  521.     elseif stackBP and lootBP and suppliesBP then
  522.         bps = {[1] = {stackBP, true}, [2] = {lootBP, true}, [3] = {suppliesBP, true}}
  523.         count = 4  
  524.     elseif lootBP and goldBP then
  525.         bps = {[1] = {lootBP, true}, [2] = {goldBP, true}}
  526.         count = 3
  527.     elseif goldBP then
  528.         bps = {[1] = {goldBP, true}}
  529.         count = 2
  530.     end
  531.     if not(relog) then
  532.         repeat
  533.             Self.CloseContainers()
  534.             wait(500)
  535.             Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
  536.             if(#Container.GetAll() == count) then
  537.                 print("Successfully opened backpacks")
  538.                 break
  539.             else
  540.                 tries = tries - 1
  541.                 wait(200)
  542.                 if(tries <= 0) then
  543.                     print("Stopping Walker! Backpack settings are wrong!")
  544.                     Walker.Stop()
  545.                     break
  546.                 end
  547.                 print("Backpacks failed to open, trying again")
  548.             end
  549.             wait(500)
  550.         until #Container.GetAll() == count or tries <= 0
  551.         if(logoutTime and (tonumber(SessionTime) >= tonumber(logoutTime))) then  
  552.             print("Session ended after "..h..':'..m)
  553.             Walker.Stop()
  554.             wait(1000)
  555.             screenshot(Self.Name()..'_session_end_'.. os.date("%H.%M"))
  556.         end
  557.     else
  558.         print("Reconnected, resetting backpacks")
  559.         setBotEnabled(false)
  560.         repeat
  561.             Self.CloseContainers()
  562.             wait(500)
  563.             Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
  564.             if(#Container.GetAll() == count) then
  565.                 print("Successfully opened backpacks")
  566.                 setBotEnabled(true)
  567.                 break
  568.             else
  569.                 tries = tries - 1
  570.                 wait(200)
  571.                 if(tries <= 0) then
  572.                     Targeting.Start()
  573.                     print("Stopping Walker! Backpack settings are wrong!")
  574.                     break
  575.                 end
  576.                 print("Backpacks failed to open, trying again")
  577.             end
  578.             wait(500)
  579.         until #Container.GetAll() == count or tries <= 0
  580.     end
  581. end
  582.  
  583. CS.OpenBackpacks1 = function (relog)
  584.     Client.HideEquipment()
  585.     tries = 3
  586.     count = 0
  587.     bps1 = {}
  588.     if suppliesBP then
  589.         --table.insert(bps1, {suppliesBP, true})
  590.         bps1[#bps1+1] = {suppliesBP, true}
  591.     end
  592.     if stackBP then
  593.         -- table.insert(bps1, {stackBP, true})
  594.         bps1[#bps1+1] = {stackBP, true}
  595.     end
  596.     if lootBP then
  597.         -- table.insert(bps1, {lootBP, true})
  598.         bps1[#bps1+1] = {lootBP, true}
  599.     end
  600.     if goldBP then
  601.         -- table.insert(bps1, {goldBP, true})
  602.         bps1[#bps1+1] = {goldBP, true}
  603.     end
  604.     if ammoBP then
  605.         -- table.insert(bps1, {ammoBP, true})
  606.         bps1[#bps1+1] = {ammoBP, true}
  607.     end
  608.    
  609.     for _, s in ipairs(bps1) do
  610.         print(s)
  611.     end
  612.     print(bps1)
  613.     table.concat(bps1, ", ")
  614.     count = #bps1+1
  615.     if not(relog) then
  616.         repeat
  617.             Self.CloseContainers()
  618.             wait(500)
  619.             Self.OpenMainBackpack(true):OpenChildren(bps1)
  620.             if(#Container.GetAll() == count) then
  621.                 print("Successfully opened backpacks")
  622.                 break
  623.             else
  624.                 tries = tries - 1
  625.                 wait(200)
  626.                 if(tries <= 0) then
  627.                     print("Stopping Walker! Backpack settings are wrong!")
  628.                     Walker.Stop()
  629.                     break
  630.                 end
  631.                 print("Backpacks failed to open, trying again")
  632.             end
  633.             wait(500)
  634.         until #Container.GetAll() == count or tries <= 0
  635.     else
  636.         print("Reconnected, resetting backpacks")
  637.         setBotEnabled(false)
  638.         repeat
  639.             Self.CloseContainers()
  640.             wait(500)
  641.             Self.OpenMainBackpack(true):OpenChildren(bps[1],bps[2],bps[3],bps[4],bps[5])
  642.             if(#Container.GetAll() == count) then
  643.                 print("Successfully opened backpacks")
  644.                 setBotEnabled(true)
  645.                 break
  646.             else
  647.                 tries = tries - 1
  648.                 wait(200)
  649.                 if(tries <= 0) then
  650.                     Targeting.Start()
  651.                     print("Stopping Walker! Backpack settings are wrong!")
  652.                     break
  653.                 end
  654.                 print("Backpacks failed to open, trying again")
  655.             end
  656.             wait(500)
  657.         until #Container.GetAll() == count or tries <= 0
  658.     end
  659. end
  660.  
  661.  
  662. CS.OpenDoor1 = function (pos, x, y, failLabel)  
  663.     Targeting.Stop()
  664.     dir = direction(pos)    
  665.     if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
  666.         wait(300, 700)
  667.         Self.OpenDoor(dir.x, dir.y, dir.z)
  668.         wait(300, 400)
  669.         Self.Step(pos)
  670.         wait(300, 400)      
  671.     end
  672.     if not(Self.Position().x == x and Self.Position().y == y) then
  673.         Walker.Goto(failLabel)
  674.     end
  675.     Targeting.Start()
  676. end
  677.  
  678. -- CS.OpenDoor({x, y, z}, "key", 1234) -- key door
  679. -- CS.OpenDoor({x, y, z}, "level") -- level door
  680. -- CS.OpenDoor({x, y, z}) -- normal door
  681. -- CS.OpenDoor("north", "level") -- level door without coordinates
  682. CS.OpenDoor = function (pos, doorType, keyid)
  683.     if type(tonumber(pos[1])) == "number" then
  684.         if(doorType == "key") then
  685.             if(keyid) then
  686.                 if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
  687.                     Self.OpenDoor(pos[1], pos[2], pos[3])
  688.                     wait(300, 500)
  689.                 end
  690.                 if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
  691.                     kSpot = getSpotById(keyid)
  692.                     repeat
  693.                         wait(500, 700)
  694.                         Container:UseItemWithGround(kSpot, pos[1], pos[2], pos[3])
  695.                         wait(1000, 2000)
  696.                         Self.OpenDoor(pos[1], pos[2], pos[3])
  697.                     until (Map.IsTileWalkable(pos[1], pos[2], pos[3]))
  698.                 end
  699.             end
  700.         elseif (doorType == "level") then
  701.             if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
  702.                 repeat
  703.                     Self.OpenDoor(pos[1], pos[2], pos[3])
  704.                     wait(300, 700)
  705.                 until (Self.Position().x == pos[1] and Self.Position().y == pos[2])
  706.             end
  707.         else
  708.             if not(Map.IsTileWalkable(pos[1], pos[2], pos[3])) then
  709.                 repeat
  710.                     Self.OpenDoor(pos[1], pos[2], pos[3])
  711.                     wait(300, 700)
  712.                 until (Map.IsTileWalkable(pos[1], pos[2], pos[3]))
  713.             end
  714.         end
  715.     elseif type(tostring(pos)) == "string" then
  716.         dir = direction(pos)
  717.         if(doorType == "key") then
  718.         if(keyid) then
  719.             if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
  720.                 Self.OpenDoor(dir.x, dir.y, dir.z)
  721.                 wait(300, 500)
  722.             end
  723.             if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
  724.                 kSpot = getSpotById(keyid)
  725.                 repeat
  726.                     wait(500, 700)
  727.                     Container:UseItemWithGround(kSpot, dir.x, dir.y, dir.z)
  728.                     wait(1000, 2000)
  729.                     Self.OpenDoor(dir.x, dir.y, dir.z)
  730.                 until (Map.IsTileWalkable(dir.x, dir.y, dir.z))
  731.             end
  732.         end
  733.         elseif (doorType == "level") then
  734.             if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
  735.                 repeat
  736.                     Self.OpenDoor(dir.x, dir.y, dir.z)
  737.                     wait(300, 700)
  738.                 until (Self.Position().x == dir.x and Self.Position().y == dir.y)
  739.             end
  740.         else
  741.             if not(Map.IsTileWalkable(dir.x, dir.y, dir.z)) then
  742.                 repeat
  743.                     Self.OpenDoor(dir.x, dir.y, dir.z)
  744.                     wait(300, 700)
  745.                 until (Map.IsTileWalkable(dir.x, dir.y, dir.z))
  746.             end
  747.         end
  748.     end
  749. end
  750.  
  751. -- Breakwall in dworcs?:D
  752. -- CS.BreakWall("NORTH", "Crowbar")
  753. CS.BreakWall = function (string, itemId)
  754.     dir = direction(string)
  755.     spot = getSpotById(itemId)
  756.     repeat
  757.         wait(500, 1000)
  758.         Container:UseItemWithGround(spot, dir.x, dir.y, dir.z)
  759.     until Map.IsTileWalkable(dir.x, dir.y, dir.z)
  760. end
  761.  
  762. -- CS.UseItem(3215)
  763. CS.UseItem = function (itemId, tries1)
  764.     spot = getSpotById(itemId)
  765.     tries = tries1 or 2
  766.     if(itemId > 0) then
  767.         repeat
  768.             wait(500, 1000)
  769.             Container:UseItem(spot)
  770.             tries = tries - 1
  771.         until tries <= 0
  772.     end
  773. end
  774.  
  775. CS.PickUpFromGround = function (x,y,z, itemId)
  776.     if(itemId) then
  777.         repeat
  778.             Map.PickupItem(x, y, z, "", 0)
  779.         until Self.ItemCount(itemId) ~= 0
  780.     else
  781.         Map.PickupItem(x, y, z, "", 0)
  782.     end
  783. end
  784.  
  785. CS.PickUpFromGroundDir = function (string, itemId)
  786.     dir = direction(string)
  787.     if(itemId) then
  788.         repeat
  789.             Map.PickupItem(dir.x, dir.y, dir.z, "", 0)
  790.         until Self.ItemCount(itemId) ~= 0
  791.     else
  792.         Map.PickupItem(dir.x, dir.y, dir.z, "", 0)
  793.     end
  794. end
  795.  
  796. CS.UseOnGround = function (pos, tries)
  797.     tries = 3 or tries
  798.     if type(tonumber(pos[1])) == "number" then
  799.         repeat
  800.             wait(500, 1000)
  801.             Self.UseItemFromGround(pos[1], pos[2], pos[3])
  802.             tries = tries - 1
  803.         until tries <= 0
  804.     elseif type(tostring(pos)) == "string" then
  805.         dir = direction(pos)
  806.         repeat
  807.             wait(500, 1000)
  808.             Self.UseItemFromGround(dir.x, dir.y, dir.z)
  809.             tries = tries - 1
  810.         until tries <= 0
  811.     end
  812. end
  813.  
  814. CS.ReachDepot = function (tries)
  815.     local tries = tries or 3
  816.     Walker.Stop()
  817.     local DepotIDs = {3497, 3498, 3499, 3500}
  818.     local DepotPos = {}
  819.     for i = 1, #DepotIDs do
  820.         local dps = CS.GetUseItems(DepotIDs[i])
  821.         for j = 1, #dps do
  822.             table.insert(DepotPos, dps[j])
  823.         end
  824.     end
  825.     local function gotoDepot()
  826.         local pos = Self.Position()
  827.         print("Depots found: " .. tostring(#DepotPos))
  828.         for i = 1, #DepotPos do
  829.             location = DepotPos[i]
  830.             Self.UseItemFromGround(location.x, location.y, location.z)
  831.             wait(1000, 2000)
  832.             if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  833.                 wait(5000, 6000)
  834.                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  835.                     Walker.Start()
  836.                     return true
  837.                 end
  838.             else
  839.                 print("Something is blocking the path. Trying next depot.")
  840.             end
  841.         end
  842.         return false
  843.     end
  844.     repeat
  845.         reachedDP = gotoDepot()
  846.         if reachedDP then
  847.             return true
  848.         end
  849.         tries = tries - 1
  850.         sleep(100)
  851.         print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  852.     until tries <= 0
  853.  
  854.     return false
  855. end
  856.  
  857. CS.GetUseItems = function (id)
  858.     if type(id) == "string" then
  859.         id = Item.GetID(id)
  860.     end
  861.     local pos = Self.Position()
  862.     local store = {}
  863.     for x = -7, 7 do
  864.         for y = -5, 5 do
  865.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  866.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  867.                 table.insert(store, itemPos)
  868.             end
  869.         end
  870.     end
  871.     return store
  872. end
  873.  
  874. local lvl = Self.Level()
  875.  
  876. local Vocation =
  877.     {
  878.         Unknown     = {Name = "Unknown", ID = 0},
  879.         Rookie      = {Name = "Rookie", ID = 1},
  880.         Neutral     = {Name = "N/A", ID = 2},
  881.         Sorcerer    = {Name = "Sorcerer", ID = 3},
  882.         Druid       = {Name = "Druid", ID = 4},
  883.         Mage        = {Name = "Mage", ID = 5},
  884.         Knight      = {Name = "Knight", ID = 6},
  885.         Paladin     = {Name = "Paladin", ID = 7}
  886.     }
  887. local Hitpoints =
  888.     {
  889.         Knight = 5 * ((3 * lvl) - (2 * 8) + 29),
  890.         Paladin = 5 * ((2 * lvl) - 8 + 29),
  891.         Mage = 5 * (lvl + 29),
  892.         Rookie = 5 * (lvl + 29)
  893.     }
  894. local Manapoints =
  895.     {
  896.         Knight = 5 * lvl,
  897.         Paladin = 5 * ((3 * lvl) - (2 * 8)),
  898.         Mage = 5 * ((6 * lvl) - (5 * 8)),
  899.         Rookie = 5 * lvl
  900.     }
  901. local Druid =
  902.     {
  903.         Armor = {8041, 8038},
  904.         Rod = {3066, 3070, 3069, 8083, 3065, 3067, 8084, 8082, 16117, 16118}
  905.     }
  906. local Sorcerer =
  907.     {
  908.         Armor = {8039, 8062, 8040, 8037},
  909.         Wand = {3074, 3075, 3072, 8093, 3073, 3071, 12603, 8092, 8094, 16096, 16115}
  910.     }
  911.    
  912. CS.Vocation =  function ()
  913.     if lvl == 8 then
  914.         return Vocation.Neutral
  915.     elseif (table.contains({ Hitpoints.Knight, Hitpoints.Knight - 10, Hitpoints.Knight - 20}, Self.MaxHealth())) then
  916.         if (table.contains({ Manapoints.Knight }, Self.MaxMana())) then
  917.             return Vocation.Knight.Name
  918.         end
  919.     elseif (table.contains({ Hitpoints.Paladin, Hitpoints.Paladin - 5, Hitpoints.Paladin - 10}, Self.MaxHealth())) then
  920.         if (table.contains({ Manapoints.Paladin, Manapoints.Paladin - 10, Manapoints.Paladin - 20}, Manapoints.Paladin)) then
  921.             return Vocation.Paladin.Name
  922.         end
  923.     elseif (table.contains({ Hitpoints.Mage }, Self.MaxHealth())) then
  924.         if (table.contains({ Manapoints.Mage, Manapoints.Mage - 25, Manapoints.Mage - 50 }, Self.MaxMana())) then
  925.             if table.contains(Druid.Armor, Self.Armor().id) or table.contains(Druid.Rod, Self.Weapon().id) then
  926.                 return Vocation.Druid.Name
  927.             elseif table.contains(Sorcerer.Armor, Self.Armor().id) or table.contains(Sorcerer.Wand, Self.Weapon().id) then
  928.                 return Vocation.Sorcerer.Name
  929.             else
  930.                 return Vocation.Mage.Name
  931.             end
  932.         end
  933.     elseif (Hitpoints.Rookie == Self.MaxHealth()) then
  934.         if (Manapoints.Rookie == Self.MaxMana()) then
  935.             return Vocation.Rookie.Name
  936.         end
  937.     else
  938.         return Vocation.Unknown.Name
  939.     end
  940. end
  941.  
  942. function getSpotById(id)
  943.     cont = Container.GetFirst()
  944.     for spot = 0, cont:ItemCount() do
  945.         local item = cont:GetItemData(spot)
  946.         if item.id == id then
  947.             Spot = spot
  948.             break
  949.         end
  950.     end
  951.     return Spot
  952. end
  953.  
  954. function direction(string)
  955.     dir = tostring(string:lower())
  956.     pos = {}
  957.     pos.x = 0
  958.     pos.y = 0
  959.     pos.z = Self.Position().z
  960.     if(dir == "north" ) then
  961.         pos.x = Self.Position().x
  962.         pos.y = Self.Position().y-1
  963.     elseif(dir == "south" ) then
  964.         pos.x = Self.Position().x
  965.         pos.y = Self.Position().y+1
  966.     elseif(dir == "west" ) then
  967.         pos.x = Self.Position().x-1
  968.         pos.y = Self.Position().y
  969.     elseif(dir == "east" ) then
  970.         pos.x  = Self.Position().x+1
  971.         pos.y = Self.Position().y
  972.     elseif(dir == "center" ) then
  973.         pos.x  = Self.Position().x
  974.         pos.y = Self.Position().y
  975.     else
  976.         print("Accepted Direction NORTH/SOUTH/WEST/EAST/CENTER")
  977.     end
  978.     return pos
  979. end
  980.  
  981. function getMonsterCount(monsterList)
  982.     local count = 0
  983.     for i = CREATURES_LOW, CREATURES_HIGH do
  984.         local creature = Creature.GetFromIndex(i)
  985.         if (creature:isValid()) and creature:ID() ~= Self.ID() then
  986.             if (creature:isOnScreen() and creature:isVisible() and creature:isAlive()) then
  987.                 local name = creature:Name()
  988.                 if(table.find(monsterList, name, true))then
  989.                     count = count + 1
  990.                 end
  991.             end
  992.         end
  993.     end
  994.     return count
  995. end
  996.  
  997. function ManaPercent()
  998.         return math.ceil((Self.Mana()/Self.MaxMana()*100))
  999. end
  1000.  
  1001. function Comma_value(amount)
  1002.     local formatted = amount
  1003.     while true do  
  1004.         formatted, k = string.format(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
  1005.         if (k==0) then
  1006.             break
  1007.         end
  1008.     end
  1009.     return formatted
  1010. end
  1011. function AddCommas(amount)
  1012.     local formatted = amount
  1013.     while true do
  1014.         formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
  1015.         if (k==0) then
  1016.             break
  1017.         end
  1018.     end
  1019.     return formatted
  1020. end
  1021.  
  1022. function transformMoney(moneyCur)
  1023.     if (tonumber(moneyCur) < 1000) then
  1024.         return moneyCur .. "gp"
  1025.     else
  1026.         return string.format("%.0f", moneyCur / 1000) .. "k"
  1027.     end
  1028. end
  1029.  
  1030. local antiPushPos = Self.Position()
  1031. local antiPushMaxTries = 5 -- number or false
  1032. local antiPushTriesLeft = antiPushMaxTries
  1033. local antiPushModule = Module.New("antiPush", function()
  1034.     stepTo(antiPushPos)
  1035. end,false)
  1036.  
  1037. function stepTo(pos)
  1038.     local p = Self.Position()
  1039.     local dx = pos.x - p.x
  1040.     local dy = pos.y - p.y
  1041.     local d = ""
  1042.     if dy == -1 then
  1043.         d = "north"
  1044.     elseif dy == 1 then
  1045.         d = "south"
  1046.     end
  1047.     if dx == 1 then
  1048.         d = d .. "east"
  1049.     elseif dx == -1 then
  1050.         d = d .. "west"
  1051.     end
  1052.     if string.len(d) > 0 then
  1053.         antiPushModule:Delay(math.random(100,300))
  1054.         local notMoved = (Self.Step(d) == 0)
  1055.         if notMoved then
  1056.             if antiPushMaxTries then
  1057.                 antiPushTriesLeft = antiPushTriesLeft - 1
  1058.                 if antiPushTriesLeft == 0 then
  1059.                     -- do something like an alarm if you want
  1060.                     antiPushModule:Stop()
  1061.                 end
  1062.             end
  1063.         else
  1064.             antiPushTriesLeft = antiPushMaxTries
  1065.         end
  1066.         antiPushModule:Delay(math.random(100,300))
  1067.     end
  1068. end
  1069.  
  1070. function antiPush(turnItOn)
  1071.     if turnItOn then
  1072.         antiPushTriesLeft = antiPushMaxTries
  1073.         antiPushPos = Self.Position()
  1074.         antiPushModule:Start()
  1075.     else
  1076.         antiPushModule:Stop()
  1077.     end
  1078. end
  1079.  
  1080.  
  1081. --========MODULES========================--
  1082. Time = HUD.New(10, 30, '', 200, 200, 200)
  1083. Module.New('Session_Time_Update', function(module)
  1084.     if (logoutTime) then
  1085.         -- Timer
  1086.         local TimeDifference = os.difftime(os.time(), SessionStart)
  1087.         h = string.format("%02.f", math.floor(TimeDifference/3600));
  1088.         m = string.format("%02.f", math.floor(TimeDifference/60 - (h*60)));
  1089.         SessionTime = string.format("%01.f", math.floor(TimeDifference/3600));
  1090.         logoutAfter = logoutTime - SessionTime
  1091.         Time:SetText(h ..':'.. m )
  1092.     end
  1093. end)
  1094. Module.New('Move_Supplies', function(module)
  1095.     local Supplies = {Item.GetID(mPots), Item.GetID(hPots), Item.GetID(runes), Item.GetID(runes2)}
  1096.     for _, c in Container.iContainers() do
  1097.         for spot, data in c:iItems() do
  1098.             if (table.contains(Supplies, data.id) and c:Index() ~= Container.New(suppliesBP):Index()) then
  1099.                 c:MoveItemToContainer(spot, Container.New(suppliesBP):Index(), Container.New(suppliesBP):EmptySlots() - 1)
  1100.                 module:Delay(300,600)
  1101.             end
  1102.             module:Delay(550, 800)
  1103.         end
  1104.     end
  1105.     module:Delay(300,600)
  1106. end, false)
  1107.  
  1108. Module.New('Move_Ammunition', function(module)
  1109.     local Ammunition = {Item.GetID(ammo)}
  1110.     for _, c in Container.iContainers() do
  1111.         for spot, data in c:iItems() do
  1112.             if (table.contains(Ammunition, data.id) and c:Index() ~= Container.New(ammoBP):Index()) then
  1113.                 c:MoveItemToContainer(spot, Container.New(ammoBP):Index(), Container.New(ammoBP):EmptySlots() - 1)
  1114.                 module:Delay(300,600)
  1115.             end
  1116.             module:Delay(550, 800)
  1117.       end
  1118.     end
  1119.     module:Delay(300,600)
  1120. end, false)
  1121.  
  1122. vialIDs = {283, 284, 285}  
  1123. Module.New('Drop_Vials', function(module)
  1124.     if Self.Cap() < 200 then
  1125.         for i = 1, #vialIDs do
  1126.             if Self.ItemCount(vialIDs[i]) > math.random(5, 10) then
  1127.                 Self.DropFlasks(Self.Position().x-math.random(-1, 2), Self.Position().y-math.random(-1, 2), Self.Position().z)
  1128.                 module:Delay(math.random(5000,9000))
  1129.             end
  1130.         end
  1131.     end
  1132. end, false)
  1133.  
  1134. local onLevel = 'yes'
  1135. local onDeath = 'yes'
  1136. cLevel = Self.Level()
  1137. cName = Self.Name()
  1138. Module.New('Screenshot', function(module)
  1139.     if cName ~= Self.Name() then
  1140.         cLevel = Self.Level()
  1141.         cName = Self.Name()
  1142.     end
  1143.     if onLevel == 'yes' then
  1144.         if cName == Self.Name() and Self.Level() > cLevel then
  1145.             wait(1000)
  1146.             screenshot(Self.Name()..'_Level_'..Self.Level())
  1147.             wait(1000)
  1148.             cLevel = Self.Level()
  1149.             cName = Self.Name()
  1150.         end
  1151.     end
  1152.     if cName == Self.Name() and onDeath == 'yes' then
  1153.         if Self.Health() <= Self.Health() * 0.05 then
  1154.             --wait(1000)
  1155.             screenshot(Self.Name()..'_Death_'..Self.Level())
  1156.             wait(1000)
  1157.             onDeath = 'no'
  1158.         end
  1159.     end
  1160.     module:Delay(200)
  1161. end, false)
  1162.  
  1163. lastTime = os.clock()
  1164. Module.New('BP_Reconnect', function()
  1165.     if (os.difftime(os.clock(), lastTime) > 1) then
  1166.         if((#Container.GetAll() < count) and not Self.isInPz()) then
  1167.             screenshot(Self.Name()..'_reconnected_'.. os.date("%H.%M"))
  1168.             CS.OpenBackpacks(true)
  1169.         end
  1170.     end
  1171.     lastTime = os.clock()
  1172. end, false)
  1173.  
  1174. Module.New('Kill_HUD', function(module)
  1175.     if doTask then
  1176.         totalkills = Self.GetCreatureKills(creature) + creatureKillCount
  1177.         TotalKillHUD:SetText("You already hunted " .. totalkills .. "/".. needToKill .. " " .. creature.."s.")
  1178.         if limitedTask then
  1179.             TotalTimesHUD:SetText("" .. taskTimes .. "/" ..taskTimesDo.. "")
  1180.         else
  1181.             TotalTimesHUD:SetText("")
  1182.         end
  1183.         module:Delay(2000)
  1184.     else
  1185.         TotalKillHUD:SetText("")
  1186.         TotalTimesHUD:SetText("")
  1187.     end
  1188. end, false)
  1189. Balance = HUD.New(10, 20, '', 200, 200, 200)
  1190. Module.New('Balance_HUD', function(module)  
  1191.     if balance then    
  1192.         Balance:SetText("Balance: "..transformMoney(balance))
  1193.     end
  1194. end)
  1195.  
  1196.  
  1197. --weaponID = 2323
  1198. --ammoID =1234
  1199. --ammoAmount = 5
  1200. --monsterAmount = 3
  1201. --mList = {"Shit"}
  1202. Module.New('Trainer', function(module)
  1203.     local mob = Self.GetTargets(7)
  1204.     local count = 0
  1205.     for i =1, #mob do
  1206.         if table.contains(mList, mob[i]:Name()) then
  1207.             count = count + 1
  1208.         end
  1209.     end
  1210.     if ((Self.ItemCount(ammoID) < ammoAmount) or (count > monsterAmount)) then
  1211.         module:Delay(1000)
  1212.         Self.Equip(weaponID, "weapon")
  1213.     elseif ((Self.ItemCount(ammoID) > ammoAmount) and (count < monsterAmount)) then
  1214.         module:Delay(1000)
  1215.         Self.Equip(ammoID, "weapon", 100)
  1216.     end
  1217.     module:Delay(2000)
  1218. end, false)
  1219.  
  1220. Module.New('Concentrated_Blood', function (module)
  1221.     if Self.ItemCount(6558) > 0 then
  1222.         Self.UseItem(6558)
  1223.     end
  1224.     module:Delay(100,6000)
  1225. end, false)
  1226.  
  1227. --mLimit = 3
  1228. --mList = {"Banshee", "Necromancer", "Lich", "Vampire", "Vampire Bride"}
  1229. --eRingID = 3051
  1230.  
  1231. Module.New("Ring_Equip", function (module)
  1232.     local curRing = Self.Ring().id
  1233.     local eneRing = getActiveRingID(eRingID)
  1234.     if (getMonsterCount(mList) >= mLimit and curRing ~= eneRing) then
  1235.         Self.Equip(eRingID, "ring")
  1236.     elseif (getMonsterCount(mList) < mLimit) then
  1237.         Self.Dequip("ring", 0)
  1238.     end
  1239.     module:Delay(500)
  1240. end, false)
  1241.  
  1242. -- useRing = true  
  1243. -- ringID = 2323 -- ring to be equiped
  1244. Module.New("Ring_Loop", function (module)
  1245.     local curRing = Self.Ring().id
  1246.     local eRing = getActiveRingID(ringID)
  1247.     if (curRing ~= eRing and useRing) then
  1248.         Self.Equip(ringID, "ring")
  1249.     end
  1250.     module:Delay(500)
  1251. end, false)
  1252.  
  1253. --lMode = true
  1254. --mLimit = 4
  1255. --mList = {"Simbang"}
  1256. Module.New("Lure", function(module)
  1257.     local mob = Self.GetTargets(10)
  1258.     local count = 0
  1259.     for i = 1, #mob do
  1260.         if table.find(mList, mob[i]:Name()) then
  1261.             count = count+1
  1262.         end
  1263.     end
  1264.     if lMode and (count >= mLimit) and not load then
  1265.         loadSettings(nTargeting, "Targeting")
  1266.         wait(300,400)
  1267.         loadSettings(nTargeting, "Spell Shooter")
  1268.         load = true
  1269.     elseif count == 0 and load then
  1270.         loadSettings(lTargeting, "Targeting")
  1271.         wait(300,400)
  1272.         loadSettings(lTargeting, "Spell Shooter")
  1273.         load = false
  1274.     end
  1275.     module:Delay(200)
  1276. end, false)
  1277.  
  1278. --lMode = true
  1279. --mLimit = 4
  1280. --mList = {"Simbang"}
  1281. Module.New("Lure_1", function(module)
  1282.     local mob = Self.GetTargets(10)
  1283.     local count = 0
  1284.     for i = 1, #mob do
  1285.         if table.find(mList, mob[i]:Name()) then
  1286.             count = count+1
  1287.         end
  1288.     end
  1289.     if lMode and (count >= mLimit) and not load or Walker.IsStuck() then
  1290.         Targeting.Start()
  1291.         load = true
  1292.     elseif count == 0 and load then
  1293.         Targeting.Stop()
  1294.         load = false
  1295.     end
  1296.     module:Delay(200)
  1297. end, false)
  1298.  
  1299. rep = 0
  1300. Module.New("Warlock_Hunter", function(module)
  1301.     for name, creature in Creature.iMonsters() do
  1302.         if creature:isTarget() and creature:isValid() and creature:Name() == "Warlock" or creature:Name() == "Infernalist" then
  1303.             Walker.Stop()
  1304.             x = creature:Position().x
  1305.             y = creature:Position().y
  1306.             z = creature:Position().z
  1307.             while creature:HealthPercent() > 0 and rep <= 6 do
  1308.                 wait(400)
  1309.                 countr = Self.ItemCount(Item.GetID(runes2))
  1310.                 tries = 2
  1311.                 repeat
  1312.                     Self.UseItemWithGround(Item.GetID(runes2), x, y, z)
  1313.                     wait(140)
  1314.                     tries = tries - 1
  1315.                 until tries <= 0
  1316.                 wait(4500)
  1317.                 rep = rep + 1
  1318.             end
  1319.             Walker.Start()
  1320.             rep = 0
  1321.         end
  1322.     end
  1323.     module:Delay(200)
  1324. end, false)
  1325.  
  1326. Module.New("Warlock_Hunter2", function(module)
  1327.     for name, creature in Creature.iMonsters() do
  1328.         if creature:isTarget() and creature:isValid() and creature:Name() == "Warlock" or creature:Name() == "Infernalist" then
  1329.             Walker.Stop()
  1330.             while creature:HealthPercent() > 0 and rep <= 6 do
  1331.                 wait(4500)
  1332.                 rep = rep + 1
  1333.             end
  1334.             Walker.Start()
  1335.             rep = 0
  1336.         end
  1337.     end
  1338.     module:Delay(200)
  1339. end, false)
  1340.  
  1341. local TempCreatureData = nil
  1342. Module.New('Anti-Stealth', function(module)
  1343.     if Self.TargetID() == 0 then
  1344.         if TempCreatureData then
  1345.             if not TempCreatureData:isVisible() then
  1346.                 if TempCreatureData:HealthPercent() > 0 then
  1347.                     if(invisibleRune) then
  1348.                         tries = 2
  1349.                         Walker.Stop()
  1350.                         repeat
  1351.                            
  1352.                             if Self.ItemCount(Item.GetID(invisibleRune)) > 0 then
  1353.                                 Self.UseItemWithGround(Item.GetID(invisibleRune), TempCreatureData:Position().x, TempCreatureData:Position().y, TempCreatureData:Position().z)
  1354.                             end
  1355.                             tries = tries - 1
  1356.                         until tries < 1
  1357.                         Walker.Start()
  1358.                     end
  1359.                    
  1360.                 else
  1361.                     TempCreatureData = nil
  1362.                 end
  1363.             end
  1364.         end
  1365.     end
  1366. end, false)
  1367.  
  1368. Module.New('UpdateData', function (module)
  1369.     if Self.TargetID() ~= 0 then
  1370.         TempCreatureData = Creature(Self.TargetID())
  1371.     end
  1372.     module:Delay(200)
  1373. end)
  1374.  
  1375. Module.New("Mana_Restore", function(module)
  1376.     if (ManaPercent() < 90) and (#Self.GetTargets(5) == 0) and (Self.ItemCount(Item.GetID(mPots)) > 0) and (Self.isInPz() == false) and manaRestore then
  1377.         Walker.Stop()
  1378.         while (ManaPercent() < 95) and (#Self.GetTargets(5) == 0) and (Self.ItemCount(Item.GetID(mPots)) > 0) do
  1379.             Self.UseItemWithMe(Item.GetID(mPots))
  1380.             wait(700,800)
  1381.         end
  1382.         Walker.Start()  
  1383.     end
  1384.     module:Delay(200)
  1385. end, false)
  1386.  
  1387. local bodyid = {6048, 17445}   -- monster body id (fresh only, 5~10 seconds after death)
  1388. local lootItems = {  -- Sort item ids into backpack index/name
  1389.     [1] = {3029, 3035, 10282, 9058},
  1390.     [2] = {3369, 3370, 3392, 3079, 3436, 3081, 3098, 9302, 9606},
  1391.     [3] = {3031}
  1392. }
  1393.  
  1394. local tmp = {}
  1395.  
  1396. Module.New("CorpseScanner", function(module)
  1397.     if loot then
  1398.         local pos = Self.Position()
  1399.         -- insert all fresh bodies position into a temporary table
  1400.         for x = -7, 7 do
  1401.             for y = -5, 5 do
  1402.                 local body = Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id
  1403.                 if table.contains(bodyid, body) then
  1404.                     local identical = false
  1405.                     for i = 1, #tmp do
  1406.                         if tmp[i].x == pos.x + x and tmp[i].y == pos.y + y and tmp[i].id == body then
  1407.                             identical = true
  1408.                         end
  1409.                     end
  1410.                     if not (identical) then
  1411.                         tmp[#tmp+1] = {x = pos.x + x, y = pos.y + y, z = pos.z, id = body}
  1412.                     end
  1413.                 end
  1414.             end
  1415.         end
  1416.     end
  1417.     module:Delay(1000, 1500)
  1418. end)
  1419.  
  1420. Module.New("CorpseHandler", function(module)
  1421.     if (#tmp > 0 and loot) then -- there is atleast one corpse on screen
  1422.         Cavebot.Stop()
  1423.         for i = #tmp, 1, -1 do -- reverse table for future removal
  1424.             local t = 0
  1425.             local indexes = #Container.GetAll()
  1426.             while indexes == #Container.GetAll() or t > 6 do
  1427.                 t = t + 1
  1428.                 Self.UseItemFromGround(tmp[i].x, tmp[i].y, tmp[i].z)
  1429.                 wait(1000)
  1430.             end
  1431.             -- body should be open by now, start looting
  1432.             if #Container.GetAll() == indexes + 1 then
  1433.                 local c = Container.GetLast()
  1434.                 for spot = c:ItemCount() - 1, 0, -1 do -- reversed
  1435.                     for index, group in pairs(lootItems) do
  1436.                         if table.contains(group, c:GetItemData(spot).id) then                          
  1437.                             c:MoveItemToContainer(spot, Container(index):Index(), Container(index):ItemCapacity()-1)
  1438.                             wait(1000)
  1439.                         end
  1440.                     end
  1441.                 end
  1442.                 wait(7000)
  1443.             end
  1444.             table.remove(tmp, i)
  1445.         end
  1446.         Cavebot.Start()
  1447.     end
  1448.     module:Delay(1000, 1500)
  1449. end)
  1450.  
  1451. -- labelName = "Exit"
  1452. -- amountToLeave = 10
  1453. -- mList = {"Medusa", "Serpent Spawn"}
  1454.  
  1455. Module('Anti-Lure', function(mod)
  1456.     local count = 0
  1457.     for name, creature in Creature.iMonsters() do
  1458.         if (table.contains(mList, name)) then
  1459.             count = count + 1
  1460.         end
  1461.     end
  1462.     if (count >= amountToLeave) then
  1463.         gotoLabel(labelName)
  1464.     end
  1465. end, false)
  1466.  
  1467. Module.New("Anti-Stalker", function (module)
  1468.     BattleMessageProxy.OnReceive('Anti Stalker', function(proxy, message)
  1469.         if message:find("You lose (.+) hitpoints due to an attack by a stalker.") and Self.TargetID() == 0 then
  1470.             Walker.Stop()
  1471.             print("Stalker detected!!")
  1472.             if(vocation == "Knight") then
  1473.                 wait(200, 300)
  1474.                 Self.Cast("exori")
  1475.             elseif (vocation == "Paladin") then
  1476.                 wait(200, 300)
  1477.                 Self.Cast("exevo mas san")
  1478.             elseif (vocation == "mage" or vocation == "druid" or vocation == "sorcerer") then
  1479.                 if(invisibleRune) then
  1480.                     tries = 2
  1481.                     repeat
  1482.                         wait(200, 300)
  1483.                         if Self.ItemCount(Item.GetID(invisibleRune)) > 0 then
  1484.                             Self.UseItemWithMe(Item.GetID(invisibleRune))
  1485.                         end
  1486.                         tries = tries - 1
  1487.                     until tries <= 0
  1488.                 end
  1489.             end        
  1490.             Walker.Start()
  1491.         end
  1492.     end)
  1493.     module:Delay(1000)
  1494. end, false)
  1495.  
  1496. Module.New("Roots", function (module)
  1497.     rootsID = {21104, 21105}
  1498.     pos = Self.Position()
  1499.     for x = -7, 7 do
  1500.         for y = -5, 5 do
  1501.             local root = Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id
  1502.             if table.contains(rootsID, root) and #Self.GetTargets(5) < 1 and Self.TargetID() == 0 then
  1503.                 Self.StopAttack()
  1504.                 Cavebot.Stop()
  1505.                 wait(1000)
  1506.                 Self.UseItemFromGround(pos.x + x, pos.y + y, pos.z)      
  1507.                 wait(1000)
  1508.                 Cavebot.Start()
  1509.             end
  1510.         end
  1511.     end
  1512. end, false)
  1513.  
  1514. --Lottery Module
  1515. Module.New('Lottery', function (module)
  1516.     if Self.ItemCount(5957) > 0 then
  1517.         Self.UseItem(5957)
  1518.     end
  1519.     module:Delay(100,6000)
  1520. end, false)
  1521.  
  1522. Module.New("Dwarven_Ring", function (mod)
  1523.     local curRing = Self.Ring().id
  1524.     local eRing = getActiveRingID(3097)
  1525.     if (curRing ~= eRing) then
  1526.         Self.Equip(3097, "ring")
  1527.     end
  1528.     mod:Delay(1000, 2000)
  1529. end, false)
  1530.  
  1531. ------------SERVERSAVE MODULE-------------
  1532. serverSave = "10:00"
  1533. --SERVER_SAVE_TEXT = HUD(10, 5, 'Next Server Save', 200, 200, 200)
  1534. --SERVER_SAVE_VALUE = HUD(140, 5, '00:00:00', 255, 255, 255)
  1535.  
  1536. Time_Now = os.date("*t")
  1537. Server_Save_Hour, Server_Save_Minutes = serverSave:match("(.+):(.+)")
  1538. Server_Save = ((Server_Save_Hour + 0) * 3600) + ((Server_Save_Minutes + 0) * 60)
  1539. if Server_Save <= ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec) then
  1540.     Server_Save_TimeLeft = (Server_Save + 24 * 3600) - ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
  1541. else
  1542.     Server_Save_TimeLeft = Server_Save - ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec)
  1543. end
  1544.  
  1545. Module.New("Update_SS", function ( mod )
  1546.     Time_Now = os.date("*t")
  1547.     if Server_Save <= ((Time_Now.hour * 3600) + (Time_Now.min * 60) + Time_Now.sec) then
  1548.         Server_Save_TimeLeft = os.difftime((Server_Save + 24 * 3600), (Time_Now.hour * 3600) + (Time_Now.min * 60)  + Time_Now.sec)
  1549.     else
  1550.         Server_Save_TimeLeft = os.difftime(Server_Save,(Time_Now.hour * 3600) + (Time_Now.min * 60)  + Time_Now.sec)
  1551.     end
  1552.  
  1553.     nHours = string.format("%02.f", math.floor(Server_Save_TimeLeft/3600))
  1554.     nMins = string.format("%02.f", math.floor((Server_Save_TimeLeft - (nHours * 3600)) / 60))
  1555.     nSecs = string.format("%02.f", math.floor(Server_Save_TimeLeft - (nHours * 3600) - (nMins * 60)))
  1556.            
  1557.     --SERVER_SAVE_VALUE:SetText(nHours..':'..nMins..':'..nSecs)
  1558. end, false)
  1559.  
  1560. Stuck = {}
  1561. --Stuck.x = 32323
  1562. --Stuck.label = "CheckStuck"
  1563. Module.New("Stuck", function (mod)
  1564.     if(Self.DistanceFromPosition(Stuck.x, Stuck.y, Stuck.z) < 10) then
  1565.         Targeting.Stop()
  1566.         Looter.Stop()
  1567.         wait(1000)
  1568.         Walker.Goto(Stuck.label)
  1569.     end
  1570.     mod:Delay(1000)
  1571. end, false)
  1572.  
  1573. --=======================================--
  1574.  
  1575. --========TASK CHANNEL===================--
  1576. sit = 0
  1577. CS.OnTaskSpeak = function (c, msg)
  1578.     c:SendYellowMessage(Self.Name(), msg)
  1579.     if sit == 0 then
  1580.         if type(tonumber(msg)) == "number" then
  1581.             c:SendOrangeMessage('Tasker','Okay, so you have killed ' .. msg .. " " .. creature ..'s.')
  1582.             creatureKillCount = msg
  1583.             Self.ResetCreatureKills(creature)
  1584.             if limitedTask then
  1585.                 c:SendOrangeMessage('Tasker','How many times have you made the task?')
  1586.                 sit = 1
  1587.             else
  1588.                 sit = 2
  1589.                 c:SendOrangeMessage('Tasker','Happy hunting :)! You can change these number whenever you want, just type /change.')
  1590.             end
  1591.         else
  1592.             c:SendOrangeMessage('Tasker','You must fill in a number!')
  1593.             sit = 0
  1594.         end
  1595.     elseif sit == 1 and limitedTask then
  1596.         if type(tonumber(msg)) == "number" then
  1597.             c:SendOrangeMessage('Tasker','Okay, so you have made the task ' .. msg .. ' times.')
  1598.             taskTimes = tonumber(msg)
  1599.             if(tonumber(msg) >= taskTimesDo) then
  1600.                 c:SendOrangeMessage('Tasker','You can only do this task ' .. taskTimesDo ..' times. Tasker inactivated')
  1601.                 c:Close()
  1602.                 doTask = false
  1603.             else
  1604.                 sit = 2
  1605.                 c:SendOrangeMessage('Tasker','Happy hunting :)! You can change these number whenever you want, just type /change.')
  1606.             end
  1607.         else
  1608.             c:SendOrangeMessage('Tasker','You must fill in a number!')
  1609.             sit = 1
  1610.         end
  1611.     elseif sit == 2 then
  1612.         if(msg == "/change") then
  1613.             sit = 0
  1614.             c:SendOrangeMessage('Tasker','How many '.. creature ..'s have you killed?')
  1615.         else
  1616.             c:SendOrangeMessage('Tasker','The only available command is /change.')
  1617.         end
  1618.     elseif sit == 3 then
  1619.         --
  1620.     end
  1621. end
  1622.  
  1623. CS.OnTaskClose = function (c)
  1624.     print('Closing Chat..')
  1625. end
  1626. --=======================================--
  1627.  
  1628. --===========HUD=========================--
  1629. xHUD = {}
  1630. function xHUD.New(x, y, value, r, g, b, shadow)
  1631.     local HUDshadow
  1632.     if (shadow == nil) then shadow = false end
  1633.     local c = {}
  1634.     setmetatable(c, HUD)
  1635.     if (type(value) == 'number') then
  1636.         c._pointer = HUDCreateItemImage(x, y, value, r, g)
  1637.     else
  1638.         if shadow == true then
  1639.             HUDshadow = xHUD.New(x+1, y+1, value, 0, 0, 0, false)
  1640.         end
  1641.         c._pointer = HUDCreateText(x, y, value, r, g, b)
  1642.     end
  1643.     return c, HUDshadow
  1644. end
  1645. --=======================================--