Official ScriptUO EasyUO Scripts > Script Debug
issues with your recall sub in Nicar's Recall Lumberjack Script
(1/1)
eightonefive:
i posted the trouble I was having on winuo forums with no response, but since it's your sub, and I see Nicar trolls these forums as well I figured I might have more luck if I posted here. I'm not familliar with your recall sub in it's working form, so I'm not sure how to fix this problem, but in the recall lumberjack script that donates to vesper museum, at least the version that is on winuo, the runebook advance isn't working. it just keeps trying to recall to the very first rune in the runebook, even when it gets the message that something is blocking the location. help please?
TrailMyx:
I just ran a bit of test code by ripping out the runebooks subs that Nic's got in his lumberjacker. Running though my routines, I get an recall error when there's a spot blocked so by my routines, they are failing as they should.
What Nicar might want to do is to verify his compute next location subroutine. I allow for computation of the next location in my routines, but the way Nicar is using them, he's just giving the TM_TravelFromRunebook one rune at a time. i.e:
--- Code: ---gosub TM_TravelFromRunebook %travel_method %currentRune %currentRune %currentBookID
--- End code ---
What I normally do in my scripts is let the runebook subs handle this:
--- Code: ---gosub TM_TravelFromRunebook %travel_method %startrune %endrune %currentBookID
--- End code ---
So since Nicar is computing the next rune position, perhaps he might want to do something special when the rune gets to the end.
eightonefive:
it's not even getting to the end, it's staying on the very first rune in the tree book. i just need to figure out a way to make it advance when you get the message there is something blocking your location etc.
TrailMyx:
I'm afraid that's deep inside Nic's code. Hopefully, he'll get on and take a look at it for you. ;)
Here's the test code I used. With one try, I just recalled. The second try, I parked my beetle where the rune is marked:
--- Code: ---gosub TM_TravelFromRunebook RE 1 1 XXYYZZ1
if #RESULT = #TRUE
display ok Error occurred.
stop
;===============================================================================
;Other People's Subs That I am Using. Thanks!
;===============================================================================
;TrailMyx Runebook Subs
;-------------------------------------------------------------------------------
; %1 = spell number
; %2 = #TARGETID or SELF or NONE
; %3 = retry count (-1 = cast until successful)
; %4 = cast delay
; %5 = recovery delay
sub TM_NewCastSpell
namespace push
namespace local NCS
set !lpc #LPC
set #LPC 100
set !whichspell %1
set !whichtarget %2
set !castretrymax %3
set !waitdelay %4
set !recovery_delay %5
set !castretry 0
set !temp_ltargetid #LTARGETID
set !temp_ltargetkind #LTARGETKIND
NewCastSpell_loop1:
if !castretrymax < 0
goto NewCastSpell_cont1
if !castretry > !castretrymax
goto NewCastSpell_end1
NewCastSpell_cont1:
gosub TM_SyncTextScan
set #LTARGETKIND 1
set #LTARGETID !whichtarget
set !tempmana #MANA
event macro 15 !whichspell ; cast the spell
wait !waitdelay
set !targettimeout #SCNT + 7
NewCastSpell_wait1:
gosub TM_FindValidTextNoAdvance spell_fizzles you_have_not_yet mana your_spirit more_reagents
if #RESULT = #TRUE || #SCNT > !targettimeout
{
set !casttimeout #SCNT2 + !recovery_delay
repeat
until #SCNT2 > !casttimeout ; finish up cast delay
set !castretry !castretry + 1
goto NewCastSpell_loop1
}
if !whichtarget = NONE
goto NewCastSpell_skip1
if #TARGCURS = 1
goto NewCastSpell_targ1
goto NewCastSpell_wait1 ; wait for target cursor
NewCastSpell_targ1:
if !whichtarget = SELF
event macro 23
else
event macro 22
NewCastSpell_skip1:
wait 5
set !casttimeout #SCNT2 + !recovery_delay
NewCastSpell_skip2:
if !whichspell >= 0 && !whichspell <= 63 ; Magery
{
gosub TM_FindValidTextNoAdvance spell_fizzles there_is_already mana your_spirit more_reagents
}
else
{
set !cont #FALSE ; Chivalry, Necromancy, etc
finditem !whichtarget *
if !whichtarget in SELF_NONE || #FINDKIND <> -1
set !cont #TRUE
if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
set #RESULT #TRUE
else
set #RESULT #FALSE
}
repeat
until #SCNT2 > !casttimeout ; finish up cast delay
if #RESULT = #TRUE
{
if !castretrymax > -1
{
set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
if !castretry > !castretrymax
goto NewCastSpell_end1
}
goto NewCastSpell_loop1
}
if #SCNT2 <= !casttimeout ; finish up cast delay
goto NewCastSpell_skip2
NewCastSpell_end1:
set #LTARGETID !temp_ltargetid
set #LTARGETKIND !temp_ltargetkind
set #LPC !lpc
namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
namespace push
namespace local RFR
set #LTARGETKIND 1
set !method %1
set !locindex %2
set !locindexend %3
set !rbook %4
finditem !rbook C_ , #BACKPACKID
if !method notin RE_GA_SJ || #FINDKIND = -1
{
namespace pop
return #TRUE
}
if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
TravelFromRunebook_loop1:
set #LOBJECTID !rbook
set #LTARGETKIND 1
event macro 17 0
gosub GumpWait generic_gump generic_gump
set !runeclickx 140 ; page 1, rune 1
set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
if !locindex > 8
{
set !runeclickx 310 ; page 2, rune 1
set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
}
set !runeclicky #CONTPOSY + 196
click !runeclickx !runeclicky
wait 5
set !runeclicky #CONTPOSY + 24
set !runeclickx #CONTPOSX + 164 ; page 1 set to default
if !locindex % 2 = 0
{
set !runeclickx #CONTPOSX + 305 ; page 2 set to default
}
click !runeclickx !runeclicky
wait 5
set !oldx #CHARPOSX
set !oldy #CHARPOSY
if !method = RE
gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
if !method = GA
{
gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
set !temp_cnt #SCNT + 10
repeat
finditem KEF_OTF_JEF G_0
until #FINDKIND <> -1 || #SCNT > !temp_cnt
if #FINDKIND <> -1
{
set #LOBJECTID #FINDID
wait 10
event macro 17 0
wait 20
if #CONTNAME = generic_gump && #CONTSIZE = 420_280
{
gosub TM_SyncTextScan
set !clickx #CONTPOSX + 26
set !clicky #CONTPOSY + 261
click !clickx !clicky ; click ok
}
}
}
if !method = SJ
gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful
wait 30
set !tempscnt #SCNT + 10
WaitforTravel_loop1:
gosub TM_FindValidTextNoAdvance location_is_blocked something_is_blocking you_spirit_lacks
if #RESULT = #TRUE
{
gosub TM_SyncTextScan
set !locindex !locindex + 1
if !locindex > !locindexend
{
namespace pop
return #TRUE
}
goto TravelFromRunebook_loop1
}
if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
goto WaitforTravel_loop1
if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
{
set !clickx #CONTPOSX + 120
set !clicky #CONTPOSY + 60
click !clickx !clicky mc r
wait 5
}
namespace pop
click 401 254 n
return #FALSE
;------------------------------------------------
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
namespace push
namespace local TFNR
set !method %1
set !start_index %2
set !end_index %3
set !runbook_name %4
if !method notin RE_GA_SJ
{
namespace pop
return #TRUE
}
if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
locatenamedrunebook:
finditem ZBN C_ , #BACKPACKID
if #FINDKIND <> -1
{
event property #FINDID
if !runbook_name in #PROPERTY
{
gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
}
else
{
ignoreitem #FINDID rbook
goto locatenamedrunebook
}
}
else
{
display ok Cannot locate specified runebook named , #SPC , !runbook_name
stop
}
ignoreitem reset rbook
namespace pop
return
;-------------------------------------------------------------------------------
sub TM_RandomRunebookTravel
namespace push
namespace local RRT
set !travelmethod %1
set !rune1 %2
set !rune2 %3
set !runebook %4
if !rune1 > !rune2
{
set !temp !rune2
set !rune2 !rune1
set !rune1 !temp
}
RunebookTravel_loop1:
set !random #RANDOM
set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
if #RESULT = #TRUE
goto RunebookTravel_loop1
namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = Object Findid
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromObject
namespace push
namespace local RFR
set !method %1
set !object %2
finditem !object C_ , #BACKPACKID
if !method notin RE_GA_SJ || #FINDKIND = -1
{
namespace pop
return #TRUE
}
set !oldx #CHARPOSX
set !oldy #CHARPOSY
TravelFromObject_loop1:
if !method = RE
gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
if !method = GA
{
gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
set !temp_cnt #SCNT + 10
repeat
finditem KEF_OTF_JEF G_0
until #FINDKIND <> -1 || #SCNT > !temp_cnt
if #FINDKIND <> -1
{
set #LOBJECTID #FINDID
wait 10
event macro 17 0
wait 20
if #CONTNAME = generic_gump && #CONTSIZE = 420_280
{
gosub TM_SyncTextScan
set !clickx #CONTPOSX + 26
set !clicky #CONTPOSY + 261
click !clickx !clicky ; click ok
}
}
}
if !method = SJ
gosub TM_NewCastSpell 210 !object -1 10 30 ; sacred journey until successful
wait 30
set !tempscnt #SCNT + 10
WaitforTravel2_loop1:
gosub TM_FindValidTextNoAdvance location_is_blocked something_is_blocking your_spirit_lacks
if #RESULT = #TRUE
{
gosub TM_SyncTextScan
set !locindex !locindex + 1
if !locindex > !locindexend
{
namespace pop
return #TRUE
}
goto TravelFromObject_loop1
}
if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
goto WaitforTravel2_loop1
namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; Brings !_jindex up to the most recent #journal entry
sub TM_SyncTextScan
namespace push
namespace local text
set !_jindex #jindex + 1
namespace pop
return
;-------------------------------------------------------------------------------
; %1, %2, %3, etc strings to match
; returns #TRUE for match, #FALSE for no match
; Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
; Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
sub TM_FindValidTextNoAdvance
namespace push
namespace local text
set !temp_lpc #LPC
set #LPC 1000
set !num_args %0
set !first_arg 1
if !_jindex = N/A
set !_jindex #jindex
set !index !first_arg
repeat
set !temp_jindex !_jindex
set !text % . !index
while !temp_jindex <= #jindex
{
scanjournal !temp_jindex
str pos #JOURNAL %charname 1
set !namepos #STRRES
str count #JOURNAL %charname
set !namecnt #STRRES
str pos #JOURNAL :_ 1
set !smcpos #STRRES
str pos #JOURNAL !text 1
set !textpos #STRRES
if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL
set !pass #TRUE
else
set !pass #FALSE
if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
{
set !temp_jindex !temp_jindex + 1
set #LPC !temp_lpc
namespace pop
return #TRUE
}
set !temp_jindex !temp_jindex + 1
}
set !index !index + 1
until !index - !first_arg >= !num_args
set #LPC !temp_lpc
namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; %1 - string to mung
sub TM_AddUnderscore
namespace push
namespace local AU
set !tempstring %1
AddUnderscore_loop1:
str pos !tempstring #SPC
if #STRRES <> 0
{
set !val #STRRES - 1
str left !tempstring !val
set !left #STRRES
set !val !val + 1
str del !tempstring 1 !val
set !tempstring !left , _ , #STRRES
goto AddUnderscore_loop1
}
set #RESULT !tempstring
namespace pop
return #RESULT
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
namespace push
namespace local GW
wait 10
set !timedelay #SCNT
while #SCNT <= !timedelay + 7
{
if #CONTNAME = %1 || #CONTNAME = %2
{
namespace pop
return #TRUE
}
}
namespace pop
return #FALSE
--- End code ---
But from this test you can see the runebook subs are functioning correctly.
Nicar:
Blah, I am such a slacker, I missed this somehow, I guess I got something to look into. Also, what are the rune books named? They need to be named "Wood XX" or "tree XX" where XX = number of runes in book. If your book is called Wood, that's why it may not be advancing.
(It's good to have this here, and I did reply back to WinUO thread, just was couple days behind and eightonefive replied saying that it was that issue, the names of the runebooks)
*** Updated due to memory loss
Navigation
[0] Message Index
Go to full version