ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: VicVega on May 25, 2009, 11:09:56 AM

Title: Animal Taming 0.1 for Public Testing
Post by: VicVega on May 25, 2009, 11:09:56 AM
What this script does?

1. Scans the zone for tame animals acording to your skill at the moment.
2. Tames an animal, releases it and then kills it with your steed, till there is no more animals left on the zone.
3. If no more animals available on the zone, returns to the starting point.

Only tested with Great Harts at the moment, but it should work with all the other animals supported I hope.  

This informative table is extracted from the UDTaming script, only works with the animals listed here, but if you want to add animals types it's easy to do so:

Quote
; The following table was generated from data gathered off the UO Stratics
; taming page. Analysing their results produces a success rate calculation
; based upon the character's Animal Taming skill only. Modifying the Animal
; Lore did not produce any noticable changes in the success rates.
;
; The formula determined for calculating success rate is R = (S - B) * 2 where
; R is the success rate, S is the character's taming skill, and B is the
; minumum skill required to tame minus 0.1 (this is the base skill
; requirement). Using basic algebra and solving for S provides a formula that
; can can be used calculate the skill required to achieve a specific success
; rate (S = R / 2 + B). This formula is used in the table below to determine
; which creatures will provide the best chances to recieve a gain while
; taming.
; Column descriptions:
;
; ANIMAL    The name of the animal to tame
; REQ SKILL The minimum skill required to tame
; MIN GAIN  The skill level that has a 10% success rate
; MAX GAIN  The skill level that has an 90% success rate
; C/M       Monster (Yes/No)
; TYPE      EasyUO FindItem type for animal
;
;                      REQ    MIN    MAX
; ANIMAL             SKILL   GAIN   GAIN  C/M  TYPE
; Sheep               11.1     16     56   N   TF_PF
; Cow                 11.1     16     56   N   IG_NG
; Hind                23.1     28     68   N   TG
; Timber Wolf         23.1     28     68   N   PG
; Great Hart          59.1     64    104   N   AH
; Bull                71.1     76    116   N   YG_XG
; Ridgeback           83.1     88    128   N   BK

Code: [Select]
;=================================================================
; Script Name: Animal Taming
; Author: VicVega
; Version: 0.3
; Shard OSI / FS: UO Legends
; Revision Date: 26/5/2009
; Purpose: Trains Animal Taming to GM
; Globals: None
;=================================================================
; Instructions: You need to setup your steed ID in %steedID
;               variable on setup
;************************ Setup **********************************
gosub setup

repeat
  gosub chooseTamingAnimal
  gosub findClosestAnimal %tameable
  gosub tamingMonitor
until #charGhost = yes
halt
;************************* Subs **********************************
sub tamingMonitor
  if %findDist <> N/A
  {
    if %findtype in %tameable
      gosub Taming %findid
  }
  if %findDist = N/A
  {
    event sysmessage no more animals around
    event pathfind %charstartx %charstarty %charstartz
    wait 10s
  }
return

sub setup
  set %steedID OFWC
  set %charstartx #charposx
  set %charstarty #charposy
  set %charstartz #charposz
return

sub Taming
  set %oldTameFollowers #followers
  set %tameID %1
  gosub checkParagon %tameID
  finditem %tameID G_16
  while #findkind <> -1
  {
    set %tameid #findid
    if %tameid <> #ltargetid
      event exmsg %tameid 3 30 target!
    gosub TameAnimal
    if #followers > %oldTameFollowers
       gosub tamingRelease
    finditem %tameID G_16
  }
return

sub checkParagon
event property %1
if Paragon in #property
{
   event sysmessage killing paragon!
   gosub killPet
}
return

sub TameAnimal
  set #ltargetid %tameid
  set #ltargetkind 1
  while #findDist > 2
  {
    event pathfind #findX #findY #findZ
    wait 1s
    finditem %tameID G_16
  }

  event macro 13 35 ; animal taming
  target 3s
  event macro 22 0 ; last target

  gosub scan seems_to_accept anger_the_beast fail_to_tame
  + too_far clear_path too_many_followers can't_see_that
  + too_angry distracted someone_else tame_already
  + cannot_be_tamed can't_tame_that no_chance

  set %ignore someone_else in #result || tame_already in #result
  if %ignore = #true
    ignoreitem %tameID
 return

sub scan
  set %maxTimeOutScan 15
  set %timeout #scnt + %maxTimeOutScan
  set %jrnl #jindex
  scanjournal %jrnl

  while #scnt < %timeout
  {
    finditem %tameID G_16
    if #finddist > 2
      event pathfind #findX #findY #findZ
    if %jrnl < #jindex
    {
      set %jrnl %jrnl + 1
      scanjournal %jrnl
    }

    for %journalCounter 1 %0
    {
      if % . %journalCounter in #journal
        return % . %journalCounter
    }
  }
return

sub TamingRelease
  msg all follow me $
  gosub releasePet
  gosub killPet
return

sub releasePet
  set %releaseGumpSize 270_120
  set %maxTimeOut 15
  set %timeOut #scnt + %maxTimeOut
  set %waitForGump #true
  
  exevent popup %tameID 10
  while %waitForGump = #true
  {
    wait 1s
    set %waitForGump #contSize <> %releaseGumpSize && #scnt < %timeOut
  }

  set %releaseGumpX #contposx + 35
  set %releaseGumpY #contposy + 90
  click %releaseGumpX  %releaseGumpY
  wait 15
return

sub killPet
  gosub dismount
  gosub atackTamedPet %tameID
  finditem %steedID
  while #findKind <> -1
  {
    gosub mount
    finditem %steedID
  }
return

sub dismount
  set #lObjectID #charID
  event macro 17
  wait 1s
return

sub atackTamedPet
  set %victimID %1
  set #lTargetKind 1
  SET #lTargetID %victimID
  event exmsg %tameid 3 30 kill this!
  gosub atack
  finditem %victimID
  set %maxTimeOut 10
  set %timeOut #scnt + %maxTimeOut
  while #findKind <> -1
  {
    wait 1s
    finditem %victimID
    event exmsg %tameid 3 30 kill this!
    gosub checkAtackTimeOut
  }
return

sub atack
  msg all kill $
  target 25s
  event macro 22 0
return

sub checkAtackTimeOut
    if #scnt > %timeOut
    {
          gosub atack
          set %timeOut #scnt + %maxTimeOut
    }
return

sub mount
  finditem %steedID
  set #lObjectID %steedID
  while #findDist > 1
  {
    msg all follow me $
    wait 1s
    finditem %steedID
  }
  event macro 17
  wait 1s
return

sub findClosestAnimal
  finditem %1 G_16
  set %findid #findid
  set %findtype #findtype
  set %finddist #findDist
  if #findcnt > 1
  {
    for #findIndex 1 #findcnt
    {
      if #findkind <> -1 && #findDist < %findDist
      {
        set %findid #findid
        set %findtype #findtype
        set %finddist #findDist
      }
    }
  }
return

sub chooseTamingAnimal
  chooseskill anim
  if #skill = #skillcap
  {
    display ok Taming skillcap reached
    halt
  }

  if #skill >= 300 && #skill < 450
    set %tameable TF_PF_IG_NG_TG
  if #skill >= 450 && #skill < 600
    set %tameable TG_PG
  if #skill >= 600 && #skill < 750
    set %tameable AH
  if #skill >= 750 && #skill < 900
    set %tameable YG_XG_AH
  if #skill >= 900 && #skill < 1200
    set %tameable BK
return
Title: Re: Animal Taming 0.1 for Public Testing
Post by: VicVega on May 26, 2009, 06:27:52 AM
New version, some fixes, improved stability and code readbility.

Version 0.3 published, fixed problem with RidgeBacks and now kills RidgeBack Paragons (wich are not tamable)
Title: Re: Animal Taming 0.1 for Public Testing
Post by: Ultima on May 29, 2009, 05:33:00 PM
I finally got around to testing this script. I got my butt thrown in jail the other day for using Maddog's Jhelom Bull Pen Trainer so some other method to get gains is urgently needed. 8)

I added Gamans to the list which are great for gains I really don't understand why more people don't tame gaman's to 120 instead of Bulls. I 120'd my first tamer off Gamans. Totally secluded and virtually danger free....

Anyways...I couldn't get the script to work for me. After taming the Gaman it would give the All Follow Me command but wouldn't release newly tamed pet and dismount and kill it. When I manually released the pet it killed it but then the script just sat there idle.

Not quite sure where the problem lay. It could be my end with my client. There are quite a few scripts that won't run on my main computer but will on my computer which runs Windows Vista. I'll try it on my 2nd computer as well and see if the results are any different.

Hopefully someone else also gives this a try because we really do need more taming scripts. ;)
Title: Re: Animal Taming 0.1 for Public Testing
Post by: 12TimesOver on May 30, 2009, 03:38:49 AM
Vic, compliments to you on such well organized code. It's refreshing to get neat code, makes it so much more readable and yours is laid out very well.

I want to give this a test for you since the timing is perfect (training a tamer as we speak but, like Ultima, am having issues with griefers using Maddog's). My only issue is that I will need to modify your "Killpet" sub to mage-kill the tame instead of mount-kill it. If that's no problem for you from the testing perspective I'll give it a whirl later today when my son goes down for a nap. If you don't want me to mod it I'll probably do it anyway but I just won't tell you how it goes  ;)

Would be REALLY easy to integrate a kill option into the setup routine then just sub out to "Sub Magekill" or "Sub Mountkill" based on the setup option. Just a thought :P

XII
Title: Re: Animal Taming 0.1 for Public Testing
Post by: VicVega on June 01, 2009, 01:47:00 AM
Feel free to modify the script, I don't mind.

I know I could support other methods of killing, but I don't have a tamer with the skills to do so and I prefer to test the script in order to know if it works fine at least for me.

I'm glad you like the code.
Title: Re: Animal Taming 0.1 for Public Testing
Post by: VicVega on June 01, 2009, 01:58:03 AM
I finally got around to testing this script. I got my butt thrown in jail the other day for using Maddog's Jhelom Bull Pen Trainer so some other method to get gains is urgently needed. 8)

I added Gamans to the list which are great for gains I really don't understand why more people don't tame gaman's to 120 instead of Bulls. I 120'd my first tamer off Gamans. Totally secluded and virtually danger free....

Anyways...I couldn't get the script to work for me. After taming the Gaman it would give the All Follow Me command but wouldn't release newly tamed pet and dismount and kill it. When I manually released the pet it killed it but then the script just sat there idle.

Not quite sure where the problem lay. It could be my end with my client. There are quite a few scripts that won't run on my main computer but will on my computer which runs Windows Vista. I'll try it on my 2nd computer as well and see if the results are any different.

Hopefully someone else also gives this a try because we really do need more taming scripts. ;)

In order to release the pet I use this command:

Quote
exevent popup %tameID 10

May be you are on a Sphere shard? (Sphere shards don't support the exevent popup command)

Or may be you are in a shard wich is RunUO but doesn't support exevent popup command anyway.

If exevent popup works fine on your shard, may be the entries on the context menu when you click on the animal are different and it's not the 10th entry wich has the "release" option, in that case you should change "10" by the entry number of your "release" option.

If the exevent popup command doesn't prompt the pop up confirmation window about releasing the pet, the script will loop on this line:

Quote
  exevent popup %tameID 10
  while %waitForGump = #true
...
Title: Re: Animal Taming 0.1 for Public Testing
Post by: TrailMyx on June 01, 2009, 05:08:54 AM
RunUO supports event popup for some reason, but OSI does not.  You have to handle the gump instance and do the clicking yourself.  Normally for my scripts to be compatible for both RunUO and OSI, I generally just do the click myself instead of using the built-in selection function.

It's annoying for a function like this to be basically broken in EUO, but it's been this way forever.
Title: Re: Animal Taming 0.1 for Public Testing
Post by: seeriusly on August 02, 2009, 08:52:07 AM
Perhaps if you just guild your tamer, all you'd have to do is say all kill...  ???  That's what I do when taming gamans...  ride ethereal, and have mare to kill.  Haven't tried the script, but will keep it in mind.
Title: Re: Animal Taming 0.1 for Public Testing
Post by: Noobie on August 30, 2009, 08:22:38 PM
I found that if i add a Return in i was able to mount back up not sure what you had in mind with the finditem %steedID, but i got it to run better with out it.



sub killPet
  gosub dismount
  gosub atackTamedPet %tameID
  finditem %steedID
  while #findKind <> -1
  {
    gosub mount
    finditem %steedID               <<<<<<<<<<<<< Return
  }
Title: Re: Animal Taming 0.1 for Public Testing
Post by: UOMaddog on August 30, 2009, 09:57:53 PM
I'm glad to hear soo many people using my script, however I do understand the frustration of Jhelom Farms! I very much like the way VicVega has his code organized (I'm OCD about stuff like that myself!) and I also like his idea of the taming "chart" so to speak. You could put almost an entire library of animals in the script, broken down into 5.0 skill segments (some animals may be in multiple sections). You already have it in there for the most part, but I'd honestly try to make it as large of a list as possible and break it down into smaller segments (such as 5.0). I am in the process of totally revamping my script at the moment (trying to make it much less Twinkle McNugget) so I'm trying to avoid reading through all your code cuz then it sticks in my mind and I unintentionally use bits and pieces. However, if you have any questions, feel free to PM me and we could work on stuff together!


Just an idea, but one of the best community projects might be an SUO Ultimate Taming Trainer! Something that would function flawlessly with a GM Detector, healing, paragons, moving to new taming areas, etc. Kind of like Roadkill's all-in-one taming script on EUO, but a million times better! The reason I suggest this is because I know 3-5 of us have been working on our own taming scripts and it seems like we might be able to put something even better together if we work together!
Title: Re: Animal Taming 0.1 for Public Testing
Post by: Endless Night on September 02, 2009, 07:03:23 AM
Just an idea, but one of the best community projects might be an SUO Ultimate Taming Trainer! Something that would function flawlessly with a GM Detector, healing, paragons, moving to new taming areas, etc. Kind of like Roadkill's all-in-one taming script on EUO, but a million times better! The reason I suggest this is because I know 3-5 of us have been working on our own taming scripts and it seems like we might be able to put something even better together if we work together!

Done and dusted already MadDog.. had a basic verion of this up on Uocoders and posted the more advanced version of it here recently .. Has the skill/Tamables chart and all thefeatures  Except for Killing paragons as i never do the ish bit myself personally.  Unfortunatly at present its an Elite only script, and im also sure it could use some improvment in places.   ENs-Automated Tamer Trainer (http://www.scriptuo.com/index.php?topic=2346.0)

Very nice looking code  VicVega
Title: Re: Animal Taming 0.1 for Public Testing
Post by: UOMaddog on September 02, 2009, 11:34:37 AM
Wow, glad to hear it EN! If I ever get access, I'll take a look and possibly send you a snippet to add for paragons and it will be the most complete taming script ever! Hehe!
Title: Re: Animal Taming 0.1 for Public Testing
Post by: Scrripty on September 11, 2009, 09:16:16 AM
I can see a potential problem with the event pathfind portion...  In the documentation for event pathfind I believe I read that it ONLY works for places that are on your screen.  So if an animal leads you away, it will fail.  Not sure how that works on RunUO?  I'm not 100 percent sure tho as I don't use event pathfind much...