04-11-2011, 05:39 PM
Kamos easy uo macro mining
Code:
; OzMining 2.0
;
; Features:
; - Moves around the mine randomly
; - Mines a tile clean of ore before moving on to next one
; ==============================================================================
set #LPC 10
set %toolTypes QPF
set %status idle
event sysmessage Starting OzMining 2.0
while ( #charghost = no )
{
if ( #WEIGHT > #MAXWEIGHT )
{
event sysmessage Max weight exceded! Halting...
halt
}
if %status = no_more_ore
{
set %status idle
goto MoveToNextSpot
}
set %jrnl #jindex
gosub MineThisSpot
gosub ProcessResults
}
halt
sub MineThisSpot
if ! ( %status = idle )
return
finditem %tooltypes C
if #FINDCNT > 0
{
set #lObjectId #findId
event macro 17 0
set %jrnl #jindex
tile Init
Tile Get #CharPosX #CharPosY 2
set #lTargetTile #tileType
set #lTargetX #charPosX
set #lTargetY #charPosY
set #lTargetZ #charPosZ
set #lTargetKind 3
target 20s
event Macro 22 0
set %status mining
}
return
sub ProcessResults
set %MiningTimer #SYSTIME
while ( %status = mining )
{
if #jindex > %jrnl
{
set %jrnl %jrnl + 1
scanjournal %jrnl
if you_dig_some in #journal
set %status idle
if you_carefully_extract_some_workable_stone in #journal
set %status idle
if you_loosen_some_rocks in #journal
{
if ( #SYSTIME <= %MiningTimer + 1000 )
wait 7s
set %status idle
}
if You_have_moved_too_far in #journal
set %status idle
if you_can't_mine_there in #journal
set %status idle
if Someone_has_gotten in #journal
set %status idle
if Can't_mine_that in #journal
{
set %status no_more_ore
gosub MoveToNextSpot
}
if target_cannot_be_seen in #journal
{
set %status no_more_ore
gosub MoveToNextSpot
}
if there_is_no_metal_here_to_mine in #journal
{
set %status no_more_ore
gosub MoveToNextSpot
}
}
if ( #SYSTIME >= %MiningTimer + 7000 )
{
set %status no_more_ore
gosub MoveToNextSpot
}
}
return
sub MoveToNextSpot
FindNextSpot:
set %GotoX #charposX
set %GotoY #charposY
set %oldX #charposX
set %oldY #charposY
set %randomInc #random % 5
; negative or positive?
set %nDirection #random % 2
if %nDirection = 1
set %randomInc %randomInc * -1
set %GotoY %GotoY + %randomInc
; Random amount of tiles to a direction
set %randomInc #random % 5
; negative or positive?
set %nDirection #random % 2
if %nDirection = 1
set %randomInc %randomInc * -1
set %GotoX %GotoX + %randomInc
tile Init
tile Get %GotoX %GotoY 2
if ( #tilename = cave_floor )
{
gosub MoveTo %GotoX %GotoY 0
set %status idle
}
return
sub MoveTo
set %oldX #charposX
set %oldY #charposY
GetThere:
if ( #charposX = %1 && #charposY = %2 )
return
event pathFind %1 %2 %3
wait 5
set %MoveStartTime #SYSTIME
while ! ( #charposX = %1 && #charposY = %2 )
{
if can't_get_there in #journal
gosub OpenDoor
if ( #charposX = %oldX && #charposY = %oldY )
return
if ( #SYSTIME > %MoveStartTime + 1000 )
return
}
return[SIGPIC][/SIGPIC]

