ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Pearls on April 30, 2010, 08:03:59 AM

Title: Pearls vs EasyUO : close encounters
Post by: Pearls on April 30, 2010, 08:03:59 AM
So ive started looking at the wiki.easyuo a lot and starting to grasp some of the basics. Havent tried writing anything yet thou. I've took UOMaddog's Jhelom Pen Taming Trainer and printed out the code so i could take some notes and understand the flow he is using. Was surprised to find out that i understood more then expected ;) There is one thing that i'm a bit confused about thou, i'll highlight the code and maybe someone could enlighten me a little on whats taking place.

Code: [Select]
;Look for animal to tame
sub LookAroundAndTame
findItem %tamingtypes G_12 ;pretty sure this means a radius of 12 tiles to scan for
;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
   return
   }
if animal_looks_tame_already in #journal
   {
   deletejournal
   ignoreitem %tamingtarget
   return
   }
if else_is_already_taming_that_creature in #journal
   {
   deletejournal
   ignoreitem %tamingtarget
   return
   }
if have_no_chance_of_taming_this_creature 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

If i read through the code i get the impression it gets stuck in a loop reading the journal, but it doesnt so i'm clearly missing something. Probably this part :

Code: [Select]
finditem %tamingtarget
if #finddist > 2
   {
   event PathFind #findx #findy #findz
   }
goto ScanForSuccess

edit : cant add colors in code?
Title: Re: Pearls vs EasyUO : close encounters
Post by: Hoby on April 30, 2010, 08:59:57 AM
haha, cleaver title for the thread  :D
Title: Re: Pearls vs EasyUO : close encounters
Post by: Masscre on April 30, 2010, 09:37:23 AM
This code snippit will move you to less than 2 tiles of the wanted tile and will continue to move you within 2 tiles of the expected animal.  So yes it will continue to do this for ever but not in the way you are thinking.  It will pathfind until you are less than 2 tiles away from the expected animal and then move to the next step and then come back again when you are over 2 tiles away from the expected animal.  did I make sense to you pearls or did i confuse you more?
Title: Re: Pearls vs EasyUO : close encounters
Post by: Pearls on April 30, 2010, 10:26:28 AM
I might have been a little too vague ;-)

Part i'm wondering about is once u tamed an animal for example, how does it break free from "goto ScanForSuccess", i know that it does deletejournal, which means u wont read what uve read already right. Then it does return, which means breaking free from the if right, or is it breaking free from sub LookAroundAndTame, which includes the ScanForSuccess part. Just curious how its breaking away so it would eventually go back to release & kill .
Title: Re: Pearls vs EasyUO : close encounters
Post by: Scotch_Tape on May 10, 2010, 05:09:47 AM
Then it does return, which means breaking free from the if right, or is it breaking free from sub LookAroundAndTame, which includes the ScanForSuccess part.

A Return will leave the sub.  So once it see's the return it will not come back to that loop until it hits the gosub again.  Unless there is a goto somewhere else in the script, but I hear that's just bad coding. 

Someone correct me if I'm wrong.