forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon-crafting.lic
More file actions
160 lines (144 loc) · 5.97 KB
/
common-crafting.lic
File metadata and controls
160 lines (144 loc) · 5.97 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# 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 DRC.bput('tap crucible', 'I could not', 'You tap.*crucible') == 'I could not'
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
case DRC.bput('get ingot from anvil', 'You get', 'the bronze ingot is not yours')
when 'the bronze ingot is not yours'
fput('clean anvil')
fput('clean anvil')
else
fput('put ingot in bucket')
end
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 DRC.bput('tap anvil', 'I could not', 'You tap.*anvil') == 'I could not'
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 DRC.bput('tap grindstone', 'I could not', 'You tap.*grindstone') == 'I could not'
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)
case bput("turn my book to chapter #{chapter}", 'You turn', 'You are too distracted to be doing that right now', 'The book is already turned')
when 'You are too distracted to be doing that right now'
echo '***CANNOT TURN BOOK, ASSUMING I AM ENGAGED IN COMBAT***'
fput('look')
fput('exit')
end
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 DRC.bput("untie my #{name} from my #{belt['name']}", 'You remove', 'Untie what') == 'You remove'
return
end
end
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
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
def logbook_item(logbook, noun, container)
DRC.bput("get my #{logbook} logbook", 'You get')
case bput("bundle my #{noun} with my logbook", 'You notate the', 'This work order has expired', 'The work order requires items of a higher quality', 'That isn\'t the correct type of item for this work order.')
when 'This work order has expired', 'The work order requires items of a higher quality', 'That isn\'t the correct type of item for this work order.'
dispose_trash(noun)
end
DRC.bput("put my #{logbook} logbook in my #{container}", 'You put')
end
end