Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Coragin

Pages: 1 ... 46 47 [48] 49 50
706
I just posted this new one up at noon today, did you try it last night or this newest one?

Guess I should start putting revisions and versions on it huh?

707
Script Debug / Re: Need help with pet transfer sub.
« on: May 29, 2009, 08:46:23 AM »
_C2_

In the taming sub I put in a rename (well used MD's) and it renames all new tames to "a" and put this code into my donation tamer.  It works well, all I needed was the x y for the click.

Code: [Select]
Sub turnin
gosub Gate                                   ; gates you and pets to moonglow zoo box
donationbox:
set #lTargetID TIGFQMD                       ; sets the ID of the donation box
set #lTargetTYPE CUD                         ; Sets Type of ID of the donation box
turninpets:
event macro 1 0 a transfer                     ;
wait 1s
event macro 22 0                                     ;
if #followers >=%varTurnins                                   ;<---IS this correct????
  {                                                  ;
  goto turninpets
  }
gosub ReturnToTame
return

708
Okay here is a more complete script, if anyone wants to try and run it for me and debug, please do so.  I have NO IDEA if it will work or not, I hope so.  Anyone want to look it over and see if it works?

EDIT: Fixed some sytax errors and some other stuff.

Code: [Select]
;=================================================================
; Script Name: Coragin's Animal Tame and Donate Script
; Author: Coragin
; Version: 1.0 Beta
; Shard OSI / FS: OSI
; Revision Date: 5/24/2009
; Purpose: Tame wolves, Polar Bears and Slimes and gate them to moonglow for turn in.
; will also tame white wolves as they can also be donated.
;=================================================================
; Special Instructions: Set up a Runebook as follows
; Book Name: Zoo
; Slot One: Your Home (Name Rune HOME or Home)(Can also set this to an Inn, just name it Home)
; Slot Two: Rune for Donation Box at Moonglow Zoo (Name this rune Zoo 1)
; Slot Three: Rune for your first taming location.  Call it Zoo 2.
; Slot Four: Rune for your first taming location.  Call it Taming 1.
; Other Slots: Additional Rune locations for taming. Taming 2, Taming 3, Taming 4 ect ect
;
; I take no credit for the Sub-Routines used that were written by others, if your Sub is
; being used and I have not given credit, please let me know and I will correct it.
;
; Thanks: Cerveza, TM, C2 & ScriptUO.com for all their help and tutorials!
; Thanks to TrailMyx, for his Runebook Subs I am using in this script.
;=================================================================
gosub TM_AddUnderscore #CHARNAME
gosub InitAnimalTaming ;this will go in beginning at setup
set %charname #RESULT
set %varTunrins #maxFol ;sets the amount of turn ins to max control slots

set %tameable PG_VF_VE_GE_ZD_ ;Sets the ID of monsters && Animals to Tame

set %varUseMount FALSE ;Variable if you are using a mount or not.

if #UseMount = #TRUE ;if you are using a horse, this will set the
   { ;turn in amount to 4.
   set %varTunrins ( %varTurnins - 1 ) ;
   } ;This script not set for mounts with more than
gosub setup ;one control slot.

mainloop:

if controlslots >=5 ; This checks for control slots to be full for turn in
  gosub turnin ;
gosub dispatch ; This is for the Taming Section
GoTo mainloop

;===================================================================
;
; This is the Sub for gating to moonglow and turning in pets.
;
;===================================================================

Sub turnin
gosub Gate ;gates you and pets to moonglow zoo box
donationbox:
set #lObjectID TIGFQMD ;sets the ID of the donation box
set #lObjectTYPE CUD ; Sets Type of ID of the donation box
turninpets:
event macro 1 0 a transfer ;
wait 1s
event macro 22 0
if controlslots >=varTurnins
  GoTo turninpets:
gosub ReturnToTame
return

;================================================================================
;
; This will return you to taming area after a turn in.
;
;================================================================================

Sub ReturnToTame
gosub TM_TravelFromNamedRunebook RE 3 Zoo ; gate using Zoo runebook at rune 3
wait 5s
return

;================================================================================
;
; This is the Gate Sub for Gating to Moonglow && Checking to make sure you gated
;
;================================================================================

Sub Gate
event Macro 1 0 All follow me
gosub TM_TravelFromNamedRunebook GA 2 Zoo ; gate using Zoo runebook at rune 2
return

;=====================================================================================
;
; TM's Runebook Travel Sub
;
;=====================================================================================
sub TM_NewCastSpell
  namespace push
  namespace local NCS
  set !lpc #LPC
  set #LPC 100
  set !whichspell %1
  set !whichtarget %2
  set !castretrymax %3
  set !waitdelay %4
  set !recovery_delay %5

  set !castretry 0
  set !temp_ltargetid #LTARGETID
  set !temp_ltargetkind #LTARGETKIND

  NewCastSpell_loop1:
    if !castretrymax < 0
      goto NewCastSpell_cont1
    if !castretry > !castretrymax
      goto NewCastSpell_end1
    NewCastSpell_cont1:
      gosub TM_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 pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
  namespace push
  namespace local RFR
  set #LTARGETKIND 1
  set !method %1
  set !locindex %2
  set !locindexend %3
  set !rbook %4

  finditem !rbook C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }
  if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }

  TravelFromRunebook_loop1:
    set #LOBJECTID !rbook
    set #LTARGETKIND 1
    event macro 17 0
    gosub GumpWait generic_gump generic_gump

    set !runeclickx 140 ; page 1, rune 1
    set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
    if !locindex > 8
    {
      set !runeclickx 310 ; page 2, rune 1
      set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
    }
    set !runeclicky #CONTPOSY + 196
    click !runeclickx !runeclicky
    wait 5

    set !runeclicky #CONTPOSY + 24
    set !runeclickx #CONTPOSX + 164 ; page 1 set to default
    if !locindex % 2 = 0
    {
      set !runeclickx #CONTPOSX + 305 ; page 2 set to default
    }
    click !runeclickx !runeclicky
    wait 5
    set !oldx #CHARPOSX
    set !oldy #CHARPOSY
    if !method = RE
      gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_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 n
return #FALSE
;------------------------------------------------
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
  namespace push
  namespace local TFNR
  set !method %1
  set !start_index %2
  set !end_index %3
  set !runbook_name %4
  if !method notin RE_GA_SJ
  {
    namespace pop
    return #TRUE
  }
  if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  locatenamedrunebook:
    finditem ZBN C_ , #BACKPACKID
    if #FINDKIND <> -1
    {
      event property #FINDID
      if !runbook_name in #PROPERTY
      {
        gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
      }
      else
      {
        ignoreitem #FINDID rbook
        goto locatenamedrunebook
      }
    }
    else
    {
      display ok Cannot locate specified runebook named , #SPC , !runbook_name
      stop
    }
  ignoreitem reset rbook
  namespace pop
return
;-------------------------------------------------------------------------------
sub TM_RandomRunebookTravel
  namespace push
  namespace local RRT
  set !travelmethod %1
  set !rune1 %2
  set !rune2 %3
  set !runebook %4
  if !rune1 > !rune2
  {
    set !temp !rune2
    set !rune2 !rune1
    set !rune1 !temp
  }
  RunebookTravel_loop1:
    set !random #RANDOM
    set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
    gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
    if #RESULT = #TRUE
      goto RunebookTravel_loop1
  namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = Object Findid
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromObject
  namespace push
  namespace local RFR
  set !method %1
  set !object %2

  finditem !object C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }

  set !oldx #CHARPOSX
  set !oldy #CHARPOSY
  TravelFromObject_loop1:
    if !method = RE
      gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_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 pop
return #FALSE
;-------------------------------------------------------------------------------
; %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
  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 #TRUE
return #FALSE
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
  namespace push
  namespace local GW
  wait 10
  set !timedelay #SCNT
  while #SCNT <= !timedelay + 7
  {
    if #CONTNAME = %1 || #CONTNAME = %2
    {
      namespace pop
      return #TRUE
    }
  }
  namespace pop
return #FALSE

;====================================================================================================
;
;  TESTING OF TAMING PORTION ALPHA!
;
;====================================================================================================
sub Dispatch
    set %finditems N/A
    if %finddist <> N/A
    {
        if %findtype in %tameable
            gosub Taming %findid
    }
return


sub InitAnimalTaming
    event macro 8 2 ; open status
    wait 1s
    set %statusposx #contposx
    set %statusposy #contposy
    set %charstartx #charposx
    set %charstarty #charposy
    set %charstartz #charposz
    set %tameid N/A
return

sub Taming
    if #followers >= #maxfol
    {
        gosub turnin
    }
    finditem %1 G_16
    if #findkind = -1
        return
    set %tameid #findid
    set %tametype #findtype
    set %tamedist #finddist
    if %tameid <> #ltargetid
        event exmsg %tameid 3 30 Pick me!
    set %tamecount 0
    gosub TameAnimal
    set %tameid N/A
return

sub TameAnimal
    TamingLoop:
    finditem %tameid G_16
    if #findkind = -1
        return
    if #finddist > 3
    {
        menu set status Too Far Away
        gosub PathfindWait #findx #findy #findz
        if %moveres = error
        {
            gosub TamingIgnore temp %tameid
            return
        }
        if #menubutton = ignorecurrent
        {
            set #menubutton N/A
            gosub TamingIgnore perm %tameid
            return
        }
        gosub ScriptIdletime
        goto TamingLoop
    }
    set %tamecount %tamecount + 1
    set %tamejournal #jindex + 1
    set %tamefollow #followers
    set #ltargetid %tameid
    set #ltargetkind 1
    event macro 13 35 ; animal taming
    target 2s
    event macro 22 0 ; last target
    gosub TamingMonitor
    if #result = success
    {
        gosub TamingRename
        return
    }
    if #result = retry
    {
        goto TamingLoop
    }
    goto TamingLoop
return

sub TamingRename
    contpos 5 30
    wait 5
    set %screenx #contposx + 130
    set %screeny #contposy + 20
    click %screenx %screeny
    for %i 1 5
    {
        key RIGHT
    }
    for %i 1 20
    {
        key BACK
    }
    msg a$
    event macro 1 0 All follow me
return

sub TamingMonitor
    TamingMonitorLoop:
    if #followers > %tamefollow
        return success
    if #systime > %tametimer
        return retry
    finditem %tameid G_16
    if #findkind = -1
        return retry
    if #finddist > 3 && #systime > %movetimer
    {
        menu get dontmove
        if #menures = #false
            event pathfind #findx #findy #findz
        set %movetimer #systime + 1500
    }
    goto TamingMonitorLoop
return

; clickScreenXYZ by ScriptFellow modded by Roadkill
; Mods by UncleDave
sub GetScreenXY
    set %1 ( %1 - #charposx ) * 22  ; world x-coordinate
    set %2 ( #charposy - %2 ) * 22  ; world y-coordinate
    set %3 ( %3 - #charposz ) * 4   ; world z-coordinate
    if %0 < 4 || %4 = N/A
        set %4 0                    ; x displacement, added to screen coordinate
    if %0 < 5 || %5 = N/A
        set %5 35                   ; y displacement, added to screen coordinate
    set %screenx #clileft + #clixres / 2 + %1 + %2 + %4
    set %screeny #clitop + #cliyres / 2 + %1 - %2 - %3 + %5
    set %offscreen #true
    if %screenx > #clileft &&
        + %screeny > #clitop &&
        + %screenx < ( #clileft + #clixres ) &&
        + %screeny < ( #clitop + #cliyres )
    {
        set %offscreen #false
        ;click %screenx %screeny F
    }
return

; GetYDisplacementForAnimType by Roadkill
; Mods by UncleDave
sub GetAnimalDisplacement
    set %screenydisp -32
    if %tametype in GE_ZD_L_M_TF__IG_NG__ZF_PF_EG_CO_TG_PG_VD
        set %screenydisp -25
    if %tametype in AH
        set %screenydisp -45
    if %tametype in DG_AG_WC_RF_WG_TC
        set %screenydisp -15
return

sub GetTargetId
    set #ltargetid N/A
    set #targcurs 1
    GetTargetIdLoop:
    if #targcurs = 1
        goto GetTargetIdLoop
return

sub PathfindWait
    set %moveres unknown
    if #charposx = %1 && #charposy = %2
    {
        set %moveres success
        return
    }
    set %js #jindex
    event pathfind %1 %2 %3
    wait 10
    set %je #jindex
    for %ji %js %je
    {
        scanjournal %ji
        if pathfinding in #journal
        {
            set %movex #charposx
            set %movey #charposy
            set %movetimer #systime + 500
            PathfindWaitLoop:
            if #systime < %movetimer
                goto PathfindWaitLoop
            if %movex = %1 && %movey = %2
            {
                set %moveres success
                return
            }
            if %movex = #charposx && %movey = #charposy
            {
                set %moveres stopped
                return
            }
            set %movex #charposx
            set %movey #charposy
            set %movetimer #systime + 500
            goto PathfindWaitLoop
        }
        if can't_get_there in #journal
        {
gosub dispatch
        }
    }
return

709
Okay, I take no credit for any of this code, it is from Uncle Daves auto taming script.  I stripped them out, removing a lot of stuff that had to do with menus and taming ignores and such.  This will all be called from the main script I am writing for moonglow turnin (see other thread for variables.

What I want to know is if the basic functionality is here to start working if called correctly from the main script.  I added in my own lines of code for namechanges and if 5 followers will return to turnin sub.

Well here it is, keeping in mind I am totally new, but this look like it will work.  If there is code or set up variables needed please point them out.

I think everything is here that is needed to pathfind with taming and to rename pet to "a"

ClickScreenxyz code from Scriptfellow and Roadkill, modified by Uncle Dave
GetDisplacement for animal type by Roadkill
Original subs by Uncle Dave (before I edited them a lot)

Code: [Select]
gosub InitAnimalTaming ;this will go in beginning at setup
sub Dispatch
    set %finditems N/A
    if %finddist <> N/A
    {
        if %findtype in %tameable
            gosub Taming %findid
    }
return


sub InitAnimalTaming
    event macro 8 2 ; open status
    wait 1s
    set %statusposx #contposx
    set %statusposy #contposy
    set %charstartx #charposx
    set %charstarty #charposy
    set %charstartz #charposz
    set %tameid N/A
return

sub Taming
    if #followers >= #maxfol
    {
        gosub turnin
    }
    finditem %1 G_16
    if #findkind = -1
        return
    set %tameid #findid
    set %tametype #findtype
    set %tamedist #finddist
    if %tameid <> #ltargetid
        event exmsg %tameid 3 30 Pick me!
    set %tamecount 0
    gosub TameAnimal
    set %tameid N/A
return

sub TameAnimal
    TamingLoop:
    finditem %tameid G_16
    if #findkind = -1
        return
    if #finddist > 3
    {
        gosub PathfindWait #findx #findy #findz
        goto TamingLoop
    }
    set %tamefollow #followers
    set #ltargetid %tameid
    set #ltargetkind 1
    event macro 13 35 ; animal taming
    target 2s
    event macro 22 0 ; last target
    goto TamingLoop
return

sub TamingRename
    contpos 5 30
    wait 5
    set %screenx #contposx + 130
    set %screeny #contposy + 20
    click %screenx %screeny
    for %i 1 5
    {
        key RIGHT
    }
    for %i 1 20
    {
        key BACK
    }
    msg a$
    event macro 1 0 All follow me
return

sub TamingMonitor
    TamingMonitorLoop:
    if #followers > %tamefollow
        return success
    if #systime > %tametimer
        return retry
    finditem %tameid G_16
    if #findkind = -1
        return retry
    if #finddist > 3 && #systime > %movetimer
    {
        menu get dontmove
        if #menures = #false
            event pathfind #findx #findy #findz
        set %movetimer #systime + 1500
    }
    goto TamingMonitorLoop
return

; clickScreenXYZ by ScriptFellow modded by Roadkill
; Mods by UncleDave
sub GetScreenXY
    set %1 ( %1 - #charposx ) * 22  ; world x-coordinate
    set %2 ( #charposy - %2 ) * 22  ; world y-coordinate
    set %3 ( %3 - #charposz ) * 4   ; world z-coordinate
    if %0 < 4 || %4 = N/A
        set %4 0                    ; x displacement, added to screen coordinate
    if %0 < 5 || %5 = N/A
        set %5 35                   ; y displacement, added to screen coordinate
    set %screenx #clileft + #clixres / 2 + %1 + %2 + %4
    set %screeny #clitop + #cliyres / 2 + %1 - %2 - %3 + %5
    set %offscreen #true
    if %screenx > #clileft &&
        + %screeny > #clitop &&
        + %screenx < ( #clileft + #clixres ) &&
        + %screeny < ( #clitop + #cliyres )
    {
        set %offscreen #false
        ;click %screenx %screeny F
    }
return

; GetYDisplacementForAnimType by Roadkill
; Mods by UncleDave
sub GetAnimalDisplacement
    set %screenydisp -32
    if %tametype in GE_ZD_L_M_TF__IG_NG__ZF_PF_EG_CO_TG_PG_VD
        set %screenydisp -25
    if %tametype in AH
        set %screenydisp -45
    if %tametype in DG_AG_WC_RF_WG_TC
        set %screenydisp -15
return

sub GetTargetId
    set #ltargetid N/A
    set #targcurs 1
    GetTargetIdLoop:
    if #targcurs = 1
        goto GetTargetIdLoop
return

sub PathfindWait
    set %moveres unknown
    if #charposx = %1 && #charposy = %2
    {
        set %moveres success
        return
    }
    set %js #jindex
    event pathfind %1 %2 %3
    wait 10
    set %je #jindex
    for %ji %js %je
    {
        scanjournal %ji
        if pathfinding in #journal
        {
            set %movex #charposx
            set %movey #charposy
            set %movetimer #systime + 500
            PathfindWaitLoop:
            if #systime < %movetimer
                goto PathfindWaitLoop
            if %movex = %1 && %movey = %2
            {
                set %moveres success
                return
            }
            if %movex = #charposx && %movey = #charposy
            {
                set %moveres stopped
                return
            }
            set %movex #charposx
            set %movey #charposy
            set %movetimer #systime + 500
            goto PathfindWaitLoop
        }
        if can't_get_there in #journal
        {
gosub dispatch
        }
    }
return

710
Script Debug / Re: Need help with pet transfer sub.
« on: May 28, 2009, 06:46:57 PM »
Okay went there with charger of the fallen mount.  Tamed 4 polar bears, renamed them all to "a" gated them to moonglow zoo.  said "A transfer" and it brought up the target, clicked the donation box and it transfer one, repeated "a transfer" and targeted the box and another was transfer.  Did this through the whole four I had, all the same name and all 4 transfer without having to single left click for the dialog to "select transfer" and didnt have to open the donation box either.  So pretty much like this...

say: a transfer
click yes
say: a transfer
click yes
say: a transfer
click yes
say: a transfer
click yes

done.

So basicly I will just need a sub with the taming to change all names to "a" or "pet" or "donation" or whatever variable is set and have the sub gate to moonglow and do what I just said...

Code: [Select]
sub Donate
petdonate:
macro 1 0 pet transfer
wait 1s
set lobjectTYPE donation box ect
set lobjectID donation box
(click yes on gump)
if #followers >1 goto petdonate:

That seem right for just the turn in?

As I said, it seems a lot easier to do this and change the pets name at the time of taming.  Probably faster too, no dialogs.

711
Script Debug / Re: Need help with pet transfer sub.
« on: May 28, 2009, 06:29:40 PM »
Wow, that just confused the hell out of me lol.  Damn pain killers fogging my perception I think.

One thing I do know in fact is if you pets have a name WITHOUT spaces, say just "bear" you can say "bear transfer" and it will bring up a target cursor.  Then click the donation box and it will bring up the yes/no dialog, click yes and there you have it, pet is donated.  No need to even open the donation box, which is cool.

Now, I think if you have 5 pets with all the same name, it will just randomly pick one to donate.  That or you will get 5 confirmation boxes that you need to click yes to.  I am going to check this, because if it works like that, no need to even use the transfer dialog by clicking on the pet just "macro 1 0 petname transfer". 

Then all I need is a sub to rename the pets as they are tamed.  To me this seems MUCH easier.  I will check that right now and let you know.

712
Scripting Chat / Thank you and Im sorry for all the questions.
« on: May 28, 2009, 12:51:50 PM »
Hi everyone,

Your resident newb here.  First I want to throw some big props to those who have been so patient for helping me in learning scripting, I know I could have picked something smaller and easier for my first project.  But, I want to let you guys know how much it is appreciated, all your time and knowledge being passed on to me.

I also want to apologize for my newbness and the ton of questions that you guys could have easily told me to find out on my own or use search, where I would probably find what I am looking for after hours of looking and referencing.  But you guys have shown that community is valuable to you and helping (so long as people are willing to help themselves) is important. 

So, while I am writing this script and researching what I want to do with it and you guys helping me with all my questions, I wanted to write this little letter of Thanks and Apology for you guys that are helping me so much. 

I truly hope one day to be a great contributor to this community and this is the start I was trying for, learning and wonderful teachers such as yourselves.

Thank you so much.

and one day I will make a signature!

~Coragin

713
Script Debug / Re: Need help with pet transfer sub.
« on: May 28, 2009, 12:31:20 PM »
for pet transfer to box the pets context menu never changes.  for that reason i would just make it short and sweet-

use:
exevent popup %pet (or #findid of pet to be transfered)

then use container positions to do a simple click.

I will show you tonight how i do it in my zoo donator.

Will this do the single left click as well?  And does %pet mean the pet name or will it grab a random pet closest?  #findid, does this need to be the type or id?  As in I can just put in the PG_VF_VE_GE_ZD_ of types of pets that would be had here?

So if setup went like this
Code: [Select]
set %varTameID PG_VF_VE_GE_ZD_

then the line to transfer could be this...
Code: [Select]
exevent popup #TameID
set %CONTEXT_Transfer 593758

Is this correct?

714
Script Debug / Need help with pet transfer sub.
« on: May 28, 2009, 11:21:21 AM »
Okay, so if your reading this, you probably know I am writing a zoo turn in script as my first script.  Yah yah I know, starting out a little big.  So here is what I am working on now, turning in bears/wolves/slimes to the donation box.  Now, I found TM's context menu handler subs, having a little problem understanding it.  Because I dont want to call ALL the context menu options, just the one for transfer and click the donation box, then click yes on the "Are you sure you want to transfer this?".  Original topic is here: http://www.scriptuo.com/index.php?topic=79.0

Code: [Select]

  set %CONTEXT_Transfer 593758  ; is the code for transfer a pet.

Here is my sub for the transfer

Code: [Select]
Sub turnin
gosub Gate ;gates you and pets to moonglow zoo box
donationbox:
set #lObjectID TIGFQMD         ;sets the ID of the donation box
set #lObjectTYPE CUD ; Sets Type of ID of the donation box
event macro ;double click donation box
event macro
turninpets:
                                                        ; Transfer code will go here.
if controlslots >=varTurnins                    ; This checks if your are done with your pet turn ins...
  GoTo turninpets:                                ; if your not done it will return to the turninpets:

return

Now, my question is, what variables do I need from TM's context menu and where do I put them?  Im still a little confused to some parts of scripting.  But I am learning fast.  So, can anyone help with this?

Do I need to put anything at the beginning of the script for config purposes?  Or can it be included in this turn in sub?  I would like it to just randomly target a tame, bring up the context menu, click transfer and target the donation box.

715
Script development tools / Re: Trailmyx's Runebook/Spellcast Subs
« on: May 28, 2009, 10:08:40 AM »
Code: [Select]
;     gosub TM_TravelFromNamedRunebook GA 1 2 LUMBERJACKING1 ; gate using LUMBERJACKING1 runebook starting at rune 1
Reading FTW!!!  I dont know how I missed that.  Sorry.

716
Script development tools / Re: Trailmyx's Runebook/Spellcast Subs
« on: May 28, 2009, 10:00:33 AM »
I read the instructions, I didnt see anything on if this supports gate travel.  Does it?

If so, what is the syntax for it instead of recall?

717
Thank you to the following people weather they know it or not.  I either used your code to get this working or you gave me great help or both!

TrailMyx, MadDog, Cerveza, _C2_, Ultima, Uncle Dave for some snippits from his taming script.

I will start off by saying I used the Tutorial section as my template for this, thanks are already in place for those who helped so far.  I am sure more will come.

The only thing I ask is if the code is working, please let me know it works before you suggest a "Better Way".  I am really trying to learn on my own here by reading code and using snippits.  I appreciate ALL help and it is helping me more than you know, but I need to know if my original code is working properly before I do it a better way.  Thank you.

If you feel or know there is a change in what I have so far, please let me know by quoting the code to change in its original form, then what it should be changed to and why.  Possibly highlighting the changed areas.  Please do not get ahead of what I already have here if it can be helped, I am learning and want to learn, I dont want this done for me.  If/When I get stuck I will post a question for that area.  But suggestions to my current work in progress is greatly appreciated, as well as corrections if needed.

Again, please remember, I am learning.  Once I get all the subs and check areas in place and working, I will then fill in and correct the areas one at a time.

Edit 5/29 7:00pm EST:  Think I MAY have fixed the taming problem, give it a go and let me know how it turns out.

Edit 5/29 3:00am EST: Trying Maddogs Subs for taming from his Jhelom Taming Script.

Edit 5/28 12:00 pm:  Fixed a lot of syntax errors, think I fixed the problem that was only turning in one pet at moonglow at a time.  Things I need to work on, one make sure it works, which I cant check now.  And have someone verify some of my syntax, to make sure it is correct.

Are the following lines/subs correct in syntax?  Including and most important, the followers portion.

Code: [Select]
Sub turnin
gosub Gate                                 ; gates you and pets to moonglow zoo box
donationbox:
set #lTargetID TIGFQMD                      ; sets the ID of the donation box
set #lTargetTYPE CUD                        ; Sets Type of ID of the donation box
turninpets:
event macro 1 0 a transfer                    ;
wait 1s
event macro 22 0                                     ;
if #followers >=%2                                   ;<---IS this correct????
  {                                                  ;
  goto turninpets
  }
gosub ReturnToTame
return

Or would it work better with the original Mount checking code which is..

Code: [Select]
set %varUseMount True                    ;Variable if you are using a mount or not.

if #UseMount = #TRUE                    ;if you are using a horse, this will set the
   {                                ;turn in amount to 4.
   set %varTurnins ( %varTurnins - 1 )      ;
   }                                ;This script not set for mounts with more than

Which would make it look like this

Code: [Select]
Sub turnin
gosub Gate                                 ; gates you and pets to moonglow zoo box
donationbox:
set #lTargetID TIGFQMD                      ; sets the ID of the donation box
set #lTargetTYPE CUD                        ; Sets Type of ID of the donation box
turninpets:
event macro 1 0 a transfer                    ;
wait 1s
event macro 22 0                                     ;
if #followers >=%varTurnins                                   ;<---IS this correct????
  {                                                  ;
  goto turninpets
  }
gosub ReturnToTame
return

Now the other problem I am having is, when it runs out of tamables its not moving around like it is supposed to, can someone check that area and see if all is in place?  

Code: [Select]
;==================================================================================================
; Script Name: Coragin's Animal Tame and Donate Script
; Author: Coragin
; Version: 1.1 Beta
; Shard OSI / FS: OSI
; Revision Date: 5/29/2009 7pm
; Purpose: Tame wolves, Polar Bears and Slimes and gate them to moonglow for turn in.
; will also tame white wolves as they can also be donated.
;==================================================================================================
; Special Instructions: Set up a Runebook as follows
; Book Name: Zoo
; Slot One: Your Home (Name Rune HOME or Home)(Can also set this to an Inn, just name it Home)
; Slot Two: Rune for Donation Box at Moonglow Zoo (Name this rune Zoo 1)
; Slot Three: Rune for your first taming location.  Call it Zoo 2.
; Slot Four: Rune for your first taming location.  Call it Taming 1.
; Other Slots: Additional Rune locations for taming. Taming 2, Taming 3, Taming 4 ect ect
; Supports only 4 FOUR Taming locations!  
; Will ALWAYS return to taming area ONE!
; When you start the script recall to your first taming area rune!!!
;
; I take no credit for the Sub-Routines used that were written by others, if your Sub is
; being used and I have not given credit, please let me know and I will correct it.
;
; Thanks: Cerveza, TM, C2 & ScriptUO.com for all their help and tutorials!
; Thanks to TrailMyx, for his Runebook Subs I am using in this script.
;==================================================================================================
gosub TM_AddUnderscore #CHARNAME               ;This is required by TM's Runebook Subs
set %charname #RESULT                          ;This is required by TM's Runebook Subs
gosub InitAnimalTaming                 ;this will go in beginning at setup
gosub AnimalType
set %varTunrins #maxFol                 ;sets the amount of turn ins to max control slots

set %name a                           ;What pet will be renamed to
set %wait 15                         ;Adjust this if you are running into lag issues
set %spot 1
set #lpc 100

set %tameable PG_VF_VE_GE_ZD_              ;Sets the ID of monsters && Animals to Tame
set %tamingtypes PG_VF_VE_GE_ZD_

set %varUseMount True                    ;Variable if you are using a mount or not.

if #UseMount = #TRUE                    ;if you are using a horse, this will set the
   {                                ;turn in amount to 4.
   set %varTunrins ( %varTurnins - 1 )      ;
   }                                ;This script not set for mounts with more than
gosub setup                            ;one control slot.

display yesno Would you like to add a short delay between taming/renaming to $ make the script appear less "Twinkle McNugget"? (Note: Script will be slower!)
if #dispres = YES
   set %scriptdelay 60
if #dispres = NO
   set %scriptdelay 0

chooseSkill Anim
set %initialtaming #skill
chooseSkill Anil
set %initiallore #skill

set %currenttaming %initialtaming
set %currentlore %initiallore

firstspot:


mainloop:

if #followers >=%varTunrins
  {                                        ; This checks for control slots to be full for turn in
  gosub turnin
  }                                      ;
gosub CheckForStatusBar
gosub AnimalType
gosub Tame                              ; This is for the Taming Section
goto mainloop

;====================================================================================================
;
;  TESTING OF TAMING PORTION ALPHA!  I take no credit for this area, copied from Maddog's Jhelom Taming.
;
;====================================================================================================

sub CheckForStatusBar
while #followers = N/A
   {
   event macro 8 2
   wait 5
   }
return

sub AnimalType
   set %tamingtypes PG_VF_VE_GE_ZD_          ;Polar Bears, White Wolves, Slimes
return

sub Tame
findItem %tamingtypes G_12
;If not found, move to next spot
if #findCnt < 1
   {
   gosub NextSpot
   return
   }
set %tamingtarget #findid
WalkToTarget:
if #finddist > 2
   {
   event PathFind #findx #findy #findz
   wait 20
   goto WalkToTarget
   }
;Attempt to tame animal (include safety timer)
AttemptToTame:
event macro 13 35                             ;Use Taming Skill
target 5s                                     ;Wait for targeting cursor
set #ltargetid %tamingtarget                  ;Set taming target to last target
set #ltargetkind 1
event macro 22 0                              ;Target taming target
set %scantimer #scnt + 20                     ;Saftey timer for poor scripting on my part!
ScanForSuccess:
scanjournal 1
if #scnt > %scantimer                         ;Check to see if saftey timer has expired
   {
   deletejournal
   return
   }
if seems_to_accept_you_as_master in #journal
   {
   deletejournal
   goto PetRename
   }
if animal_looks_tame_already in #journal
   {
   deletejournal
   ignoreitem %tamingtarget
   return
   }
if fail_to_tame_the_creature in #journal
   {
   deletejournal
   wait 5
   goto AttemptToTame
   }
if are_too_far_away_to_continue_taming in #journal
   {
   deletejournal
   goto WalkToTarget
   }
if animal_is_too_angry_to_continue_taming in #journal
   {
   deletejournal
   ignoreitem %tamingtarget
   return
   }
finditem %tamingtarget
if #finddist > 2
   {
   event PathFind #findx #findy #findz
   }
goto ScanForSuccess
return

sub NextSpot
if #followers >=2
   {
   event Macro 3 0 All follow me
   }
if %rune = 1
   {
   gosub TM_TravelFromNamedRunebook GA 4 4 Zoo ; gate using Zoo runebook at rune 4
   set %rune 2
   return
   }
if %rune = 2
   {
   gosub TM_TravelFromNamedRunebook GA 5 5 Zoo ; gate using Zoo runebook at rune 5
   set %rune 3
   return
   }
if %rune = 3
   {
   gosub TM_TravelFromNamedRunebook GA 6 6 Zoo ; gate using Zoo runebook at rune 6
   set %rune 4
   return
   }
if %rune = 4
   {
   gosub TM_TravelFromNamedRunebook GA 3 3 Zoo ; gate using Zoo runebook at rune 3
   set %rune 1
   return
   }
return

sub PetRename
event macro 3 0 all follow me                      ; whisper all follow me so you dont have to chase the released pet
wait %scriptdelay
exevent RenamePet %tamingtarget %name              ;Rename tamed target to "tamed"
wait %wait
return
;===================================================================
;
; This is the Sub for gating to moonglow and turning in pets.
;
;===================================================================

Sub turnin
gosub Gate                                 ; gates you and pets to moonglow zoo box
donationbox:
set #lTargetID TIGFQMD                      ; sets the ID of the donation box
set #lTargetTYPE CUD                        ; Sets Type of ID of the donation box
turninpets:
event macro 1 0 a transfer                    ;
wait 1s
event macro 22 0
if #followers >=%1
  {
  goto turninpets:
  }
gosub ReturnToTame
return

;================================================================================
;
; This will return you to taming area after a turn in.
;
;================================================================================

Sub ReturnToTame
if #followers >=%2
  {
  event macro 1 0 All follow me
  }
gosub TM_TravelFromNamedRunebook GA 3 3 Zoo       ; gate using Zoo runebook at rune 3
wait 5s
return

;================================================================================
;
; This is the Gate Sub for Gating to Moonglow && Checking to make sure you gated
;
;================================================================================

Sub Gate
event Macro 1 0 All follow me
gosub TM_TravelFromNamedRunebook GA 2 2 Zoo         ; gate using Zoo runebook at rune 2
wait 5s
return

;=====================================================================================
;
; TM's Runebook Travel Sub
;
;=====================================================================================
sub TM_NewCastSpell
  namespace push
  namespace local NCS
  set !lpc #LPC
  set #LPC 100
  set !whichspell %1
  set !whichtarget %2
  set !castretrymax %3
  set !waitdelay %4
  set !recovery_delay %5

  set !castretry 0
  set !temp_ltargetid #LTARGETID
  set !temp_ltargetkind #LTARGETKIND

  NewCastSpell_loop1:
    if !castretrymax < 0
      goto NewCastSpell_cont1
    if !castretry > !castretrymax
      goto NewCastSpell_end1
    NewCastSpell_cont1:
      gosub TM_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 pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
  namespace push
  namespace local RFR
  set #LTARGETKIND 1
  set !method %1
  set !locindex %2
  set !locindexend %3
  set !rbook %4

  finditem !rbook C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }
  if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }

  TravelFromRunebook_loop1:
    set #LOBJECTID !rbook
    set #LTARGETKIND 1
    event macro 17 0
    gosub GumpWait generic_gump generic_gump

    set !runeclickx 140 ; page 1, rune 1
    set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
    if !locindex > 8
    {
      set !runeclickx 310 ; page 2, rune 1
      set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
    }
    set !runeclicky #CONTPOSY + 196
    click !runeclickx !runeclicky
    wait 5

    set !runeclicky #CONTPOSY + 24
    set !runeclickx #CONTPOSX + 164 ; page 1 set to default
    if !locindex % 2 = 0
    {
      set !runeclickx #CONTPOSX + 305 ; page 2 set to default
    }
    click !runeclickx !runeclicky
    wait 5
    set !oldx #CHARPOSX
    set !oldy #CHARPOSY
    if !method = RE
      gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_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 n
return #FALSE
;------------------------------------------------
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
  namespace push
  namespace local TFNR
  set !method %1
  set !start_index %2
  set !end_index %3
  set !runbook_name %4
  if !method notin RE_GA_SJ
  {
    namespace pop
    return #TRUE
  }
  if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  locatenamedrunebook:
    finditem ZBN C_ , #BACKPACKID
    if #FINDKIND <> -1
    {
      event property #FINDID
      if !runbook_name in #PROPERTY
      {
        gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
      }
      else
      {
        ignoreitem #FINDID rbook
        goto locatenamedrunebook
      }
    }
    else
    {
      display ok Cannot locate specified runebook named , #SPC , !runbook_name
      stop
    }
  ignoreitem reset rbook
  namespace pop
return
;-------------------------------------------------------------------------------
sub TM_RandomRunebookTravel
  namespace push
  namespace local RRT
  set !travelmethod %1
  set !rune1 %2
  set !rune2 %3
  set !runebook %4
  if !rune1 > !rune2
  {
    set !temp !rune2
    set !rune2 !rune1
    set !rune1 !temp
  }
  RunebookTravel_loop1:
    set !random #RANDOM
    set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
    gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
    if #RESULT = #TRUE
      goto RunebookTravel_loop1
  namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = Object Findid
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromObject
  namespace push
  namespace local RFR
  set !method %1
  set !object %2

  finditem !object C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }

  set !oldx #CHARPOSX
  set !oldy #CHARPOSY
  TravelFromObject_loop1:
    if !method = RE
      gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_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 pop
return #FALSE
;-------------------------------------------------------------------------------
; %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
  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 #TRUE
return #FALSE
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
  namespace push
  namespace local GW
  wait 10
  set !timedelay #SCNT
  while #SCNT <= !timedelay + 7
  {
    if #CONTNAME = %1 || #CONTNAME = %2
    {
      namespace pop
      return #TRUE
    }
  }
  namespace pop
return #FALSE

718
Scripting Chat / Re: Can a scirpt have this basic type of setup....
« on: May 28, 2009, 06:15:15 AM »
Cerveza,

Thats the thread I did read.  I know some lines are not needed, but as I said, its easier for me to read and kinda like what I am used to.  Since from what I can tell, it wont slow the script down, its just a few extra lines of code.  At least until I get the hang of things, then clean my scripts up. 

So, I do know that they are not needed, but my question is, will it work?  My guess is yes.

719
Scripting Chat / Can a scirpt have this basic type of setup....
« on: May 28, 2009, 05:58:33 AM »
I didnt search, because I am SURE no one has ever asked this before, unless they wrote scripts for macroquest 2.

But can I set up my script to work like this....
(code snips taken from TM's how-to step one thread.
Code: [Select]

;Header
;==================================

set %var1 500
set %books 3
gosub setup
gosub main

Sub main
mainloop:
;all the crap the script does here
GoTo mainloop

Sub setup
;all setup commands here
return

This is very similar to MQ2, except most commands use the "/" switch, in MQ2 it would look like this...

Code: [Select]


|Header
|==================================

/set %var1 500
/set %books 3
/call setup
/call main

Sub main
:mainloop
|all the crap the script does here
/goto :mainloop

Sub setup
;all setup commands here
/return

As you can see, it is mostly the same, | used instead of ; and / use with goto and return and : used at the beginning of the command instead of the end.  But for the most part, it is exactly the same and if commands always started with the / switch.

But back to my main question, can the first code I wrote be used?  Having a Sub Main that is called right after setup that is the main loop?  I know for most of you, this is redundant, since just adding in loop: or mainloop: is basicly the same thing, but for me, it makes it easier to read.

I do not have access to UO ATM so I can make a simple script to test if it would work, thats why I am asking here, so I can learn.

Finally, am I the only one who thinks it would be much easier to have the command to use a skill like this

Code: [Select]
useskill hiding

Instead of...

Code: [Select]
macro (numbers here)

720
General UO Chat / Re: Last Target BoS Trick or for chopping boards?
« on: May 28, 2009, 05:13:20 AM »
TYVM TM.  :)

Pages: 1 ... 46 47 [48] 49 50