forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-items.lic
120 lines (98 loc) · 4.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
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-items
=end
$TRASH_STORAGE = %w(bin gloop barrel bucket urn log statue)
custom_require.call(%w(common common-travel))
module DRCI
module_function
def buy_item(room, item)
DRCT.walk_to(room)
case DRC.bput("buy #{item}", /prepared to offer it to you for (.*) kronars/, /Let me but ask the humble sum of (.*) coins/, /for a mere (.*) kronars/, /I can let that go for...(.*) kronars/, /That'll cost you (.*) lirums/, 'You decide to purchase', 'Buy what', /I'll give that to you for (.*) dokoras/)
when /prepared to offer it to you for (.*) kronars/
amount = Regexp.last_match(1)
when /Let me but ask the humble sum of (.*) coins/
amount = Regexp.last_match(1)
when /for a mere (.*) kronars/
amount = Regexp.last_match(1)
when /I can let that go for...(.*) kronars/
amount = Regexp.last_match(1)
when /That'll cost you (.*) lirums/
amount = Regexp.last_match(1)
when /I'll give that to you for (.*) dokoras/
amount = Regexp.last_match(1)
end
fput("offer #{amount}") if amount
end
def order_item(room, item_number)
DRCT.walk_to(room)
return if 'you don\'t have enough coins' == DRC.bput("order #{item_number}", 'Just order it again', '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')
when 'You get'
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'
end
unless /What were you/ =~ DRC.bput("put my #{item} in #{trashcan}", '^You drop', '^You put', 'What were you referring to')
return
end
end
DRC.bput("drop my #{item}", 'You drop', 'What were you')
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 .*', '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')
result =~ /You tap/
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)
room = get_data('town')[hometown]['locksmithing']['id']
if room.nil?
echo '***No locksmith location found for current Hometown! 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')
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')
dispose_trash(DRC.get_noun(Regexp.last_match(1))) if braid_regex.match(result)
end
end