Hey Guys!
I have been working on adapting Spewy's Runebook Mining Script so that it seperates the Granite into seperate containers. The Script recalls to my house, walks inside, and seperates the Ore and Gems into a seperate container, then seperates each of the Granite Colors into 8 seperate containers, and throws away the Normal Granite in the House Trash Barrel. Problem I have is that the House Trash Barrel only holds 400 stones or 40 pieces of Granite, so when the Trash Barrel is full it yoyos on one piece of Granite.
Other problem with Spewy's is that the Script does not provide any protection for your Pack Animal. If your Miner gets targeted or attacked, then you recall to your "Escape Rune". If your Pack Animal gets targeted or attacked, your Miner just stands there and watches their Pack Animal die.
Last problem (or addition I can't figure out how to make) is that I sometimes mine in Felucca's Guard Zone Areas, so when I get attacked I can call Guards and 'Guard Whack" the Monster or Red/Murderer. I would like the Script to automatically do this for both my Miner and my Beetle.
There is code in there that is supposed to do something but it doesn't...
Will very much appreciate any and all to take a look at it...
;==================================
; Script Name: Runebook Mining
; Original Author: Spewy
; Version: 3.5
; Client Tested with: 6.0.10.0 (Patch 71)
; EUO version tested with: 1.5 build 143
; Shard OSI / FS: OSI Tested
; Granite Mining Added by Oracle and MW
; Revision Date: September 21, 2008
; Original Public Release: September 16th, 2003
; Purpose: Efficient mining with the use of runebooks and pack animal
; Sorts Granite into seperate containers, tosses Normal Granite
; into House Trash Barrel
;==================================
GoSub InitializeRuneBookMiningBySpewy ; Do not change/remove this line
Set %UseInteractiveSetup #true ; ******* Set to #false to manually set the values for variables ******
If %UseInteractiveSetup
GoSub InteractiveDefaults
; ********* MANUAL ENTRY OF VARIABLES ***************
If ! %UseInteractiveSetup
{
LinesPerCycle %lpsFast
;*********** REQUIRED Variables ******************
; ---------- Backpacks and Home Base Setup ----------
Set %BaseRunebook XXXXXXX ; Set this to the ID of your House or Bank Runebook
Set %NumBaseRunes 2 ; *** NEW *** Set the Total Number of Base runes to randomly use
Set %BaseRune1 5 ; The position of the house/bank rune in the runebook (1=First rune, 16=last rune)
Set %BaseRune2 6 ; An alternative rune just in case your first one is blocked (1=First rune, 16=last rune)
; For House Drop-off
Set %SecureId XXXXXXX ; Set to your HOUSE Secure ID (best if on stairs 2 squares away from recall spot)
Set %BankDrop #false ; Drop ore at the bank? #true = Bank, #false = House (Default)
Set %OreBagId XXXXXXX ; Set to the backpack id INSIDE your bank or house secure (Needed: House and Bank)
;---------- Mining Runebook Setup --------------------
; GoSub AddRunebook <RuneBook ID> <# of Mining Runes> [Color] [External Definition Filename]
; GoSub AddRunebook XXXXXXX 16
; Examples: (!!! Make sure you delete the semicolon ';' !!!) (!!! Filename must not contain spaces !!!)
; GoSub AddRunebook XXXXXXX 14 %Valorite SpewRunes.euo
; GoSub AddRunebook XXXXXXX 11 %Verite SpewRunes.euo
; GoSub AddRunebook XXXXXXX 16 %Agapite SpewRunes.euo
; *** LOOK FOR *** SetDigLocations subroutine to enter your mining locations
;********* OPTIONAL Variables *********
;---------- Bonded Packhorse/Packllama Setup ----------
Set %UsePackAnimal #false ; Use #true to use a bonded pack animal, #false otherwise
Set %PackAnimalId XXXXXXX ; The pack animal ID (use a dagger on it and look at #lTargetId)
Set %PackAnimalBagId XXXXXXX ; The Container ID of the pack animal backpack (Open Pack and use #ContId value)
Set %PackAnimalDropId XXXXXXX ; Backpack INSIDE pack animal backpack where the ore will be unloaded
;---------- Miscellaneous Variables ----------
Set %MaxWeight 360 ; Set this to the weight you would like to stop digging at 400 for trammel 380 for felluca
Set %RegSuit #false ; #false = Restock regeants, #true = Do not need regeants
Set %MineUseTime 15 ; Time between shovel usage is much smaller (For 'You must wait...' messages while mining set this higher)
Set %UseTime 23 ; The wait between item usage other than shovels (For 'You must wait...' message when not mining set this higher)
Set %HideMineInFel #true ; *** NEW *** Hide when mining in Feluca only
Set %HideMineElsewhere #false ; *** NEW *** Hide when mining even when not in Fel
Set %HideWhileManaWait #true ; *** NEW *** Hide when you are waiting for mana to regenerate
Set %HideOnPackUnload #true ; *** NEW *** Hide when you unload to the pack animal
Set %HideOnBaseUnload #true ; *** NEW *** Hide when you unload to your bank/house
Set %ShowStatus #true ; Show the status window while mining (Really should be #true, pause/escape button are on the status window)
Set %MinShovels 2 ; Set to the minimum number of shovels to carry when leaving Bank/House (Use up all those damn sturdy shovels)
Set %UseTinkering #true ; In case you don't have enough tinkering to make shovels (Make sure you set %MinShovels
Set %MakeTwoShovels #true ; Make 2 shovels when you have to make a shovel
Set %UseAnyColourIngot #false ; *** NEW *** Change this to true if you want the script to pickup coloured ingots from your bank/secure to tinker with
Set %TravelMethod 0 ; *** NEW *** Change this to True for Magery, False for Chivalry
Set %GiveUpTime 20 ; # of *seconds* of no successful mining strikes before script moves to the next mining spot
;---------- Walking directions to House Secure after Recall ---------------
Set %StandLocationX 0 ;4823 ; Set these three variables to #CharPosX, #CharPosY, #CharPosZ when you have your
Set %StandLocationY 0; 652 ; character standing in the spot close enough to unload the ore
Set %StandLocationZ 0 ;7
Set %DoorID XXXXXXX ; To use a door heading to %StandLocation, provide the ID of the door (double click door, use #LObjectID)
Set %DoorUseX 0 ; Set these three variables to #CharPosX, #CharPosY, #CharPosZ when you have your
Set %DoorUseY 0 ; character standing in the spot close enough open the door
Set %DoorUseZ -1
;---------- Enemy Detection and Evasion ---------------
Set %RedEscape #true ; Run the escape sequence if a red is detected
Set %RedCheckNPC #false ; Take extra time to see if Red found is a Red Healer
Set %TrackPackAnimal #true ; If your pack animal (if used) moves away from you, the escape sequence is run
Set %EscapeOnMonsterSighting #true ; #true: When a monster targets you, the script will try to escape (even before damage is done)
Set %HighThreatMonster N/A ; Upon the sighting of the specified monsters you will immediately try to escape
Set %NoThreatMonster GD ; (Corpsers, Reapers) Specified monsters will not cause an escape attempt (will still escape on damage)
Set %PauseAfterEscape #false
Set %EscapeOnDamage #true ; #true: Run the Escape sequence when you take more than %DamageThreshold damage
Set %DamageThreshold 10 ; the amount of damage before the escape is triggered [Fixes the escape problem caused by items that increase Hit Points]
Set %EscapeRecallTarget XXXXXXX ; ID of runebook or rune to target when you click on the ESCAPE button.
; Leave as is and script will open house runebook and recall from there
; Spewy sets this to %BaseRunebook and in UO sets the runebook default rune to be the house rune.
Set %MinutesBeforeReturn 20 ; Minutes to avoid the dangerous rune location (NOT TESTED, PLEASE POST IF IT WORKS)
Set %CureWithMagery #true ; Attempts to cast Cure after an escape attempt (after you press Run Macro after the pause)
Set %GrHealAfterEscape #true ; Attempts to cast Greater Heal after an escape attempt (after you press Run Macro after the pause)
Set %WaitForMana #true ; Make sure you have enough mana to recall to and recall out of a mining location (32 mana)
Set %MountBeforeRecall #true ; #true to mount your beetle before recalling to a mining location (less chance of loosing the beetle especially if you have hiding)
;---------- Mining Filter Setup ---------------
Set %BringUpMenuForFilters #true ; Brings up a selection menu for which colors to mine, and prospect
Set %UseProspector %NoColor ; Add (literally +) all the colors you want prospected !!! Spaces between everything are required !!!
Set %MineFor %AllColors ; Add (using +) all the colors you wish to mine (filters runebooks used)
; Color Variables:
; %AllColors, %NoColor, %Iron, %Dull, %Shadow, %Copper %Bronze, %Gold, %Agapite, %Verite, %Valorite, and %UnknownColor
; Examples:
; Set %UseProspector %UnknownColor + %Dull + %Bronze + %Agapite ; Prospect Dull Copper, Bronze, Agapite and any unlabelled runebooks
; Set %MineFor %AllColors ; Use all runebooks
; Set %MineFor %Bronze + %Gold ; Use Bronze and Gold runebooks ('Set %UseProspector %Bronze' and you only get Gold ore)
;---------- Mining Efficiency Variables ------------
; These variables are intended for people wanting to increase mining efficiency as much as possible.
; Choosing good mining locations (w/ multiple veins per rune) will yield easy improvements
Set %DumpIron #true ; #true results in large IRON ore to be dropped on exisint piles of ore within reach
; Note: I manually place large iron ore in a visible spot 2 squares from me (saw 12% improvement))
Set %NextRuneOnBaseUnload #true ; #true results in recalling to the next rune after Unloading to Bank/House [Suggested by Paton]
; This is displayed on the the status window (Keep track of your mining efficiency)
Set %TrackGPValue %ShowStatus ; Tracks how much gold (equivalent) you have mined based on the ore evaluation set below
;---------- Logging Variables ----------
; [REQUIRES: ALLOW EXECUTE and the file Save.js, saves to MiningSpots.txt]
Set %LogMiningResults #false ; Saves how many large color/iron ore is mined at each mining location
;------------- Siege Support -------------
Set %CastGate #false
; Set %UseGateScrolls #false ; Support in future versions
;---------- UOAssist Integration Setup ----------
; For these variables Key is the keystroke (A-Z, 0-9, F1 to F12) and the Mod comes from the list of EUO's Key function (Alt, Ctrl, Shift)
; *** NOTE *** This area was not tested, please report any problems *** NOTE ***
; Tinker Tool creation UOA macro (Should Use Item Type (tinker tools), Choose Tinker Tool, Close Tinker Menu)
Set %UOATinkerToolKey N/A
Set %UOATinkerToolMod N/A
Set %UOATinkerToolWait 10s
; Shovel creation UOA macro (Should Use Item Type (tinker tools), Choose Shovel, Close Tinker Menu)
Set %UOAShovelKey N/A
Set %UOAShovelMod N/A
Set %UOAShovelWait 10s
; Escape UOA macro key (If this is defined, the Escape button will press this key and then pause the script)
Set %UOAEscapeKey N/A
Set %UOAEscapeMod N/A
LinesPerCycle %lpsNormal
}
;********* User Defined Digging Locations Setup *******************************
Sub SetDigLocations
GoSub RunExternalDefinitions ; Do not change/remove this line
; You can define multiple mining spots (veins) per recall location (rune). Undefined mining locations will only work in a cave (it mines at your feet)
; There is a howto post on the thread for this script on how to set this up
GoSub FindRunebook XXXXXXX ; or %_RuneBook1 if you used the Interactive Setup and do not know the IDs
Set %sdlBook %return
if %sdlBook > 0
{
; SetUserDigCoord - *** Specify world coordinate mining locations ***
; Mine the location then use #LTargetX, #LTargetY, #LTargetZ, #LTargetKind #LTargetTile in EUO (Ctrl-R to View variables)
;
; GoSub SetUserDigCoord <RuneBook Index> <Rune Index 1-16> <#lTargetX> <#lTargetY> <#lTargetZ> <#lTargetKind> <#lTargetTile>
; Look at http://www.easyuo.com/forum/viewtopic.php?t=200 for tutorial on how to set these up
}
GoSub FindRunebook XXXXXXX ; or %_RuneBook2
Set %sdlBook %return
if %sdlBook > 0
{
; See above
}
Return
;*******************************************************
;******** DONT CHANGE ANYTHING PAST HERE
;*******************************************************
LinesPerCycle %lpsFast
Set %FixForUORecallBug #false ; I left this in here just in case the UO Bug hasn't been fixed
Set %HaveTargetted #false
Set %HaveProspected #false
Set %LastMadeWasShovel #false
Set %BackpackId null
Set %IsMounted #true
Set %UsingBeetle #true
Set %LastEnemyID #enemyID
Set %gNeedsCoordConv #false
Set #sCnt2 0
Set #sCnt 0
Set %_uowLastUse #scnt2
Set %TryHideAgain 0
Set %LogTimeUsage #false ; Log how much time major operations take and when they happen (Optimize the script, so internal use)
ChooseSkill tink
Set %TinkerSkill #skill
GoSub SetDigLocations
LinesPerCycle %lpsNormal
;*****************************************
;******** Start Up Code
;*****************************************
GoSub MineForMenu
Set %iRune 1
Set %iSpot 1
Set %iRuneBook 0
GoSub CheckInit
GoSub IncrementRuneBook
GoSub CreateStatusWindow
;*****************************************
;******** Main Loop
;*****************************************
GoSub RecordTimingComment Starting...
MainLoop:
GoSub RecallMine
CheckShovel:
GoSub FindShovel
If %return = Escape
{
GoSub Escape
Goto MainLoop
}
GoSub Digger
If %return = Escape
GoSub Escape
If %return = CheckShovel
goto CheckShovel
goto MainLoop
;*****************************************
;******** Tinkering
;*****************************************
; ** FindShovel **
; Tries to find a shovel, if non are found will initial
; tinkering or recall back to home base
Sub FindShovel
GoSub UpdateStatusWindow FindShovel
FindShovelStart:
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
GoSub FindUsableMiningTool %BackpackId
If #FindId = X
{
if %UseTinkering
{
If %TinkerSkill >= 900
Set %_fsIngotsNeeded 10
Else
Set %_fsIngotsNeeded 20
FindItem %IngotType C_ , %BackpackId
If #FindKind = -1 || #FindStack < %_fsIngotsNeeded
GoSub UnloadAtBase #false
GoSub MakeShovel
Goto FindShovelStart
}
if ! %UseTinkering
{
GoSub UnloadAtBase #false
Goto FindShovelStart
}
}
Return
; ** MakeShovel **
; Will make 1-2 shovels using tinkering - Using the menus or
; UOA macros if they have been setup
Sub MakeShovel
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
Set %_msTimeStart #sCnt2
GoSub UpdateStatusWindow MakeShovel
FindItem %TinkerType C_ , %BackpackId
Wait 5
If #FindKind <> -1 && #FindCnt = 1
{
If %UOATinkerToolKey <> N/A
{
Key %UOATinkerToolKey %UOATinkerToolMod
Wait %UOATinkerToolWait
}
If %UOATinkerToolKey = N/A
{
GoSub BringUpTinkerMenu #FindId
Wait 10
GoSub ClickTinkerButton 30 110
If %return
GoSub ClickTinkerButton 230 130
Set %LastMadeWasShovel #false
}
}
FindItem %TinkerType C_ , %BackpackId
If #FindKind <> -1
{
If %UOAShovelKey <> N/A
{
Key %UOAShovelKey %UOAShovelMod
Wait %UOAShovelWait
}
If %UOAShovelKey = N/A
{
GoSub BringUpTinkerMenu #FindId
If %LastMadeWasShovel ; If the last thing we made was a shovel, its easy!
GoSub ClickTinkerButton 285 410
If ! %LastMadeWasShovel
{
GoSub ClickTinkerButton 30 110
If %Return
{
GoSub ClickTinkerButtonNext
GoSub ClickTinkerButton 230 70
}
}
If %return
{
Set %LastMadeWasShovel #true
If %MakeTwoShovels
GoSub ClickTinkerButton 285 410
}
}
Set %_msCancelX #ContPosX + 10
Set %_msCancelY #ContPosY + 10
Click %_msCancelX %_msCancelY R ; Close tinker menu
}
GoSub RecordTiming %_msTimeStart MakeShovel
Return
; ** ClickTinkerButton **
Sub ClickTinkerButton
Set %_ctbX %1 + #ContPosX
Set %_ctbY %2 + #ContPosY
Click %_ctbX %_ctbY
Gosub waitForSysVar contSize <> 530_437 30
Gosub waitForSysVar contSize = 530_437 30
Wait 5
Return
; ** ClickTinkerButtonNoWait **
Sub ClickTinkerButtonNext
Set %_ctbnX 385 + #ContPosX
Set %_ctbnY 270 + #ContPosY
Click %_ctbnX %_ctbnY F
Wait 2s
Return
; ** BringUpTinkerMenu **
; Lag resistant opening of tinker menu
; Parameter 1: ID of tinker tool
Sub BringUpTinkerMenu
Set %_butmTinkerTool %1
Wait 5 ; A lot of times the tinker tool usage get 'You must wait...'
_butmTinkerMenu:
GoSub UseObject %_butmTinkerTool #false #false
Gosub waitForSysVar contSize = 530_437 30
if ! %return
goto _butmTinkerMenu
Return
;*****************************************
;******** Digging routines
;*****************************************
; ** Digger **
; The main digging sub, this is called (at least) once per mining
; location. It will prospect, hide, mine, unload to pack, unload to base
; Returns: GotoNextLocation. StayAtLocation, CheckShovel
Sub Digger
_diggerStart:
Set %_diggerLastStrike #sCnt
Set %_diggerNoReponse #false
; Give the reds less time to react, as soon as we come in, check if they are around and hide before dismounting
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
If ( ( %HideMineInFel && #cursKind = 0 ) || ( %HideMineElsewhere && #cursKind <> 0 ) ) && ( H notin #CharStatus ) && #scnt > %TryHideAgain
{
Event Macro 13 21
Set %TryHideAgain #scnt + 12
}
GoSub ShouldProspect
Set %_digShouldProspect %return
If ! %_digShouldProspect
GoSub DismountBeetle
_diggerLoop:
GoSub UpdateStatusWindow Digging
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
If ( ( %HideMineInFel && #cursKind = 0 ) || ( %HideMineElsewhere && #cursKind <> 0 ) ) && ( H notin #CharStatus ) && #scnt > %TryHideAgain
{
Event Macro 13 21
Set %TryHideAgain #scnt + 12
}
If ! %HaveTargetted && %_digShouldProspect
GoSub MountBeetle
GoSub FindUsableMiningTool
GoSub UseObject #Result %HaveTargetted #true
Set %_digShovelUsed ( %return <> Blocked )
if %_digShovelUsed
{
GoSub TargetMiningLocation
If %return = Failed
{
Set %return CheckShovel
Return
}
}
LinesPerCycle %lpsFast
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
GoSub CheckProgress
Set %CheckProgress %return
If %CheckProgress = Success
{
If %gNeedsCoordConv
GoSub RedefineDigSpot
Set %_diggerLastStrike #sCnt
Set %_diggerNoReponse #false
}
If %CheckProgress = MustWait
goto _diggerLoop
If %CheckProgress = Dismount
{
Set %_diggerNoReponse #false
GoSub DismountUnexpected
}
If %CheckProgress = NoResult
Set %_diggerNoReponse #true
If %CheckProgress = GotoNextLocation || %CheckProgress = CheckShovel
Return
If %CheckProgress = StayAtLocation
Goto _diggerStart
If ( %_diggerLastStrike + %GiveUpTime < #sCnt )
{
GoSub IncrementRuneIndex
Set #MenuButton N/A
If %return = GotoNextLocation
Return
If %return = StayAtLocation
Goto _diggerStart
}
LinesPerCycle %lpsNormal
If %_digShovelUsed && %_digShouldProspect && ! %HaveProspected
{
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
GoSub UpdateStatusWindow Prospecting
FindItem %ProspType C_ , %BackpackId
If #FindKind <> -1
{
GoSub UseObject #FindId #false #false
GoSub TargetMiningLocation
GoSub DismountBeetle
}
Set %HaveProspected #true
}
goto _diggerLoop
return
Sub CountUsableMiningTool
Set %_cumtCount 0
_cumtLoop:
FindItem %DiggingTools C_ , %BackpackId
If #FindKind <> -1
{
GoSub IsUsableMiningTool
If #Result
Set %_cumtCount %_cumtCount + 1
IgnoreItem #FindId
goto _cumtLoop
}
IgnoreItem Reset
Return %_cumtCount
Sub FindUsableMiningTool
_fumtLoop:
FindItem %DiggingTools C_ , %BackpackId
If #FindKind <> -1
{
GoSub IsUsableMiningTool
If ! #Result
{
IgnoreItem #FindId
goto _fumtLoop
}
}
IgnoreItem Reset
Return #FindId
Sub IsUsableMiningTool
If #FindType notin %PickAxe || #FindCol <> 0
Return #true
GoSub EventProperty #FindId
Return ( Gargoyle notin #Property )
Sub EventProperty
Event Property %1
Set %_propTimeout #sCnt + 4
_propLoop:
If #Property = 0 && #sCnt < %_propTimeout
goto _propLoop
Return
; ** TargetMiningLocation **
; Gets the mining target for this location, waits for the target cursor
; and actually does the targetting
; Returns: Failed, Success
Sub TargetMiningLocation
target 2s
If #TargCurs = 0
{
Set %return Failed
Return
}
Set %isClickLoc #true
If ! %HaveTargetted
{
GoSub GetUserDigLocation %iRuneBook %iRune %iSpot
if %return = InCoords
Set %isClickLoc #false
if %return <> InCoords
Set %gNeedsCoordConv #true
}
_tmlTargetAgain:
If #TargCurs = 1
{
If %HaveTargetted
Event Macro 22 0
If ! %HaveTargetted
{
if %isClickLoc
Click %DigSpotX %DigSpotY d
if ! %isClickLoc
{
Set #LTargetX %DigSpotX
Set #LTargetY %DigSpotY
Set #LTargetZ %DigSpotZ
Set #LTargetKind %DigSpotKind
Set #LTargetTile %DigSpotTile
Event Macro 22 0
}
}
Goto _tmlTargetAgain
}
Set %HaveTargetted #true
Set %return Success
Return
;*****************************************
;******** Check mining progress
;*****************************************
; ** CheckProgress **
; Checks weight and initiates unload, mining failur attempts, and report whether
; mining is progressing
; Returns: Success, GotoNextLocation, StayAtLocation, Dismount, MustWait
Sub CheckProgress
Set %return Unknown
If #Weight > %MaxWeight
{
If %UsePackAnimal
GoSub UnloadToPackAnimal
If ! %UsePackAnimal
GoSub UnloadAtBase #false
}
for %_cpIndex 1 4
{
ScanJournal %_cpIndex
if #journal = N/A
Return
If ( you_dig_some in #journal ) || ( you_loosen_some_rocks in #journal )
{
Set %return Success
Goto _cpReturn
}
If ( There_is_no_metal_here_to_mine in #journal ) || ( that_is_too_far_away in #journal ) || ( you_can't_mine_that in #journal ) || ( you_can't_mine_there in #journal ) || ( you_cannot_see_that_location in #journal )
{
GoSub IncrementRuneIndex
Goto _cpReturn
}
If mine_while_riding in #journal
{
Set %return Dismount
Goto _cpReturn
}
If You_must_wait in #journal
{
Set %return MustWait7
Goto _cpReturn
}
If ( #Weight > %MaxWeight ) || ( Your_backpack_is_full in #journal )
{
Set %_cpReturnValue %return
If %UsePackAnimal
GoSub UnloadToPackAnimal
If ! %UsePackAnimal
GoSub UnloadAtBase #false
Set %_diggerLastStrike #sCnt
Goto _cpReturn
}
}
Return
_cpReturn:
deletejournal
Return
Second part of code involves enemy detection and evasion, as well as unloading.
;*****************************************
;******** Enemy Detection and Evasion
;*****************************************
; ** Escape **
; Does its best attempt to recall away. If successful it will attempt
; to cure and heal before going to the next rune
Sub Escape
_escapeTryRecallAgain:
Set %_escapeLocationX #charPosX
Set %_escapeLocationY #charPosY
Set #MenuButton N/A
If %UOAEscapeKey = N/A
{
If %EscapeRecallTarget <> XXXXXXX
{
wait 30
GoSub RecallWithoutRunebook %EscapeRecallTarget
}
If %EscapeRecallTarget = XXXXXXX
GoSub Travel %BaseRunebook %BaseRune1 %TravelMethod #true
}
If %UOAEscapeKey <> N/A
Key %UOAEscapeKey %UOAEscapeMod
GoSub UpdateStatusWindow Escape
GoSub GetUserAttention Emergency
If %PauseAfterEscape
{
; Press [Play] when you are safe at your escape destination
pause
; Press [Play] when you are safe at your escape destination
}
Else
{
Set %_escapeRecallTimeout #sCnt + 10
_escapeCheckRecall:
If #sCnt > %_escapeRecallTimeout
{
GoSub CheckForConnDeath
Goto _escapeTryRecallAgain
}
If %_escapeLocationX = #charPosX && %_escapeLocationY = #charPosY
Goto _escapeCheckRecall
}
GoSub IncrementRuneIndex 1
Set %LastEnemyID #enemyID
If %UsePackAnimal
event macro 1 4 guards
Msg All Follow Me$
Wait 1s ; Allow time for recall and character information to populate (#charStatus)
Set %_escapeCureAttempt 0
_escapeCheckPoison:
If %CureWithMagery && %_escapeCureAttempt < 7 && ( C in #charStatus )
{
If %TravelMethod = 0
event macro 15 201
Else
event Macro 15 10
Target 6s
event Macro 23 0
Wait 2s
Set %_escapeCureAttempt %_escapeCureAttempt + 1
Goto _escapeCheckPoison
}
If C in #charStatus
{
GoSub GetUserAttention Emergency
Display OK You must cure yourself to continue (Press Play After)
Pause
Goto _escapeCheckPoison
}
Set %_escapeHealAttempt 0
_escapeCheckHP:
If %GrHealAfterEscape && %_escapeHealAttempt < 7 && ( #hits < #MaxHits )
{
If %TravelMethod = 0
event Macro 15 202
Else
event Macro 15 28
Target 6s
event Macro 23 0
Wait 10
Set %_escapeHealAttempt %_escapeHealAttempt + 1
Goto _escapeCheckHP
}
If #hits < #MaxHits
{
GoSub GetUserAttention
Display OK You must heal yourself to full to continue (Press Play After)
Pause
Goto _escapeCheckHP
}
If ! %BankDrop
{
FindItem %SecureId G_2
If #FindKind <> -1
GoSub UnloadAtBase #true
}
Return
; ** CheckEscapeStatus **
; Looks if there are reasons for the script to escape. Reds, damage, pack animal moving
; Returns: Escape, N/A
Sub CheckEscapeStatus
Set %return N/A
If %ShowStatus && #MenuButton = Escape
{
Set %return Escape
Set %escapeReason User , #spc , Request
}
If %EscapeOnDamage && #Hits + %DamageThreshold < #MaxHits
{
Set %return Escape
Set %escapeReason Damage
}
If %RedEscape && %return = N/A && #cursKind = 0
{
_cesSearch:
FindItem NAB_OAB_HS_IS
If #FindKind <> -1
{
If #FindRep <> 6 || #FindId = #CharID || #FindId in #CharID
{
IgnoreItem #findId
Goto _cesSearch
}
If %RedCheckNPC
{
}
Set %return Escape
event macro 1 4 guards
Set %escapeReason Red , #spc , Sighted
}
}
If %HighThreatMonster <> N/A
{
_cesSearch2:
FindItem %HighThreatMonster
If #FindKind <> -1
{
If #FindId = #CharID || #FindId in #CharID
{
IgnoreItem #findId
Goto _cesSearch2
}
Set %return Escape
event macro 1 4 guards
Set %escapeReason Monster , #spc , Threat
}
}
If %TrackPackAnimal && %UsePackAnimal && %return = N/A && ! %IsMounted
{
FindItem %PackAnimalId
If #FindDist > 1
{
Set %return Escape
Set %escapeReason Packy , #spc , Left
event macro 1 4 guards
Msg All Follow Me$
}
}
If %EscapeOnMonsterSighting && %LastEnemyID <> #enemyID
{
Set %LastEnemyID #enemyID
FindItem %LastEnemyID
if #FindType notin %NoThreatMonster
{
Set %return Escape
event macro 1 4 guards
Set %escapeReason Monster , #spc , Target
}
}
Set %CheckEscapeStatus ( %return <> N/A )
If ! %CheckEscapeStatus && %ShowStatus && #MenuButton = PauseBut
{
GoSub HandlePauseButton
}
Return
;*****************************************
;******** UnloadAtBase
;*****************************************
; ** UnloadAtBase **
; Unloads ore at the house or bank, recalls to the location, opens up all the containers
; moves all the ore to the bag then picks up whatever is needed (ingots, shovels, prosp tools)
; Parameter 1: boolean Need to recall or not
Sub UnloadAtBase
Set %AlreadyAtBase %1
If ! %AlreadyAtBase
{
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
If %MountBeforeRecall
GoSub MountBeetle
Set %_uabBaseRuneIndex ( #Random % %NumBaseRunes ) + 1
Set %_uabTimeStart #sCnt2
_uabStart:
GoSub Travel %BaseRunebook %BaseRune . %_uabBaseRuneIndex %TravelMethod #true
if %return = Blocked
{
Wait 6s
Set %_uabBaseRuneIndex %_uabBaseRuneIndex + 1
if %_uabBaseRuneIndex > %NumBaseRunes
Set %_uabBaseRuneIndex 1
Goto _uabStart
}
}
If %UsePackAnimal
{
GoSub DismountBeetle
Msg All Follow Me$
If ! %AlreadyAtBase
Wait 1s
;gosub genius
event macro 5 3
event macro 5 3
event macro 5 1
event macro 5 1
event macro 5 1
}
If %StandLocationX <> 0
{
GoSub UpdateStatusWindow MoveToPosition
If %DoorID <> XXXXXXX
{
_uabRetryPFDoor:
GoSub PathFind %DoorUseX %DoorUseY %DoorUseZ 6
if ! %Return
goto _uabRetryPFDoor
GoSub UseObject %DoorID #false #false
}
_uabRetryPFSecure:
GoSub PathFind %StandLocationX %StandLocationY %StandLocationZ 6
If ! %Return
goto _uabRetryPFSecure
}
GoSub UpdateStatusWindow UnloadingToBase
GoSub UpdateMiningResults
GoSub OpenAnyContainer PaperDoll #CharID 534 1 5
GoSub OpenAnyContainer Backpack %BackpackId 650 335 5
If %BankDrop
{
GoSub OpenAnyContainer Bank N/A 27 49 5
Set %_uabSecureId #ContId
}
If %HideOnBaseUnload && H notin #CharStatus
Event Macro 13 21
If ! %BankDrop
{
FindItem %SecureId G
If #FindDist > 2
Move #findX #findy 2 5s
GoSub OpenAnyContainer Container %SecureId 27 49 5
Set %_uabSecureId %SecureId
}
FindItem %OreBagId
If #FindKind = -1
{
Display OK Cannot find Backpack in Bank Box/House Secure to drop off ore.$Is it missing or has it not been specified correctly (OreBagId).$$The script will now stop.
Halt
}
If %UsePackAnimal
{
GoSub OpenAnyContainer Container %PackAnimalBagId 40 480 5
;FindItem %PackAnimalDropId C_ , %PackAnimalBagId
;GoSub OpenAnyContainer Container #FindId 265 490 5
GoSub DragAnyItem %OreTypes #true %PackAnimalBagId All %OreBagId %TrackGPValue
;GoSub DragAnyItem %GraniteType #true %PackAnimalBagId All %OreBagId #false
GoSub DragAnyItem %OreTypes #true %PackAnimalBagId All %OreBagId %TrackGPValue
}
gosub genius
GoSub DragAnyItem %OreTypes #true %BackpackId All %OreBagId %TrackGPValue
;GoSub DragAnyItem %GraniteType #true %BackpackId All %OreBagId #false
If %UseProspector <> %NoColor
{
FindItem %ProspType C_ , %BackpackId
If #FindKind = -1
{
GoSub DragAnyItem %ProspType #true %_uabSecureId 1 #charid #false
If %return = NoneFound
{
Display YesNo Could not find any prospector's tools at the top of your bank/secure container.$$Would you like to continue without the use of a prospector's tool?
If #DispRes = No
Halt
Set %UseProspector %NoColor
}
}
}
if %UseTinkering
{
_uabMoreIngots:
FindItem %IngotType C_ , %BackpackId
If #FindKind = -1 || #FindStack < 40
{
GoSub DragAnyItem %IngotType %UseAnyColourIngot %_uabSecureId 60 %backpackid #false
If %return = NoneFound
{
Display YesNo Could not find any ingots at the top of your bank/secure container.$
+Without more you will not be able to continue mining (can't make shovels)$$
+Would you like to have 20 seconds to place some ingots at the top of your secure?
If #DispRes = No
Halt
Wait 20s
Goto _uabMoreIngots
}
}
}
_uabShovelLoop:
GoSub CountUsableMiningTool
If #Result < %MinShovels
{
GoSub DragAnyItem %DiggingTools #true %_uabSecureId 1 %BackpackId #false
If %return = NoneFound
{
If %UseTinkering
goto _uabBreakShovelLoop
Display YesNo Could not find any shovels at the top of your bank/secure container.$
+You won't be able to continue without more.$$
+Would you like to have 15 seconds to place shovels where script can find them?
If #DispRes = No
Halt
Wait 15s
}
Goto _uabShovelLoop
}
_uabBreakShovelLoop:
If ! %RegSuit
{
GoSub PickupReagent %MandrakeRoot Mandrake %_uabSecureId
GoSub PickupReagent %Bloodmoss Bloodmoss %_uabSecureId
GoSub PickupReagent %BlackPearl Black , #spc , Pearl %_uabSecureId
}
Event Macro 9 1 ; Close PaperDoll
GoSub SetStartOre #false
GoSub RecordTiming %_uabTimeStart UnloadToBase
If ! %AlreadyAtBase
{
If %NextRuneOnBaseUnload
GoSub IncrementRuneIndex 1
GoSub RecallMine
}
Return
; ** PickupReagent **
; A support function to remove duplicate code
; Parameter 1: ITEM_TYPE Type for Reagent
; Parameter 2: STRING Name of Reagent for user displayed dialog
; Parameter 3: ITEM_ID The container to look for reagents
Sub PickupReagent
Set %_prRegType %1
Set %_prRegName %2
Set %_prSecureId %3
FindItem %_prRegType C_ , %BackpackId
If #findkind = -1 || #findstack < 20
{
_prMoreIngots:
GoSub DragAnyItem %_prRegType #true %_prSecureId 30 %BackpackId #false
If %return = NoneFound
{
Display YesNo Could not find any , #spc , %_prRegName , #spc , at the top of your bank/secure container.$
+You won't be able to continue without more.$$
+Would you like to have 15 seconds to place some regs at the top of your secure?
If #DispRes = No
Halt
Wait 15s
Goto _prMoreIngots
}
}
Return
;*****************************************
;******** Pack Animal Routines
;*****************************************
; ** UnloadToPackAnimal **
; Unloads ore from the backpack to the pack animal (uses DragAnyItem to do the work)
Sub UnloadToPackAnimal
Set %_utpTimeStart #sCnt2
GoSub UpdateStatusWindow UnloadToPack
GoSub UpdateMiningResults
Set %_utpaUnload #false
_utpaStart:
FindItem %PackAnimalId
If #FindKind = -1
Set %_utpaUnload #true
If #FindKind <> -1
{
If #FindDist > 1
{
event macro 1 4 guards
Msg All Follow Me$
Wait 1s
Goto _utpaStart
}
If %HideOnPackUnload && ( H notin #CharStatus ) && #scnt > %TryHideAgain
{
Event Macro 13 21
Set %TryHideAgain #scnt + 12
}
;FindItem %PackAnimalDropId C_ , %PackAnimalBagId
;If #FindKind = -1
;GoSub OpenAnyContainer Container %PackAnimalBagId 40 480 5
;FindItem %PackAnimalDropId C_ , %PackAnimalBagId
;If #FindKind = -1
;Display OK Could not find the drop bag inside the Pack Animal container$$Check PackAnimalBagId variable
GoSub DragAnyItem %OreTypes #true %BackpackId All %PackAnimalId #false
If %return = DestinationMissing
{
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
}
If %return = ContainerFull
Set %_utpaUnload #true
GoSub DragAnyItem %GraniteType #true %BackpackId All %PackAnimalId #false
If %return = DestinationMissing
{
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
}
If %return = ContainerFull
Set %_utpaUnload #true
}
GoSub SetStartOre #false
If ! %_utpaUnload
GoSub RecordTiming %_utpTimeStart UnloadToPack
If %_utpaUnload
{
GoSub RecordTiming %_utpTimeStart UnloadToPackPartial
GoSub UnloadAtBase #false
}
Return
; ** DismountUnexpected **
; This is called to dismount when the script thought you were already dismounted
Sub DismountUnexpected
GoSub UseObject #CharID #false #false
Set %IsMounted #false
Return
; ** DismountBeetle **
; Dismount from your beetle, the sub will check if you are even using beetles
; This moves the checking code to one place and removed 'if conditions' from places
; like the Digger sub. MountBeetle is the other side of this function
Sub DismountBeetle
If ! %UsePackAnimal || ! %UsingBeetle || ! %IsMounted
Return
FindItem %PackAnimalId G
If #FindKind = -1 || #FindBagId = #CharId
{
_dbLoop:
GoSub UseObject #CharID #false #false
Set %_dbTimeout #sCnt + 3
_dbWaitForBeetle:
if %_dbTimeout < #sCnt
Goto _dbLoop
FindItem %PackAnimalId
If #FindKind = -1
goto _dbWaitForBeetle
}
Set %IsMounted #false
Return
; ** MountBeetle **
; Mount from your beetle, the sub will check if you are even using beetles
; DismountBeetle is the other side of this function
Sub MountBeetle
If ! %UsePackAnimal || ! %UsingBeetle || %IsMounted
Return
_mbCallBeetle:
FindItem %PackAnimalId
If #FindKind <> 1
Return
If #FindDist > 1
{
event macro 1 4 guards
Msg All Follow Me$
Wait 1s
}
Set %_mbCallTimeout #scnt + 4
_mbWaitForBeetle:
If %_mbCallTimeout < #scnt
Goto _mbCallBeetle
If #FindDist > 1
goto _mbWaitForBeetle
_mbMount:
GoSub UseObject %PackAnimalId #false #false
Wait 1s
FindItem %PackAnimalId
If #FINDKIND <> -1 && #FindBagId <> #CharID
Goto _mbMount
Set %IsMounted #true
Return
;*****************************************
;******** Runebook routines
;*****************************************
; ** RecallMine **
; Recall for the purposes of going to another mining location (not escaping), waits for mana
; and moves to the next rune if blocked
Sub RecallMine
If %MountBeforeRecall
GoSub MountBeetle
If %WaitForMana && #Mana < 32
{
GoSub UpdateStatusWindow WaitMana
_rmWaitMana:
GoSub CheckEscapeStatus
If %CheckEscapeStatus
Return
If %HideWhileManaWait && ( H notin #CharStatus ) && #scnt > %TryHideAgain
{
Event Macro 13 21
Set %TryHideAgain #scnt + 12
}
If #Mana < 32
goto _rmWaitMana
}
_rmTryAgain:
GoSub Travel %_RuneBook . %iRuneBook %iRune %TravelMethod #true
If %return = Blocked
{
GoSub IncrementRuneIndex 1
goto _rmTryAgain
}
GoSub SetStartOre #true
Return
; ** RecallWithoutRunebook **
; Recall by casting the spell and targetting a provided item
; Parameter 1: ITEM_ID Target for the recall (rune or runebook)
Sub RecallWithoutRunebook
Set %_rwrRuneTarget %1
_rwrCastRecall:
if %CastGate
Event Macro 15 51
Else
{
If %TravelMethod = 0
Event Macro 15 210
Else
Event Macro 15 31
}
Set #lTargetId %_rwrRuneTarget
Set #lTargetKind 1
Target 6s
If #TargCurs = 0
Goto _rwrCastRecall
Event Macro 22 0
if %CastGate
{
Set %_rwrGateTimeOut #sCnt + 6
_rwrLookForGate:
FindItem %GateType G_0
If #sCnt > %_rwrGateTimeOut
Goto _rwrCastRecall
If #FindKind = -1
Goto _rwrLookForGate
GoSub UseObject #FindID #false #false
}
Return
; ** Travel **
; Slightly reworked version of Recall sub from Standard subs, handles Gates as well as recall
; Parameter 1: ITEM_ID Runebook ID
; Parameter 2: Integer Rune index (1-16)
; Parameter 3: String Gate, SacredJourney, Recall
; Parameter 4: Boolean #true if called during mining, #flase when used through Location Definer (doesn't update status window)
Sub Travel
Set %_travelBookId %1
Set %_travelRune %2
If %3 = 0
Set %_travelType SacredJourney
Else
Set %_travelType Recall
Set %_travelStandard %4
Set %_travelLastMessage N/A
If %CastGate
Set %_travelType Gate
Set %_travelTimeStart #sCnt2
if %_travelStandard
GoSub UpdateStatusWindow Recall
Set %_pagex ( ( ( %_travelRune + 1 ) / 2 ) * 34 )
If ( ( %_travelRune + 1 ) / 2 ) > 4
Set %_pagex %_pagex + 31
_travelAgain:
Set %_travelOldX #CharPosx
Set %_travelOldY #CharPosy
_travelOpenAgain:
GoSub UseObject %_travelBookId #false #false
Gosub waitForSysVar contSize = 452_236 60
If ! %return
{
if %_travelStandard 2
Set %_travelLastMessage %_uswLastMessage
GoSub UpdateStatusWindow RecallBookError
Goto _travelOpenAgain
}
if %_travelLastMessage <> N/A
GoSub UpdateStatusWindow %_travelLastMessage
Wait 10
Set %_usePageX #ContPosX + 105 + %_pagex
Set %_usePageY #ContPosY + 200
Click %_usePageX %_usePageY F
Wait 5
deletejournal
Set %_usePageX #ContPosX + 140
If ( %_travelRune % 2 ) = 0
Set %_usePageX #ContPosX + 300
Set %_usePageY #ContPosY + 145
If %_travelType = Gate
Set %_usePageY %_usePageY + 20
If %_travelType = SacredJourney
Set %_usePageY %_usePageY + 40
Click %_usePageX %_usePageY F
Gosub waitForSysVar contSize <> 452_236 30
Set %_travelTimeout #sCnt + 10
_travelWaitForRecall:
If #SCNT > %_travelTimeout
{
If %FixForUORecallBug
{
Set %return Bl