Official ScriptUO EasyUO Scripts > Script Debug

Trick or treat starter

<< < (2/9) > >>

baldielocks:
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 ---mainloop:gosub findgosub trickortreatgoto mainloop sub find  repeat    wait 1    finditem HS_IS G_4    if #findcnt = 0    {        ignoreitem reset       gosub TM_TravelFromNamedRunebook RE 1 5 TRICKORTREAT1    }    if #findid = #charid        ignoreitem #FINDID    if #findrep = 2_3_4_5_6       ignoreitem #FINDID  until #FINDcnt >= 1 && #findid <> #charidRETURN Sub trickortreatmsg $trick or treatset #ltargetid #findidset #ltargetkind 1repeat wait 1until #targcurs <> 0targetEvent macro 22 0ignoreitem #ltargetidreturn ;=================================================================; Script Name: TrailMyx's Runebook/Spellcast Subs; Author: TrailMyx; Version: 2.5; Shard OSI / FS: OSI / FS; Revision Date: 09/27/2007; Purpose:;   Runebook subs to manage your runebook travel needs.  You need either to know;   the runebook ID or runebook name.;; Subroutines:;     TM_NewCastSpell - casts spells with appropriate waits, delays, retrys.;     TM_TravelFromRunebook - Uses specified runbook #FINDID to travel from .  If a location is blocked;                             the next location will be tried until success.;     TM_TravelFromNamedRunebook - Same as TM_TravelFromRunebook, but allows you to specify a runebook name;;  Examples:;     gosub TM_NewCastSpell 31 !rbook 10 20 20 ; recall;     gosub TM_TravelFromRunebook RE 1 3 %runebookid ; travel (recall) to location from #FINDID runebook using slots 1-3;     gosub TM_TravelFromNamedRunebook GA 1 2 LUMBERJACKING1 ; gate using LUMBERJACKING1 runebook starting at rune 1;     gosub TM_RandomRunebookTravel SJ 1 6 %runebookid  ; Randomly choose a rune from 1-6 in runebook;     gosub TM_TravelFromObject RE %runeid ; travels to rune specified by %runeid;;  Use of these subrountes is allowed, but please give me (TrailMyx) credit somewhere in your script.;;  Release History:;     2.0 - Initial public release;     2.1 - Bug in TM_FindValidTextNoAdvance, added return value to TM_TravelFromNamedRunebook;     2.2 - Bug in TM_NewCastSpell when mana gets too low;     2.3 - Better spellcasting for chivalry, necro;           Added TM_TravelFromNamedRunebook;           Added TM_RandomRunebookTravel;     2.4 - Little fix for journal handler;     2.5 - Hack to allow for transport through a red moongate.;;  Requirements:;;    This script requires that you have your character name;    setup in a variable called %charname.  Place this bit of code;    in your script initialization somewhere:;;   gosub TM_AddUnderscore #CHARNAME;   set %charname #RESULT;=================================================================;-------------------------------------------------------------------------------; %1 = spell number; %2 = #TARGETID or SELF or NONE; %3 = retry count (-1 = cast until successful); %4 = cast delay; %5 = recovery delaysub TM_NewCastSpell  namespace push  namespace local NCS  set !lpc #LPC  set #LPC 100  set !whichspell %1  set !whichtarget %2  set !castretrymax %3  set !waitdelay %4  set !recovery_delay %5   set !castretry 0  set !temp_ltargetid #LTARGETID  set !temp_ltargetkind #LTARGETKIND   NewCastSpell_loop1:    if !castretrymax < 0      goto NewCastSpell_cont1    if !castretry > !castretrymax      goto NewCastSpell_end1    NewCastSpell_cont1:      gosub TM_AdvJournalSync SPELLCAST      set #LTARGETKIND 1      set #LTARGETID !whichtarget      set !tempmana #MANA      event macro 15 !whichspell ; cast the spell      wait !waitdelay      set !targettimeout #SCNT + 7      NewCastSpell_wait1:        gosub TM_AdvJournalScan SPELLCAST VALID you_have_not_yet mana your_spirit more_reagents        if #RESULT = #TRUE || #SCNT > !targettimeout        {          set !casttimeout #SCNT2 + !recovery_delay          repeat          until #SCNT2 > !casttimeout     ; finish up cast delay          set !castretry !castretry + 1          goto NewCastSpell_loop1        }        if !whichtarget = NONE          goto NewCastSpell_skip1        if #TARGCURS = 1          goto NewCastSpell_targ1        goto NewCastSpell_wait1 ; wait for target cursor   NewCastSpell_targ1:    if !whichtarget = SELF      event macro 23    else      event macro 22   NewCastSpell_skip1:    wait 5    set !casttimeout #SCNT2 + !recovery_delay    NewCastSpell_skip2:      if !whichspell >= 0 && !whichspell <= 63 ; Magery      {        gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents      }      else      {        set !cont #FALSE  ; Chivalry, Necromancy, etc        finditem !whichtarget *        if !whichtarget in SELF_NONE || #FINDKIND <> -1          set !cont #TRUE         if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there          set #RESULT #TRUE        else          set #RESULT #FALSE      }      repeat      until #SCNT2 > !casttimeout     ; finish up cast delay      if #RESULT = #TRUE      {        if !castretrymax > -1        {          set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful          if !castretry > !castretrymax            goto NewCastSpell_end1        }        goto NewCastSpell_loop1      }      if #SCNT2 <= !casttimeout     ; finish up cast delay        goto NewCastSpell_skip2  NewCastSpell_end1:    set #LTARGETID !temp_ltargetid    set #LTARGETKIND !temp_ltargetkind    set #LPC !lpc    namespace popreturn;-------------------------------------------------------------------------------; %1 = Method (RE, GA, SJ); %2 = index location within runebook (1-16); %3 = index location within runebook (1-16), try up to this point; %4 = runebook item id; returns #TRUE if error, #FALSE for no errorsub TM_TravelFromRunebook  namespace push  namespace local RFR  set #LTARGETKIND 1  set !method %1  set !locindex %2  set !locindexend %3  set !rbook %4   finditem !rbook C_ , #BACKPACKID  if !method notin RE_GA_SJ || #FINDKIND = -1  {    namespace pop    return #TRUE  }  if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16  {    namespace pop    return #TRUE  }  if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16  {    namespace pop    return #TRUE  }   TravelFromRunebook_loop1:    set #LOBJECTID !rbook    set #LTARGETKIND 1    event macro 17 0    gosub GumpWait generic_gump generic_gump     set !runeclickx 140 ; page 1, rune 1    set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )    if !locindex > 8    {      set !runeclickx 310 ; page 2, rune 1      set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )    }    set !runeclicky #CONTPOSY + 196    click !runeclickx !runeclicky    wait 5     set !runeclicky #CONTPOSY + 24    set !runeclickx #CONTPOSX + 164 ; page 1 set to default    if !locindex % 2 = 0    {      set !runeclickx #CONTPOSX + 305 ; page 2 set to default    }    click !runeclickx !runeclicky    wait 5    set !oldx #CHARPOSX    set !oldy #CHARPOSY    if !method = RE      gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful    if !method = GA    {      gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful      set !temp_cnt #SCNT + 10      repeat        finditem KEF_OTF_JEF G_0      until #FINDKIND <> -1 || #SCNT > !temp_cnt      if #FINDKIND <> -1      {        set #LOBJECTID #FINDID        wait 10        event macro 17 0        wait 20        if #CONTNAME = generic_gump && #CONTSIZE = 420_280        {          gosub TM_AdvJournalSync SPELLCAST          set !clickx #CONTPOSX + 26          set !clicky #CONTPOSY + 261          click !clickx !clicky ; click ok        }      }    }     if !method = SJ      gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful    wait 30     set !tempscnt #SCNT + 10  WaitforTravel_loop1:    gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks    if #RESULT = #TRUE    {      gosub TM_AdvJournalSync SPELLCAST      set !locindex !locindex + 1      if !locindex > !locindexend      {        namespace pop        return #TRUE      }      goto TravelFromRunebook_loop1    }    if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )      goto WaitforTravel_loop1   if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook  {    set !clickx #CONTPOSX + 120    set !clicky #CONTPOSY + 60    click !clickx !clicky mc r    wait 5  }  namespace pop  click 401 254 nreturn #FALSE;------------------------------------------------; %1 method; %2 starting index; %3 ending index; %4 runebook namesub TM_TravelFromNamedRunebook  namespace push  namespace local TFNR  set !method %1  set !start_index %2  set !end_index %3  set !runbook_name %4  if !method notin RE_GA_SJ  {    namespace pop    return #TRUE  }  if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16  {    namespace pop    return #TRUE  }  if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16  {    namespace pop    return #TRUE  }  locatenamedrunebook:    finditem ZBN C_ , #BACKPACKID    if #FINDKIND <> -1    {      event property #FINDID      if !runbook_name in #PROPERTY      {        gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location      }      else      {        ignoreitem #FINDID rbook        goto locatenamedrunebook      }    }    else    {      display ok Cannot locate specified runebook named , #SPC , !runbook_name      stop    }  ignoreitem reset rbook  namespace popreturn;-------------------------------------------------------------------------------sub TM_RandomRunebookTravel  namespace push  namespace local RRT  set !travelmethod %1  set !rune1 %2  set !rune2 %3  set !runebook %4  if !rune1 > !rune2  {    set !temp !rune2    set !rune2 !rune1    set !rune1 !temp  }  RunebookTravel_loop1:    set !random #RANDOM    set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )    gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook    if #RESULT = #TRUE      goto RunebookTravel_loop1  namespace popreturn;-------------------------------------------------------------------------------; %1 = Method (RE, GA, SJ); %2 = Object Findid; returns #TRUE if error, #FALSE for no errorsub TM_TravelFromObject  namespace push  namespace local RFR  set !method %1  set !object %2   finditem !object C_ , #BACKPACKID  if !method notin RE_GA_SJ || #FINDKIND = -1  {    namespace pop    return #TRUE  }   set !oldx #CHARPOSX  set !oldy #CHARPOSY  TravelFromObject_loop1:    if !method = RE      gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful    if !method = GA    {      gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful      set !temp_cnt #SCNT + 10      repeat        finditem KEF_OTF_JEF G_0      until #FINDKIND <> -1 || #SCNT > !temp_cnt      if #FINDKIND <> -1      {        set #LOBJECTID #FINDID        wait 10        event macro 17 0        wait 20        if #CONTNAME = generic_gump && #CONTSIZE = 420_280        {          gosub TM_AdvJournalSync SPELLCAST          set !clickx #CONTPOSX + 26          set !clicky #CONTPOSY + 261          click !clickx !clicky ; click ok        }      }    }     if !method = SJ      gosub TM_NewCastSpell 210 !object -1 10 30 ; sacred journey until successful    wait 30     set !tempscnt #SCNT + 10  WaitforTravel2_loop1:    gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking your_spirit_lacks    if #RESULT = #TRUE    {      gosub TM_AdvJournalSync SPELLCAST      set !locindex !locindex + 1      if !locindex > !locindexend      {        namespace pop        return #TRUE      }      goto TravelFromObject_loop1    }     if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )      goto WaitforTravel2_loop1  namespace popreturn #FALSE;-------------------------------------------------------------------------------; %1 - Journal Name; %2 - #LPC setting (optional); Brings !_jindex up to the most recent #journal entrysub 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 #TRUEreturn;-------------------------------------------------------------------------------; %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 copysub 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  if !_jindex = N/A    set !_jindex #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 <= #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 #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 #LPC !temp_lpc  namespace pop  set !TM_FunctionCalled #TRUEreturn #FALSE;-------------------------------------------------------------------------------; %1 = Gumpname 1; %2 = Gumpname 2; #TRUE gump occured before timeoutsub GumpWait  namespace push  namespace local GW  wait 10  set !timedelay #SCNT  while #SCNT <= !timedelay + 7  {    if #CONTNAME = %1 || #CONTNAME = %2    {      namespace pop      return #TRUE    }  }  namespace popreturn #FALSE 

Oracle:
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

The Ghost:
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.


Gaderian:
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 ---      gosub TM_TravelFromNamedRunebook RE 1 5 TRICKORTREAT1I 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 ---; 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.; If you go over the full book, then it resets to the first rune pair.if _ , %RuneLocStart , _ notin _1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_ set %RuneLocStart 17 ; this forces a resetset %RuneLocStart %RuneLocStart + 2if %RuneLocStart > 16 set %RuneLocStart 1set %RuneLocEnd %RuneLocStart + 1set %BookName TRICKORTREAT1 ; this could be changed as you reset to the beginning rune location in a book...gosub TM_TravelFromNamedRunebook RE %RuneLocStart %RuneLocEnd %BookName
Gaderian

Gaderian

Oracle:
HI Baldielocks....

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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version