ScriptUO
Scripting Resources & Utilities => ScriptUO Application => General Discussion => Topic started by: TrailMyx on June 14, 2008, 11:16:25 AM
-
Although I have a bunch of code (lol) I'd like to throw a bunch of different styles at the parser to be sure it's functioning correctly. So if you have anything that consists of these commands:
break
continue
display (complete)
for
gosub
goto
halt
if (bracketed, no 3rd argument skip yet)
menu (see list below)
pause
repeat
return
set
stop
sub
until
while
namespace (complete)
str (complete)
Attached them to this thread and I can add it to my test suit. There are still a few parts of the menu that I haven't implemented yet. The shape drawing parts in particular, but I do have the following implemented:
window size
window title
text
show
set
list create (no add yet)
font bgcolor
font color
font name
font size
font style
edit
delete
combo create (no add yet)
clear
check
button
activate
-
I bet this code is going to be too much. But it has some Str and some namespace.. If.. if/else.. just one thing, i believe to go through the rest of the code you can only target containers that have map fragments, horns and minotaur arties in the top level of the chest. Also, need a blue beetle. I have clicked multi secures to test that it opens, it then will halt when it gets to calculating. saying that you're missing a quest item. you can then restart and just click a chest say with 6 maps, 18 arties and 120 horns. This is nice because it'll drop 100 horns on you and rest in the beetle. So, hope you can use the code to test.
set %mapfrag UVH
set %horn GJG
set %minoarti SEE_CFE_JRD
set %secure n/a
display Please target your secure (do not target containers inside a secure)!
setmultisecure:
wait 1
set #targcurs 1
target
while #targcurs = 1
wait 0
if %secure = n/a
set %secure #ltargetid , _
else
{
if #ltargetid notin %secure
set %secure %secure , #ltargetid , _
}
wait 5
display yesno Do you have another secure to target?
if #dispres = yes
goto setmultisecure
gosub dismount
display Please target your pack animal
wait 1
set #targcurs 1
target
while #targcurs = 1
wait 0
set %packanimal #ltargetid
wait 5
str count %secure _
set %numbersecures #strres
set %startpos 1
for %i 1 %numbersecures
{
str mid %secure %startpos 7
set %cursecure #strres
gosub open_container %cursecure
set %startpos %startpos + 8
}
;display You chosen %secure secure containers
gosub find_quest_items %mapfrag
set %nummaps #result
gosub find_quest_items %horn
set %numhorn #result
gosub find_quest_items %minoarti
set %numminoarti #result
display Number map horn mino %nummaps %numhorn %numminoarti
gosub calculate_num_quest %numhorn %nummaps %numminoarti
set %run_quest_this_many #result
display %run_quest_this_many
recalculate:
gosub calculate_totalarti_weight
display Quest weight %total_questrun_weight and mino arties 5/30 %minoarti_5stone_cnt %minoarti_30stone_cnt
gosub weight_for_run %total_questrun_weight
gosub grab_items %run_quest_this_many %tripweight
gosub mount_beetle
display %tripweight
halt
sub calculate_totalarti_weight
set %gamanhornweight %run_quest_this_many * 20
gosub calculate_minotaur_arties
gosub calculate_minoartie_weight
set %mapweight %run_quest_this_many
set %total_questrun_weight %gamanhornweight + %mapweight + %total_minoartie_weight
return
sub weight_for_run
;%1 weight for avaliable runs
set %charavailweight #maxweight - #weight
set %char_packy_weight %charavailweight + 1600
set %availcarryweight 1600 + %charavailweight
if %1 <= %availcarryweight
set %tripweight %1
if %1 > %availcarrweight
{
set %run_quest_this_many %run_quest_this_many - 5
goto recalculate
}
return
sub calculate_minotaur_arties
namespace push
namespace local Secure
set %minoarti_5stone_cnt 0
set %minoarti_30stone_cnt 0
set !startpos 1
for !i 1 %numbersecures
{
str mid %secure !startpos 7
set !cursecure #strres
gosub open_container !cursecure
finditem %minoarti c_ , !cursecure
for #findindex 1 #findcnt
{
event property #findid
if 5 in #property
set %minoarti_5stone_cnt %minoarti_5stone_cnt + 1
if 30 in #property
set %minoarti_30stone_cnt %minoarti_5stone_cnt + 1
}
set !startpos !startpos + 8
}
if %minoarti_5stone_cnt >= %run_quest_this_many
set %grab_this_many_minoarti_5cnt %run_quest_this_many
if %minoarti_5stone_cnt < %run_quest_this_many
{
set %grab_this_many_minoarti_5cnt %minoarti_5stone_cnt
if ( %minoarti_5stone_cnt + %minoarti_30stone_cnt ) >= %run_quest_this_many
set %grab_this_many_minoarti_30cnt %run_quest_this_many - %grab_this_many_minoarti_5cnt
}
namespace clear
namespace pop
return
sub calculate_minoartie_weight
set %minoarti_5stone_weight %minoarti_5stone_cnt * 5
set %minoarti_30stone_weight %minoarti_30stone_cnt * 30
set %total_minoartie_weight %minoarti_5stone_weight + %minoarti_30stone_weight
return
;finditem %mapfrag c_ , %secure
;for #findindex 1 %run_quest_this_many
;{
; exevent dragc #findid
; exevent dropc #backpackid
;}
sub find_quest_items
;%1 = Current quest item to search for
namespace push
namespace local NS1
set !itemcount 0
set !i 0
set !j 0
set !item %1
findquestitems:
set !startpos 1
for !j 1 %numbersecures
{
str mid %secure !startpos 7
set !cursecure #strres
gosub open_container !cursecure
finditem !item c_ , !cursecure
display #findcnt
if findkind = -1 && %numbersecures - !j = 0
{
display ok You are lacking one of the quest items, get some and press play
pause
set !i !i + 1
if !i < 4
goto findquestitems
display ok Halting Script, you did not listen, tried too many times, or are out of some quest items!
halt
}
set !startpos !startpos + 8
if !item = %horn
set !itemcount ( !itemcount + #findstack )
else
set !itemcount ( !itemcount + #findcnt )
}
set #result !itemcount
namespace pop
return #result
sub calculate_num_quest
;%1 = number gaman horns
;%2 = number map fragments
;%3 = number minotaur artifacts
namespace push
namespace local NS1
set !horntotal %1 / 20
set !maptotal %2
set !minototal %3 / 3
display !horntotal !maptotal !minototal
if !horntotal = 0 || !maptotal = 0 || !minototal = 0
{
display ok You do not have enough quest items to complete a quest! Script is ending!
namespace pop
halt
}
if !horntotal <= !maptotal && !horntotal <= !minototal
{
set #result !horntotal
namespace pop
return #result
}
if !maptotal <= !horntotal && !maptotal <= !minototal
{
set #result !maptotal
namespace pop
return #result
}
if !minototal <= !maptotal && !minototal <= !horntotal
{
set #result !minototal
namespace pop
return #result
}
return #false ;should never reach here
sub grab_items
;%1 total times to run quest
;%2 total weight of quest items
namespace push
namespace local grabitems
set !itemcount 1 + %1 + %1
set %hornsleft %1 * 20
set %startpos 1
for !i 1 %numbersecures
{
str mid %secure %startpos 7
set %cursecure #strres
gosub open_container %cursecure
if %hornsleft > 0
{
display %hornsleft
finditem %horn c_ , %cursecure
if #findkind <> -1
{
display #findstack %hornsleft
If #findstack > 100 && %hornsleft > 100
{
exevent drag #findid 100
set %hornsleft %hornsleft - 100
wait 5
finditem %horn c_ , #backpackid
if #findkind = -1
exevent dropc #backpackid
else
exevent dropc %packanimal
wait 10
}
else
{
if #findstack <= %hornsleft
{
exevent drag #findid #findstack
set %hornsleft %hornsleft - #findstack
wait 5
finditem %horn c_ , #backpackid
if #findkind = -1
exevent dropc #backpackid
else
exevent dropc %packanimal
wait 10
}
else
{
exevent drag #findid %hornsleft
set %hornsleft %hornsleft - %hornsleft
wait 5
finditem %horn c_ , #backpackid
if #findkind = -1
exevent dropc #backpackid
else
exevent dropc %packanimal
wait 10
}
}
}
wait 10
finditem %horn c_ , %cursecure
if #findkind <> 1
{
if #findstack >= %hornsleft
{
exevent drag #findid %hornsleft
set %hornsleft %hornsleft - %hornsleft
}
if #findstack < %hornsleft
{
exevent drag #findid #findstack
set %hornsleft %hornsleft - #findstack
}
wait 5
exevent dropc %packanimal
wait 10
}
}
set %startpos %startpos + 8
}
namespace pop
return
sub open_container
;%1 = Container to open
set #lobjectid %1
wait 5
event macro 17
wait 20
return
sub mount_beetle
remount:
msg all follow me$
finditem %packanimal g_2
gosub open_container %packanimal
finditem %packanimal c_ #charid
if findkind = -1
goto remount
return
sub dismount
redismount:
set #lobjectid #charid
event macro 17
wait 10
finditem %packanimal g_2
msg all follow me$
wait 5
if findkind = -1
goto redismount
return
-
Well as the parser evolves, I'll continuously throw code at it. It's a bit too much at this point, but then 3 weeks ago, I didn't have much working at all parser-wise. ;)
-
Well, I can go through some stuff later and maybe chop some up. How many lines you want? Here a little with str, while, if/else, goto, gosub.. basically, target secures in your reach, and then it will open them up. That's it.
display Please target your secure (do not target containers inside a secure)!
setmultisecure:
wait 1
set #targcurs 1
target
while #targcurs = 1
wait 0
if %secure = n/a
set %secure #ltargetid , _
else
{
if #ltargetid notin %secure
set %secure %secure , #ltargetid , _
}
wait 5
display yesno Do you have another secure to target?
if #dispres = yes
goto setmultisecure
wait 5
str count %secure _
set %numbersecures #strres
set %startpos 1
for %i 1 %numbersecures
{
str mid %secure %startpos 7
set %cursecure #strres
gosub open_container %cursecure
set %startpos %startpos + 8
}
halt
sub open_container
;%1 = Container to open
set #lobjectid %1
wait 5
event macro 17
wait 20
return
-
if you just want syntax stuff okay...You can see my super ugly code that I just use real quick that's mad ghetto to just do what I want to do quickly.
loop:
event macro 13 9
target 2s
event macro 23 0
gosub cheat
goto loop
sub cheat
{
msg /add
key ENTER
repeat
wait 1
until #targcurs = 1
key esc
return
}
InitEvents
set %reg REMOVED
set %white REMOVED
set %loom REMOVED
set %amt
yarn:
finditem NLF_PLF_ZPC_UAG_QLF C_ , #backpackid
if #findid <> X
{
if ( ( #findcol = 1153 ) || ( #findcol = 1258 ) )
{
set %white #findid
set %amt #findstack
ignoreitem #findid
goto yarn
}
else
{
set %reg #findid
ignoreitem #findid
goto yarn
}
}
for %i 1 %amt
{
set #ltargetid %loom
set #lobjectid %reg
event macro 17 0
wait 10
event macro 22 0
wait 20
event macro 17 0
wait 10
event macro 22 0
wait 20
event macro 17 0
wait 10
event macro 22 0
wait 20
event macro 17 0
wait 10
event macro 22 0
wait 20
set #lobjectid %white
event macro 17 0
wait 10
event macro 22 0
wait 20
}
finditem ZZF C_ , #backpackid
for %i 1 #findcnt
{
event drag #findid
click 953 503 p
wait 20
set #findindex #findindex + 1
}
halt
set %bank_bag REMOVED
set %bankId REMOVED
set %returnBool #false
set %personToBuyFrom the , #spc , reagent , #spc , vendor
set %vendorId NA
set %amtToBuy NA
set %itemsToShopFor JUF_KUF_SZF_RZF_JZF_WZF_KZF_MZF
set %itemWeight 10
set %maxGold 0
loop:
gosub findVendor
if ( %returnBool )
{
ignoreitem reset
goto loop
}
gosub openShop
gosub shopForItem
if ( #weight > 300 )
{
gosub bankregs
}
goto loop
sub bankregs
{
wait 15
wait 5
finditem JUF_KUF_SZF_RZF_JZF_WZF_KZF_MZF C_ , #backpackId ;-<<<<<<<<<<<< Your backpack id
if #findkind = -1 2
return
event drag #findid
wait 15
msg $
finditem %bank_bag
set #findmod 22_10
click #findx #findy p
gosub bankregs
return
}
sub getGold
{
wait 15
wait 5
finditem POF C_ , %bankId ;-<<<<<<<<<<<< Your backpack id
if #findkind = -1 2
{
return
halt
}
event drag #findid
wait 15
msg 2300
key enter
wait 20
;event macro 8 1
;set %x #contposx + 142
;set %y #contposy + 218
click 1122 406 p
return
}
sub shopForItem
{
if ( %vendorId = NA )
{
set %returnBool #true
return
}
wait 5
getShopInfo
if ( #shopCnt = 0 )
{
ignoreitem %vendorId
gosub findVendor
if ( %returnBool )
{
ignoreitem reset
goto loop
}
gosub openShop
gosub shopForItem
return
}
set %wamt %amtToBuy
if ( %amtToBuy = NA )
{
set %wamt ( #maxWeight - #weight ) * %itemWeight
}
if ( %wamt > #shopItemMax )
{
set %wamt #shopItemMax
}
set %maxGold ( %wamt * #shopItemPrice ) - #gold
if ( %wamt * #shopItemPrice > #gold && %wamt * #shopItemPrice < 2300 )
{
gosub getGold
}
getShopInfo
set %clickx #contPosX - 41
set %clicky #contPosY - 125
click %clickx %clicky f
click %clickx %clicky f
setShopItem #shopItemID %wamt
set %clickx #contPosX + 49
set %clicky #contPosY + 207
click %clickx %clicky
return
}
sub findVendor
{
set %returnBool #false
finditem HS_IS G_10
if #FINDKIND = -1
{
set %vendorId NA
set %returnBool #true
return
}
set %vendorId #findid
event property %vendorId
if ( %personToBuyFrom notIn #property )
{
ignoreitem %vendorId
gosub findVendor
}
return
}
sub openShop
{
exevent popup %vendorId
wait 10
click 31 41 f
wait 20
if ( #contKind <> UQCD )
{
;gosub openShop
gosub findVendor
}
return
}
repeat
{
onhotkey f7
{
gosub a
}
}
until #false
sub a
{
finditem LQF C_ , #backpackid
set #lobjectid #findid
event macro 17 0
event macro 13 9
repeat
wait 1
until #targcurs = 1
event macro 23 0
gosub cheat
return
}
sub cheat
{
msg /add
key ENTER
wait 5
key esc
return
}
;HARDYZHARDYZHARDYZHARDYZHARDYZHARDYZ
;A Hardyz String Comparison Sub H
;R So you know I pwnz A
;D PWNZ HARD R
;Y I just like displaying my name D
;Z Y
;HARDYZHARDYZHARDYZHARDYZHARDYZHARDYZ
set %letterA 1
set %letterB 2
set %letterC 3
set %letterD 4
set %letterE 5
set %letterF 6
set %letterG 7
set %letterH 8
set %letterI 9
set %letterJ 10
set %letterK 11
set %letterL 12
set %letterM 13
set %letterN 14
set %letterO 15
set %letterP 16
set %letterQ 17
set %letterR 18
set %letterS 19
set %letterT 20
set %letterU 21
set %letterV 22
set %letterW 23
set %letterX 24
set %letterY 25
set %letterZ 26
set %remainOne
set %remainTwo
set %emptyOne
set %emptyTwo
set %letterOne
set %letterTwo
set %valueOne
set %valueTwo
set %newOne
set %newTwo
; This sub takes two arguements that are strings
; It will then tell you which String comes first
; It returns -1 if the first parameter comes first
; It returns 1 if the second paramter comes first
; It returns 0 if they are the same string
sub compareString
{
str Len %1
set %remainOne #strRes
str Len %2
set %remainTwo #strRes
set %emptyOne ( %remainOne = 0 )
set %emptyTwo ( %remainTwo = 0 )
;display %emptyOne
;Base cases
if ( %emptyOne || %emptyTwo )
{
if ( %emptyOne && %emptyTwo )
{
return 0
}
if ( %emptyOne )
{
return -1
}
else
{
return 1
}
}
str Left %1 1
set %letterOne #strRes
str Left %2 1
set %letterTwo #strRes
set %valueOne %letter . %letterOne
set %valueTwo %letter . %letterTwo
if ( %valueOne < %valueTwo )
{
return -1
}
if ( %valueOne > %valueTwo )
{
return 1
}
str Del %1 1 1
set %newOne #strRes
str Del %2 1 1
set %newTwo #strRes
gosub compareString %newOne %newTwo
return #result
}
finditem EWH G
set #ltargetid #findid
msg i wish to lock this down $
event macro 22 0
ignoreitem #findid
wait 100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;Hardyz Ghetto Scroll Buyer (in luna) ;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set %bag XXXXXX ; CHANGE ME
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set %vendorId NA
set %personToBuyFrom Holy , #spc , Mage
set %itemsToShopFor DPF
loop:
gosub findVendor
buy:
gosub shopForItem
finditem %itemsToShopFor C_ , #backpackid
if ( #findkind = -1 )
{
finditem %itemsToShopFor G_3
if ( #findkind = -1 )
{
goto buy
}
}
if ( #result )
{
goto loop
}
moves:
gosub moveScrolls
finditem %itemsToShopFor C_ , #backpackid
if ( #findkind <> -1 )
{
goto moves
}
finditem %itemsToShopFor G_3
if ( #findkind <> -1 )
{
goto moves
}
goto loop
sub openShop
{
exevent popup %vendorId
wait 10
click 31 41 f
wait 20
if ( #contKind <> UQCD )
{
;gosub openShop
gosub findVendor
}
return #false
}
sub findVendor
{
finditem HS_IS G_10
if #FINDKIND = -1
{
ignoreitem reset 1
gosub findVendor
return #result
}
set %vendorId #findid
event property %vendorId
if ( %personToBuyFrom notIn #property )
{
ignoreitem %vendorId 1
gosub findVendor
return #result
}
return #false
}
sub scrollShop
{
getShopInfo
while ( #shopItemType notin %itemsToShopFor && #shopCurPos <> #shopCnt )
{
set %clickx #contPosX + 74
set %clicky #contPosY - 16
click %clickx %clicky f
getShopInfo
}
if ( #shopItemType notin %itemsToShopFor )
{
return #true
}
return #shopItemType
}
sub moveScrolls
{
finditem %itemsToShopFor G_3
if #findkind = -1
{
finditem %itemsToShopFor C_ , #backpackid
if #findkind = -1
{
return
}
}
event drag #findid
wait 15
msg $
finditem %bag
set #findmod 22_10
click #findx #findy p
return
}
sub shopForItem
{
gosub openShop
gosub scrollShop
if ( #result )
{
ignoreitem %vendorId 1
gosub findVendor
if ( #result )
{
return #result
}
gosub shopForItem
return #result
}
set %amtToBuy #shopItemMax
ignoreitem %vendorId 1
}
set %newMax %amtToBuy * #shopItemPrice
if ( %newMax > #gold && %newMax < 2300 )
{
gosub withdrawGold %newMax
gosub shopForItem
return #result
}
getShopInfo
set %clickx #contPosX - 41
set %clicky #contPosY - 125
click %clickx %clicky f
click %clickx %clicky f
setShopItem #shopItemID %amtToBuy
set %clickx #contPosX + 49
set %clicky #contPosY + 207
click %clickx %clicky
return #false
}
sub withdrawGold
{
set %goldneeded %1 - #gold
msg withdraw %goldneeded $
return #false
}
set %food PRD_RQD_QQD_PQD_YRD_HND_SQD_BND_AQD_FUD
set %charName REMOVED
set %cotton NFF
set %cottonId removed
set %xpack 1165
set %ypack 222
if ( %charName = #charName )
{
loop:
gosub floor
finditem %cotton C_ , #backpackid
wait 20
repeat
{
event drag %cottonId
}
until #conttype = %cotton
wait 10
msg $
wait 10
event macro 15 1
finditem %food C_ , #backpackid
repeat
finditem %food C_ , #backpackid
until #findkind <> -1
click %xpack %ypack p
wait 10
finditem %food C_ , #backpackid
event drag #findid
wait 5
click 380 318 p
gosub floor
finditem %cotton C_ , #backpackid
repeat
finditem %cotton C_ , #backpackid
until #findcol <> 1258 && #findkind <> -1
event drag %cottonId
msg $
wait 10
click 418 333 p
wait 2s
}
sub floor
{
event drag %cottonId
wait 10
msg $
click %xpack %ypack p
exevent popup #charid
wait 10
click 80 130
finditem %cotton C_ , #backpackid
repeat
finditem %cotton C_ , #backpackid
until #findkind <> -1
set #ltargetid %cottonId
event macro 22 0
return
}
-
Ugly is good; down-right fugly is great. I want to torture it. ;)
-
Ugly is good; down-right fugly is great. I want to torture it. ;)
Hmm, maybe ought to throw some of SM's old stuff into it then?
Ok, ok - just kidding ;D
-
Hmm, maybe ought to throw some of SM's old stuff into it then?
Ok, ok - just kidding ;D
Ouch! *zing* Hey, at least she had the balls to post what people felt was "taboo". Crappy or not, it started our little movement toward world automation. :)
-
Believe me, I am greatful for SM's contributions that is for damn sure! In fact, so greatful that I've decided not to let that Daisho donator fall to the wayside because I think it's beautiful, just needs some TLC and it will be more stable and one to keep for the "Dangerous" script section hehe. "Greatful" is an action word where I come from! :p
Once I'm ready to jump back in to learning mode I'll be putting out the next version of the Miner and working on a cleaner version of SM's Daisho script.
The way things are going with 1.81 I might have to get moving this weekend, I'm starting to feel inspired. If the weather goes my way I won't be able to seal the decks so I'll have one less responsibility to weasel out of LOL!
Just printed the Daisho donator and am giddy as a schoolgirl as I gaze upon a properly color-coded script printout!
Boy, that's a lot of exclamation points....
!
X
-
That's good. I love to see when old scripts get new life; that's how the quester started. However if you compare the original SMQ with the present offering, you'll find there's almost no original code, however the design intention didn't change or the initial inspiration. It was a great decision by Cerveza to use Machine's crafting gump stuff; that simply rocks. My crafting subs are ones that I think I've never gotten a single question or complaint about, so from a script support perspective I call that perfect. ;)
-
Even blind squirrels sometimes find a nut....