forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-items.lic
193 lines (163 loc) · 7.02 KB
/
common-items.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-items
=end
$TRASH_STORAGE = %w[bin gloop barrel bucket urn log arms stump tree]
custom_require.call(%w[common common-travel])
module DRCI
module_function
def buy_item(room, item)
DRCT.walk_to(room)
# Amount to pay should be first capturing group.
patterns = [/prepared to offer it to you for (.*) (?:kronar|lirum|dokora)s?/,
/Let me but ask the humble sum of (.*) coins/,
/for a (?:mere )?(.*) (?:kronar|lirum|dokora)s?/,
/I can let that go for...(.*) (?:kronar|lirum|dokora)s?/,
/cost you (?:just )?(.*) (?:kronar|lirum|dokora)s?/,
/it may be yours for just (.*) (?:kronar|lirum|dokora)s?/,
/I'll give that to you for (.*) (?:kronar|lirum|dokora)s?/,
/I ask that you give (.*) copper (?:kronar|lirum|dokora)s?/,
/it'll be (.*) (?:kronar|lirum|dokora)s?/,
/the price of (.*) coins? is all I ask/,
/tis only (.*) (?:kronar|lirum|dokora)s?/,
/That will be (.*) copper (?:kronar|lirum|dokora)s? please/,
/to you for (.*) (?:kronar|lirum|dokora)s?/,
/I ask (.*) copper (?:kronar|lirum|dokora)s or if you would prefer/,
/Cost you just (.*) (?:kronar|lirum|dokora)s?, okie dokie\?/i,
/It will cost just (.*) (?:kronar|lirum|dokora)s?/i,
/I would suggest (.*) (?:kronar|lirum|dokora)s?/i,
'You decide to purchase',
'Buy what']
match = DRC.bput("buy #{item}", *patterns)
if match
patterns.each { |p| break if p.match(match) }
end
amount = Regexp.last_match(1)
fput("offer #{amount}") if amount
end
def order_item(room, item_number)
DRCT.walk_to(room)
return if DRC.bput("order #{item_number}", 'Just order it again', 'you don\'t have enough coins') == 'you don\'t have enough coins'
DRC.bput("order #{item_number}", 'takes some coins from you')
end
def dispose(item, trash_room = nil)
DRCT.walk_to(trash_room) unless trash_room.nil?
case DRC.bput("get my #{item}", 'You get', 'What were you', 'You pick up')
when 'You get', 'You pick up'
dispose_trash(item)
end
end
def dispose_trash(item)
return if item.nil?
trashcans = DRRoom.room_objs
.map { |long_name| DRC.get_noun(long_name) }
.select { |obj| $TRASH_STORAGE.include?(obj) }
trashcans.each do |trashcan|
if trashcan == 'gloop'
trashcan = 'bucket' if DRRoom.room_objs.include? 'bucket of viscous gloop'
trashcan = 'cauldron' if DRRoom.room_objs.include? 'small bubbling cauldron of viscous gloop'
elsif trashcan == 'arms'
trashcan = 'statue'
elsif trashcan == 'tree'
trashcan = 'hollow' if DRRoom.room_objs.include?('dead tree with a darkened hollow near its base')
elsif XMLData.room_title == '[[A Junk Yard]]'
trashcan = 'bin'
end
if /^You (drop|put)/ =~ DRC.bput("put my #{item} in #{trashcan}", '^You drop', '^You put', "You're kidding, right", 'What were you referring to', "You can't do that")
return
end
end
DRC.bput("drop my #{item}", 'You drop', 'What were you', 'You spread .* on the ground.')
end
def search?(item)
/Your .* is in/ =~ DRC.bput("inv search #{item}", 'You can\'t seem to find anything that looks like that', 'Your .* is in')
end
def wearing?(description)
result = DRC.bput("tap my #{description}", 'You tap .*', 'I could not find', 'on the shoulder')
result =~ /wearing/
end
def inside?(description, container)
result = DRC.bput("tap my #{description} in my #{container}", 'You tap .*', 'atop your', 'I could not find', 'on the shoulder')
result =~ /inside/
end
def exists?(description)
result = DRC.bput("tap my #{description}", 'You tap .*', 'I could not find', 'on the shoulder', '^You thump your fingers')
result =~ /You tap|You thump/
end
def count_item_parts(item)
match_messages = [
/and see there (?:is|are) (.+) left\./,
/There (?:is|are) (?:only )?(.+) parts? left/,
/There's (?:only )?(.+) parts? left/,
/There are enough left to create (.+) more/
]
count = 0
$ORDINALS.each do |ordinal|
case DRC.bput("count my #{ordinal} #{item}",
'I could not find what you were referring to.',
'tell you much of anything.',
*match_messages)
when 'I could not find what you were referring to.'
break
when 'tell you much of anything.'
echo "ERROR: count_item_parts called on non-stackable item: #{item}"
count = count_items(item)
break
when *match_messages
count += DRC.text2num(Regexp.last_match(1).tr('-', ' '))
end
waitrt?
end
count
end
def count_items(item)
/inside your (.*).|I could not find/ =~ DRC.bput("tap my #{item}", 'inside your (.*).', 'atop your', 'I could not find')
container = Regexp.last_match(1)
return 0 if container.nil?
count_items_in_container(item, container)
end
def count_items_in_container(item, container)
contents = DRC.bput("rummage /C #{item.split.last} IN MY #{container}", '^You rummage .*', 'That would accomplish nothing')
# This regexp avoids counting the quoted item name in the message, as
# well as avoiding finding the item as a substring of other items.
contents.scan(/ #{item}\W/).size
end
def count_lockpick_container(container)
count = DRC.bput("app my lockpick #{container}", 'and it appears to be full', 'and it might hold an additional \d+', '\d+ lockpicks would probably fit').scan(/\d+/).first.to_i
waitrt?
count
end
def refill_lockpick_container(lockpick_type, hometown, container, count)
return if count < 1
room = get_data('town')[hometown]['locksmithing']['id']
if room.nil?
echo '***No locksmith location found for current Hometown! Skipping refilling!***'
return
end
DRCT.walk_to(room)
if Room.current.id != room
echo '***Could not reach locksmith location! Skipping refilling!***'
return
end
count.times do
buy_item(room, "#{lockpick_type} lockpick")
DRC.bput("put my lockpick on my lockpick #{container}", 'You put')
end
# Be polite to Thieves, who need the room to be empty
DRC.fix_standing
move('out') if XMLData.room_exits.include?('out')
end
def stow_hands
stow_hand('right') if DRC.right_hand
stow_hand('left') if DRC.left_hand
end
def stow_hand(hand)
braid_regex = /The braided (.+) is too long/
result = DRC.bput("stow #{hand}", 'You put', braid_regex, 'is too long', '^As you open your hand to release the', 'You easily strap')
dispose_trash(DRC.get_noun(Regexp.last_match(1))) if braid_regex.match(result)
end
def get_item(item, container)
result = DRC.bput("get #{item} in my #{container}", 'You get', 'I could not', 'What were you', 'You need a free')
result =~ /^You get/
end
end