PDA

View Full Version : [Tutorial] 100% AFK Script Making



XtrmJosh
06-12-2013, 09:18 PM
I noticed someone had made a text-based tutorial on how to create a 100% AFK script. I decided I would take it one step further with a video tutorial. There are a number of elements to making a script, and this just about covers the basics (making sure you deposit, resupply, and hunt correctly according to the script setup.)

In this video you should learn to:

Setup an "auto selector" for where to begin running the script
Choose if you should use a node or stand waypoint, and how to deal with NPCs on PVP
Sensibly add waypoints to avoid hassle - This requires a kean eye, and I don't demonstrate it incredibly well
Modify a lua script to suit the needs of the spawn you're scripting for
Modify an XBST in a text editor to edit loot items and view waypoints
All in all, generate a completely AFK script with some stability checks
Deal with doors, depots, backpacks, and floor changing spawn entry points
Configure spawn specific variables
Generate and use loot lists using a loot list generator
Use the Walker.ConditionalGoto without breaking it
Use Self.UseItemFromGround to manipulate tiles within 1 square range of your character


The link to a loot list generator is here: http://neobot-scripts.com/xenobot_lootlist_creator.php. This will generate an XML format loot list, so you don't need to do what I did (which was to go through the deposit list and put the items into the XBST file), you can just copy the XML and replace the existing XML in your XBST with this.

The link to the deposit list generator is here: http://neobot-scripts.com/SelfDepositItems_creator.php. This is what I used to generate a list of the loot items.

Credits to biaggio12‎ for inspiring me (not in a bad way) to make this video. Credits also go to DarkstaR for maintaining the bot, Royaliti for being an amazing friend and putting up with my random decisions to run a whole variety of projects at the same time (and complete very few of them, I might add), and to everyone I play on Olympa with for being a great team. Rydan for his amazing work with the PHP based loot list and deposit list generators, massive thanks, these two tools save me hours of abusing TibiaWiki and Item ID lists.


http://youtu.be/1Hquf2URnGI

The lua file looks like this (copy it to notepad, save as, change the "Document Type" to "All Files", and save it as something like "MyScript.lua" - Make sure it ends with .lua and not .txt or the bot won't recognise it.


------ REFILL SETTINGS ------
local LeaveMana = 100 --- How many mana potions until you leave the hunt?
local BuyMana = 300 --- How many mana potions you begin the hunt with?

local LeaveHealth = 5 --- How many health potions until you leave the hunt?
local BuyHealth = 10 --- How many health potions you begin the hunt with?

local AmmoName = "Royal Spear" --- What ammunition are you using?
local LeaveAmmo = 10 --- How much ammunition until you leave hunt?
local BuyAmmo = 45 --- How much ammunition do you begin the hunt with?
local AmmoCost = 15 --- What is the cost of your selected ammunition?

local LeaveCap = 100 --- Leaves spawn when character reaches this cap.
local HideEquipment = true --- Do you want to minimize your equipment?
local LogoutStamina = false --- Do you want to logout at 16 hours? (Inside the depot)

-- Item ID's, if you don't want to use SHP and SMP, change these:

local ManaName = "Strong Mana Potion"
local ManaCost = 80
local HealthName = "Strong Health Potion"
local HealthCost = 100

-- Backpack Configuration:

local LootBP = "Fur Backpack"
local GoldBP = "Jewelled Backpack"

-- Spawn Options

local HuntMiddle = false

-- Here I'm gonna get the item ids, leave this as it is.

local ManaID = Item.GetID(ManaName)
local HealthID = Item.GetID(HealthName)
local AmmoID = Item.GetID(AmmoName)

-- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
local FlaskID = 283
local FlaskIDA = 284
local FlaskIDB = 285

-- local GoldBP = 5801 --- Item ID of your gold backpack.

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then
-- Check Supplies, Hunt or Leave
Walker.ConditionalGoto((Self.ItemCount(ManaID) <= LeaveMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(HealthID) <= LeaveHealth) or (Self.ItemCount(AmmoID) <= LeaveAmmo), "Leave", "BeginHunt")

elseif (labelName == "Start") then
Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")

elseif (labelName == "DepositGold") then
-- Deposit Gold, check balance.
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 100)

local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthCost
local withdrawAmmo = math.max(BuyAmmo - Self.ItemCount(AmmoID), 0)*AmmoCost
local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)

if total >= 1 then
Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
end
Walker.Start()

elseif (labelName == "DepositItems") then
-- Deposit Items
Walker.Stop()
Self.ReachDepot(5)
Self.DepositItems({5882, 1}, {3028, 1}, {3029, 1}, {5948, 1}, {11457, 1}, {5920, 1}, {5877, 1}, {3061, 1})
Self.DepositItems({3386, 0}, {3392, 0}, {7402, 0}, {7399, 0}, {3428, 0}, {3416, 0}, {3280, 0}, {3071, 0}, {7430, 0}, {3322, 0})
Walker.Start()

elseif (labelName == "BuyManas") then
-- Buy Mana Potions
Walker.Stop()
if (Self.ItemCount(ManaID) < BuyMana) or (Self.ItemCount(HealthID) < BuyHealth) then
print("Buying manas or healths")
Self.SayToNpc({"hi", "flasks"}, 100)
while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
Self.SayToNpc("yes", 100)
end
wait(2000)
Self.SayToNpc("trade", 100)
wait(2000)
while (Self.ItemCount(ManaID) < BuyMana) do
Self.ShopBuyItemsUpTo(ManaID, BuyMana)
wait(500,800)
end
if (Self.ItemCount(HealthID) < BuyHealth) then
Self.ShopBuyItemsUpTo(HealthID, BuyHealth)
wait(500)
end
wait(200, 500)
end
Walker.Start()

elseif (labelName == "CheckGoneUp") then
-- Check we're on floor 3
Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")

elseif (labelName == "CheckGoneDown") then
-- Check we're on floor 7
Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")

elseif (labelName == "BuySpears") then
--------------------------------- TODO -------------------------
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 100)
-- Buy spears, make sure Self.ItemCount returns items in hands.
while (Self.ItemCount(AmmoID) < BuyAmmo) do
Self.ShopBuyItemsUpTo(AmmoID, BuyAmmo)
wait(500,800)
end
Walker.Start()

elseif (labelName == "ResetBps") then
-- Reset Backpacks
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
Container.GetFirst():Minimize()
Walker.Start()

elseif (labelName == "OpenNorth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
Walker.Start()

elseif (labelName == "OpenSouth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
Walker.Start()

elseif (labelName == "MiddleSpawn") then
Walker.Stop()
Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
Walker.Start()
end
end

Self.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 = Map.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

Map.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

The XBST for Darashia Dragon Lords for RP is attached here and all are free to use it as they wish, excluding for profitable reasons. Credits should be given unless permission is granted by myself.

Thanks all!

Niyar
06-12-2013, 09:25 PM
You're doing some great things for the community Josh, I like it!

XtrmJosh
06-12-2013, 09:42 PM
You're doing some great things for the community Josh, I like it!

Thanks mate, as most people I talk to know, my only goal is to obtain and share knowledge. I've learnt all the shit I know from the people here (and their questions, answers, and just general posts), so I owe it to everyone here to return the favour where possible. Same reason I'm still on OTLand, actually, haha.

<3

DarkRoses
06-12-2013, 09:42 PM
Been looking for tutorials forever. Thanks alot!

XtrmJosh
06-12-2013, 09:50 PM
You've added the DP list generator link as lootlist generator :P

So I have, but then again that's the list I used in the video haha... I didn't know there was one of each. Anyway, will add both now, and will add credits (I forgot who made it, hence lack of credits originally). Thanks!

DarkRoses - No problem, hope it helps mate!

XtrmJosh
06-12-2013, 09:53 PM
Check the source code (A)

Here's a link to the thread with both: http://forums.xenobot.net/showthread.php?2761-Xenobot-Lootlist-Creator

The source code for what?

Also, your style is beautiful but your CSS is ugly haha

XtrmJosh
06-12-2013, 09:59 PM
There's a comment within the source that says that it was made by me xD
Yeah^^ didn't really spend time on the CSS... just copied and pasted things together from other shits I had made before until it looked satisfying.

Ah I didn't look hard enough... Tbh I've just sat here talking to my computer for the last hour, the last thing on my mind is credits, but credit will be given where credit is due, you honestly have saved me hours with that loot list creator lol

Xeno Scripts
06-12-2013, 10:03 PM
Great tutorial!

Sure
06-12-2013, 11:00 PM
Thank you so much josh! I really appreciate your work! Keep it up!

biaggio12
06-13-2013, 02:11 PM
Awesome word Dude i wish i have enough patience to make video tutorial xD

zxzero
06-13-2013, 02:20 PM
Nice man! I will have a look at this after work. :) I want to get into scripting as some places I want to hunt aren't yet scripted and others I don't want to pay for. heh. Thanks.

Ryszard
06-13-2013, 03:13 PM
Thank you, great job! :D

Bandido
06-13-2013, 04:11 PM
Thanks mate!

XtrmJosh
06-13-2013, 09:20 PM
Great tutorial!


Thank you so much josh! I really appreciate your work! Keep it up!


Awesome word Dude i wish i have enough patience to make video tutorial xD


Nice man! I will have a look at this after work. :) I want to get into scripting as some places I want to hunt aren't yet scripted and others I don't want to pay for. heh. Thanks.


Thank you, great job! :D


Thanks mate!

No worries guys, if any of you have any questions or spot any errors in the video let me know and I'll fix it ASAP :P

Good luck <3

sausting
06-13-2013, 11:19 PM
this is great, thanks!

malakz
06-15-2013, 01:20 AM
Nice! Thank you. Just one question thought, with this depositer it only deposits inside 1 backpack right? Which means when that backpack is full it will stop depositing.. Which means you can't really bot that much untill you have to either sell the loot or change backpack? If there is another sulution I would appreciate knowing it.

Adky
06-15-2013, 08:56 AM
Nice! Thank you. Just one question thought, with this depositer it only deposits inside 1 backpack right? Which means when that backpack is full it will stop depositing.. Which means you can't really bot that much untill you have to either sell the loot or change backpack? If there is another sulution I would appreciate knowing it.

Stack the BPs inside each other, just like you do with your gold backpack.

malakz
06-15-2013, 06:30 PM
Stack the BPs inside each other, just like you do with your gold backpack.

But it doesn't open the bp? Sorry for questioning, I like knowing :<

Nakuu
06-15-2013, 06:42 PM
But it doesn't open the bp? Sorry for questioning, I like knowing :<
It won't do it automatically using XenoBot's function, but it's possible via script. The easiest way would be to make it work with 2 backpacks - first you deposit from 2nd one, then you reset all containers and deposit again.

malakz
06-15-2013, 11:43 PM
It won't do it automatically using XenoBot's function, but it's possible via script. The easiest way would be to make it work with 2 backpacks - first you deposit from 2nd one, then you reset all containers and deposit again.

I don't mean like that, I mean the backpack inside of the depot..

Lets say I hunt for x hours and get an loot of 19 items which is more than a whole backpack. The backpack I have in depot for example non stackables would then get full which means it won't deposit and instead have it left in the loot backpack in my main backpack. So the problem isn't the backpack I'm carrying but the one I have in depot for storing the loot is basically what I'm asking.

Nakuu
06-15-2013, 11:46 PM
Oh, then it should work like Adky said. It might get interrupted sometimes tho by eating food or lag or dunno what else but it will work most of the time.

XtrmJosh
06-16-2013, 12:09 AM
I don't mean like that, I mean the backpack inside of the depot..

Lets say I hunt for x hours and get an loot of 19 items which is more than a whole backpack. The backpack I have in depot for example non stackables would then get full which means it won't deposit and instead have it left in the loot backpack in my main backpack. So the problem isn't the backpack I'm carrying but the one I have in depot for storing the loot is basically what I'm asking.

The bot will deposit to multiple levels in the depot. That means you can put a bp in a bp in a bp and so on inside your dp and it should work just fine. You may hit issues if you use 10 or more backpacks though (I found 6 backpacks is plenty for a couple of days botting, any more and the time it takes to deposit items gets a bit silly...)

malakz
06-16-2013, 11:33 AM
I see, I guess I will be fine then ^_^

XtrmJosh
06-16-2013, 03:53 PM
I see, I guess I will be fine then ^_^

Should be, just FYI if you quote or tag someone using the @ symbol before there name or by clicking quote, it alerts them in the top right of the screen when they click their name. You're probably aware already but it helps a lot if people quote when asking questions (makes it easier to trace which need answering etc...)

jorgeriva
06-17-2013, 10:43 PM
This is the most amazing thing I have ever found. Using a little initiative and this video, you can do so much.

Thanks a lot, its great.

jayjay23
06-22-2013, 10:29 PM
Gonna check it out, always been interested in learning how to make my own scripts. Never really had the time to sit down for a good week or two solid and study it all, I've got like the basics and can edit already made scripts to fix them (most of the time)

Thank ye kindly fellow Josh!

superoy
07-08-2013, 04:32 PM
Great work!
Thanks a bunch!

Mrgaboh
07-29-2013, 04:23 PM
AEWSOME! also bro. which program is the one u use for edit al files? XtrmJosh

XtrmJosh
07-30-2013, 06:15 AM
AEWSOME! also bro. which program is the one u use for edit al files? XtrmJosh

Hi mate,

I use Sublime Text 2, available at www.sublimetext.com

Cheers

Mrgaboh
07-30-2013, 09:38 AM
Hi mate,

I use Sublime Text 2, available at www.sublimetext.com

Cheers

thanks for the info bro :)

Umbled
08-15-2013, 06:02 PM
Sent this one to my mate, he got it working :)

Gordo
08-15-2013, 07:27 PM
awesome thread, and awesome job in the video XtrmJosh

(sexy voice :p)

shockey
09-01-2013, 09:13 PM
hey i havent tested nor executed this script/lua, but i want to know how do i edit this lua to buy bolts and put them in a certain back pack, like if i change what ammo to buy from royal spears to bolts, would it put the bolts in my hand? and not in a designated bp? would be awesome if i can figure this out alone im going to attempt to but if you get to me before i do, than your the fUCKING MAN!!!!! lol thanks again. XtrmJosh

XtrmJosh
09-04-2013, 06:18 AM
hey i havent tested nor executed this script/lua, but i want to know how do i edit this lua to buy bolts and put them in a certain back pack, like if i change what ammo to buy from royal spears to bolts, would it put the bolts in my hand? and not in a designated bp? would be awesome if i can figure this out alone im going to attempt to but if you get to me before i do, than your the fUCKING MAN!!!!! lol thanks again. XtrmJosh

The bolts will land in your bp and ammo slot when you buy them, but there is an ammo refiller built into the bot. I can't remember exactly where, but I think it's in support somewhere...

shockey
09-05-2013, 11:58 PM
XtrmJosh thanks bro, i realized tho that my pally handles fine in that place with royal spears xD cheers !!

Noceur
09-15-2013, 08:07 AM
This was really helpful but one thing I was wondering is why you simply didn't make the CheckGoneUp functions by first calling a function when you are above the stairs to remember current z pos and then comparing it after you are supposed to go down stairs, with the z at that point... (???).

HeHao
10-02-2013, 10:48 AM
helped me thanks :)

billy3673
10-06-2013, 07:45 PM
Hey what syntax do you use to view the Lua files??? I've looked around didn't find much..
Thanks! Haven't spent much time around scripts but that format and watching your tutorial helped a lot!

reecey
10-06-2013, 08:31 PM
Hey what syntax do you use to view the Lua files??? I've looked around didn't find much..
Thanks! Haven't spent much time around scripts but that format and watching your tutorial helped a lot!

What are you asking? Which program or which syntax highlighting option?

He's using Sublime text 2 and obviously the sytax highlighting is Lua.

You can also use Notepad++

I recommend Notepad++ since it's alot smoother and user friendly in my opinion and much like regular notepad so you will already be familiar with it.

http://notepad-plus-plus.org/
(http://notepad-plus-plus.org/)
http://www.sublimetext.com/2

billy3673
10-06-2013, 08:49 PM
Thanks! Some how i overlooked the Lua option...
Hey... I gotta start somewhere!

kamilson_92
12-10-2013, 10:13 AM
hello josh, i see that u r an expert ;) what can u propose for me? i need something for my 40ek (skills-73) and 45ed (~43mlvl). Ed can make waste, but it'll be nice when ek earn some money for waste for ed. I'll be happy when scripts are 100% afk :) Thanks in advice.

anwes1
12-17-2013, 11:12 PM
XtrmJosh Thanks for this thread!
Started making my own script from youre lua file. And it works like a charm!
So my first script ever made on Xenobot is covering whole Okolnir including the 3 hard spawns, using pick, refilling, banking, depoting, checker, levitate.
Thumbs up! Keep that video alive :)

XtrmJosh
12-18-2013, 07:39 PM
XtrmJosh Thanks for this thread!
Started making my own script from youre lua file. And it works like a charm!
So my first script ever made on Xenobot is covering whole Okolnir including the 3 hard spawns, using pick, refilling, banking, depoting, checker, levitate.
Thumbs up! Keep that video alive :)

Thanks, I appreciate the feedback mate :)

Hope your script is still going well

anwes1
12-19-2013, 01:30 PM
Thanks, I appreciate the feedback mate :)

Hope your script is still going well

Yeah Its going fine. Got Pked thought. Need to cover that somehow.
Thinking on making the script stop the targeting and run to buddle and idle.
Or just run to buddle and logout.
I'm not home right now so can't look at it atm but I think il make it :)
Thanks again!

Kociii
12-19-2013, 01:34 PM
Gr'rear

rafau94
05-18-2014, 07:38 AM
XtrmJosh - your "Checker" keep going to Leave label, even if im full with supplies and my cap is 3,5 times above LeaveCap.

XtrmJosh
05-18-2014, 05:39 PM
XtrmJosh - your "Checker" keep going to Leave label, even if im full with supplies and my cap is 3,5 times above LeaveCap.

Can you pastebin your entire code and drop me the link? Might get chance to take a look at it this evening.

rafau94
05-18-2014, 08:52 PM
Can you pastebin your entire code and drop me the link? Might get chance to take a look at it this evening.

well, i've found out the problem

solution:
Do not use Waypoint Creator script for this.
Most things there are bugged, like creating label, it doesnt create correct label for example:

wpt label Checker

it creates label named Checke
so i fixed it, added r to the end + :

so final label looked like Checker:

rafau94
05-31-2014, 09:38 AM
Great TUT, but 1 question, why making Flasks as local ? if they are not supposed to be changed?

DfauQ
06-26-2014, 09:24 PM
XtrmJosh Awesome tutorial man! thanks alot! Sadly I have a problem, I dont know if i missed anything in the tutorial but.. I changed the local ManaName and price to great mana potion and now my banking is messed up :confused: When it tries to withdraw this happens:

Rokyn: Hiho, hiho, --- ! Welcome to the bank! What can I do for you?
Rokyn: Please tell me how much gold it is you would like to deposit.
Rokyn: You do not have enough gold.
Rokyn: You certainly have made a pretty penny. Your account balance is - gold.

Im not getting any error, just that ^ I do have the money for my supplies etc. Am I missing some Library? Just cant figure it out.

PS. Im trying to use it on shadowcores OT if that makes any difference.
Thanks in advance.

XtrmJosh
06-26-2014, 10:55 PM
XtrmJosh Awesome tutorial man! thanks alot! Sadly I have a problem, I dont know if i missed anything in the tutorial but.. I changed the local ManaName and price to great mana potion and now my banking is messed up :confused: When it tries to withdraw this happens:

Rokyn: Hiho, hiho, --- ! Welcome to the bank! What can I do for you?
Rokyn: Please tell me how much gold it is you would like to deposit.
Rokyn: You do not have enough gold.
Rokyn: You certainly have made a pretty penny. Your account balance is - gold.

Im not getting any error, just that ^ I do have the money for my supplies etc. Am I missing some Library? Just cant figure it out.

PS. Im trying to use it on shadowcores OT if that makes any difference.
Thanks in advance.

Did you change the variable name in all places it was used? If there is a chance you missed one, you should search the script to double check. That sounds like the most likely candidate. Is that the entire banking transcript? Does it attempt to withdraw money at all?

Also, it sounds to me like the banking system on the OT you're using doesn't accept the term "deposit all", in which case you will need to modify the script to cycle through all your gold backpacks and count how much you have, then deposit the whole lot at once. It's all rather tedious, and would take me probably an hour to code up, but right now I simply wouldn't have the time to do so.

Thanks for the feedback regardless, hope it goes better for you once you follow these steps. Let me know if you have any further problems.

DfauQ
06-27-2014, 07:18 PM
XtrmJosh Problem solved! I got some help at the Lua section, The problem is that you need to have some cash in your inventory before going to bank, or else it f*cks up for some reason.

XtrmJosh
06-27-2014, 09:37 PM
XtrmJosh Problem solved! I got some help at the Lua section, The problem is that you need to have some cash in your inventory before going to bank, or else it f*cks up for some reason.

It's probably trying to compare a number with nil (your current gold)... Thanks again :)

przemoboski
07-06-2014, 11:30 AM
BEST GUIDE EVA!! :)

reecey
10-17-2014, 09:56 AM
Does this lua code still work properly? i know there's been alot of updates since and im looking to make a script now

zuenn040
10-19-2014, 12:31 AM
So happy with this made my first script for my 50 mage, getting 100k exp an hour with a profile never shown sold here before your the best :D Finally got what I wanted hehe.

Just one issue bro please help me solve it, the bp's wont make itself smaller and the equipment still shows how to fix this?

ohagan
10-19-2014, 04:38 AM
man you prob just did this community the greatest thing ever making it so much easier to understand!

zuenn040
10-20-2014, 02:49 PM
hey m8, Im trying to figure out for over an hour now what I do wrong but I cant seem to find it, it doesnt go to my second spawn.
elseif (labelName == "FullSpawn") then
Walker.Stop()
Walker.ConditionalGoto(FullSpawn, "FullSpawnGo", "FullSpawnDone")
Walker.Start()
end

thousand times checked my Spelling, its all correct.

-- Spawn Options

local FullSpawn = true

Yet the option keeps springing from, FullSpawn to FullSpawnGo than instantly jumps to FullSpawnDone, than does the checker and goes back to BeginHunt

I cant find out what the problem is so frustrated ::D manic laugh xD

zuenn040
10-20-2014, 04:01 PM
jaaaj just out of nowhere it started working hurraaay

xXiSlaughterXx
10-21-2014, 05:14 AM
Great guide man, learning from it and made my first full AFK script with no issues, thanks!

Lukeharper
11-07-2014, 11:36 PM
Great guide man! One problem I'm getting though is

Every second or third time on average (Its completely random) When resetting the bps, it will accidentally tries to exit the client.
So then I get the option come up, do you really want to leave tibia.. And it will stay like that till u press no, but what that does is it means u cant buy manas because the trade window can't come up so he'll just log after 15mins of standing at the mana shop.

I'm almost 100% sure it happens when resetting the bps, and might be a result of trying to minimize the bps?
Not sure. Cheers for your guide and any advice would be awesome thanks again

Nakuu
11-07-2014, 11:45 PM
Great guide man! One problem I'm getting though is

Every second or third time on average (Its completely random) When resetting the bps, it will accidentally tries to exit the client.
So then I get the option come up, do you really want to leave tibia.. And it will stay like that till u press no, but what that does is it means u cant buy manas because the trade window can't come up so he'll just log after 15mins of standing at the mana shop.

I'm almost 100% sure it happens when resetting the bps, and might be a result of trying to minimize the bps?
Not sure. Cheers for your guide and any advice would be awesome thanks again

Move the panel with logout, quests etc buttons above the map or open ie. the skills window and put it between that panel and backpacks.

Lukeharper
11-09-2014, 03:18 AM
Cheers much appreciated :)

Coupa
11-17-2014, 12:45 AM
If I wanted to add say...

elseif (labelName == "BoatNPC") then
Walker.Stop()
Self.SayToNpc({"hi", "passage", "yes"}, 100)
end

How would I do about doing this?

Im using notepad++

Joshwa534
11-17-2014, 09:25 PM
If I wanted to add say...

elseif (labelName == "BoatNPC") then
Walker.Stop()
Self.SayToNpc({"hi", "passage", "yes"}, 100)
end

How would I do about doing this?

Im using notepad++

Exactly as you have it actually, except I would slow down the words per minute, lol.


if (labelName == 'BoatNPC') then
Self.SayToNpc({'hi', 'passage', 'yes'}, 45)
end

Coupa
11-18-2014, 11:06 AM
Exactly as you have it actually, except I would slow down the words per minute, lol.


if (labelName == 'BoatNPC') then
Self.SayToNpc({'hi', 'passage', 'yes'}, 45)
end


I assume the 100 (or in your case 45) after the Self.SayToNpc? Would you recommend to always use 45 or below?

Cheers, Coupa.

Tibiano
11-26-2014, 06:50 PM
Is it correct if I just deleted all Ammo things and I switch Health word by Rune?

LIKE THIS:


------ REFILL SETTINGS ------
local LeaveMana = 50 --- How many mana potions until you leave the hunt?
local BuyMana = 120 --- How many mana potions you begin the hunt with?

local LeaveRune = 150 --- How many SD until you leave the hunt?
local BuyRune = 500 --- How many SD you begin the hunt with?


local LeaveCap = 100 --- Leaves spawn when character reaches this cap.
local HideEquipment = false --- Do you want to minimize your equipment?
local LogoutStamina = false --- Do you want to logout at 16 hours? (Inside the depot)

-- Item ID's, if you don't want to use SHP and SMP, change these:

local ManaName = "Great Mana Potion"
local ManaCost = 120
local RuneName = "Sudden Death Rune"
local RuneCost = 108

-- Backpack Configuration:

local LootBP = "Fur Backpack"
local GoldBP = "Jewelled Backpack"

-- Spawn Options

local HuntMiddle = false

-- Here I'm gonna get the item ids, leave this as it is.

local ManaID = Item.GetID(ManaName)
local RuneID = Item.GetID(RuneName)

-- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
local FlaskID = 283
local FlaskIDA = 284
local FlaskIDB = 285

-- local GoldBP = 5801 --- Item ID of your gold backpack.

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then
-- Check Supplies, Hunt or Leave
Walker.ConditionalGoto((Self.ItemCount(ManaID) <= LeaveMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(RuneID) <= LeaveRune), "Leave", "BeginHunt")

elseif (labelName == "Start") then
Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")

elseif (labelName == "DepositGold") then
-- Deposit Gold, check balance.
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 100)

local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawRunes = math.max(BuyRune - Self.ItemCount(RuneID), 0)*RuneCost
local total = math.abs(withdrawManas + withdrawRunes)

if total >= 1 then
Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
end
Walker.Start()

elseif (labelName == "DepositItems") then
-- Deposit Items
Walker.Stop()
Self.ReachDepot(5)
Self.DepositItems({5882, 1}, {3028, 1}, {3029, 1}, {5948, 1}, {11457, 1}, {5920, 1}, {5877, 1}, {3061, 1})
Self.DepositItems({3386, 0}, {3392, 0}, {7402, 0}, {7399, 0}, {3428, 0}, {3416, 0}, {3280, 0}, {3071, 0}, {7430, 0}, {3322, 0})
Walker.Start()

elseif (labelName == "BuyManas") then
-- Buy Mana Potions
Walker.Stop()
if (Self.ItemCount(ManaID) < BuyMana) or (Self.ItemCount(RuneID) < BuyRune) then
print("Buying manas or Runes")
Self.SayToNpc({"hi", "flasks"}, 100)
while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
Self.SayToNpc("yes", 100)
end
wait(2000)
Self.SayToNpc("trade", 100)
wait(2000)
while (Self.ItemCount(ManaID) < BuyMana) do
Self.ShopBuyItemsUpTo(ManaID, BuyMana)
wait(500,800)
end
if (Self.ItemCount(RuneID) < BuyRune) then
Self.ShopBuyItemsUpTo(RuneID, BuyRune)
wait(500)
end
wait(200, 500)
end
Walker.Start()

elseif (labelName == "CheckGoneUp") then
-- Check we're on floor 3
Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")

elseif (labelName == "CheckGoneDown") then
-- Check we're on floor 7
Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")

elseif (labelName == "ResetBps") then
-- Reset Backpacks
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
Container.GetFirst():Minimize()
Walker.Start()
end
end

Self.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 = Map.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

Map.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






---------------- DO NOT TOUCH ANYTHING BELOW HERE ----------------

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)

-- ALL "LEVITATE SPELLS" THAT CHARACTER WILL USE --

if (labelName == "Levitate up") and (Self.Position().x == 33027) and (Self.Position().y == 31551) and (Self.Position().z == 6) then --change to pos where character will stand to say the spell
delayWalker(1000)
setWalkerEnabled(false)
Self.Say("exani hur up")
wait(500)
if (Self.Position().z == 5) then -- change to Z where you arrive after levitate, so it checks that u are up
setWalkerEnabled(true)
end
else if (labelName == "Levitate down") and (Self.Position().x == 33008) and (Self.Position().y == 31554) and (Self.Position().z == 4) then --change to pos where character will stand to say the spell
delayWalker(1500)
setWalkerEnabled(false)
Self.Say("exani hur down")
wait(500)
if (Self.Position().z == 5) then -- change to Z where you arrive after levitate, so it checks that u are down
setWalkerEnabled(true)
end
-- ALL LEVERS THAT CHARACTER WILL USE --

elseif (labelName == "LeverE") then
Self.UseLever(32994, 31547, 4, 2773)
end
if (labelName == "LeverEE") then
Self.UseLever(32994, 31547, 4, 2772)
end
if (labelName == "LeverEEE") then
Self.UseLever(33062, 31527, 10, 2773)
end
if (labelName == "LeverEEEE") then
Self.UseLever(33062, 31527, 10, 2772)
end
if (labelName == "LeverX") then
Self.UseLever(32992, 31539, 4, 2773)
end
if (labelName == "LeverXX") then
Self.UseLever(32992, 31539, 4, 2772)
end

-- ALL DOORS THAT CHARACTER WILL CHECK/OPEN --

if (labelName == "OpenDoorE") then
setWalkerEnabled(false)
delayWalker(3000)
Self.OpenDoor(32990, 31547, 4)
wait(500, 1000)
setWalkerEnabled(true)
end

if (labelName == "CheckManaDoor") then
setWalkerEnabled(false)
delayWalker(3000)
Self.OpenDoor(33010, 31537, 10)
wait(500, 1000)
setWalkerEnabled(true)
end

if (labelName == "door") then -- Open door if closed, If opened just keep walking.
setWalkerEnabled(false)
delayWalker(2000)
Self.OpenDoor(33061, 31529, 10)
wait(500, 1000)
setWalkerEnabled(true)
end
end
end

wojewodzki12
11-28-2014, 12:44 AM
Sure !:) just try it before, works fine here when i change it :P

Tibiano
11-29-2014, 10:26 PM
Did you change the variable name in all places it was used? If there is a chance you missed one, you should search the script to double check. That sounds like the most likely candidate. Is that the entire banking transcript? Does it attempt to withdraw money at all?

Also, it sounds to me like the banking system on the OT you're using doesn't accept the term "deposit all", in which case you will need to modify the script to cycle through all your gold backpacks and count how much you have, then deposit the whole lot at once. It's all rather tedious, and would take me probably an hour to code up, but right now I simply wouldn't have the time to do so.

Thanks for the feedback regardless, hope it goes better for you once you follow these steps. Let me know if you have any further problems.

This bug happens too to me when you dont deposit gold (0 gp on you) so after that even if you need supplys doesnt withdraw anything.

Here is my post about that error: http://forums.xenobot.net/showthread.php?31771-Problem-with-quot-Deposit-Gold-quot-script-doesnt-work-good

XtrmJosh
11-30-2014, 12:22 AM
This bug happens too to me when you dont deposit gold (0 gp on you) so after that even if you need supplys doesnt withdraw anything.

Here is my post about that error: http://forums.xenobot.net/showthread.php?31771-Problem-with-quot-Deposit-Gold-quot-script-doesnt-work-good

You'll probably need to add some check:

if (ItemCount("Gold Coin") == nil) then
--- do stuff without that comparison
else
--- do stuff with that comparison
end

Shouldn't be too difficult to implement, given that the error message itself provides all the information you should need :)

Aloha Mense
01-25-2015, 03:20 PM
Hey, It's a nice script and works perfectly so far, except for one thing and that is the DepositItem part.. I have put bps inside depot and it still would not deposit the items and it just keeps opening depot and then the first backpack and it closes both of them and reopens .. Also, since that Autolootlist creator is updated, it isnt possible to put it straight into the part of selfdeposit. Is there still an easier way to just fill in the monster name and get the loot list with the selfdeposit text so i can just set it in straight without having to fill everything in myself?

Aloha Mense
01-29-2015, 07:11 PM
Hey, It's a nice script and works perfectly so far, except for one thing and that is the DepositItem part.. I have put bps inside depot and it still would not deposit the items and it just keeps opening depot and then the first backpack and it closes both of them and reopens .. Also, since that Autolootlist creator is updated, it isnt possible to put it straight into the part of selfdeposit. Is there still an easier way to just fill in the monster name and get the loot list with the selfdeposit text so i can just set it in straight without having to fill everything in myself?

Found one now :)

mrplank
05-12-2015, 05:41 PM
My checker is crazy I guess. Everytime It checks, it goes to the right label but it seems that the walker stucks. Even if it is enabled it doesnt walk.



Edit: Actually , any label change stucks dunno why

Abbepowerd
05-12-2015, 06:31 PM
Maybe the label isn't reachable? You don't have map unlocked? Any of these could be the cause. If the label is on another floor or is too far away then it is impossible to reach it which is why you're being stuck.

mrplank
05-12-2015, 06:36 PM
My map is wide open. The label is reached by the walker but it stucks. It is still enabled but dont do any action. And even if I try to re-enable the walker, it doesnt work so I have to Reload the script. Its crazy.


---
Changed many things inside de LUA file. Seems to work

draco
06-16-2015, 05:00 AM
Thanks !!!

bibkop
07-04-2015, 10:09 AM
Hi,
Can someone tell me, what i have to change in this:

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then
-- Check Supplies, Hunt or Leave
Walker.ConditionalGoto((Self.ItemCount(ManaID) <= LeaveMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(HealthID) <= LeaveHealth) or (Self.ItemCount(AmmoID) <= LeaveAmmo), "Leave", "BeginHunt")
The problem is that my bot returns to depot with a lot of potions.

BIRDIE13
10-21-2015, 05:02 PM
Is this tutorial still usable? :)

Nakuu
10-21-2015, 05:10 PM
Is this tutorial still usable? :)

It's, although some of those things can be achieved easier nowadays :)

BIRDIE13
10-25-2015, 12:18 AM
It's, although some of those things can be achieved easier nowadays :)

Is there any other guide i can follow which is more up to date? :)

Tibiano
11-12-2015, 05:31 PM
CAN YOU SHARE A SIMILAR OF THAT CODE UPDATED FOR SCRIPTING?

REGARDS BRO! <3


------ REFILL SETTINGS ------
local LeaveMana = 100 --- How many mana potions until you leave the hunt?
local BuyMana = 300 --- How many mana potions you begin the hunt with?

local LeaveHealth = 5 --- How many health potions until you leave the hunt?
local BuyHealth = 10 --- How many health potions you begin the hunt with?

local AmmoName = "Royal Spear" --- What ammunition are you using?
local LeaveAmmo = 10 --- How much ammunition until you leave hunt?
local BuyAmmo = 45 --- How much ammunition do you begin the hunt with?
local AmmoCost = 15 --- What is the cost of your selected ammunition?

local LeaveCap = 100 --- Leaves spawn when character reaches this cap.
local HideEquipment = true --- Do you want to minimize your equipment?
local LogoutStamina = false --- Do you want to logout at 16 hours? (Inside the depot)

-- Item ID's, if you don't want to use SHP and SMP, change these:

local ManaName = "Strong Mana Potion"
local ManaCost = 80
local HealthName = "Strong Health Potion"
local HealthCost = 100

-- Backpack Configuration:

local LootBP = "Fur Backpack"
local GoldBP = "Jewelled Backpack"

-- Spawn Options

local HuntMiddle = false

-- Here I'm gonna get the item ids, leave this as it is.

local ManaID = Item.GetID(ManaName)
local HealthID = Item.GetID(HealthName)
local AmmoID = Item.GetID(AmmoName)

-- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
local FlaskID = 283
local FlaskIDA = 284
local FlaskIDB = 285

-- local GoldBP = 5801 --- Item ID of your gold backpack.

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then
-- Check Supplies, Hunt or Leave
Walker.ConditionalGoto((Self.ItemCount(ManaID) <= LeaveMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(HealthID) <= LeaveHealth) or (Self.ItemCount(AmmoID) <= LeaveAmmo), "Leave", "BeginHunt")

elseif (labelName == "Start") then
Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")

elseif (labelName == "DepositGold") then
-- Deposit Gold, check balance.
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 100)

local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthCost
local withdrawAmmo = math.max(BuyAmmo - Self.ItemCount(AmmoID), 0)*AmmoCost
local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)

if total >= 1 then
Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
end
Walker.Start()

elseif (labelName == "DepositItems") then
-- Deposit Items
Walker.Stop()
Self.ReachDepot(5)
Self.DepositItems({5882, 1}, {3028, 1}, {3029, 1}, {5948, 1}, {11457, 1}, {5920, 1}, {5877, 1}, {3061, 1})
Self.DepositItems({3386, 0}, {3392, 0}, {7402, 0}, {7399, 0}, {3428, 0}, {3416, 0}, {3280, 0}, {3071, 0}, {7430, 0}, {3322, 0})
Walker.Start()

elseif (labelName == "BuyManas") then
-- Buy Mana Potions
Walker.Stop()
if (Self.ItemCount(ManaID) < BuyMana) or (Self.ItemCount(HealthID) < BuyHealth) then
print("Buying manas or healths")
Self.SayToNpc({"hi", "flasks"}, 100)
while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
Self.SayToNpc("yes", 100)
end
wait(2000)
Self.SayToNpc("trade", 100)
wait(2000)
while (Self.ItemCount(ManaID) < BuyMana) do
Self.ShopBuyItemsUpTo(ManaID, BuyMana)
wait(500,800)
end
if (Self.ItemCount(HealthID) < BuyHealth) then
Self.ShopBuyItemsUpTo(HealthID, BuyHealth)
wait(500)
end
wait(200, 500)
end
Walker.Start()

elseif (labelName == "CheckGoneUp") then
-- Check we're on floor 3
Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")

elseif (labelName == "CheckGoneDown") then
-- Check we're on floor 7
Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")

elseif (labelName == "BuySpears") then
--------------------------------- TODO -------------------------
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 100)
-- Buy spears, make sure Self.ItemCount returns items in hands.
while (Self.ItemCount(AmmoID) < BuyAmmo) do
Self.ShopBuyItemsUpTo(AmmoID, BuyAmmo)
wait(500,800)
end
Walker.Start()

elseif (labelName == "ResetBps") then
-- Reset Backpacks
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
Container.GetFirst():Minimize()
Walker.Start()

elseif (labelName == "OpenNorth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
Walker.Start()

elseif (labelName == "OpenSouth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
Walker.Start()

elseif (labelName == "MiddleSpawn") then
Walker.Stop()
Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
Walker.Start()
end
end

Self.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 = Map.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

Map.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


Thanks all![/QUOTE]

Decio Diniz
11-18-2015, 02:43 AM
very good

gregory
11-18-2015, 10:55 PM
Is there a label to use a key on a door?

Talis
12-22-2015, 03:26 AM
Hey Josh can you show the lua files for mages, cause if i try to delete the ammo crap the complete script trashed and now nothign works he ingore all labels what i ma doing wrong?

XtrmJosh
12-22-2015, 05:59 PM
Hey Josh can you show the lua files for mages, cause if i try to delete the ammo crap the complete script trashed and now nothign works he ingore all labels what i ma doing wrong?

You don't need to delete much to make it work for mages, just gotta adjust gotta remove the math which adds gold for spears or whatever from this:


local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthCost
local withdrawAmmo = math.max(BuyAmmo - Self.ItemCount(AmmoID), 0)*AmmoCost
local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)

Delete the withdrawAmmo line so it becomes


local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthCost
local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)

However, as a mage you might just want to use it to buy runes or something instead. Up to you, aside from that, you just don't add the labels to go buy items and while it consumes an extra few bytes of your storage, it won't do you any real harm. To do this, leave the script exactly as it was, but change the name of your ammo to the name of your rune, set the cost up as if the rune is a type of ammo, and set waypoints to the rune NPC instead of the ammo NPC. It'd be a mess but it would work. I don't advocate that anyone who uses this tutorial uses it to make scripts "for sale", so I anticipate this would be fine.

zormitar
02-25-2016, 08:37 PM
Hell Josh, I have a question about a supply bp. I have tried to add one but I failed every time. The bot wont open it. Do you know why/how?
Can you also explain how the bot will move the supplies?

melimao
07-21-2016, 05:52 PM
hi how to add sellitem on this script?
i tryed just change that buyitem to sellitem and name/id but still not working.

mikjail
08-18-2016, 01:22 AM
outdate? deprecated?

Barao
07-15-2017, 02:32 AM
Sup Guys!

I have ben tryed change this script and update then for a knight hunt.
But, idk why, the scrip cant read how many potions the character have and always buy all supply again, in addition to always leave on checkers hunt.

So, can someone help me?:D:D

this is my try:


------ REFILL SETTINGS ------
local LeaveMana = 500 --- How many mana potions until you leave the hunt?
local BuyMana = 1500 --- How many mana potions you begin the hunt with?

local LeaveHealth = 50 --- How many health potions until you leave the hunt?
local BuyHealth = 100 --- How many health potions you begin the hunt with?

local AmmoName = "Royal Spear" --- What ammunition are you using?
local LeaveAmmo = 0 --- How much ammunition until you leave hunt?
local BuyAmmo = 0 --- How much ammunition do you begin the hunt with?
local AmmoCost = 0 --- What is the cost of your selected ammunition?

local LeaveCap = 100 --- Leaves spawn when character reaches this cap.
local HideEquipment = true --- Do you want to minimize your equipment?
local LogoutStamina = false --- Do you want to logout at 16 hours? (Inside the depot)

-- Item ID's, if you don't want to use SHP and SMP, change these:

local ManaName = "mana potion"
local ManaCost = 50
local HealthName = "supreme health potion"
local HealthCost = 500

-- Backpack Configuration:

local LootBP = "Backpack"
local GoldBP = "Brocade Backpack"

-- Spawn Options

local HuntMiddle = true

-- Here I'm gonna get the item ids, leave this as it is.

local ManaID = Item.GetID(ManaName)
local HealthID = Item.GetID(HealthName)
local AmmoID = Item.GetID(AmmoName)

-- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
local FlaskID = 283
local FlaskIDA = 284
local FlaskIDB = 285

-- local GoldBP = 5801 --- Item ID of your gold backpack.
-- local GoldBP = 5801 --- Item ID of your gold backpack.

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then
-- Check Supplies, Hunt or Leave
Walker.ConditionalGoto((Self.ItemCount(ManaID) <= LeaveMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(HealthID) <= LeaveHealth), "Leave", "BeginHunt")

elseif (labelName == "Start") then
Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")

elseif (labelName == "DepositGold") then
-- Deposit Gold, check balance.
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 100)

local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaCost
local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthCost
local total = math.abs(withdrawManas + withdrawHealths)

if total >= 1 then
Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
end
Walker.Start()

elseif (labelName == "DepositItems") then
-- Deposit Items
Walker.Stop()
Self.ReachDepot(5)
Self.DepositItems({12683, 2}, {14043, 2}, {14247, 2}, {14248, 2}, {14250, 2}, {3052, 2}, {13987, 2}, {13990, 2}, {14009, 2}, {14247, 2}, {3052, 2}, {12683, 2}, {14040, 2}, {14042, 2}, {12683, 2}, {14043, 2}, {14247, 2}, {14248, 2}, {14250, 2}, {3052, 2}, {12683, 2}, {14040, 2}, {14042, 2}, {3052, 2}, {13987, 2}, {13990, 2}, {14009, 2}, {14247, 2}, {238, 1}, {239, 1}, {3029, 1}, {12730, 1}, {14010, 1}, {14011, 1}, {14044, 1}, {14142, 1}, {3029, 1}, {3578, 1}, {5895, 1}, {12730, 1}, {14008, 1}, {14085, 1}, {238, 1}, {239, 1}, {3032, 1}, {5895, 1}, {12730, 1}, {14012, 1}, {14013, 1}, {14041, 1}, {14085, 1}, {14252, 1}, {238, 1}, {239, 1}, {3029, 1}, {12730, 1}, {14010, 1}, {14011, 1}, {14044, 1}, {14142, 1}, {238, 1}, {239, 1}, {3032, 1}, {5895, 1}, {12730, 1}, {14012, 1}, {14013, 1}, {14041, 1}, {14085, 1}, {14252, 1}, {281, 1}, {3029, 1}, {3578, 1}, {5895, 1}, {12730, 1}, {14017, 1}, {3029, 1}, {3578, 1}, {5895, 1}, {12730, 1}, {14008, 1}, {14085, 1})
Walker.Start()

elseif (labelName == "BuyManas") then
-- Buy Mana Potions
Walker.Stop()
if (Self.ItemCount(ManaID) < BuyMana) or (Self.ItemCount(HealthID) < BuyHealth) then
print("Buying manas or healths")
Self.SayToNpc({"hi", "flasks"}, 100)
while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
Self.SayToNpc("yes", 100)
end
wait(2000)
Self.SayToNpc("trade", 100)
wait(2000)
while (Self.ItemCount(ManaID) < BuyMana) do
Self.ShopBuyItemsUpTo(ManaID, BuyMana)
wait(500,800)
end
if (Self.ItemCount(HealthID) < BuyHealth) then
Self.ShopBuyItemsUpTo(HealthID, BuyHealth)
wait(500)
end
wait(200, 500)
end
Walker.Start()

elseif (labelName == "CheckGoneUp") then
-- Check we're on floor 3
Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")

elseif (labelName == "CheckGoneDown") then
-- Check we're on floor 7
Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")

elseif (labelName == "BuySpears") then
--------------------------------- TODO -------------------------
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 100)
-- Buy spears, make sure Self.ItemCount returns items in hands.
while (Self.ItemCount(AmmoID) < BuyAmmo) do
Self.ShopBuyItemsUpTo(AmmoID, BuyAmmo)
wait(500,800)
end
Walker.Start()

elseif (labelName == "ResetBps") then
-- Reset Backpacks
Walker.Stop()
Self.CloseContainers()
Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
Container.GetFirst():Minimize()
Walker.Start()

elseif (labelName == "OpenNorth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
Walker.Start()

elseif (labelName == "OpenSouth") then
Walker.Stop()
Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
Walker.Start()

elseif (labelName == "MiddleSpawn") then
Walker.Stop()
Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
Walker.Start()
end
end

Self.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 = Map.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

Map.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

bakedsodah
09-28-2017, 12:32 AM
Anyone know what to add to make it travel by boat? would really appreciate it!

Igorscz2
12-02-2019, 09:24 PM
nice bro