Author Topic: Trick or treat starter  (Read 23903 times)

0 Members and 1 Guest are viewing this topic.

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Trick or treat starter
« on: October 05, 2020, 08:56:16 AM »
+1
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
;-------------------------------------------------------------------------------

« Last Edit: October 05, 2020, 09:13:24 AM by baldielocks »

Offline Crisis

  • Global Moderator
  • *
  • *
  • Posts: 3084
  • Activity:
    2.6%
  • Reputation Power: 42
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +566
  • Referrals: 2
    • View Profile
Re: Trick or treat starter
« Reply #1 on: October 05, 2020, 01:27:13 PM »
+1
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.

Offline Gaderian

  • Elite
  • *
  • *
  • Posts: 490
  • Activity:
    0%
  • Reputation Power: 10
  • Gaderian barely matters.Gaderian barely matters.
  • Respect: +283
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #2 on: October 05, 2020, 01:40:20 PM »
+1
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

"Go ahead ask me: 'Should I use hard waits or timers?'"
You say:"Should I"
Gaderian:"Timers!"
You Say:"use hard waits or timers?"

The serious side of timer use is illustrated here: http://www.scriptuo.com/index.php?topic=12094.msg101926#msg101926

However, every time I go back and look at this [AutoLooter] script, I realize I had wrote it in my zen state of EUO scripting - so it makes my brain hurt.

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +556
  • Referrals: 0
    • View Profile
Re: Trick or treat starter
« Reply #3 on: October 05, 2020, 05:32:53 PM »
+1
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
« Last Edit: October 05, 2020, 05:36:04 PM by The Ghost »

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Re: Trick or treat starter
« Reply #4 on: October 05, 2020, 09:02:20 PM »
+1
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.

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Re: Trick or treat starter
« Reply #5 on: October 05, 2020, 10:52:21 PM »
+1
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.  
« Last Edit: October 06, 2020, 07:30:34 AM by TrailMyx »

Offline Oracle

  • Hero Member
  • *
  • Posts: 888
  • Activity:
    0%
  • Reputation Power: 14
  • Oracle barely matters.Oracle barely matters.
  • Gender: Male
  • We always want something that we cannot have...!
  • Respect: +188
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #6 on: October 06, 2020, 10:44:41 AM »
-1
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
ORACLE
Get me a Straw...because I suck...!
PIXEL CRACK -- Love it! Crave it! Want it! Got to have it!

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +556
  • Referrals: 0
    • View Profile
Re: Trick or treat starter
« Reply #7 on: October 06, 2020, 05:42:53 PM »
+1
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.



Offline Gaderian

  • Elite
  • *
  • *
  • Posts: 490
  • Activity:
    0%
  • Reputation Power: 10
  • Gaderian barely matters.Gaderian barely matters.
  • Respect: +283
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #8 on: October 06, 2020, 06:20:52 PM »
+2
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
"Go ahead ask me: 'Should I use hard waits or timers?'"
You say:"Should I"
Gaderian:"Timers!"
You Say:"use hard waits or timers?"

The serious side of timer use is illustrated here: http://www.scriptuo.com/index.php?topic=12094.msg101926#msg101926

However, every time I go back and look at this [AutoLooter] script, I realize I had wrote it in my zen state of EUO scripting - so it makes my brain hurt.

Offline Oracle

  • Hero Member
  • *
  • Posts: 888
  • Activity:
    0%
  • Reputation Power: 14
  • Oracle barely matters.Oracle barely matters.
  • Gender: Male
  • We always want something that we cannot have...!
  • Respect: +188
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #9 on: October 15, 2020, 06:44:30 PM »
+1
HI Baldielocks....

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

ORACLE
Get me a Straw...because I suck...!
PIXEL CRACK -- Love it! Crave it! Want it! Got to have it!

Offline Oracle

  • Hero Member
  • *
  • Posts: 888
  • Activity:
    0%
  • Reputation Power: 14
  • Oracle barely matters.Oracle barely matters.
  • Gender: Male
  • We always want something that we cannot have...!
  • Respect: +188
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #10 on: October 18, 2020, 05:34:50 PM »
+1
;D TRICK OR TREAT! :laugh:



ORACLE
Get me a Straw...because I suck...!
PIXEL CRACK -- Love it! Crave it! Want it! Got to have it!

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Re: Trick or treat starter
« Reply #11 on: October 20, 2020, 10:16:45 PM »
+1
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

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Re: Trick or treat starter
« Reply #12 on: October 21, 2020, 07:19:12 AM »
+1
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.

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
BL Trick Or Treat Recall.txt
« Last Edit: October 21, 2020, 07:40:40 AM by baldielocks »

Offline Oracle

  • Hero Member
  • *
  • Posts: 888
  • Activity:
    0%
  • Reputation Power: 14
  • Oracle barely matters.Oracle barely matters.
  • Gender: Male
  • We always want something that we cannot have...!
  • Respect: +188
  • Referrals: 3
    • View Profile
Re: Trick or treat starter
« Reply #13 on: October 21, 2020, 03:29:07 PM »
+1
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?




« Last Edit: October 21, 2020, 04:26:37 PM by Oracle »
ORACLE
Get me a Straw...because I suck...!
PIXEL CRACK -- Love it! Crave it! Want it! Got to have it!

Offline baldielocksTopic starter

  • Sr. Member
  • *
  • Posts: 301
  • Activity:
    0%
  • Reputation Power: 4
  • baldielocks has no influence.
  • Gender: Male
  • Respect: +94
  • Referrals: 5
    • View Profile
Re: Trick or treat starter
« Reply #14 on: October 21, 2020, 04:25:28 PM »
+1
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.
« Last Edit: October 21, 2020, 04:33:11 PM by baldielocks »

Tags: