forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mining-buddy.lic
124 lines (101 loc) · 3.36 KB
/
mining-buddy.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#mining-buddy
=end
custom_require.call(%w(common common-items common-money common-travel drinfomon))
class MiningBuddy
include DRC
include DRCI
include DRCM
include DRCT
def initialize
setup
ensure_copper_on_hand(10_000, @hometown)
if @use_packet
buy_deed_packet unless exists?('packet')
buy_deed_packet unless exists?('second packet')
first = bput('look first packet', 'You count \d+').scan(/\d+/).first.to_i
second = bput('look second packet', 'You count \d+').scan(/\d+/).first.to_i
if second < first
fput('get my second packet')
fput('stow my packet')
end
end
@areas.each { |area_name| mine_rooms(@area_list[area_name]) }
end
def buy_deed_packet
order_item(8775, 14)
fput('stow my packet')
end
def setup
settings = get_settings
@area_list = get_data('mining').mining_buddy_rooms
@forging_belt = settings.forging_belt
@areas = settings.mines_to_mine
@skip_populated = settings.mining_skip_populated
@mine_every_room = settings.mining_buddy_mine_every_room
@vein_list = settings.mining_buddy_vein_list
@mining_implement = settings.mining_implement
@use_packet = settings.mine_use_packet
@hometown = settings.hometown
echo("#{@areas}:#{@vein_list}") if UserVars.mining_debug
end
def get_mining_tool
if @forging_belt['items'].grep(/shovel/i).any?
bput("untie my #{@mining_implement}", 'You remove')
else
bput("get my #{@mining_implement}", 'You get', 'You are already')
end
end
def store_mining_tool
waitrt?
if @forging_belt['items'].grep(/shovel/i).any?
fput("tie my #{@mining_implement} to #{@forging_belt['name']}")
else
fput("stow my #{@mining_implement}")
end
end
def check_repair
get_mining_tool
result = bput("anal my #{@mining_implement}", 'practically in mint', 'pristine condition', 'in good condition', 'crafting tool and it is rather scuffed up', 'Roundtime')
waitrt?
store_mining_tool
return unless /roundtime/i =~ result
repair = get_data('town')[@hometown]['metal_repair']
walk_to(repair['id'])
get_mining_tool
fput("give #{repair['name']}")
fput("give #{repair['name']}")
pause 10 until 'should be ready by now' == bput('look at my ticket', 'should be ready by now', 'Looking at the')
fput("give #{repair['name']}")
store_mining_tool
end
def mine_rooms(rooms)
rooms.each do |room|
wait_for_script_to_complete('safe-room') if bleeding?
check_repair if mine?(room)
end
end
def mine?(room)
waitrt?
walk_to(room)
unless DRRoom.pcs.empty?
return false if @skip_populated
fput('wave')
end
unless @mine_every_room
bput('prospect', 'Roundtime')
results = reget(20, 'can be mined here')
echo(results) if UserVars.mining_debug
return false if results.nil?
return false unless results
.each_with_object([]) { |line, array| array << line.match(/You are certain that (.*) can be mined here/i)[1] }
.reject(&:nil?)
.map(&:downcase)
.any? { |vein| @vein_list.map(&:downcase).include?(vein) }
end
waitrt?
wait_for_script_to_complete('mine')
true
end
end
MiningBuddy.new