Log in

View Full Version : Tutorial: Efficient potionbuying



Crille
12-20-2008, 06:05
Hello there :)

in this tutorial we will look into how to implement a potionbuyer into your script, it is rather easy as long as you got a template to copypaste from, so here goes


1. The script

A simple script would look somewhat like this:


setPriority ancient scarab:+1
setSpellkill ancient scarab,exori flam,3
setmeleekill larva
setloot 00 0D
setloot 70 0D
setLoot E2 0B
setLoot D8 0B
setLoot D9 0B
setLoot D7 0B
setLoot 3E 03
setLoot CA 0B
setLoot 1D 0D
setloot D1 0B
move 33042,32668,11
move 33093,32655,11
move 33067,32677,11
move 33091,32683,11
move 33062,32652,11
gotoscriptline 0

First off we have parameters which remains constant (until a reset is requested), such as what monsters will be targetted, how to kill them and what loot to take, then follows the waypoints, and at last we have gotoscriptline 0.


2. Checking potions and walking to city

Now, what we want the script to do is to return to the city to refill manapotions and/or deposit loot, so we'll need to use an IfTrue statement;


fastExiva _manapotionid = ED 00
IfTrue ($countitems:{$_manapotionid$}$#number<#45) Goto $nlineoflabel:refill$
gotoScriptLine 0
:refill
move 33119,32674,10
move 33118,32677,9
move 33163,32685,9
move 33164,32685,8
move 33153,32686,8
move 33153,32687,7

The first line gives the variable _manapotionid the value ED 00 (strong manapotion) and the second line checks your opened containers for the value you assigned to _manapotionid, and if you have below 45 potions left, the script will jump to the label :refill.
If this is false, then it will go back to hunt. If true, the script will follow what's written below :refill, namely waypoints out of the cave.


3. Withdrawing money from bank

When you're at the bank, you'll need to withdraw money to afford the potions, and by using this template it's pretty easy;


fastExiva _manas = 300
fastExiva _idcost = 80
fastExiva _mana = $numericalexp:{$_manas$}-{$countitems:{$_manapotionid$}$}$
fastExiva _manacost = $numericalexp:{$_mana$}*{$_idcost$}$
saymessage hi
waitX 2
fastExiva > 96 04 $hex-tibiastr:deposit all$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
sayInTrade withdraw $_manacost$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1

The first four lines assigns values to variables, the first line defines how many potions you're carrying in total, the second line defines what one potion of that type costs (strong manapotion in this case), the third line calculates how many manas you'll need to buy, and the fourth line defines how much it will cost.
The following banking lines are basic NPC talking, it'll say hi, deposit all the cash you have on you and withdraw the cost of the potions.
Onwards to the potionbuying!


4. Buying the potions

Now, to make this actually work as an AFK script, you'll need to have your backpack/bag with backpacks/bags of potions in your backpack slot, and your main backpack/bag in arrowslot. You'll also need to cover the empty space in your backpack/bag with potions, I find worms to be most efficient (do NOT use gold/platinum/crystal coins to fill out the space).
Okay, so now to the actual buying;


saymessage hi
waitx 2
fastExiva > 96 04 $hex-tibiastr:vial$
waitx 2
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
fastExiva > 96 04 $hex-tibiastr:yes$
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 2
fastExiva > 96 04 $hex-tibiastr:trade$
waitx 2
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00

The first few lines greets the NPC and sells the vials you have on you, to make space for new potions.
Next, the script will bring up the trade window with the NPC, then the script will buy a fourth of the needed potions four times. I made it this way since you can't buy more than 100 potions at once, however, you may edit this to your needs.


CONTINUES IN NEXT POST

Crille
12-20-2008, 06:05
5. The final script

The final script has functions that are not explained in this tutorial, but anyway, here it is;


# Script made by Karelazi
# Special thanks to Erra :)
# Add Scarab, Larva, Hyaena and Nomad to safelist

# <--------- CHANGE THESE SETTINGS --------->
# MP = 0C 01, SMP = ED 00, GMP = EE 00
fastExiva _manapotionid = ED 00
# How many manas do you have?
fastExiva _manas = 300
# How much does 1 potion cost? MP = 50, SMP = 80, GMP = 120
fastExiva _idcost = 80

onGMpause
:hunt
setfollow
setany
setPriority ancient scarab:+1
setSpellkill ancient scarab,exori flam,3
setmeleekill larva
setdontretryattacks
setlootdistance 3
setloot 00 0D
setloot 70 0D
setLoot E2 0B
setLoot D8 0B
setLoot D9 0B
setLoot D7 0B
setLoot 3E 03
setLoot CA 0B
setLoot 1D 0D
setloot D1 0B
move 33042,32668,11
move 33093,32655,11
move 33067,32677,11
move 33091,32683,11
move 33062,32652,11
setveryfriendly
setnofollow
move 33064,32652,10
setspellkill scarab,exori flam,3
setmeleekill larva
move 33067,32653,10
waitx 2
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
resetLoot
setLoot D7 0B
setLoot 00 0D
setLoot 70 0D
setLoot D7 0B
setLoot 3E 03
setLoot CA 0B
setLoot 1D 0D
setloot D1 0B
dropLootOnGround 33067,32653,10
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2A 81 8C 7F 0A 1B 01 01 2B 81 8D 7F 0A 01
waitx 1
resetkill
setspellkill ancient scarab,exori flam,3
setany
IfTrue ($countitems:82 19$#number>#0) Goto $nlineoflabel:refill$
IfTrue ($countitems:{$_manapotionid$}$#number<#45) Goto $nlineoflabel:refill$
move 33062,32652,11
gotoScriptLine $nlineoflabel:hunt$
:refill
resetkill
setSpellkill ancient scarab,exori flam,3
saymessage utana vid
move 33119,32674,10
saymessage utani hur
move 33118,32677,9
move 33163,32685,9
setveryfriendly
setfollow
setmeleekill larva
move 33164,32685,8
move 33153,32686,8
move 33153,32687,7
:ankgate
move 33153,32758,7
move 33153,32761,7
move 33153,32761,7
waitx 1
IfTrue ($myy$#string=#32760) Goto $nlineoflabel:exiva1$
gotoscriptline $nlineoflabel:check1$
:exiva1
fastexiva > 67
waitx 1
:check1
IfTrue ($myy$#string<>#32761) Goto $nlineoflabel:ankgate$
fastexiva > 67
waitx 1
IfTrue ($myz$#string<>#6) Goto $nlineoflabel:ankgate$
:ankgate2
move 33152,32763,6
move 33155,32766,6
waitx 1
saymessage exiva > 67
waitX 1
IfTrue ($myz$#string<>#7) Goto $nlineoflabel:ankgate2$
:bank
move 33135,32827,7
IfTrue ($myy$#string=#32827) Goto $nlineoflabel:go3$
Gotoscriptline $nlineoflabel:bank$
saymessage exiva > 65
:go3
move 33135,32823,6
IfTrue ($countitems:{$_manapotionid$}$#number<#45) Goto $nlineoflabel:bankmanas$
IfTrue ($countitems:82 19$#number>#0) Goto $nlineoflabel:banksofts$
:banksofts
saymessage hi
waitX 2
fastExiva > 96 04 $hex-tibiastr:deposit all$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
fastExiva > 96 04 $hex-tibiastr:withdraw 10500$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
Gotoscriptline $nlineoflabel:goboat$
:bankmanas
# Calculates how many manas you're gonna need and how much it costs
fastExiva _mana = $numericalexp:{$_manas$}-{$countitems:{$_manapotionid$}$}$
fastExiva _manacost = $numericalexp:{$_mana$}*{$_idcost$}$
saymessage hi
waitX 2
fastExiva > 96 04 $hex-tibiastr:deposit all$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
sayInTrade withdraw $_manacost$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
move 33131,32817,6
move 33131,32815,5
move 33131,32813,5
saymessage hi
waitx 2
fastExiva > 96 04 $hex-tibiastr:vial$
waitx 2
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
fastExiva > 96 04 $hex-tibiastr:yes$
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 2
fastExiva > 96 04 $hex-tibiastr:trade$
waitx 2
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
fastExiva > 07 00 7A $_manapotionid$ 00 $numbertohex2:{$numericalexp:{$_mana$}/4$}$ 00
waitx 1
move 33131,32817,6
move 33134,32818,6
IfTrue ($countitems:82 19$#number>#0) Goto $nlineoflabel:banksofts$
move 33137,32815,6
move 33139,32815,7
Gotoscriptline $nlineoflabel:back$
:goboat
move 33135,32827,7
move 33084,32876,7
move 33084,32878,6
move 33092,32884,6
fastExiva > A2 $hex-idofname:Captain Sinbeard$
waitx 2
saymessage hi
waitX 2
fastExiva > 96 04 $hex-tibiastr:venore$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
move 32953,32050,6
move 32952,32108,6
sayMessage hi
waitX 2
:softs
fastExiva > 96 04 $hex-tibiastr:soft boots$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
IfTrue ($countitems:82 19$#number>#0) Goto $nlineoflabel:softs$
move 32954,32041,6
move 32955,32023,6
fastExiva > A2 $hex-idofname:Captain Fearless$
waitx 3
sayMessage hi
waitX 2
fastExiva > 96 04 $hex-tibiastr:ankrahmun$
waitX 1
fastExiva > 96 04 $hex-tibiastr:yes$
waitx 1
move 33084,32878,6
move 33084,32876,7
:back
move 33135,32827,7
:ankgate3
move 33153,32770,7
move 33153,32766,7
waitX 1
IfTrue ($myz$#string<>#6) Goto $nlineoflabel:ankgate3$
waitx 1
:ankgate4
move 33153,32762,6
waitx 1
move 33153,32759,7
waitX 1
IfTrue ($myz$#string<>#7) Goto $nlineoflabel:ankgate4$
waitx 1
move 33154,32687,7
saymessage utana vid
move 33153,32686,8
move 33163,32684,8
move 33164,32684,9
saymessage utani hur
move 33119,32677,9
move 33118,32676,10
move 33064,32652,10
move 33064,32653,10
move 33062,32652,11
gotoScriptLine $nlineoflabel:hunt$


That concludes this tutorial, and I hope you've learned what I'm trying to teach :)

Random-j
12-20-2008, 06:10
Ty for this it will help alot of people xD

Crille
12-20-2008, 06:11
got stickied pretty fast, haha

Fake
12-20-2008, 10:56
Great tutorial!

Marissa
12-20-2008, 15:01
BEWARE OF CRILLE!
HE GOT A T-SHIRT IRL WITH HIS TIBIA CHARACTER NAME ON. XDDDDDDDDDDDDDDDDDDDDDDDDd

Crille
12-20-2008, 15:09
and I know you guys want it ;)

SimoS
12-20-2008, 15:25
Hello there :)

Now, to make this actually work as an AFK script, you'll need to have your backpack/bag with backpacks/bags of potions in your backpack slot, and your main backpack/bag in arrowslot. You'll also need to cover the empty space in your backpack/bag with potions, I find worms to be most efficient (do NOT use gold/platinum/crystal coins to fill out the space).
Okay, so now to the actual buying;

I dont really get what you mean with this, for example:

You got your bp with more backpacks in your bpslot. You got 16 bps in your bp so you will need to fill 4slots (normal bp) with worms?

Crille
12-20-2008, 15:33
no, you just put worms in the empty spaces

Bejker
12-21-2008, 00:41
hightech script, nice :D

Hrichi
12-22-2008, 12:12
nice job, I'll check it on my character

Eragon
12-28-2008, 00:20
It don't work for me as i want. I have my bag (no empty spaces) with bps of potions in backpack slot. When i'm selling vials and buying potions they are in my main bp in arrow slot and bps with potions have empty spaces.
And the second thing, 'countitems' work only when i have bps opened :(

Erra
12-30-2008, 17:58
Guys, guys! Don't forget the "Special thanks to Erra" part!

Plus, Crille, you didn't use the 5gp vial deposit in your calculation, who would not want to save 1k every 10 bp manas?! That's 9 bp manas + 1 for free, you know!

Taken from my own script (which has yet to be released! it's edron trolls ._.):
fastExiva _nhptobuy = $numericalexp:{$_nhp$}-{$countitems:0A 01$}$
fastExiva _nhpcost = $numericalexp:{$numericalexp:{$_nhptobuy$}*45$}-{$numericalexp:{$countitems:1D 01$}*5$}$

/\ How much it's supposed to withdraw

fastExiva > 7B 1D 01 00 $numbertohex1:{$countitems:1D 01$}$
waitX 3
fastExiva > 7A 0A 01 00 $numbertohex1:{$_nhptobuy$}$ 00 00

/\ Selling vials and buying, well... health potions :(

IfTrue ($countitems:0A 01$#number<#$_nhp$) Goto $nlineoflabel:close$
gotoScriptLine $nlineoflabel:back$
:close
closeConnection

/\ My epic script shouldn't fail, if it does then it's because I'm out of gold, so logout!



ASHEUAHESUHEUAHEU =D

Vuda Pig
01-02-2009, 02:42
Nice work thx

Saito88
01-13-2009, 01:19
i dont know how work this:
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01
waitx 1
fastexiva > 0F 00 78 2B 81 8D 7F 0A 1B 01 01 2A 81 8C 7F 0A 01

i mean how can i use this or what is it real fuction.

pls explain me. :D

ferigon
01-19-2009, 12:50
Nice tuto. But theres a easier way to do this, just deposit all the money from your hunt, sell the vials, count how many gps you got after selling the vials, go to dp again, withdraw the necessary money and buy more manas/hp's.

Belzebuth
01-21-2009, 19:28
nice work :) this will help me and others alot! :P thx again

mooth
01-29-2009, 16:52
Is it posible to buy potions with backpack ?

Webber
05-08-2009, 00:27
Thats pretty much the exact thing I do, but instead I create a loop while buying until the amount is bought, wich is simpler and takes only 10 seconds longer so I will use variables like:

how many manas you want total =Bmana
how many manas you want before you leave =Lmana(if you want to leave when you only have 3 mana potions this would be 3)
and the id of the mana type = idmana
amount you want to buy at a time (to speed up buying process you can make it 50 if you want 100 because this line will almost always execute twice)
and the same for health potions if i were doing that

then the script would looks something like this (note i wont be using code as i havent touched tibia in a long time)

kill larva
loot gold
move move
if Lmana =< number goto 6
goto 0
:Lmana
move to 3 sqm away from exact position i want to be
waitX 1 (wait one second before next line)
move to exact position you want to goto (making it more accurate)
waitX 1
have convo to bring up trade
:buy
hex to buy idmana and setnumber of them
if countitems:idmana < Bmana goto lineoflabel:buy
move all the way back to where script origionally starts
goto 0

wow im gettin rusty huh:rolleyes:

zepy10
05-08-2009, 13:11
So niceeeeee

BldMx
01-18-2010, 00:26
I tend to add this line of code when taking to some NPC (those who move a lot) in order to successfully get their attention. However, if its a NPC thats trapped (most shops) then it might not be need.



fastExiva > A2 $hex-idofname:NAME OF NPC$

living10
01-31-2010, 21:58
Thank you for sharing codes...

Tony32
10-11-2010, 17:37
Excellent work! I haven't used it yet, but it surely looks great. Thanks!