; Kolie - Copyright Everdev.Com 2003
;
Kolie@everdev.com
; the runebookrecall is not mine, nor is
; the main idea of the reagent buyer, but i
; have heavily modified the reagent buyer.
; ver 3.0 actually fixed the gold bug, addedalot more code to make it less prone to errores..
; o tookout all char id variables and manually put them in
; other vars started not working, so hardcoding alot of the #'s and whatnot made it work
; ver 2.0 Attempted fix on buying over gold value - untested.
; known problems with no fix
; - The gold withdraw sub doesnt check for weight for god knows why
; - goldtocarry for some reason didnt work, so i hard coded it
; ver 1.0 more problems then my grandma. Weight check untested, gold check didnt work. It bough the regs though Razz
set %bank_bag XXXXXX ; Your bag n your bank to drop regs in
set %BagID XXXXXX ; Your backpack id
set %stackID YKWC ; The contkind for item stacks to select how many to drag
set %vendortype HS_IS
ignoreitem XXXXXX ;-<<<<<<<< set this to your charid
;runebook 1 is ur bank book, 2 and 3 are mage locations
; set rune# to how many runes you have in that book
; if you only have one book, set runebook2 settings same as runebook3
set %_runebook1 XXXXXX
set %runes1 5
set %_runebook2 XXXXXX
set %runes2 7
set %_runebook3 XXXXXX
set %runes3 7
set %runenum 1
set %runebook 1
; dont change these
set %currentvendor 0
set %currentbook 2
set %currentshop 1
;
;################################################# ###########################
initevents
gosub recalltobank
gosub atthebank
set %runebook %currentbook
set %runenum %currentshop
buylooperz:
gosub recalltocurrent
gosub buyinshop
gosub recalltobank
gosub atthebank
; use the above line cause it wasnt executing the code if you bought something, to lazy to fix it
gosub incrementshop
ignoreitem reset
ignoreitem XXXXXX ; -<<<<<<< Your charid goes here
goto buylooperz
;################################################# ###########################
sub recalltobank
set %runenum 1
set %runebook 1
tryagian1:
gosub recall
if *91 = 2
{
set %runenum %runenum + 1
if %runenum > %runes1
set %runenum 1
goto tryagian1
}
return
;################################################# ###########################
sub incrementshop
set %currentshop %currentshop + 1
if %currentbook = 2
{
if %currentshop > %runes2
{
set %currentbook 3
set %currentshop 1
}
}
if %currentbook = 3
{
if %currentshop > %runes3
{
set %currentbook 2
set %currentshop 1
}
}
set %runenum %currentshop
set %runebook %currentbook
return
;################################################# ###########################
sub buyinshop
set *93 0
buyinshoploop:
gosub findvendor
; if no vendor found
if *92 = 0
{
return
}
gosub regbuyer
if *90 = 1
{
set *93 = 1
}
goto buyinshoploop
return
;################################################# ###########################
sub recalltocurrent
; recalls to current place, if blocked goes to next
set %runebook %currentbook
set %runenum %currentshop
recallprob:
gosub recall
if *91 = 2
{
gosub incrementshop
goto recallprob
}
set %currentbook %runebook
set %currentshop %runenum
return
;################################################# ###########################
sub atthebank
gosub bankregs
gosub withdrawgold
return
;################################################# ###########################
sub withdrawgold
set %maxgold 4000
if #gold < 4000
{
set %goldtoget 0
set %goldtoget 4000 - #gold
msg withdraw %goldtoget $
wait 2s
if #gold < 4000
halt
}
return
;################################################# ###########################
sub bankregs
msg #smc bank$
wait 15
contpos 0 0
wait 5
loop:
finditem JUF_KUF_SZF_RZF_JZF_WZF_KZF_MZF C_XXXXXX ;-<<<<<<<<<<<< Your backpack id
if #findkind = -1 2
return
halt
event drag #findid
wait 15
If #ContKind = YKWC
msg $
finditem %bank_bag
set #findmod 22_10
click #findx #findy p
goto loop
return
;################################################# ###########################
sub regbuyer
;sets *90 to 0 if it cant buy
;sets *90 if it did buy
set %saleweight 0
set %additionalweight 0
set *90 0
;goto %vendorx %vendory
msg vendor buy$
wait 20
if #contkind <> UYGD
{
set *90 0
return
}
set %currentsale 0
buyloop:
wait 5
getshopinfo
wait 5
if #shopcnt = 0
goto end
if #shopitemtype in SZF_RZF_JZF_WZF_KZF_MZF 2
if #shopitemprice > 3
goto buyit
if #shopitemtype in JUF_KUF 2
if #shopitemprice > 5
goto buyit
if #shopitemtype in JUF_KUF_SZF_RZF_JZF_WZF_KZF_MZF
{
set %maxbuy 0
set %maxbuy #shopitemmax
set %cashofgoodswewant 0
set %currentusablecash 0
set %newcurrentcash 0
set %cashofgoodswewant %maxbuy * #shopitemprice
set %currentusablecash #gold - %currentsale
set %currentusablecash %currentusablecash
event sysmessage %currentusablecash
if %cashofgoodswewant > %currentusablecash
{
set %maxbuy %currentusablecash / #shopitemprice
set %cashofgoodswewant %maxbuy * #shopitemprice
}
set %newcurrentcash %cashofgoodswewant + %currentsale
if %newcurrentcash > #gold
goto end
; add item to list
click 266 83 d
wait 10
; MAX BUY IS WHAT WE ARE GOING TO BUY SALEWEIGHT IS OUR SALE WEIGHT SO FAR
set %newweight 0
set %additionalweight %maxbuy / 10
set %newweight #weight + %additionalweight
set %newweight %newweight + %saleweight
if %newweight > #maxweight
{
set %availableweight 0
set %availableweight #maxweight - #weight
set %availableweight %availableweight - %saleweight
set %maxbuy %availableweight / 10
}
setshopitem #shopitemid %maxbuy
set %additionalweight %maxbuy / 10
set %saleweight %saleweight + %additionalweight
set %currentsale %cashofgoodswewant + %currentsale
goto buyit
}
buyit:
if #shopcurpos = #shopcnt
goto end
; if not we are not done, so goto next item
wait 5
click 391 201
goto buyloop
end:
; buy items
wait 20
click 363 428 d
click 363 428
wait 40
set *90 1
if #gold < 500
{
gosub recalltobank
gosub atthebank
gosub recalltocurrent
return
}
ignoreitem %currentvendor
return
;################################################# ###########################
sub Recall
;set *91 to 1 if it works and 2 if location is blocked
set *91 0
recallagain:
event macro 31 0
wait 20
event macro 8 7
wait 20
set #contposx 57
set #contposy 500
wait 20
event macro 8 2
wait 20
set #contposx 251
set #contposy 500
wait 20
set %_runebooknum %runebook
set %_runenumber %runenum
set %_style 0
set %_time 10
set %_oldx #charposx
set %_oldy #charposy
set %_page 0
set %_side 0
set %_num %_runenumber / 2
set %_page %_runenumber + 1
set %_page %_page / 2
set %_num %_num * 2
if %_num = %_runenumber
set %_side 1
set %_runex 305
if %_side = 1
set %_runex 466
set %_pagexmod %_page * 34
set %_pagex 256
set %_pagex %_pagex + %_pagexmod
if %_page > 4
set %_pagex %_pagex + 31
recallselectbook:
if %_runebooknum = 1
set %_runebookid %_runebook1
if %_runebooknum = 2
{
set %currentbook 2
set %_runebookid %_runebook2
}
if %_runebooknum = 3
{
set %currentbook 3
set %_runebookid %_runebook3
}
recallopenagain:
set #LOBJECTID %_runebookid
event macro 17 0
set #SCNT 0
recallwaitforbook:
if #SCNT > 10
goto recallopenagain
if #CONTKIND <> WLQB
goto recallwaitforbook
deletejournal
click %_pagex 397
click %_runex 365
set #SCNT 0
recallwaitforrecall:
if #SCNT > 10
goto recallagain
scanjournal 1
if something_is_blocking_the_location in #journal
{
set *91 2
wait 5s
return
}
}
if for_this_spell in #journal 2
event macro 13 46
wait 30
if %_oldx = #charposx
{
if %_oldy = #charposy
{
goto recallwaitforrecall
}
}
set *91 1
if %_runebooknum <> 1
{
set %currentbook %_runebooknum
set %currentshop %runenum
}
return
;################################################# ###########################
sub findvendor
set *92 0
top:
finditem HS_IS
if #findid = XXXXXXX ; -<<<<<<<< your charid
{
ignoreitem #findid
goto top
}
if #findkind = -1
{
set *92 0
return
}
msg $
move #findx #findy 0 5s
;this will double check to make
;sure you made it within one square
;of vendor
finditem HS_IS
if #findid =XXXXXXX ; -<<<<<<<< your charid
{
ignoreitem #findid
goto top
}
if #finddist >= 2
{
ignoreitem #findid
goto top
}
; if we get here we got a vendor
msg vendor buy$
wait 20
if #contkind <> UYGD
{
ignoreitem #findid
goto top
}
set %currentvendor #findid
set *92 1
return