forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-crafting.lic
143 lines (128 loc) · 5.06 KB
/
common-crafting.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-crafting
=end
custom_require.call(%w(common common-travel drinfomon))
module DRCC
module_function
def empty_crucible?
['nothing in there'].include?(DRC.bput('look in cruc', 'nothing in there', 'you see'))
end
def find_empty_crucible(hometown)
return unless 'I could not' == DRC.bput('tap crucible', 'I could not', 'You tap.*crucible')
crucibles = get_data('crafting')['blacksmithing'][hometown]['crucibles']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(crucibles, idle_room, proc { (DRRoom.pcs - DRRoom.group_members).empty? && empty_crucible? })
end
def clean_anvil?
case DRC.bput('look on anvil', 'surface looks clean and ready', 'anvil you see .*bronze', 'anvil you see')
when /surface looks clean and ready/i
true
when /bronze/
case DRC.bput('clean anvil', 'You drag the', 'remove them yourself')
when /drag/
fput('clean anvil')
pause
waitrt?
else
fput('get ingot from anvil')
fput('put ingot in bucket')
end
true
else
false
end
end
def find_wheel(hometown)
wheels = get_data('crafting')['tailoring'][hometown]['spinning-rooms']
idle_room = get_data('crafting')['tailoring'][hometown]['idle-room']
DRCT.find_sorted_empty_room(wheels, idle_room)
end
def find_anvil(hometown)
return unless 'I could not' == DRC.bput('tap anvil', 'I could not', 'You tap.*anvil')
anvils = get_data('crafting')['blacksmithing'][hometown]['anvils']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(anvils, idle_room, proc { (DRRoom.pcs - DRRoom.group_members).empty? && clean_anvil? })
end
def find_grindstone(hometown)
return unless 'I could not' == DRC.bput('tap grindstone', 'I could not', 'You tap.*grindstone')
grindstones = get_data('crafting')['blacksmithing'][hometown]['grindstones']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(grindstones, idle_room)
end
def find_sewing_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
sewingrooms = get_data('crafting')['tailoring'][hometown]['sewing-rooms']
idle_room = get_data('crafting')['tailoring'][hometown]['idle-room']
DRCT.find_sorted_empty_room(sewingrooms, idle_room)
end
end
def find_shaping_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
shapingrooms = get_data('crafting')['shaping'][hometown]['shaping-rooms']
idle_room = get_data('crafting')['shaping'][hometown]['idle-room']
DRCT.find_sorted_empty_room(shapingrooms, idle_room)
end
end
def recipe_lookup(recipes, item_name)
match_names = recipes.map { |x| x['name'] }.select { |x| x =~ /#{item_name}/i }
case match_names.length
when 0
echo("No recipe in base-recipes.yaml matches #{item_name}")
nil
when 1
recipes.find { |x| x['name'] =~ /#{item_name}/i }
else
echo('Please select desired recipe ;send #')
match_names.each_with_index { |x, i| respond " #{i + 1}: #{x}" }
line = get until line.strip =~ /^([0-9]+)$/
item_name = match_names[Regexp.last_match(1).to_i - 1]
recipes.find { |x| x['name'] =~ /#{item_name}/i }
end
end
def find_recipe(chapter, match_string)
fput("turn my book to chapter #{chapter}")
recipe = DRC.bput('read my book', "Page \\d+.*#{match_string}").split('Page').find { |x| x =~ /#{match_string}/i }
recipe =~ /(\d+):/
Regexp.last_match(1)
end
def get_crafting_item(name, bag, bag_items, belt)
waitrt?
if belt && belt['items'].find { |item| /\b#{name}/i =~ item || /\b#{item}/i =~ name }
if 'untie what' == DRC.bput("untie my #{name} from my #{belt['name']}", 'you remove', 'untie what')
echo("You seem to be missing: #{name} from your #{belt['name']}")
exit
end
else
command = "get my #{name}"
command += " from my #{bag}" if bag_items && bag_items.include?(name)
case DRC.bput(command, '^You get', '^You are already', '^What do you', '^What were you', 'You pick up', "can't quite lift it")
when 'What do you', 'What were you'
echo("You seem to be missing: #{name}")
exit
when "can't quite lift it"
get_crafting_item(name, bag, bag_items, belt)
end
end
end
def stow_crafting_item(name, bag, belt)
return unless name
waitrt?
if belt && belt['items'].find { |item| /\b#{name}/i =~ item || /\b#{item}/i =~ name }
DRC.bput("tie my #{name} to my #{belt['name']}", 'you attach')
else
case DRC.bput("put my #{name} in my #{bag}", 'You put your', 'What were you referring to', 'is too \w+ to fit', 'You can\'t put that there')
when /is too \w+ to fit/
fput("stow my #{name}")
when 'You can\'t put that there'
fput("put my #{name} in my other #{bag}")
return false
end
end
true
end
end