ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: baldielocks on October 05, 2020, 08:56:16 AM

Title: Trick or treat starter
Post by: baldielocks on October 05, 2020, 08:56:16 AM
HI! I'm baby stepping my way through making a robust trick or treater. First, I want to ensure I can reliably target, trick or treat, detect a teleport, and recall back to the spot. The script will "eventually" be a recall based script with bank/trash support. BUT I am having issues getting it to detect the teleport. This is what I have for one static NPC. The targetting and trick or treat and timing are spot on so far.

Code: [Select]
Display ok Target your recall rune or book
set #targcurs 1
  while #targcurs = 1
    wait 0
  set %rune #ltargetid
wait 5
;----------
 Display ok Target your First Animal.
     set #targcurs 1
  while #targcurs = 1
    wait 0
  set %heal1 #ltargetid
wait 5
;-----------
mainloop:
gosub TM_AdvJournalSync TRICK 100
gosub trickortreat1
wait 60s
return
;----------
Sub trickortreat1
set #ltargetid %heal1
set #ltargetkind 1
msg $trick or treat
 if  #targcurs = 0
{
 repeat
}
target
Event macro 22 0
gosub trickcheck
return
;-----------
Sub trickcheck
gosub TM_AdvJournalScan TRICK VALID_Advance teleports
 If #result = #true
          {
          msg $trick detected
           }
  return
;=================================================================
; Script Name: TrailMyx's Advanced Journal Scanner
; Author: TrailMyx     gosub TM_AdvJournalScan heal VALID_ADVANCE
; Version: 1.2
; Shard OSI / FS: OSI / FS?
; Revision Date: 10/20/2007
; Purpose:
;   Use these subs to quickly find text in your #journal entries.  These subs
; use #jindex for flawless journal scanning and is much more reliable than using
; standard indexing of #journal and #SYSMSG.
;
;   Now it is possible to manage separate journals based on unrelated text.  It's now possible
; to monitor spellcasting, bandaging, stealing, or anything else without a TM_AdvJournalSync
; potentially removing text needed for another UO funciton.
;
;   New is the ability to either gosub or call these functions without the need to change the
; header!  When calling, a limit of 10 arguments is allowed, but more can be added by editing the
; call interface section.
;
;  Examples:
;     gosub TM_AdvJournalSync speech 100 ; sync "speech" journal space, set #LPC to 100 from default of 1000
;     gosub TM_AdvJournalScan speech VALID Find_this_text and_find_this_too ; will not advance copy of #jindex
;     gosub TM_AdvJournalScan heal VALID_ADVANCE you_heal_what that_patient_is_not ; advances pointer after scan
;     gosub TM_AdvJournalScan spellcast NONE fizzle ; no spam checking and doesn't advance #jindex copy automatically
;
;  Subs included:
;     TM_AdvJournalGetTrigger - retrieve the triggering string (#FALSE for no trigger)
;     TM_AdvJournalSync - Must call this in initialzation
;     TM_AdvJournalScan - see header for details....
;
;  Release history:
;    v1.0 - Initial release.
;    v1.1 - debug code added, fixed small possibility to miss an incoming journal entry
;
;  Requirements:
;    Nothing special
;
;  Credit:
;    If you use these subs, please leave credit for me somewhere in your script header.
;=================================================================
;------------------------  Call interface  -----------------------
;=================================================================
set !TM_FunctionCalled #FALSE
if %0 = 1
  gosub %1
if %0 = 2
  gosub %1 %2
if %0 = 3
  gosub %1 %2 %3
if %0 = 4
  gosub %1 %2 %3 %4
if %0 = 5
  gosub %1 %2 %3 %4 %5
if %0 = 6
  gosub %1 %2 %3 %4 %5 %6
if %0 = 7
  gosub %1 %2 %3 %4 %5 %6 %7
if %0 = 8
  gosub %1 %2 %3 %4 %5 %6 %7 %8
if %0 = 9
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9
if %0 = 10
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10
if %0 = 11
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11
if %0 > 11
{
  display ok Too many arguments for "call", edit file.
  stop
}

if !TM_FunctionCalled = #TRUE
  exit
if %0 = N/A
  display ok You may not run this script directly.
else
  display ok Function " , %1 , " not found.
stop
;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - #LPC setting (optional)
; Brings !_jindex up to the most recent #journal entry
sub TM_AdvJournalSync
  namespace push
  namespace local TM_AdvJS_ , %1
  set !_jindex #jindex + 1
  if %0 > 1
    set !lpc_set %2
  namespace pop
  set !TM_FunctionCalled #TRUE
return
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
; %3, %4, %5, 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
;  About %2 arguments:
;    NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
;    ADVANCE: no spam checking, advances #jindex copy
;    VALID: invokes SPAM filtering, no advance of #jindex copy
;    VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
sub TM_AdvJournalScan
  namespace push
  namespace local TM_AdvJS_ , %1
  set !args %2
  set !temp_lpc #LPC
  if !lpc_set = N/A
    set #LPC 1000
  else
    set #LPC !lpc_set
  set !num_args %0
  set !first_arg 3
  set !sampled_jindex #JINDEX
  if !_jindex = N/A
    set !_jindex !sampled_jindex
  if !charname = N/A
  {
    set !charname #CHARNAME
AdvJournalScan_loop1:
    str pos !charname #SPC
    if #STRRES <> 0
    {
      set !val #STRRES - 1
      str left !charname !val
      set !left #STRRES
      set !val !val + 1
      str del !charname 1 !val
      set !charname !left , _ , #STRRES
      goto AdvJournalScan_loop1
    }
  }
  set !index !first_arg
  repeat
    set !temp_jindex !_jindex
    set !text % . !index
    while !temp_jindex <= !sampled_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 || VALID notin !args
        set !pass #TRUE
      else
        set !pass #FALSE
      if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
      {
        set !temp_jindex !temp_jindex + 1
        if ADVANCE in !args
          set !_jindex !temp_jindex
        set !trigger !text
        set #LPC !temp_lpc
        namespace pop
        set !TM_FunctionCalled #TRUE
        return #TRUE
      }
      set !temp_jindex !temp_jindex + 1
    }
    set !index !index + 1
  until !index - !first_arg > !num_args - !first_arg
  set %10 !sampled_jindex - !_jindex
  set %10 %1 , _ , %10 ; for debugging purposes
  set #LPC !temp_lpc
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------

Title: Re: Trick or treat starter
Post by: Crisis on October 05, 2020, 01:27:13 PM
Someone had a good script using a personal attendant before they fixed that. I am sure that you can get an idea from that. I don't remember whose script it was but am thinking it was probably The Ghost.
Title: Re: Trick or treat starter
Post by: Gaderian on October 05, 2020, 01:40:20 PM
My 2 cents:

Repeat is the first part of a repeat...until construct. If you want to build your own timeout using a wait loop on the target cursor, consider changing:

Code: easyuo
  1. Sub trickortreat1
  2. set #ltargetid %heal1
  3. set #ltargetkind 1
  4. msg $trick or treat
  5.  if  #targcurs = 0
  6. {
  7.  repeat
  8. }
  9. target
  10. Event macro 22 0
  11. gosub trickcheck
  12. return

Code: easyuo
  1. Sub trickortreat1
  2. set #ltargetid %heal1
  3. set #ltargetkind 1
  4. msg $trick or treat
  5. repeat
  6.  wait 1
  7. until #targcurs <> 0
  8. target
  9. Event macro 22 0
  10. gosub trickcheck
  11. return

But honestly, if you are expecting it will bring up the target cursor 100% of the time, then simply use the 'target' command with a timeout by doing this:
Code: easyuo
  1. Sub trickortreat1
  2. set #ltargetid %heal1
  3. set #ltargetkind 1
  4. msg $trick or treat
  5. target 4s
  6. ; Here you would have #targcurs <> 0 or you would have reached the 4 second timeout provided
  7. ; So you could now test if #targcurs <> 0 and bail with an appropriate error result if for some
  8. ; reason it did not come up with a target cursor...
  9. Event macro 22 0
  10. gosub trickcheck
  11. return

The command 'msg' is appropriate when you want your character to say something to the public/npc's. If you want to give yourself feedback, consider using "event sysmessage". I am looking at the use of 'msg' in the sub trickcheck specifically.

I have a slightly different version of the AdvJournal Routines - not sure the difference in function. Here is the version of the routines Oracle and I have been using this year for hundreds of hours in a project we did together. I know this code works as expected, so maybe there is some logic difference that you are experiencing.

Code: easyuo
  1. ;-------------------------------------------------------------------------------
  2. ; %1 - Journal Name
  3. ; %2 - #LPC setting (optional)
  4. ; Brings !_jindex up to the most recent #journal entry
  5. sub TM_AdvJournalSync
  6.   namespace push
  7.   namespace local TM_AdvJS_ , %1
  8.   set !_jindex #jindex + 1
  9.   if %0 > 1
  10.     set !lpc_set %2
  11.   namespace pop
  12.   set !TM_FunctionCalled #TRUE
  13. return
  14. ;-------------------------------------------------------------------------------
  15. ; %1 - Journal Name
  16. ; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
  17. ; %3, %4, %5, etc strings to match
  18. ; returns #TRUE for match, #FALSE for no match
  19. ;  Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
  20. ;  Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
  21. ;  About %2 arguments:
  22. ;    NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
  23. ;    ADVANCE: no spam checking, advances #jindex copy
  24. ;    VALID: invokes SPAM filtering, no advance of #jindex copy
  25. ;    VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
  26. sub TM_AdvJournalScan
  27.   namespace push
  28.   namespace local TM_AdvJS_ , %1
  29.   set !args %2
  30.   set !temp_lpc #LPC
  31.   if !lpc_set = N/A
  32.     set #LPC 1000
  33.   else
  34.     set #LPC !lpc_set
  35.   set !num_args %0
  36.   set !first_arg 3
  37.   if !_jindex = N/A
  38.     set !_jindex #jindex
  39.   if !charname = N/A
  40.   {
  41.     set !charname #CHARNAME
  42.     AdvJournalScan_loop1:
  43.       str pos !charname #SPC
  44.       if #STRRES <> 0
  45.       {
  46.         set !val #STRRES - 1
  47.         str left !charname !val
  48.         set !left #STRRES
  49.         set !val !val + 1
  50.         str del !charname 1 !val
  51.         set !charname !left , _ , #STRRES
  52.         goto AdvJournalScan_loop1
  53.       }
  54.   }
  55.   set !index !first_arg
  56.   repeat
  57.     set !temp_jindex !_jindex
  58.     set !text % . !index
  59.     while !temp_jindex <= #jindex
  60.     {
  61.       scanjournal !temp_jindex
  62.       str pos #JOURNAL !charname 1
  63.       set !namepos #STRRES
  64.       str count #JOURNAL !charname
  65.       set !namecnt #STRRES
  66.       str pos #JOURNAL :_ 1
  67.       set !smcpos #STRRES
  68.       str pos #JOURNAL !text 1
  69.       set !textpos #STRRES
  70.       if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
  71.         set !pass #TRUE
  72.       else
  73.         set !pass #FALSE
  74.       if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
  75.       {
  76.         set !temp_jindex !temp_jindex + 1
  77.         if ADVANCE in !args
  78.           set !_jindex !temp_jindex
  79.         set #LPC !temp_lpc
  80.         namespace pop
  81.         set !TM_FunctionCalled #TRUE
  82.         return #TRUE
  83.       }
  84.       set !temp_jindex !temp_jindex + 1
  85.     }
  86.     set !index !index + 1
  87.   until !index - !first_arg > !num_args - !first_arg
  88.   set #LPC !temp_lpc
  89.   namespace pop
  90.   set !TM_FunctionCalled #TRUE
  91. return #FALSE
  92. ;-------------------------------------------------------------------------------
  93.  

That is what jumps out at me...

Maybe it will help push your project along.

Gaderian

Title: Re: Trick or treat starter
Post by: The Ghost on October 05, 2020, 05:32:53 PM
Why event bored with the recall back to where you were.  At best you have 5 npc,  most are 3 -4.    Not sure it wort the effort  ATm .  If you get teleported,  you will recall back when  you can't find any NPC.    Once you  have a solid working build,  now you can to improve it
 
Don't over complicated the script.   Start with the basic.   

1) scan for NPC and ToT,
2)  recall to new location
3) Weight recall to bank and track


C2    Happy Halloween
 http://www.scriptuo.com/index.php?topic=3151.0
Title: Re: Trick or treat starter
Post by: baldielocks on October 05, 2020, 09:02:20 PM
Good suggestions Ghost. Those steps are in my plan. But FIRST, I have to get it to recognize that I teleported away. Either way, getting the hang of the journal scan is actually my priority here.
Title: Re: Trick or treat starter
Post by: baldielocks on October 05, 2020, 10:52:21 PM
OKay, I took all the suggestions and rethought my process using ghosts simplification. I instead went with TM's recall sub. The script seems to work, but the runebook wont change pages, instead it stays on the starting number in the range, no matter what I put it at. I will be adding other subs, weight check, bank, trash, menu, etc once I get this working and recalling around. I tried recall from targeted runebook, and recall from named runebook. same result. Random runebook travel works though. However, it doesn't appear to detect blocked spots. If it randomly chooses the same spot I occupy, it recalls continously.


Code: easyuo
  1. mainloop:
  2. gosub find
  3. gosub trickortreat
  4. goto mainloop
  5.  
  6. sub find
  7.   repeat
  8.     wait 1
  9.     finditem HS_IS G_4
  10.     if #findcnt = 0
  11.     {
  12.         ignoreitem reset
  13.        gosub TM_TravelFromNamedRunebook RE 1 5 TRICKORTREAT1
  14.     }
  15.     if #findid = #charid
  16.         ignoreitem #FINDID
  17.     if #findrep = 2_3_4_5_6
  18.        ignoreitem #FINDID
  19.   until #FINDcnt >= 1 && #findid <> #charid
  20. RETURN
  21.  
  22. Sub trickortreat
  23. msg $trick or treat
  24. set #ltargetid #findid
  25. set #ltargetkind 1
  26. repeat
  27.  wait 1
  28. until #targcurs <> 0
  29. target
  30. Event macro 22 0
  31. ignoreitem #ltargetid
  32. return
  33.  
  34. ;=================================================================
  35. ; Script Name: TrailMyx's Runebook/Spellcast Subs
  36. ; Author: TrailMyx
  37. ; Version: 2.5
  38. ; Shard OSI / FS: OSI / FS
  39. ; Revision Date: 09/27/2007
  40. ; Purpose:
  41. ;   Runebook subs to manage your runebook travel needs.  You need either to know
  42. ;   the runebook ID or runebook name.
  43. ;
  44. ; Subroutines:
  45. ;     TM_NewCastSpell - casts spells with appropriate waits, delays, retrys.
  46. ;     TM_TravelFromRunebook - Uses specified runbook #FINDID to travel from .  If a location is blocked
  47. ;                             the next location will be tried until success.
  48. ;     TM_TravelFromNamedRunebook - Same as TM_TravelFromRunebook, but allows you to specify a runebook name
  49. ;
  50. ;  Examples:
  51. ;     gosub TM_NewCastSpell 31 !rbook 10 20 20 ; recall
  52. ;     gosub TM_TravelFromRunebook RE 1 3 %runebookid ; travel (recall) to location from #FINDID runebook using slots 1-3
  53. ;     gosub TM_TravelFromNamedRunebook GA 1 2 LUMBERJACKING1 ; gate using LUMBERJACKING1 runebook starting at rune 1
  54. ;     gosub TM_RandomRunebookTravel SJ 1 6 %runebookid  ; Randomly choose a rune from 1-6 in runebook
  55. ;     gosub TM_TravelFromObject RE %runeid ; travels to rune specified by %runeid
  56. ;
  57. ;  Use of these subrountes is allowed, but please give me (TrailMyx) credit somewhere in your script.
  58. ;
  59. ;  Release History:
  60. ;     2.0 - Initial public release
  61. ;     2.1 - Bug in TM_FindValidTextNoAdvance, added return value to TM_TravelFromNamedRunebook
  62. ;     2.2 - Bug in TM_NewCastSpell when mana gets too low
  63. ;     2.3 - Better spellcasting for chivalry, necro
  64. ;           Added TM_TravelFromNamedRunebook
  65. ;           Added TM_RandomRunebookTravel
  66. ;     2.4 - Little fix for journal handler
  67. ;     2.5 - Hack to allow for transport through a red moongate.
  68. ;
  69. ;  Requirements:
  70. ;
  71. ;    This script requires that you have your character name
  72. ;    setup in a variable called %charname.  Place this bit of code
  73. ;    in your script initialization somewhere:
  74. ;
  75. ;   gosub TM_AddUnderscore #CHARNAME
  76. ;   set %charname #RESULT
  77. ;=================================================================
  78. ;-------------------------------------------------------------------------------
  79. ; %1 = spell number
  80. ; %2 = #TARGETID or SELF or NONE
  81. ; %3 = retry count (-1 = cast until successful)
  82. ; %4 = cast delay
  83. ; %5 = recovery delay
  84. sub TM_NewCastSpell
  85.   namespace push
  86.   namespace local NCS
  87.   set !lpc #LPC
  88.   set #LPC 100
  89.   set !whichspell %1
  90.   set !whichtarget %2
  91.   set !castretrymax %3
  92.   set !waitdelay %4
  93.   set !recovery_delay %5
  94.  
  95.   set !castretry 0
  96.   set !temp_ltargetid #LTARGETID
  97.   set !temp_ltargetkind #LTARGETKIND
  98.  
  99.   NewCastSpell_loop1:
  100.     if !castretrymax < 0
  101.       goto NewCastSpell_cont1
  102.     if !castretry > !castretrymax
  103.       goto NewCastSpell_end1
  104.     NewCastSpell_cont1:
  105.       gosub TM_AdvJournalSync SPELLCAST
  106.       set #LTARGETKIND 1
  107.       set #LTARGETID !whichtarget
  108.       set !tempmana #MANA
  109.       event macro 15 !whichspell ; cast the spell
  110.       wait !waitdelay
  111.       set !targettimeout #SCNT + 7
  112.       NewCastSpell_wait1:
  113.         gosub TM_AdvJournalScan SPELLCAST VALID you_have_not_yet mana your_spirit more_reagents
  114.         if #RESULT = #TRUE || #SCNT > !targettimeout
  115.         {
  116.           set !casttimeout #SCNT2 + !recovery_delay
  117.           repeat
  118.           until #SCNT2 > !casttimeout     ; finish up cast delay
  119.           set !castretry !castretry + 1
  120.           goto NewCastSpell_loop1
  121.         }
  122.         if !whichtarget = NONE
  123.           goto NewCastSpell_skip1
  124.         if #TARGCURS = 1
  125.           goto NewCastSpell_targ1
  126.         goto NewCastSpell_wait1 ; wait for target cursor
  127.  
  128.   NewCastSpell_targ1:
  129.     if !whichtarget = SELF
  130.       event macro 23
  131.     else
  132.       event macro 22
  133.  
  134.   NewCastSpell_skip1:
  135.     wait 5
  136.     set !casttimeout #SCNT2 + !recovery_delay
  137.     NewCastSpell_skip2:
  138.       if !whichspell >= 0 && !whichspell <= 63 ; Magery
  139.       {
  140.         gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents
  141.       }
  142.       else
  143.       {
  144.         set !cont #FALSE  ; Chivalry, Necromancy, etc
  145.         finditem !whichtarget *
  146.         if !whichtarget in SELF_NONE || #FINDKIND <> -1
  147.           set !cont #TRUE
  148.  
  149.         if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
  150.           set #RESULT #TRUE
  151.         else
  152.           set #RESULT #FALSE
  153.       }
  154.       repeat
  155.       until #SCNT2 > !casttimeout     ; finish up cast delay
  156.       if #RESULT = #TRUE
  157.       {
  158.         if !castretrymax > -1
  159.         {
  160.           set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
  161.           if !castretry > !castretrymax
  162.             goto NewCastSpell_end1
  163.         }
  164.         goto NewCastSpell_loop1
  165.       }
  166.       if #SCNT2 <= !casttimeout     ; finish up cast delay
  167.         goto NewCastSpell_skip2
  168.   NewCastSpell_end1:
  169.     set #LTARGETID !temp_ltargetid
  170.     set #LTARGETKIND !temp_ltargetkind
  171.     set #LPC !lpc
  172.     namespace pop
  173. return
  174. ;-------------------------------------------------------------------------------
  175. ; %1 = Method (RE, GA, SJ)
  176. ; %2 = index location within runebook (1-16)
  177. ; %3 = index location within runebook (1-16), try up to this point
  178. ; %4 = runebook item id
  179. ; returns #TRUE if error, #FALSE for no error
  180. sub TM_TravelFromRunebook
  181.   namespace push
  182.   namespace local RFR
  183.   set #LTARGETKIND 1
  184.   set !method %1
  185.   set !locindex %2
  186.   set !locindexend %3
  187.   set !rbook %4
  188.  
  189.   finditem !rbook C_ , #BACKPACKID
  190.   if !method notin RE_GA_SJ || #FINDKIND = -1
  191.   {
  192.     namespace pop
  193.     return #TRUE
  194.   }
  195.   if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  196.   {
  197.     namespace pop
  198.     return #TRUE
  199.   }
  200.   if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  201.   {
  202.     namespace pop
  203.     return #TRUE
  204.   }
  205.  
  206.   TravelFromRunebook_loop1:
  207.     set #LOBJECTID !rbook
  208.     set #LTARGETKIND 1
  209.     event macro 17 0
  210.     gosub GumpWait generic_gump generic_gump
  211.  
  212.     set !runeclickx 140 ; page 1, rune 1
  213.     set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
  214.     if !locindex > 8
  215.     {
  216.       set !runeclickx 310 ; page 2, rune 1
  217.       set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
  218.     }
  219.     set !runeclicky #CONTPOSY + 196
  220.     click !runeclickx !runeclicky
  221.     wait 5
  222.  
  223.     set !runeclicky #CONTPOSY + 24
  224.     set !runeclickx #CONTPOSX + 164 ; page 1 set to default
  225.     if !locindex % 2 = 0
  226.     {
  227.       set !runeclickx #CONTPOSX + 305 ; page 2 set to default
  228.     }
  229.     click !runeclickx !runeclicky
  230.     wait 5
  231.     set !oldx #CHARPOSX
  232.     set !oldy #CHARPOSY
  233.     if !method = RE
  234.       gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
  235.     if !method = GA
  236.     {
  237.       gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
  238.       set !temp_cnt #SCNT + 10
  239.       repeat
  240.         finditem KEF_OTF_JEF G_0
  241.       until #FINDKIND <> -1 || #SCNT > !temp_cnt
  242.       if #FINDKIND <> -1
  243.       {
  244.         set #LOBJECTID #FINDID
  245.         wait 10
  246.         event macro 17 0
  247.         wait 20
  248.         if #CONTNAME = generic_gump && #CONTSIZE = 420_280
  249.         {
  250.           gosub TM_AdvJournalSync SPELLCAST
  251.           set !clickx #CONTPOSX + 26
  252.           set !clicky #CONTPOSY + 261
  253.           click !clickx !clicky ; click ok
  254.         }
  255.       }
  256.     }
  257.  
  258.     if !method = SJ
  259.       gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful
  260.     wait 30
  261.  
  262.     set !tempscnt #SCNT + 10
  263.   WaitforTravel_loop1:
  264.     gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks
  265.     if #RESULT = #TRUE
  266.     {
  267.       gosub TM_AdvJournalSync SPELLCAST
  268.       set !locindex !locindex + 1
  269.       if !locindex > !locindexend
  270.       {
  271.         namespace pop
  272.         return #TRUE
  273.       }
  274.       goto TravelFromRunebook_loop1
  275.     }
  276.     if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
  277.       goto WaitforTravel_loop1
  278.  
  279.   if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
  280.   {
  281.     set !clickx #CONTPOSX + 120
  282.     set !clicky #CONTPOSY + 60
  283.     click !clickx !clicky mc r
  284.     wait 5
  285.   }
  286.   namespace pop
  287.   click 401 254 n
  288. return #FALSE
  289. ;------------------------------------------------
  290. ; %1 method
  291. ; %2 starting index
  292. ; %3 ending index
  293. ; %4 runebook name
  294. sub TM_TravelFromNamedRunebook
  295.   namespace push
  296.   namespace local TFNR
  297.   set !method %1
  298.   set !start_index %2
  299.   set !end_index %3
  300.   set !runbook_name %4
  301.   if !method notin RE_GA_SJ
  302.   {
  303.     namespace pop
  304.     return #TRUE
  305.   }
  306.   if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  307.   {
  308.     namespace pop
  309.     return #TRUE
  310.   }
  311.   if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  312.   {
  313.     namespace pop
  314.     return #TRUE
  315.   }
  316.   locatenamedrunebook:
  317.     finditem ZBN C_ , #BACKPACKID
  318.     if #FINDKIND <> -1
  319.     {
  320.       event property #FINDID
  321.       if !runbook_name in #PROPERTY
  322.       {
  323.         gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
  324.       }
  325.       else
  326.       {
  327.         ignoreitem #FINDID rbook
  328.         goto locatenamedrunebook
  329.       }
  330.     }
  331.     else
  332.     {
  333.       display ok Cannot locate specified runebook named , #SPC , !runbook_name
  334.       stop
  335.     }
  336.   ignoreitem reset rbook
  337.   namespace pop
  338. return
  339. ;-------------------------------------------------------------------------------
  340. sub TM_RandomRunebookTravel
  341.   namespace push
  342.   namespace local RRT
  343.   set !travelmethod %1
  344.   set !rune1 %2
  345.   set !rune2 %3
  346.   set !runebook %4
  347.   if !rune1 > !rune2
  348.   {
  349.     set !temp !rune2
  350.     set !rune2 !rune1
  351.     set !rune1 !temp
  352.   }
  353.   RunebookTravel_loop1:
  354.     set !random #RANDOM
  355.     set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
  356.     gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
  357.     if #RESULT = #TRUE
  358.       goto RunebookTravel_loop1
  359.   namespace pop
  360. return
  361. ;-------------------------------------------------------------------------------
  362. ; %1 = Method (RE, GA, SJ)
  363. ; %2 = Object Findid
  364. ; returns #TRUE if error, #FALSE for no error
  365. sub TM_TravelFromObject
  366.   namespace push
  367.   namespace local RFR
  368.   set !method %1
  369.   set !object %2
  370.  
  371.   finditem !object C_ , #BACKPACKID
  372.   if !method notin RE_GA_SJ || #FINDKIND = -1
  373.   {
  374.     namespace pop
  375.     return #TRUE
  376.   }
  377.  
  378.   set !oldx #CHARPOSX
  379.   set !oldy #CHARPOSY
  380.   TravelFromObject_loop1:
  381.     if !method = RE
  382.       gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
  383.     if !method = GA
  384.     {
  385.       gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
  386.       set !temp_cnt #SCNT + 10
  387.       repeat
  388.         finditem KEF_OTF_JEF G_0
  389.       until #FINDKIND <> -1 || #SCNT > !temp_cnt
  390.       if #FINDKIND <> -1
  391.       {
  392.         set #LOBJECTID #FINDID
  393.         wait 10
  394.         event macro 17 0
  395.         wait 20
  396.         if #CONTNAME = generic_gump && #CONTSIZE = 420_280
  397.         {
  398.           gosub TM_AdvJournalSync SPELLCAST
  399.           set !clickx #CONTPOSX + 26
  400.           set !clicky #CONTPOSY + 261
  401.           click !clickx !clicky ; click ok
  402.         }
  403.       }
  404.     }
  405.  
  406.     if !method = SJ
  407.       gosub TM_NewCastSpell 210 !object -1 10 30 ; sacred journey until successful
  408.     wait 30
  409.  
  410.     set !tempscnt #SCNT + 10
  411.   WaitforTravel2_loop1:
  412.     gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking your_spirit_lacks
  413.     if #RESULT = #TRUE
  414.     {
  415.       gosub TM_AdvJournalSync SPELLCAST
  416.       set !locindex !locindex + 1
  417.       if !locindex > !locindexend
  418.       {
  419.         namespace pop
  420.         return #TRUE
  421.       }
  422.       goto TravelFromObject_loop1
  423.     }
  424.  
  425.     if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
  426.       goto WaitforTravel2_loop1
  427.   namespace pop
  428. return #FALSE
  429. ;-------------------------------------------------------------------------------
  430. ; %1 - Journal Name
  431. ; %2 - #LPC setting (optional)
  432. ; Brings !_jindex up to the most recent #journal entry
  433. sub TM_AdvJournalSync
  434.   namespace push
  435.   namespace local TM_AdvJS_ , %1
  436.   set !_jindex #jindex + 1
  437.   if %0 > 1
  438.     set !lpc_set %2
  439.   namespace pop
  440.   set !TM_FunctionCalled #TRUE
  441. return
  442. ;-------------------------------------------------------------------------------
  443. ; %1 - Journal Name
  444. ; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
  445. ; %3, %4, %5, etc strings to match
  446. ; returns #TRUE for match, #FALSE for no match
  447. ;  Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
  448. ;  Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
  449. ;  About %2 arguments:
  450. ;    NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
  451. ;    ADVANCE: no spam checking, advances #jindex copy
  452. ;    VALID: invokes SPAM filtering, no advance of #jindex copy
  453. ;    VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
  454. sub TM_AdvJournalScan
  455.   namespace push
  456.   namespace local TM_AdvJS_ , %1
  457.   set !args %2
  458.   set !temp_lpc #LPC
  459.   if !lpc_set = N/A
  460.     set #LPC 1000
  461.   else
  462.     set #LPC !lpc_set
  463.   set !num_args %0
  464.   set !first_arg 3
  465.   if !_jindex = N/A
  466.     set !_jindex #jindex
  467.   if !charname = N/A
  468.   {
  469.     set !charname #CHARNAME
  470.     AdvJournalScan_loop1:
  471.       str pos !charname #SPC
  472.       if #STRRES <> 0
  473.       {
  474.         set !val #STRRES - 1
  475.         str left !charname !val
  476.         set !left #STRRES
  477.         set !val !val + 1
  478.         str del !charname 1 !val
  479.         set !charname !left , _ , #STRRES
  480.         goto AdvJournalScan_loop1
  481.       }
  482.   }
  483.   set !index !first_arg
  484.   repeat
  485.     set !temp_jindex !_jindex
  486.     set !text % . !index
  487.     while !temp_jindex <= #jindex
  488.     {
  489.       scanjournal !temp_jindex
  490.       str pos #JOURNAL !charname 1
  491.       set !namepos #STRRES
  492.       str count #JOURNAL !charname
  493.       set !namecnt #STRRES
  494.       str pos #JOURNAL :_ 1
  495.       set !smcpos #STRRES
  496.       str pos #JOURNAL !text 1
  497.       set !textpos #STRRES
  498.       if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
  499.         set !pass #TRUE
  500.       else
  501.         set !pass #FALSE
  502.       if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
  503.       {
  504.         set !temp_jindex !temp_jindex + 1
  505.         if ADVANCE in !args
  506.           set !_jindex !temp_jindex
  507.         set #LPC !temp_lpc
  508.         namespace pop
  509.         set !TM_FunctionCalled #TRUE
  510.         return #TRUE
  511.       }
  512.       set !temp_jindex !temp_jindex + 1
  513.     }
  514.     set !index !index + 1
  515.   until !index - !first_arg > !num_args - !first_arg
  516.   set #LPC !temp_lpc
  517.   namespace pop
  518.   set !TM_FunctionCalled #TRUE
  519. return #FALSE
  520. ;-------------------------------------------------------------------------------
  521. ; %1 = Gumpname 1
  522. ; %2 = Gumpname 2
  523. ; #TRUE gump occured before timeout
  524. sub GumpWait
  525.   namespace push
  526.   namespace local GW
  527.   wait 10
  528.   set !timedelay #SCNT
  529.   while #SCNT <= !timedelay + 7
  530.   {
  531.     if #CONTNAME = %1 || #CONTNAME = %2
  532.     {
  533.       namespace pop
  534.       return #TRUE
  535.     }
  536.   }
  537.   namespace pop
  538. return #FALSE
  539.  
Title: Re: Trick or treat starter
Post by: Oracle on October 06, 2020, 10:44:41 AM
C2 has an old Trick or  Treater that used a Herald and you could sit in one place in your house and Trick or Treat over and over. EA nixed that method and gave the guy no candy or anything in the following years.   Look at C2's script and see how he dealt with the teleports etc. I loved his candy drop-off system.

ORACLE
Title: Re: Trick or treat starter
Post by: The Ghost on October 06, 2020, 05:42:53 PM
In Ce you was base on your X& Y.  if those change, it mean  you move.    Like I mention,  no need to focus on teleportation. their only account 2.5% of the time. 

So let work on your Travel.
You use this format if you hardcore the rune
gosub TM_TravelFromNamedRunebook RE 1 5 TRICKORTREAT1

Here what you need to answer.
How can you make this into a variable sub.  Which variable will you set.     Your  first variable In you setup sub should be
set %bookname TRICKORTREAT1. 

Which one can be set  to help you increase your recall number.  This will help you if a rune get block as well.


Title: Re: Trick or treat starter
Post by: Gaderian on October 06, 2020, 06:20:52 PM
I agree with The Ghost's suggestion about the rune book name. His way allows you to have multiple books if you want in a future enhancement easily.

Now this looks like it isn't varying where to recall to by rune:
Code: easyuo
  1.       gosub TM_TravelFromNamedRunebook RE 1 5 TRICKORTREAT1
I believe this call for travel from rune book uses the first unblocked rune between 1 to 5, no?

So don't you have to increment your rune number to use so that it is under your control. I have found you need to have good rune locations that are not blocked because there is an error in the recall so that it tries until it succeeds. It is missing a test in the posted version of TM's travel routine where it will try to recall forever to a blocked location. I changed my personal version to get around that, but I wouldn't want to publicly post it. I fear my hack fix could break something else...

So you would have a variable for first rune number and last rune number to use. This way it could have a few runes in case one was blocked.
You would pass a variable for those runes which you increment for each location.

Code: easyuo
  1. ; This will use a pair of runes for each location. It will increment the rune location for the first and last one to use in the book.
  2. ; If you go over the full book, then it resets to the first rune pair.
  3. if _ , %RuneLocStart , _ notin _1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_
  4.  set %RuneLocStart 17 ; this forces a reset
  5. set %RuneLocStart %RuneLocStart + 2
  6. if %RuneLocStart > 16
  7.  set %RuneLocStart 1
  8. set %RuneLocEnd %RuneLocStart + 1
  9. set %BookName TRICKORTREAT1 ; this could be changed as you reset to the beginning rune location in a book...
  10. gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName

Gaderian

Gaderian
Title: Re: Trick or treat starter
Post by: Oracle on October 15, 2020, 06:44:30 PM
HI Baldielocks....

Are you still working on this? I would love to test it for you...Not too much longer until Halloween is over...

Title: Re: Trick or treat starter
Post by: Oracle on October 18, 2020, 05:34:50 PM
;D
TRICK OR TREAT!
:laugh:



Title: Re: Trick or treat starter
Post by: baldielocks on October 20, 2020, 10:16:45 PM
I had to take some time off due to RL world stuffs. Im back and working at it. Thank you very much Gaderian and Ghost for your time and suggestions! Ill have a test done tomorrow I think Oracle
Title: Re: Trick or treat starter
Post by: baldielocks on October 21, 2020, 07:19:12 AM
First, Great news. Neo granted me permission to scavenge subs from his trick or treater, so it will be much easier to do the bank and trash subs!! Thanks NEO!!!!

I finally understood what you were getting at there Gaderian. I was misreading the instructions in the travel sub header, which lead to my confusion. I ASSUMED that the numbers represented the range of the runes in the book, not the range of runes to be used for the recall attempt.
When I ran the script with your suggested changes, I noticed it was skipping every other rune n the book, because of :
Code: [Select]
set %RuneLocStart %RuneLocStart + 2Yet, it worked flawlessly except for not hitting all the runes.
When I changed it to :
Code: [Select]
set %RuneLocStart %RuneLocStart + 1I would always get stuck on the third rune and not change to the fourth.

Here is a decently working version, but you have to dump it every couple of hours.

Need 16 runes to places with 2 or more valid trick or treat targets that are static. Targets must be within 4 tiles for Trick Or Treat to work.


Ill work on adding in NEO's subs later today. One tip, Do not start it standing on your first recall spot. It will get stuck. Start from your home or anywhere and it will be fine.

*heads up for prep* Ill probably call for a 16 bank rune book and a 16 trash rune book as well. Lots of set up I know, but beats getting paged. I just gotta fix the skipping thing.
Title: Re: Trick or treat starter
Post by: Oracle on October 21, 2020, 03:29:07 PM
Thanks, Baldielocks...

In preparation, I am going to make a 16 bank rune book and a 16 trash book, a total of 2 Runebooks then...

I am assuming the rare is the Burning Scarecrow and Skulls?

Are there 16 places to mark for a Trash Can?




Title: Re: Trick or treat starter
Post by: baldielocks on October 21, 2020, 04:25:28 PM
Im trying to figure out how to modify what Gaderian gave me to be less than 16. I think I got it, but will need to test it.

I tested all day, and even only doing half the runes was filling my pack about once pet hour. So figure 6 trash barrels to get a good spread over time.
Title: Re: Trick or treat starter
Post by: Gaderian on October 21, 2020, 07:28:57 PM
You had chosen the Random Rune travel routine, so I was just following your lead with my example/suggestion. The rune "+ 2" logic meant that you setup 2 runes at each location. It would try the first one, but if blocked, then it would try the second one setup for near the first one in the pair.

That means you need 32 runes for 16 locations (16 locations, 2 runes marked close to each other to avoid being blocked as much).

When you reset the starting rune number, you would swap to the next rune book. If the rune book number exceeds your number of rune books, then you reset it to the first one.

So you could have runebooks named:
trickortreat1
trickortreat2
trickortreat3

and either hard code a value for how many runebooks you have
set %NumberRunebooks 3
or inventory the books in your main backpack in a setup routine, which is well beyond the scope of current application.

Now you would increment the runebook index each time it resets the starting rune number...
Then check if your rune book index exceeds %NumberRunebooks, you reset the runebook index to 1.

That could make a nice reusable routine for future scripting projects. ;)

Now as for having less than 16 runes in a book, there is the very obvious line:
Code: easyuo
  1. if %RuneLocStart > 16
  2.  set %RuneLocStart 1
which would get changed to reflect how many runes you have in your book:
Code: easyuo
  1. if %RuneLocStart > 7 ; means 7 rune locations in the book...
  2.  set %RuneLocStart 1

Gaderian


Title: Re: Trick or treat starter
Post by: baldielocks on October 21, 2020, 08:21:59 PM
GOTCHA!!!
I only used the random because that was the only one i could get working. Which was the issue. I couldn't get any of the others to change runes, that is what I was really after.

Lets say I want to do sequential recall then, which is what I tried to do, but couldn't figure out how from the header.
I would much rather randomize my runes in the book at this point and recall sequentially 1- 16. Maybe when I get rid of my scripter pacifier I'll try the random multi book thingy.

While I figure THAT part out, which won't take a lot of code rearranging i think, I have gone ahead and fleshed out the bank and trash routines, with the option (hardcode for now) to save candy or trash it.
This is totally untested. I will not have the time until late tomorrow. If someone brave wants to take a stab, here it is.
Need one rune book with 16 trick or treat target runes named TrickOrTreat1.
One rune book with 16 bank runes named Bank
One rune book with 6 runes to trash barrels named Trash
2 empty bags in your bank (1 if you want to trash the candy)
It'll take about 12 hours to fill a 125 spots, or about 10 specials an hour. ish. I don't have a bank is full option coded, so it's up to you to watch that.
Title: Re: Trick or treat starter
Post by: Gaderian on October 21, 2020, 08:33:35 PM
Here is an example where you have to setup the 4 parameters that get passed... this would need the runebook id changed from XXXXXX to whatever it really is. This would only use the first rune in the book and Recall method.
Code: easyuo
  1. set %Travel_Method RE ; recall
  2. set %RuneFirst 1
  3. set %RuneLast 1
  4. set %RunebookID XXXXXX
  5. gosub TM_TravelFromRunebook %Travel_Method %Runefirst %RuneLast %RunebookID
  6. if #result = #True
  7.  {
  8.  ; error while trying to travel ... probably from bad parmaters passed
  9.  }
  10.  

Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 21, 2020, 08:51:49 PM
ok. I want to advance the rune book by one rune when I run out of targets. As you say (i think) control the variable.
Code: [Select]
finditem HS_IS G_4 ;find trick or treat targets
    if #findcnt = 0 ; Teleported or all targeted, go to next rune in book.
    {
        ignoreitem reset ; clear queue
set %RuneLocStart %RuneLocStart + 1 ; start at first rune? I think this is how?
if %RuneLocStart > 16
 set %RuneLocStart 1
set %RuneLocEnd %RuneLocStart + 1 ;since runelocend is always one greater, should it reset to 1 first?
if %RuneLocEnd > 16
set%RuneLocEnd 1

gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName
    }
Title: Re: Trick or treat starter
Post by: Oracle on October 21, 2020, 10:46:27 PM
Testing .03 version. Have 3 books in my backpack 1. Bank 2. Trash 3. TrickOrTreat1

Starting up the script at the bank and it asks me to target a secure. So I target a bag in my bank box, then it goes to trick or treating but the target stays up. I click on the NPC and then another target cursor comes up. when I T and T all the NPCs it recalls to the next sot, but the same thing it leaves the target still up after it calls out Trick or Treat.
Title: Re: Trick or treat starter
Post by: Gaderian on October 22, 2020, 01:35:48 AM
If you want to advance a single rune then use the Start and End rune location as the same value when you gosub to the TM_Travel... routine.

The only reason to have more than 1 location is if you want it to drop through to an additional rune when it fails.

You must supply both the start and end rune slot number on the gosub line - even if it is a single location that you want to recall to...

If it were me, I would test this out for blocked locations. Login with a second character and have it stand on your recall spot. Or use one of the carpentry red boxes that low level carpenters can make - set that on your recall location and test out the script. When blocked, does it recall indefinitely or does it give up and return "#result = #true" so you can script accordingly?

Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 06:40:29 AM
Oracle, thanks for the test. I broke it last night trying to get fancy and was too tired. I got an extra hour so I fixed and partly tested. I did not test the trash sub, but the bank subs work fine. I updated the script to recalling straight through all locations for the beta file below. I did find a couple of specials ID's I had to add. If you find any, let me know and I'll get the types added. Thanks for testing!! If You find any I missed, post em here and I'll get them added.

still finding stuff I don't have in the specials yet. I know I'm missing the north/south webs. The Type is in the %loot list, but since I don't know what it is, I haven't moved it yet. THis could create a problem if you are dumping the candy, as they are getting dumped too.

Another minor issue is blocked runes. When I change the end location variable to +1, it tries to recall the the blocked rune, then stops. When I have it = the start location, it recalls over and over, then stops. Welcome any advice on this! (hint hint nudge nudge Gaderian)

Title: Re: Trick or treat starter
Post by: Oracle on October 22, 2020, 02:47:54 PM
This is what I found:

The script freezes if an NPC is too far away
When teleported it freezes at the Moongate
There is no option to trash the candy -- the script just asks me to target a secure in my bank box
If the rune is blocked then it casts recall over and over


So far...


Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 03:05:54 PM
Never had the freeze with npc distance. I'll see if I can duplicate so I can fix it.

Waiting for someone WAY smarter than me (which is almost anyone) for advice on the blocked rune. It seems to be getting stuck in the TM random journal sub. I think I may have squashed this by downloading and pasting in a fresh copy of the TM travel sub.

Found and fixed an issue with it begging from the runebook.

Added South facing web type.

I have been running it all day, and frozen once at a moongate after a lag spike. I'm wondering if it is a latency issue. Otherwise, it seems to handle to teleport really well.

TAt the top of the script change %savecandy to #false. Change %trashcandy to #true. That should fix that portion.
Attached an updated betaV2 for you. That will fix some of it I hope.
Title: Re: Trick or treat starter
Post by: Oracle on October 22, 2020, 04:28:46 PM
Which one is the newer one? The 19kb or the smaller one?
Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 04:46:29 PM
The smaller one. I THOUGHT I had deleted the other. My bad! Fixed now.
Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 06:14:43 PM
It will only bank when full, then it cleans out the pack. I got super lucky with the teleport handling, and not on purpose. It turned out the way I set the script up, that either it will recall right after the teleport happens, or it will do an npc scan, return null, and recall to the next rune. Thanks Ghost!

Do you know how to get the item types if you find anything I don't have listed as special yet?
Title: Re: Trick or treat starter
Post by: Oracle on October 22, 2020, 06:17:01 PM
Running great so far -- over 2 hours... I am waiting to see the trash routine.

When it started the first bank run, it did not place anything in the bank. It then went to a Trick or Treat Spot, then a bank, then a Trick or Treat spot -- rinse repeat...

I am watching it -- so it is semi-AFK. when it gets to a rune hat is blocked I manually open the runebook and set the default to the next rune in the book. Don't know how it started on the bank runebook alternating

I watched it Bank the specials but my backpack is full of candy. I think that is why he keeps going to the banks. It is not getting to the trash book

Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 07:06:27 PM
As a double check, is %trashcandy set to #true at the top?
Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 07:57:20 PM
Im working on the trash issue. It's skipping the gosub even though %trashcandy is #true. As a work around, do the second bag option in your bank. It will take up an additional 24 items though.
Okay, got it fixed. Turned out I was being fancy again, and as Ghost would say "KISS!"
I'm not seeing any more recasting with blocked runes. It gets blocked once, then recalls to a random rune. Can you see if it is working now in this version for you?
In Beta V3:
Got rid of %trashcandy. If %savecandy true, it banks it. If false, it trashes it.
Added 4 new special types
Added in bank full protection
Added in backpack full protection
Title: Re: Trick or treat starter
Post by: Gaderian on October 22, 2020, 08:44:56 PM
So starting with BL Trick Or Treat Recall betaV2.txt
First have 65.0 magery skill so you do not fizzle casting recall or it will skip locations.
Now you can rely on a single attempt to recall in the book so you can change the "continually cast" logic by changing "-1" to "1" on the following line:

Modify line number 356 to:
Code: easyuo
  1.       gosub TM_NewCastSpell 31 !rbook 1 10 10 ; recall once (instead of 'until successful')
This will allow a single attempt to cast Recall, so have enough magery skill that you do not fizzle.

If for some reason a person refuses to use recall, in short it needs more changes.
Gate Travel would have a modification to the Travel routine similar to what I am showing for Recall.
The Sacred Journey solution is very simple: soulstone off Chivalry and replace it with 65.0+ magery.
The issues over non-Recall script travel has been discussed in detail in TM's original thread for his travel routines. My summary answer is to apply a soulstone swap to use Recall instead as the wisest solution.

Gaderian


Title: Re: Trick or treat starter
Post by: Oracle on October 22, 2020, 09:02:06 PM
More Trashcan types:

 Set %trashcan JIF_BKF_IIF_HIF_

when it goes to place candy in the trash it starts to lift it over and over -- never placing the item in the trash

It displays the message "You must wait to perm another action"

Title: Re: Trick or treat starter
Post by: baldielocks on October 22, 2020, 09:17:02 PM
Okay, Still having an issue with the blocked rune not advancing. And I am plum out of ideas!

 Gaderian, I'll take a look at the file, but It is so EASY now to get to 65 with book/jewels/skill that I just can't see anyone legitimately griping they cant do the script with no chiv/magery. I can throw in a skill check and a message to say at least 65 magery required.

But FIRST, I really need to fix the blocked rune problem. That seems to be my last major hurdle here.
Title: Re: Trick or treat starter
Post by: Gaderian on October 22, 2020, 10:32:24 PM
Several of the routines are either odd logic or missing conditions/badly structured.

Each sub should always reach a return statement. This isn't necessarily true for the last posted version of your script.

Some subs make some logic assumptions that do not seem to be accurate.

If your character is human, then you find yourself each time you call the find sub when at a new location. The #FIND___ variables are set on the finditem statement, but not modified with the ignoreitem statements.

Here is your routine:
Code: easyuo
  1. sub find
  2.  repeat
  3.   finditem HS_IS_ G_4 ;find trick or treat targets
  4.   if #findid = #charid
  5.    ignoreitem #FINDID
  6.   if #findcnt = 0 ; Teleported or all targeted, go to next rune in book.
  7.    {
  8.    ignoreitem reset ; clear queue
  9.    set %RuneLocStart %RuneLocStart + 1 ; start at first rune
  10.    if %RuneLocStart > 16
  11.     set %RuneLocStart 1
  12.    set %RuneLocEnd %RuneLocStart
  13.    gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName
  14.    gosub find
  15.    }
  16.  
  17.   if #findrep = 2_3_4_5_6
  18.    ignoreitem #FINDID
  19.  until #FINDcnt >= 1 && #findid <> #charid
  20. RETURN

Consider this logic where it returns #true if we went to a new location and do not yet have an NPC, but #false (no error) if we succeeded in locating an NPC.
It has the advantage of not being recursive (calling itself which can be problematic if you are not careful... and there is a limit to how many subs deep you can be in Easyuo)
Code: easyuo
  1. sub find
  2.  set %ReturnValue #false
  3. FindEm:
  4.  finditem HS_IS G_4
  5.  if #findid = #charid || _ , #findrep , _ in _2_3_4_5_6_
  6.   {
  7.   ignoreitem #FINDID
  8.   goto FindEm
  9.   }
  10.  if #findcnt = 0
  11.   {
  12.   ignoreitem reset ; clear queue
  13.   set %RuneLocStart %RuneLocStart + 1 ; start at first rune
  14.   if %RuneLocStart > 16
  15.    set %RuneLocStart 1
  16.   set %RuneLocEnd %RuneLocStart
  17.   gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName
  18.   set %ReturnValue #true
  19.   goto FindEnd
  20.   }
  21. FindEnd:
  22. return %ReturnValue
  23.  
  24.  
That also requires a modification to the mainloop:
Code: easyuo
  1. mainloop:
  2. gosub find
  3. if ! #Result
  4.  gosub trickortreat
  5. goto mainloop

You keep using the same variable for your rune book location so you advance through your NPC runes, bank runes and trash runes. Make separate variables for each type of book.

Dumpit has a few issues.
You advance the end rune location by 3 above the starting rune slot, but do not have a validation that it is still <= 16. I would either set the bank to use random travel and set the range for the book with it's own variables (do not reuse var names here) or make more resilient logic using a single rune slot location. If you are really using 16 bank runes and you wish to pass rune locations that are 3 more than the starting one, then you need to adjust the value where you reset the value to 1. I am keeping your +3 slots but changing the test to make it valid by setting it to 13.

This will pass rune slot locations in pairs as:
1 - 4
2 - 5
3 - 6
...
12 - 15
13 - 16
and then cycle back to the beginning of the rune locations.

If your settings for %savecandy is not #true and %trashcandy is not #true, then the dumpit sub is badly formed. I would argue that you either save or trash the candy (you do not want your backpack filled to the brim), so a single variable using if/else works. I chose to show it with "%savecandy" is #true or #false. Change it to guarantee a return from the sub like this:
Code: easyuo
  1. sub dumpit
  2.  set %BankRuneLocStart %BankRuneLocStart + 1
  3.  if %BankRuneLocStart > 13
  4.   set %BankRuneLocStart 1
  5.  set %BankRuneLocEnd %BankRuneLocStart + 3
  6.  gosub TM_TravelFromNamedRunebook RE %BankRuneLocStart %BankRuneLocEnd %Bankbook
  7.  wait 5
  8.  event macro 3 0 bank
  9.  wait 10
  10.  gosub specials
  11.  if %savecandy = #true
  12.   gosub unload
  13.  else
  14.   gosub trashcan
  15. return

Trashcan eventually will hit #findcnt = 0 and fall out of the subroutine without a proper return. Take advantage of #FINDINDEX which allows you to advance through all items returned by FINDITEM. This will apply to the subroutines Unload and Specials. Here are the 3 routines rewritten:
Code: easyuo
  1. sub trashcan
  2.  set %TrashRuneLocStart %TrashRuneLocStart + 1
  3.  if %TrashRuneLocStart > 6
  4.   set %TrashRuneLocStart 1
  5.  gosub TM_TravelFromNamedRunebook RE %TrashRuneLocStart %TrashRuneLocStart %Trashbook
  6.  wait 5
  7.  finditem %trash G_2
  8.  if #findcnt > 0
  9.   {
  10.   set %trashid #findid
  11.   finditem %loot c_ , #backpackid
  12.   if #findcnt > 0
  13.    {
  14.    for #findindex 1 #findcnt
  15.     {
  16.     exevent drag #findid #findstack
  17.     wait 10
  18.     exevent dropc %trashid
  19.     wait 20
  20.     }
  21.    }
  22.   }
  23. return
  24.  
  25.  
  26. ;C_2 Subs --------------------
  27. sub unload
  28.  finditem %loot c_ , #backpackid
  29.  if #findcnt > 0
  30.   {
  31.   for #findindex 1 #findcnt
  32.    {
  33.    exevent drag #findid #findstack
  34.    wait 10
  35.    exevent dropc %Candystash
  36.    wait 20
  37.    }
  38.   }
  39. return
  40. ;--------------
  41. sub specials
  42.  finditem %specialsonly c_ , #backpackid
  43.  if #findcnt > 0
  44.   {
  45.   for #findindex 1 #findcnt
  46.    {
  47.    exevent drag #findid #findstack
  48.    wait 10
  49.    exevent dropc %Specialstash
  50.    wait 20
  51.    }
  52.   }
  53. return
  54.  

Now you need some additional variable for the various rune setup in the beginning to make sure these have initialized variables:
Make sure there is a space before any comments ';' must be ' ;' or it isn't recognized as a comment... and in the case of %trashcandy it would have a value of "#false;change to false to bank candy" which is not what you want. :)
Code: easyuo
  1. Set %BookName TrickOrTreat1 ; this could be changed as you reset to the beginning rune location in a book...
  2. Set %Bankbook Bank
  3. Set %Trashbook Trash
  4. Set %savecandy #true ;change to true to bank candy
  5. ;Set %trashcandy #false ;change to false to bank candy.
  6. set %RuneLocStart 0
  7. set %BankRuneLocStart 1
  8. set %TrashRuneLocStart 1
  9. ignoreitem #charid

Especially cleaning up the exits from each sub to be clean will make this less buggy. Eliminating the recursion will help smooth out a really dreadful debug situation where you exceed the number of subs that can be 'gosub'ed. Both of these kinds of logic issues make scripts become unresponsive when it happens. Then reproducing it is nearly impossible and debugging EUO scripts when the program no longer responds is enough to make anyone insane. You can stare at the logic and never see why it is flaking out because it is really about what happened in other places. So the short of it is be kind to yourself and:
1) Always make clean subroutines.
2) Ideally code it for a single exit/return.
3) Only code recursion as a last resort - find another logic structure to make your scripting life simpler.

The blocks after FINDITEM where I demonstrate "if #findcnt > 0" and "for #findindex 1 #findcnt" lets you create much simpler code. That for loop using #findindex is all the magic. That is the "top shelf" stuff that you want in your scripting. :)

Finally, here is my hacked version of TM's Travel routines where I fixed my block rune issue:
Code: easyuo
  1. ; This is a snippet showing how I used Recall2Destination
  2.       set %tries 0
  3.       try_library_again_buyer:
  4.       set %tries %tries + 1
  5.       gosub Recall2Destination %RunebookLibrary %LibraryRune1 %LibraryRune2
  6.       if #result = error
  7.        {
  8.        if %tries < 10
  9.         goto try_library_again_buyer
  10.        else
  11.         {
  12.         pause 15s
  13.         set %tries 0
  14.         goto try_library_again_buyer
  15.         }
  16.        }
  17. ; This is the end of that snippet.
  18. ; It would attempt to recall to a blocked location 10 times and then wait for 15 seconds and reset the 10 attempts...
  19.  
  20. sub Recall2Destination
  21.  set %Runebook %1
  22.  set %RuneNumber1 %2
  23.  set %RuneNumber2 %3
  24.  set %ReturnVal OK
  25.  set %charposxy #charposx , _ , #charposy
  26.  set %saveLPC #LPC
  27.  set #LPC 2000
  28.  set %Status Recalling
  29.  gosub Menu_Refresh
  30.  gosub TM_TravelFromRunebook %TravelMethod %RuneNumber1 %RuneNumber2 %RuneBook
  31.  set #LPC %saveLPC
  32.  if #result = #false
  33.   {
  34.   set %RecallTimer #SCNT2 + 100 ; 10 second wait... means failure to arrive
  35.   repeat
  36.    wait 1
  37.   until %charposxy <> #charposx , _ , #charposy || %RecallTimer < #SCNT2
  38.   if %RecallTimer < #SCNT2
  39.    set %ReturnVal error
  40.   }
  41.  else
  42.   set %ReturnVal error
  43. return %ReturnVal
  44.  
  45.  
Here are the routines I revised in TM's travel subs. I consider it a hack with no promises other than it did solve my blocked rune issues.
Code: easyuo
  1. ;-------------------------------------------------------------------------------
  2. ; %1 = spell number
  3. ; %2 = #TARGETID or SELF or NONE
  4. ; %3 = retry count (-1 = cast until successful)
  5. ; %4 = cast delay
  6. ; %5 = recovery delay
  7. sub TM_NewCastSpell
  8.   namespace push
  9.   namespace local NCS
  10.   set !lpc #LPC
  11.   set #LPC 100
  12.   set !whichspell %1
  13.   set !whichtarget %2
  14.   set !castretrymax %3
  15.   set !waitdelay %4
  16.   set !recovery_delay %5
  17.  
  18.   set !castretry 0
  19.   set !temp_ltargetid #LTARGETID
  20.   set !temp_ltargetkind #LTARGETKIND
  21.  
  22.   NewCastSpell_loop1:
  23.     if !castretrymax < 0
  24.       goto NewCastSpell_cont1
  25.     if !castretry > !castretrymax
  26.       goto NewCastSpell_end1
  27.     NewCastSpell_cont1:
  28.       gosub TM_AdvJournalSync SPELLCAST
  29.       set #LTARGETKIND 1
  30.       set #LTARGETID !whichtarget
  31.       set !tempmana #MANA
  32.       event macro 15 !whichspell ; cast the spell
  33.       wait !waitdelay
  34.       set !targettimeout #SCNT + 7
  35.       NewCastSpell_wait1:
  36.         gosub TM_AdvJournalScan SPELLCAST VALID you_have_not_yet mana your_spirit more_reagents
  37.         if #RESULT = #TRUE || #SCNT > !targettimeout
  38.         {
  39.           set !casttimeout #SCNT2 + !recovery_delay
  40.           repeat
  41.           until #SCNT2 > !casttimeout     ; finish up cast delay
  42.           set !castretry !castretry + 1
  43.           goto NewCastSpell_loop1
  44.         }
  45.         if !whichtarget = NONE
  46.           goto NewCastSpell_skip1
  47.         if #TARGCURS = 1
  48.           goto NewCastSpell_targ1
  49.         goto NewCastSpell_wait1 ; wait for target cursor
  50.  
  51.   NewCastSpell_targ1:
  52.     if !whichtarget = SELF
  53.       event macro 23
  54.     else
  55.       event macro 22
  56.  
  57.   NewCastSpell_skip1:
  58.     wait 5
  59.     set !casttimeout #SCNT2 + !recovery_delay
  60.     NewCastSpell_skip2:
  61.       if !whichspell >= 0 && !whichspell <= 63 ; Magery
  62.       {
  63.         gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents
  64.       }
  65.       else
  66.       {
  67.         set !cont #FALSE  ; Chivalry, Necromancy, etc
  68.         finditem !whichtarget *
  69.         if !whichtarget in SELF_NONE || #FINDKIND <> -1
  70.           set !cont #TRUE
  71.  
  72.         if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
  73.           set #RESULT #TRUE
  74.         else
  75.           set #RESULT #FALSE
  76.       }
  77.       repeat
  78.       until #SCNT2 > !casttimeout     ; finish up cast delay
  79.       if #RESULT = #TRUE
  80.       {
  81.         if !castretrymax > -1
  82.         {
  83.           set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
  84.           if !castretry > !castretrymax
  85.             goto NewCastSpell_end1
  86.         }
  87.         goto NewCastSpell_loop1
  88.       }
  89.       if #SCNT2 <= !casttimeout     ; finish up cast delay
  90.         goto NewCastSpell_skip2
  91.   NewCastSpell_end1:
  92.     set #LTARGETID !temp_ltargetid
  93.     set #LTARGETKIND !temp_ltargetkind
  94.     set #LPC !lpc
  95.     namespace pop
  96. return
  97. ;-------------------------------------------------------------------------------
  98. ; %1 = Method (RE, GA, SJ)
  99. ; %2 = index location within runebook (1-16)
  100. ; %3 = index location within runebook (1-16), try up to this point
  101. ; %4 = runebook item id
  102. ; returns #TRUE if error, #FALSE for no error
  103. sub TM_TravelFromRunebook
  104.   namespace push
  105.   namespace local RFR
  106.   set #LTARGETKIND 1
  107.   set !method %1
  108.   set !locindex %2
  109.   set !locindexend %3
  110.   set !rbook %4
  111.  
  112.   finditem !rbook C_ , #BACKPACKID
  113.   if !method notin RE_GA_SJ || #FINDKIND = -1
  114.   {
  115.     namespace pop
  116.     return #TRUE
  117.   }
  118.   if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  119.   {
  120.     namespace pop
  121.     return #TRUE
  122.   }
  123.   if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  124.   {
  125.     namespace pop
  126.     return #TRUE
  127.   }
  128.  
  129.   TravelFromRunebook_loop1:
  130.     set #LOBJECTID !rbook
  131.     set #LTARGETKIND 1
  132.     event macro 17 0
  133.     gosub GumpWait generic_gump generic_gump
  134.  
  135.     set !runeclickx 140 ; page 1, rune 1
  136.     set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
  137.     if !locindex > 8
  138.     {
  139.       set !runeclickx 310 ; page 2, rune 1
  140.       set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
  141.     }
  142.     set !runeclicky #CONTPOSY + 196
  143.     click !runeclickx !runeclicky
  144.     wait 5
  145.  
  146.     set !runeclicky #CONTPOSY + 24
  147.     set !runeclickx #CONTPOSX + 164 ; page 1 set to default
  148.     if !locindex % 2 = 0
  149.     {
  150.       set !runeclickx #CONTPOSX + 305 ; page 2 set to default
  151.     }
  152.     click !runeclickx !runeclicky
  153.     wait 5
  154.     set !oldx #CHARPOSX
  155.     set !oldy #CHARPOSY
  156.     if !method = RE
  157.       gosub TM_NewCastSpell 31 !rbook 1 10 10 ; recall until successful
  158.     if !method = GA
  159.     {
  160.       gosub TM_NewCastSpell 51 !rbook 1 10 20 ; gate until successful
  161.       set !temp_cnt #SCNT + 10
  162.       repeat
  163.         finditem KEF_OTF_JEF G_0
  164.       until #FINDKIND <> -1 || #SCNT > !temp_cnt
  165.       if #FINDKIND <> -1
  166.       {
  167.         set #LOBJECTID #FINDID
  168.         wait 10
  169.         event macro 17 0
  170.         wait 20
  171.         if #CONTNAME = generic_gump && #CONTSIZE = 420_280
  172.         {
  173.           gosub TM_AdvJournalSync SPELLCAST
  174.           set !clickx #CONTPOSX + 26
  175.           set !clicky #CONTPOSY + 261
  176.           click !clickx !clicky ; click ok
  177.         }
  178.       }
  179.     }
  180.  
  181.     if !method = SJ
  182.       gosub TM_NewCastSpell 210 !rbook 1 10 30 ; sacred journey until successful
  183.     wait 30
  184.  
  185.     set !tempscnt #SCNT + 10
  186.   WaitforTravel_loop1:
  187.     gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks
  188.     if #RESULT = #TRUE
  189.     {
  190.       gosub TM_AdvJournalSync SPELLCAST
  191.       set !locindex !locindex + 1
  192.       if !locindex > !locindexend
  193.       {
  194.         namespace pop
  195.         return #TRUE
  196.       }
  197.       goto TravelFromRunebook_loop1
  198.     }
  199.     if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
  200.       goto WaitforTravel_loop1
  201.  
  202.   if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
  203.   {
  204.     set !clickx #CONTPOSX + 120
  205.     set !clicky #CONTPOSY + 60
  206.     click !clickx !clicky mc r
  207.     wait 5
  208.   }
  209.   namespace pop
  210. ;  click 401 254 n
  211. return #FALSE
  212. ;------------------------------------------------

My blocked recall rune is not a copy/paste solution for you, but if you can follow the logic it demonstrates a potential solution.

Oracle and I have run this code probably 30,000 times or more. I am pretty sure he can also vouch that it functions as it came from my library donation script that he helped me debug.

Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 23, 2020, 11:24:12 AM
Gaderian, thanks for taking all that time to explain! I put it to good use. I won't say I have mastery over the "For" loop, but I at least get it now. In V5, I finally got a header on it. Added in ALL your suggestions and proofed them. Seems good so far.
I ran into an issue that I don't see a ready way to fix.
I made the change from -1 to 1 on RE casting. It now changes rune to the next one (%runelocstart + 1) for %RuneLocEnd. It does recall successfully! YAY!!! :D
BUT......
After if does it once, it has to use it every time thereafter. This is because %RunelocStart doesn't increment up with the change. How do I force it to skip a location to get caught back up?

Other changes:
Added in bank and pack full protection. If bank is full of items, it will skip banking specials and just dump candy in the trash.
Added 1 ID type for scarecrow.

To Do:
Fix the blocked recall rune increment.

Add in a halt command if the bank is full AND the pack is > 101 items. SInce there are 24 candy types, after you get to 102 specials in bag, you start recalling a lot. I played with the logic operators some and had a hard time getting it to work so far. Don't know how to find / set how many items are in pack.

Add in bank box gump detection. Go to next rune if bank did not open. Sometimes, latency will cause you to teleport away (due to a trick) AFTER you recalled to bank, leaving you stuck dragging items at the moongate. I know the gump is sizex 180, sizey 240. Playing with the logic operators I was unable to get it to work though. For example, I used This and it wound up in a loop, going back to dumpit.
Code: [Select]
sub dumpit
 If %BankFull = #true
 gosub trashcan
set %BankStart %BankStart + 1
if %BankStart > 16
 set %BankStart 1
set %BankEnd %BankStart + 1
gosub TM_TravelFromNamedRunebook RE %BankStart %BankEnd %Bankbook
wait 5
event macro 3 0 bank
wait 10
if #contsizex <> 180
{
gosub dumpit ; recall back and make sure toon is at bank

}





Title: Re: Trick or treat starter
Post by: Oracle on October 23, 2020, 01:47:46 PM
V5:
No Blocked runes so far
It's not trashing the candy - it stands by the trash can for a couple of seconds and then recalls away
Goes to a bank every 3-4 trick or treat runs
Title: Re: Trick or treat starter
Post by: Gaderian on October 23, 2020, 02:15:55 PM
Looks like you implemented most of the suggestions above.

I have 2 things that can help further:
1) use some indentation rules as a standard to increase readability. If you are uncertain how to do that, at least use the 'auto indent' feature in the Scriptuo executable.
2) the start/end rune slots in the book is a little odd - it has an ending rune location after what your documentation states is needed

Here is an example from your find subroutine:
Code: easyuo
  1. sub find
  2.  set %ReturnValue #false
  3. FindEm:
  4.  finditem HS_IS G_4
  5.  if #findid = #charid || _ , #findrep , _ in _2_3_4_5_6_
  6.   {
  7.   ignoreitem #FINDID
  8.   goto FindEm
  9.   }
  10.  if #findcnt = 0
  11.   {
  12.   ignoreitem reset ; clear queue
  13.   set %RuneLocStart %RuneLocStart + 1 ; start at first rune
  14.   if %RuneLocStart > 16
  15.    set %RuneLocStart 1
  16.   set %RuneLocEnd %RuneLocStart + 1
  17.   gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName
  18.   set %ReturnValue #true
  19.   goto FindEnd
  20.   }
  21. FindEnd:
  22. return %ReturnValue

You increment %RuneLocStart
You test if it is > 16 and if so, then reset to 1
now you set the %RuneLocEnd as %RuneLocStart + 1

When %RuneLocStart is the values 1 to 15 this is great as you pass 2 possible rune locations before it gives up.
You pass:
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16

But notice what happens when the %RuneLocStart = 16:
it checks if it is > 16 (it is not) so it does not reset to 1...
now it sets %RuneLocEnd to 16 + 1 = 17... oops
There is no 17th slot in the book.

Your test for if %RuneLocStart > _number_ should be the last slot number - how many in the range you want to use.
So "if %RuneLocStart > 15" and "set %RuneLocEnd %RuneLocStart + 1" is sound logic
Similar for the trash rune where you have 6... it should probably be 5 when it resets and then + 1 for the range to pass...

If slot number 15 is not blocked, it would never get to try slot 16. So what would be a good way to get it to pass 16 and the %RuneLocStart, but not 17 as %RuneLocEnd? (I will leave that as an exercise for you to try to work out...)

As for your question about advancing when a blocked rune was found:
1) consider setting a flag before the gosub TM_Travel... routine,
2) Modify the TM_ routine to set the flag if you hit a blocked rune,
3) check the flag when returning from the TM_ routine and increment your rune slot variable - if necessary.
That would be the cleanest way and it would apply to all 3 of your rune slot uses without stomping on a different one.


Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 23, 2020, 04:41:35 PM
MY BAD. I did the huge change and misnamed the trashcan variable. Fixed. Plus, I added another crystal skull to the specials.

As to runuo, I miss using it. My virus checker, bit defender, detects it as having a virus though, so I havent found a way to download it. See screenshot.
Title: Re: Trick or treat starter
Post by: Gaderian on October 23, 2020, 06:05:20 PM
I meant using the Scriptuo application http://www.scriptuo.com/index.php?action=downloads;cat=1 (http://www.scriptuo.com/index.php?action=downloads;cat=1) here on this site by TrailMyx. It has some nice syntax checking and auto-indent features among other useful options for scripting. If I mis-stated it as something else, my apologies...

That is a great tool to help with writing EUO code...

Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 23, 2020, 07:28:48 PM
Same result Gaderian, Bit Defender virus alert. I used SUO extensivley years ago. But after I returned I could no longer download it.
Title: Re: Trick or treat starter
Post by: Gaderian on October 23, 2020, 10:02:24 PM
you may need to specifically 'white list' the scriptuo executable.
Title: Re: Trick or treat starter
Post by: baldielocks on October 24, 2020, 04:14:42 AM
How do I break out of the  "for" loop? I want to throw in a journal scan for full back pack. I tried a few times, and couldn't come up with a clean way to do it.
Code: [Select]
sub specials
 finditem %specialsonly c_ , #backpackid
 if #findcnt > 0
  {
  for #findindex 1 #findcnt
   {
   exevent drag #findid #findstack
   wait 10
   exevent dropc %Specialstash
   wait 20
   }
  }
return

Code: [Select]
sub specials
 finditem %specialsonly c_ , #backpackid
 if #findcnt > 0
  {
  for #findindex 1 #findcnt
   {
gosub Journalscan NAME ; as a place holder   
exevent drag #findid #findstack
   wait 10
   exevent dropc %Specialstash
gosub Journal sync name valid container_full
if full
{
do something
}
   wait 20
   }
  }
return
Title: Re: Trick or treat starter
Post by: The Ghost on October 24, 2020, 10:34:55 AM

If you look , most of the sub are geniric, so we can use it  in multiple situation.

This is what I use in my Crafting Factory build

This can look like this for you
gosub TG_ClearPack %loot %hardcode_dump_candy_bag

Code: [Select]
;======================= TG_ClearPack =============================

; gosub TG_ClearPack (Item) (Container)
sub TG_ClearPack
; %1 Item to move
; %2 Container to move too
Namespace Push
   Namespace Local TGCP
  finditem %1 C_ , #backpackid
  if #findcnt < 1 2
    NameSpace Pop
    return
  for #findindex 1 #findcnt
  {
      exevent drag #findid #findstack
    exevent dropc %2
    wait 20
  }
  Namespace Pop
return
; ---------------------------------------------------------------------

 Most of Lumber/mining script have this kind of build.   TM/ C2/ MWnic   just to name a few have those basic sub. 





Title: Re: Trick or treat starter
Post by: Gaderian on October 25, 2020, 06:06:00 AM
The 2 keywords that help you control loops are break and continue.

Continue = skip processing left in the loop and advance to the next iteration of the loop
break = end the current loop immediately


Gaderian
Title: Re: Trick or treat starter
Post by: baldielocks on October 25, 2020, 09:18:01 AM
Thanks Gaderian!!! I'll work on that.

You mentioned "setting a flag" for advancing the rune if there is a block. I am struggling to comprehend that. I THINK you mean like you showed me with the find sub, but put it down in the TM travel sub..  Since there is already a flag there in the find loop, how do I differentiate?