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)
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