Code: Select all
#event turbo
#include routines.mac
Sub Main
/cleanup
/call DefineGlobals
/if $cursor()!=NULL /click left auto
/if $invpanel==True /press I
/Call DoLog Begining Collection in zone $zone
:Next
/call finditem *green
/call MoveToTarget
/call PickUpItem
/goto :Next
/return
Sub DefineGlobals
/declare CollectedItem global
/declare LastY global
/declare LastX global
/declare ObstCount global
/declare Notfound global
/return
Sub FindItem
:NotFoundReturn
/varset NotFound 0
/seterror clear
/itemtarget @Param0
/if "$getlasterror"=="ITEM_NOTFOUND" /call NotFound @Param0
/if "$getlasterror"=="ITEM_NOTFOUND" /varset NotFound $return
/if n @NotFound==1 /goto :NotFoundReturn
/call DoLog "Item found at: $ground(y), $ground(x)."
/return
Sub MoveToTarget
:KeepMoving
/call CheckForObst
/face loc $ground(y), $ground(x)
/sendkey down up
/if n $distance(item)>15 /goto :KeepMoving
:StopMoving
/sendkey up up
/return
Sub PickUpItem
/face item
:Nudge
/if n $distance(item)>10{
/press up
/goto :Nudge
}
/face item
/sendkey down Page_Down
/delay 2s
/sendkey up Page_Down
/click left item
/delay 1s
/if "$cursor()"=="NULL" /goto :Nudge
/autoinventory
/delay 1s
/if $invpanel==True /press I
/press Home
/return
Sub CheckForObst
/if n $char(x)==@LastX /if n $char(y)==@LastY {
/varadd ObstCount 1
} else {
/varset ObstCount 0
}
/varset LastX $char(x)
/varset LastY $char(y)
/if n @ObstCount>3 {
/call DoLog "Obstruction at $char(y), $char(x)"
/call GoAroundObst
}
/return
Sub GoAroundObst
/sendkey up up
/sendkey down down
/delay (2+$rand(5))s
/sendkey up down
/if n "$rand(20)">="10" {
/sendkey down left
/delay 5
/sendkey up left
/sendkey down up
/delay 7s
/sendkey up up
} else {
/sendkey down right
/delay 5
/sendkey up right
/sendkey down up
/delay 7s
/sendkey up up
}
/return
sub Notfound
/call Dolog "Item: ~~ @Param0 ~~ not found. . ."
/sit
/camp desktop
/return
Sub DoLog
/mqlog @Param0
/echo @Param0
/return 
