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