Author Topic: Shear Sheep, kill and repeat  (Read 19405 times)

0 Members and 2 Guests are viewing this topic.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Shear Sheep, kill and repeat
« on: July 11, 2008, 05:01:47 PM »
+1
TM or anyone else...
Can you look through this for me. Currently, the script finally uses the rune books ( I installed TM's subs ) however, I still think I am missing something as the rune is never advanced. Also, the for loop does not work as it shears, kill, and then waits for more to spawn instead of leaving to another pen.  :(

Code: [Select]

;==============================================================
; Script Name: Sheep Shear, Kill and Repeat
; Author: Ramses
; Version: 1.0
; Client Tested with:
; EUO version tested with: 141
; Shard OSI / FS: OSI
; Revision Date:
; Public Release:
; Purpose: To gather wool for making cloth
;
;==============================================================
;
; Acknowledgements:
; Drak for testing
; Nicar and Freddy for support and help
; TrailMyx (TM) for review, support, runebook subs and formatting
;
;==============================================================
;
; Script Notes:
; Rune Books must be labeled with the word Sheep, multiple books are ok.
; One Rune book must be labeled House or Home with your house as rune #1
;
;==============================================================
;==============================================================
;==============================================================
; Inits & Setup GoSubs
;==============================================================
finditem TSF_WSF_ c
if #findkind = -1
{
  display Ok, you do not have a dagger in your backpack. Please get
  + one and then restart the script, or count resources using UOA
  + and then restrat the script.
  halt
}
set %daggerID #findid

GoSub setup
GoSub setup_secure_runebook %travel_method 1 1 %securerunebookid
GoSub setup_sheep_runebooks
set %numberOfBooks #result
GoSub setup_opperation

;===============================================================
; Begin Main Loop
;===============================================================
MAIN_LOOP:
GoSub to_sheep
GoSub find_sheep %sheeptypes G_16
if %overweight = YES
{
        GoSub TM_TravelFromRunebook %travel_method 1 1 %securerunebookid
  GoSub to_house
}
goto main_loop
;===============================================================
; End Main Loop
;===============================================================
;===============================================================
; Kill sheep
;===============================================================
Sub kill
set #lobjectid %sheepID
  event macro 27 0
  wait 3
;check_death
SCAN:
  event macro 27 0
  wait 2
  finditem #lobjectid
  if #findkind = -1
  return
Goto scan
;===============================================================
; Find the Sheep
;===============================================================
sub find_sheep
  set %new_startposx #CHARPOSX
  set %new_startposy #CHARPOSY
  set %new_startposz #CHARPOSZ
  set %moveinitposy %new_startposy + 1
  event pathfind %new_startposx %moveinitposy %new_startposz

      shear_another:
      finditem %sheeptypes G_16
      set %sheepID #findid
      if #findkind = - 1
            {
              goto move_to_next_pen
            }
      set %x #charposx - 1
      set %y #charposy - 1
      set %x_limit #charposx + 16
      set %y_limit #charposy + 16
      While #finddist > 2
      {
      event pathfind #findx #findy #findz
      wait 1
      }
      GoSub check_weight
      GoSub shear_sheep
      GoSub kill
      goto shear_another
     
move_to_next_pen:
    gosub calc_next_location
    Return                  ;goto main_loop

;===============================================================
; Shear Sheep
;===============================================================
sub shear_sheep
  wait 1
  set #lobjectid %daggerID
  event macro 17 0
  target
  wait 5
  set #ltargetid %sheepID
  set #ltargetkind 1
  event macro 22 0
return
;===============================================================
; Sub Setup_Opperation for method of travel
;===============================================================
sub setup_opperation
  set %travel_method SJ
  display YESNO Do you wish to use sacred journaey rather than recalling?
  if #dispres = NO
  {
    set %travel_method RE
  }
SETUP_OF_OPPERATION_COMPLETE:
  GoSub setup_secure
return
;===============================================================
; Check Weight
;===============================================================
sub check_weight
  if #weight > #maxweight - 30
    set %overweight YES
  if #weight > 390
    set %overweight YES
  if %overweight = YES
  {
        GoSub TM_TravelFromRunebook %travel_method 1 1 %securerunebookid
    GoSub to_house
  }
return
;===============================================================
; Drop Wool
;===============================================================
sub drop_off
  finditem %wool C_ , %packid
  if #findkind <> -1
  {
    exevent drag #findid #findstack
    exevent dropc %secure
    wait 5s
  }
  set %overweight NO
return
;===============================================================
; Return Home and move to secure
;===============================================================
sub to_house
  wait 2
_pathfind:
  event pathfind %start_x %start_y %start_z
  wait 2s
  if #charposx <> %start_x
    goto _pathfind
  if #charposy <> %start_y
    goto _pathfind
  if #charposz <> %start_z
    goto _pathfind
  GoSub drop_off
  GoSub to_sheep
return
;===============================================================
; Setup the Secure at house
;===============================================================
sub setup_secure
  event sysmessage Now click on your secure container
  wait 5
  set #targcurs 1
  target
  while #targcurs = 1
    wait 0
  set %secure #ltargetid #findx #findy #findz
  GoSub check_weight
  wait 2
return
;===============================================================
; To Sheep Pen
;===============================================================
sub to_sheep
set %currentBookID %_runebook . %currentSet
    GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %currentBookID
return
;===============================================================
;
;
;
;
;===============================================================
;===============================================================
; Movement with runebook
; TM RuneBook Subs
;===============================================================
;===============================================================
;
;
;
;

;===============================================================
; 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 delay
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
;===============================================================
; End TM RuneBook Subs
;===============================================================
;===============================================================
;
;
;
;
;===============================================================
; Following Subs are excerpts From TM's recall LJ'ing script
;===============================================================
;==================================================================================================
; setup_secure_runebook: Setup secure runebook
;==================================================================================================
sub setup_secure_runebook
event sysmessage Now click on your secure Rune Book (House rune must be in the number one location)
  wait 1
  set #targcurs 1
  while #targcurs = 1
    wait 0
set %securerunebookid #ltargetid
return
;==================================================================================================
; setup_sheep_runebooks: Setup runebooks for sheep
;==================================================================================================
sub setup_sheep_runebooks


  set %z 0
sheepbook:
  finditem ZBN C_ , #backpackid
  if #findid = x
    goto rbs2
  event property #findid
  if sheep in #property
  {
    set %z %z + 1
    set #lobjectid #findid
    set %_runebook , %z #lobjectid
    gosub rune
    set %_numrunes , %z %qqq
  }
  ignoreitem #findid
  goto sheepbook

rbs2:
  if %z < 1
  {
    menu hide
    display ok No sheep books found.  (Script stopping)
    halt
  }

  ignoreitem reset

rbsend:

return %z
;==================================================================================================
; rune: Figure out number of runes in runebook or which rune is house rune
;==================================================================================================
sub rune
   set %qqq 16
up:
   if %qqq notin #property
      {
        set %qqq %qqq - 1
        goto up
      }
return

;==================================================================================================
; calc_next_location: moves book and rune pointers to next location
;==================================================================================================
sub calc_next_location
set %currentRune %currentRune + 1
    if %currentRune > %_numrunes . %currentSet
    {
       set %currentRune 1
       set %currentSet %currentSet + 1
       if %currentSet > %numberOfBooks
          set %currentSet 1
    }
return
;===============================================================
; End Subs from TM's recall LJ'ing script
;===============================================================
;===============================================================
;
;
;
;
;===============================================================
;===============================================================
; Main Setup
;===============================================================
sub setup
    gosub TM_AddUnderscore #CHARNAME
    set %charname #RESULT

  set #lpc 100
  set %wool OFF_
  set %start_x #charposx
  set %start_y #charposy
  set %start_z #charposz
  set %sheeptypes FG_PF_
    ;Runebook variables
    set %currentBookID x
    set %currentRune 1
    set %numberOfBooks 0
    set %currentSet 1
    set %jstart #jindex
   
    set %securerune 17
    set %securerunebookid NA

  event macro 31 0 ; CLOSES ALL GUMPS

  event macro 8 1
wait_for_paperdoll_to_open:
  if #contname <> paperdoll_gump
  {
    goto wait_for_paperdoll_to_open
  }
  contpos 850 2 ;643 -193 (if normal screen size)
  set %packx 781
  set %packy 30
  set %paperdoll #contid
  set %paperdollx 750
  set %paperdolly 64
  wait 15

  event macro 8 2
wait_for_status_to_open:
  if #contname <> status_gump
  {
    goto wait_for_status_to_open
  }
  contpos 700 300 ;-24 493 (if normal screen size)
  wait 15
  event macro 8 7
wait_for_pack_to_open:
  if #contid <> #backpackid
  {
    goto wait_for_pack_to_open
  }
  set %packid #contid
  contpos 812 500 ; 612 118 (if normal screen size)
  wait 15

return
;===============================================================
; End of Sheep Shearing, Killing, Rinse Repeating Script !!!!!!!
;===============================================================
;
;                             RAMSES
;
;===============================================================


Thank you all...
« Last Edit: July 22, 2008, 03:17:17 PM by Ramses »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #1 on: July 11, 2008, 06:28:17 PM »
+1
When is it you want the rune index to advance?  In looking at your code, it looks like you only want the rune index to advance when there is an error.  If that's not what you intended, then you might want to rework your "to_sheep" sub.

Also, in this sub:

Code: [Select]
sub to_sheep
  set %currentBookID %_runebook . %currentSet
  GoSub TM_TravelFromNamedRunebook %travel_method %currentRune %currentRune Sheep ;%currentBookID
  if #result  ;error
  {
    gosub calc_next_location
    goto _main_loop
  }
return

you are going to "_main_loop" but if you look at your code, that label doesn't exist.  However you don't want to goto out of your sub anyhow.  So because of that typo, it will actually work ok.

But in summary, because of what you've written, the next location will only advance if there is an error that comes from the runebook subs.  I doubt that's what you had in mind..
« Last Edit: July 11, 2008, 06:29:53 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #2 on: July 12, 2008, 05:50:02 AM »
+1
OMG!!!

Thanks TM!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #3 on: July 16, 2008, 04:16:14 PM »
+1

TM

OK...I updated my code in the top most post of this thread. 7/16/08

I finally have this shearing all sheep in a pen, and then moving to the next pen. However, this is currently only moving between the first and second runes in my book and does not seem to be finding multiple books.

When I place the %currentBookID in place of "sheep" on this sub

Code: [Select]
sub to_sheep
set %currentBookID %_runebook . %currentSet
    GoSub TM_TravelFromNamedRunebook %travel_method %currentRune %currentRune sheep ;%currentBookID
return

I get an error that JEZBOLD could not be found. This is the ID for my "sheep" runebook. The other rune book with Sheep in the title seems to be completely ignored.

I have reviewed this area for two days now, and do not seem to beable to find the problem. Thanks for any and all help here.  :)





Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #4 on: July 18, 2008, 09:12:48 AM »
+1
Oh I just saw what part of your problem is.  I give you two ways to use rune books.  You can either supply the #FINDID of the book or a named book.  Throughout all your code you are using the #FINDID version for that or "TM_TravelFromRunebook", but there is one instance where you are using the named book version or "TM_TravelFromNamedRunebook" (line 204).
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #5 on: July 18, 2008, 03:05:22 PM »
+1
OK, I see the line you are talking about and that is one of the issues I have.
So, I want to be able to use multiple books with the word sheep in them. I originally was using %currentBookID however, that only sends me the error about not finding JEZBOLD when infact the book is right there in my back.  :(

Do I need to change that to TM_TravelFromRunebook and then use the %currentBookID? Hmm, I will try that.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #6 on: July 18, 2008, 03:25:14 PM »
+1
OMG!!! TM, thanks that worked.

OK, now I am looking at the way I advance to the next rune. So far the script is only moving back and fourth between the first and second rune for some reason.  :( 

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #7 on: July 18, 2008, 03:29:06 PM »
+1
Keep your code updated on the linky and I'll keep looking at it for ya.  ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #8 on: July 18, 2008, 03:47:56 PM »
+1
Yeah...Just updated it, wanted to try a few things first.

So far the code seems to be functional. Shears all the sheep in a pen, goes to the next pen, when weight limit is reached goes home drops off.

Issues that I still see and are working on:
After dropping off, returns to pen #1
Only visits pen #1 and #2 does not advance past #2.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #9 on: July 18, 2008, 04:00:18 PM »
+1
I'm not sure if this is what's happening, but you are running the "goto main_loop" in your find_sheep sub.  You should just "return" there I think.

Actually, I'm not quite sure what your logic is for your find_sheep sub.  You have a set of brackets there that really aren't doing anything.  Was there an "if" statement there or something?
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #10 on: July 19, 2008, 04:37:21 AM »
+1
Yes,
the original code had
Code: [Select]

If #findindex 1 #findcnt
{
     If #findcnt > 0
     {


but I could not get this loop to work properly.  :( So, I changed it to what we see now. A simple return did not work, because we gosub to_seep in a second area other than the main loop area. Perhaps I need to find a way to stop that? I also put the goto main_loop after I advance the rune, yet the rune only advances one time.  :(


Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #11 on: July 19, 2008, 10:24:36 AM »
+1
Well you are going to have to fix that goto out of the subroutine.  That's bad to do and will eventually play havoc with EUO since you are never returning from a gosub then.  But if we can fix your flow here, then you will be able to return from the sub with no problem.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #12 on: July 19, 2008, 10:42:05 AM »
+1
Another problem is that when you pathfind to your sheep, you need to do another finditem to update the #FINDDIST, otherwise that won't change.  I modified a couple of your sections, so give this a try:

Your main_loop:

Code: [Select]
MAIN_LOOP:
  GoSub to_sheep
  GoSub find_sheep %sheeptypes G_16
  if %overweight = YES
  {
    GoSub TM_TravelFromRunebook %travel_method 1 1 %securerunebookid
    GoSub to_house
  }
  gosub calc_next_location
goto MAIN_LOOP

And your find_sheep sub:

Code: [Select]
sub find_sheep
  set %new_startposx #CHARPOSX
  set %new_startposy #CHARPOSY
  set %new_startposz #CHARPOSZ
  set %moveinitposy %new_startposy + 1
  event pathfind %new_startposx %moveinitposy %new_startposz
 
shear_another:
  finditem %sheeptypes G_16
  set %sheepID #findid
  if #findkind = - 1
    return
 
  While #finddist > 2
  {
    event pathfind #findx #findy #findz
    wait 5
    finditem %sheepID G_16
    if #findkind = - 1
      goto shear_another
  }
  GoSub check_weight
  GoSub shear_sheep
  GoSub kill
  goto shear_another
return

I got rid of your goto main_loop out of your sub, and also added a finditem after every pathfind to make sure you'll follow the sheep if it moves and takes note that you have moved closer.

I think you'll still need to re-do your main_loop a bit since I don't think it's doing everything in the right order.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Shear Sheep, kill and repeat
« Reply #13 on: July 21, 2008, 01:59:02 PM »
+1
TM,
So should my main loop be set up in such a way that

We move to the sheep
find the sheep
shear
kill
?

Right now, the main loop has everything in order, with the only issue being that shearing and killing are contained inside of the find the sheep sub routine. Is this not a good idea?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Shear Sheep, kill and repeat
« Reply #14 on: July 21, 2008, 02:24:53 PM »
+1
TM,
So should my main loop be set up in such a way that

We move to the sheep
find the sheep
shear
kill
?

Right now, the main loop has everything in order, with the only issue being that shearing and killing are contained inside of the find the sheep sub routine. Is this not a good idea?

Well, you should keep all your functions as close to the main loop as you can.  Having nested functions/subs starts leading to hard to follow code.  Make sense?
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: