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

0 Members and 1 Guest are viewing this topic.

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 #30 on: October 22, 2020, 08:44:56 PM »
+1
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


"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 #31 on: October 22, 2020, 09:02:06 PM »
+1
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"

« Last Edit: October 22, 2020, 09:32:43 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 #32 on: October 22, 2020, 09:17:02 PM »
+1
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.

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 #33 on: October 22, 2020, 10:32:24 PM »
+1
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
"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 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 #34 on: October 23, 2020, 11:24:12 AM »
+1
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

}






There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
BL Trick Or Treat Recall betaV5.txt
« Last Edit: October 23, 2020, 01:31:18 PM 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 #35 on: October 23, 2020, 01:47:46 PM »
+1
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
ORACLE
Get me a Straw...because I suck...!
PIXEL CRACK -- Love it! Crave it! Want it! Got to have it!

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 #36 on: October 23, 2020, 02:15:55 PM »
+1
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
« Last Edit: October 23, 2020, 02:32:53 PM by 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 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 #37 on: October 23, 2020, 04:41:35 PM »
+1
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.

There are 2 attachment(s) in this post. You must register and post an acceptable introduction to download
2020-10-23.png
BL Trick Or Treat Recall betaV6.txt
« Last Edit: October 23, 2020, 04:55:12 PM by baldielocks »

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 #38 on: October 23, 2020, 06:05:20 PM »
+1
I meant using the Scriptuo application 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
"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 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 #39 on: October 23, 2020, 07:28:48 PM »
+1
Same result Gaderian, Bit Defender virus alert. I used SUO extensivley years ago. But after I returned I could no longer download it.

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
2020-10-23 (1).png

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 #40 on: October 23, 2020, 10:02:24 PM »
+1
you may need to specifically 'white list' the scriptuo executable.
"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 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 #41 on: October 24, 2020, 04:14:42 AM »
+1
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

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 #42 on: October 24, 2020, 10:34:55 AM »
+1

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. 






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 #43 on: October 25, 2020, 06:06:00 AM »
+1
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
"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 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 #44 on: October 25, 2020, 09:18:01 AM »
+1
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?

Tags: