Author Topic: Mining 0.1 for Public Testing  (Read 2730 times)

0 Members and 1 Guest are viewing this topic.

Offline VicVegaTopic starter

  • Jr. Member
  • **
  • Posts: 71
  • Activity:
    0%
  • Reputation Power: 0
  • VicVega has no influence.
  • Respect: +8
  • Referrals: 0
    • View Profile
Mining 0.1 for Public Testing
« on: June 07, 2009, 09:10:44 AM »
0
Features: This script recalls to the mining spot, when overloaded recalls home and drops the ores and the jewelry to a chest in your home, and then recalls to the next mining spot on your runebook. If your shovel brokes, recalls home, picks up iron and tinkering tools from the chest and makes a new shovel. The script also writes to a miningData.txt file some data about your mining rates.

Here is a miningData.txt sample output:

Quote
Start Time: 18:08:01
Time: 18:18:21 | Time Mining: 00:10:20 | Ore Mined: 159 | Ore Per Hour: 923
Time: 18:28:21 | Time Mining: 00:20:20 | Ore Mined: 318 | Ore Per Hour: 938
Time: 18:38:40 | Time Mining: 00:30:38 | Ore Mined: 480 | Ore Per Hour: 940

Here is the mining.txt code, you need another three auxiliar scripts included on the zip:

Code: [Select]
;=================================================================
; Script Name: Mining
; Author: VicVega
; Version: 0.1
; Shard OSI / FS: UO Legends
; Revision Date: 7/5/2009
; Purpose: Mines, recalls, drops ores and mines again
; Globals: None
;=================================================================
; Instructions: You need auxiliar scripts saveTextFoFile.vbs, runebooks.txt and
; makeShovel.txt to be in the same folder as this script.
; You need to setup each mining position coords at the
; setupMiningPos sub. You need a runebook with the mining spots in order.
; Example: First Runebook Slot = First Mining Spot,
; Second Runebook Slot = Second Mining Spot ...
; You must specify the spot's number at %maxRunes variable
; You must specify in wich slot it's your rune for recalling home at the
; %runeHomeNo variable.
; You need a wood chest outside your home in order to drop the ingots and jewels.
; If your character it's an elf, you must adjust the %maxWeight variable
; Thanks: TrailMyx for his ConvertTimeHourMinSec sub
;         JoMac for his saveTextToFile.vbs script
;         Vito for his runeBook.txt script
;************************ Setup **********************************
gosub setup
;*********************** Main Loop *******************************
repeat
  gosub checkWeight
  gosub saveData
  gosub recallMiningPosition
  gosub mining
until #charGhost = yes
halt
;************************* Subs **********************************
sub setup
  gosub setupMiningPos
  set %maxWeight #maxWeight + 40
  set %oreType DWJ
  set %shovelType TWF_QPF
  set %recallType recall
  set %woodenChestType JIF
  finditem %woodenChestType G_2
  set %woodenChestID #findID
  gosub saveStartData
return

sub setupMiningPos
  set %posX1 xxxx
  set %posY1 xxxx
  set %posX2 xxxx
  set %posY2 xxxx
  set %posX3 xxxx
  set %posY3 xxxx

  set %homeX 733
  set %homeY 720

  set %runeHomeNo 8
  set %runeNo 0
  set %maxRunes 3
return

sub saveStartData
  set %startTime #scnt
  set %lastSave %startTime
  gosub time #time
  set %oreMined 0
  gosub writeStartData
return

sub writeStartData
  execute SaveTextToFile.Vbs #false #false #curPath miningData.txt
  + Start Time: %time
return

sub saveData
  if #scnt >= %lastSave + 600
  {
    set %timeMining #scnt - %startTime
    gosub ConvertTimeHourMinSec %timeMining
    set %timeMiningConverted #result
    set %lastSave #scnt
    set %orePerHour ( %oreMined * 3600 ) / %timeMining
    gosub time #time
    gosub writeData
  }
return

sub writeData
  execute SaveTextToFile.Vbs #false #false #curPath miningData.txt
  + Time: %time |
  + Time Mining: %timeMiningConverted |
  + Ore Mined: %oreMined |
  + Ore Per Hour: %orePerHour
return

sub recallHome
  call runeBook.txt %recallType %runeHomeNo
  gosub waitingRecallPos %homeX %homeY
return

sub recallMiningPosition
  set %runeNo %runeNo + 1
  if %Runeno > %MaxRunes
    set %runeNo 1

  set %posX  %posX . %RuneNo
  set %posY  %posY . %RuneNo

  wait 10
  call runeBook.txt %recallType %runeNo
  gosub waitingRecallPos %posX %posY
return

sub waitingRecallPos
  set %maxTimeOut 10
  set %posX %1
  set %posY %2
  set %timeOut #scnt + %maxTimeOut
  while #charPosX <> %posX && #scnt < %timeOut
    wait 1s
  set %timeOut #scnt + %maxTimeOut
  while #charPosY <> %posY && #scnt < %timeOut
    wait 1s
  if #scnt >= %timeOut
  {
    call runeBook.txt %recallType %runeNo
    gosub waitingRecallPos %posX %posY
  }
return

sub checkWeight
  if #weight >= %maxWeight
  {
    if %spotDepleted = #false
      set %runeNo %runeNo - 1
    gosub recallHome
    gosub dropItemsChest %oreType
    gosub dropJewels
  }
return

sub dropJewels
  set %turquoise ZWS
  set %fireRuby VWS
  set %darkSapphire AXS
  set %blueDiamond GXS
  set %perfectEmerald UWS
  set %ecruCitrine TWS

  gosub dropItemsChest %turquoise
  gosub dropItemsChest %fireRuby
  gosub dropItemsChest %darkSapphire
  gosub dropItemsChest %blueDiamond
  gosub dropItemsChest %perfectEmerald
  gosub dropItemsChest %ecruCitrine
return

sub dropItemsChest
  finditem %1 C_ , #backpackID
  while #findKind <> -1
  {
    if #findType = %oreType
      set %oreMined %oreMined + #findStack
    exevent drag #findID #findStack
    wait 10
    exevent dropc %woodenChestID
    wait 2s
    finditem %1 C_ , #backpackID
  }
return

sub mining
  set %spotDepleted #false
  gosub tileName
  while #weight <= %maxWeight && %spotDepleted = #false
  {
    gosub useShovel
    gosub scan
  }
return

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

  while #scnt < %timeout
  {
    if %jrnl < #jindex
    {
      set %jrnl %jrnl + 1
      scanjournal %jrnl
    }

    if you_dig in #journal || loosen_some in #journal
    {
      set %spotDepleted #false
      return
    }

    if there_is_no_metal in #journal
    {
      set %spotDepleted #true
      return
    }
  }
return

sub useShovel
  set #lTargetKind 3
  set #lTargetX #CHARPOSX
  set #lTargetY #CHARPOSY
  set #lTargetZ #charPosZ
  finditem %shovelType C_ , #backpackID
  while #findKind = -1
  {
    gosub recallHome
    call makeShovel.txt
    set %runeNo %runeNo - 1
    gosub recallMiningPosition
    finditem %shovelType C_ , #backpackID
  }
  set #LOBJECTID #FINDID
  event macro 17
  target 3s
  event macro 22
return

sub tileName
  set %miningPosX #charPosX + %x
  set %miningPosY #charPosY + %y
  tile init
  tile cnt %miningPosX %miningPosY
  for %j 1 #tilecnt
  {
    tile get %miningPosX %miningPosY  %j
    set %canMine cave_floor in #tileName
    if %canMine
    {
      set #lTargetTile #tileType
      return #true
    }
  }
return

sub time
  set %time %1
  str ins %time : 3
  set %time #strRes
  str ins %time : 6
  set %time #strRes
return

; %1 = input - Time to convert
; #RESULT -  Time converted to H:MM:SS format
sub ConvertTimeHourMinSec
  namespace push
  namespace local ctime
  set !hourpart %1 / 3600
  set !secpart ( %1 % 3600 ) % 60
  set !minpart ( ( %1 % 3600 ) / 60 )

  if !hourpart >= 10
    set #RESULT !hourpart , :
  else
    set #RESULT 0 , !hourpart , :
  if !minpart < 10
    set #RESULT #RESULT , 0
  set #RESULT #RESULT , !minpart , :
  if !secpart < 10
    set #RESULT #RESULT , 0
  set #RESULT #RESULT , !secpart
  namespace pop
return #RESULT

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
mining.zip
« Last Edit: June 17, 2009, 01:38:53 PM by VicVega »
To learn, read.
To know, write.
To master, teach.

Offline Imithole

  • Newbie
  • *
  • Posts: 4
  • Activity:
    0%
  • Reputation Power: 0
  • Imithole has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Mining 0.1 for Public Testing
« Reply #1 on: June 19, 2009, 12:48:00 PM »
0
thx for your effort!

Tags: