forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forestry-buddy.lic
106 lines (85 loc) · 2.91 KB
/
forestry-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
=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 ForestryBuddy
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| chop_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('lumber').lumber_buddy_rooms
@areas = settings.forests_to_chop
@skip_populated = settings.lumber_skip_populated
@chop_every_room = settings.mining_buddy_chop_every_room
@tree_list = settings.lumber_buddy_tree_list
@lumber_implement = settings.lumber_implement
@use_packet = settings.lumber_use_packet
@hometown = settings.hometown
echo("#{@areas}:#{@tree_list}") if UserVars.lumber_debug
end
def check_repair
fput("get #{@lumber_implement}")
result = bput("app my #{@lumber_implement}", 'practically in mint', 'pristine condition', 'in good condition', 'Roundtime')
waitrt?
fput("stow #{@lumber_implement}")
return unless /roundtime/i =~ result
repair = get_data('town')[@hometown]['metal_repair']
walk_to(repair['id'])
fput("get #{@lumber_implement}")
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']}")
fput("stow #{@lumber_implement}")
end
def chop_rooms(rooms)
rooms.each do |room|
wait_for_script_to_complete('safe-room') if bleeding?
check_repair if chop?(room)
end
end
def chop?(room)
waitrt?
walk_to(room)
unless DRRoom.pcs.empty?
return false if @skip_populated
fput('wave')
end
unless @chop_every_room
bput('watch forest', 'Roundtime')
results = reget(20, 'can be harvested')
echo(results) if UserVars.lumber_debug
return false if results.nil?
return false unless results
.each_with_object([]) { |line, array| array << line.match(/You are certain that (.*) trees can be/i)[1] }
.reject(&:nil?)
.map(&:downcase)
.any? { |tree| @tree_list.map(&:downcase).include?(tree) }
end
waitrt?
wait_for_script_to_complete('chop-wood')
true
end
end
ForestryBuddy.new