-
Notifications
You must be signed in to change notification settings - Fork 0
/
betazzherb2.lic
executable file
·584 lines (497 loc) · 22.8 KB
/
betazzherb2.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
=begin
locates and forages what you want and how many then returns you to the room you started.
***Script will immediately exit if both hands are full. Empty hands or empty the one hand you want to forage with***
syntax is ;zzherb <herb name> <qty you want to find> <location (optional)>
;zzherb setup for GUI setup.
example: ;zzherb some pothinir grass 9 greymist woods (to find 9 pothinir in greymist woods only)
or ;zzherb some acantha leaf 17 (just to find 17 acantha leaf anywhere close)
****Item name has to match, almost all herbs have 'some' in front, 'some acantha leaf'****
finds any forageable items including sticks and wiregrass
This script doesnt care if creatures are in the room, so be careful using it.
*******AGAIN, THIS SCRIPT HAS NO COMBAT CAPABILITIES, DO NOT LEAVE UNATTENDED!!!*******
author: Zzentar
location function added by Baswab/Gibreficul
GUI setup, additional features by Gnomad
Ongoing maintence by Gnomad
tags: foraging, herbs
=end
#hands full check
if not(checkleft and checkright).nil?
puts "#{monsterbold_start} YOU MUST HAVE AT LEAST ONE HAND EMPTY TO USE THIS SCRIPT.#{monsterbold_end}"
puts "#{monsterbold_start} WAITING UNTIL YOU EMPTY A HAND.#{monsterbold_end}"
wait_until{(checkleft and checkright).nil?}
puts "#{monsterbold_start} OK, CONTINUING.#{monsterbold_end}"
end
#echo lootsack.id
#borrowing liberally from sloot for easy extensibility despite the spartan GTK window I'm building.
CharSettings.load
before_dying { CharSettings.save }
settings = CharSettings.to_hash
setup = proc {
gtk_globals = Hash.new
gtk_locals = Hash.new
window = window_action = nil
Gtk.queue {
ttips = Gtk::Tooltips.new.enable
ttips_text = {
'lootsack' => "Container to hold your foraged herbs.\n\nIf you're using this for bounties, maybe\ndon't choose an auto-bundler.",
'sanct_rooms' => "Cast minor sanctuary in each room before foraging?\n\nThe script won't recast 213 if it fails or wears off.\n\nDoes not sing Peace.",
'kneel_to_forage' => "Kneel before foraging?\n\nRemember, this script will not try to keep you alive.",
'hide_to_forage' => "Hide before foraging?\n\nTries once per round, doesn't care if you succeed.",
'stow_stuff' => "Stow your gear before foraging?\n\n(In case you want to walk around with it out.)"
}
gtk_globals['lootsack'] = Gtk::Entry.new.set_text(UserVars.lootsack)
gtk_locals['kneel_to_forage'] = Gtk::CheckButton.new('Kneel to forage?').set_active(settings['kneel_to_forage'])
gtk_locals['sanct_rooms'] = Gtk::CheckButton.new('Sanct the room first?').set_active(settings['sanct_rooms'])
gtk_locals['hide_to_forage'] = Gtk::CheckButton.new('Hide when foraging?').set_active(settings['hide_to_forage'])
gtk_locals['stow_stuff'] = Gtk::CheckButton.new('Stow your gear?').set_active(settings['stow_stuff'])
# Add tooltips
ttips_text.each_pair { |widget,tip|
if widget = gtk_globals[widget] || gtk_locals[widget]
ttips.set_tip(widget,tip,'')
end
}
# Primary Window
window = Gtk::Window.new
window.title = "Zzentar's Forgaging Script"
window.border_width = 3
window.resizable = false
#window.resize(450, 300)
# Notebooks for tabs at the top
nb = Gtk::Notebook.new.set_show_border(true).set_tab_border(3)
#
# Notebook Page 1 - The only page thus far and probably forever.
#
vb_pg1 = Gtk::VBox.new(false,1).set_border_width(3)
#
# Page 1, Frame 1 - Probably the only frame
#
vb_pg1_1 = Gtk::VBox.new(false,1).set_border_width(3)
fr_pg1_1 = Gtk::Frame.new.set_border_width(5).set_label_widget(Gtk::Label.new.set_markup('<b>Zzherb Options</b>'))
fr_pg1_1.add(vb_pg1_1)
vb_pg1.pack_start(fr_pg1_1,false)
lbl = Gtk::Label.new.set_markup("Zzherb was created by the late Ken Dumas, " +
"longtime player of Zzentar and others. If you got to play with him, " +
"you were lucky. If not, you missed out. Rest in peace.")
lbl.set_wrap(true).set_padding(0,10)
vb_pg1_1.pack_start(lbl,false)
hb = Gtk::HBox.new(false,1)
hb.pack_start(Gtk::Alignment.new(1,0,0,1).add(Gtk::Label.new('Lootsack for your foraging: ')),true)
hb.pack_start(gtk_globals['lootsack'],false)
vb_pg1_1.pack_start(hb,false)
hb = Gtk::HBox.new(false,1)
hb.pack_start(gtk_locals['kneel_to_forage'].set_width_request(145),false)
hb.pack_start(gtk_locals['sanct_rooms'],false)
vb_pg1_1.pack_start(hb,false)
hb = Gtk::HBox.new(false,1)
hb.pack_start(gtk_locals['hide_to_forage'].set_width_request(145),false)
hb.pack_start(gtk_locals['stow_stuff'],false)
vb_pg1_1.pack_start(hb,false)
nb.append_page(vb_pg1,Gtk::Label.new('Setup'))
# Save/Close buttons
hb_saveclose = Gtk::HBox.new
save = Gtk::Button.new('_Save & Close')
close = Gtk::Button.new('E_xit')
save.signal_connect('clicked') { window_action = :save }
close.signal_connect('clicked') { window_action = :done }
hb_saveclose.pack_start(save,false)
hb_saveclose.pack_start(close,false)
# Primary VerticalBox to split up Notebook and Save/Close buttons
vb_main = Gtk::VBox.new(false,5)
vb_main.border_width = 3
vb_main.pack_start(nb,false)
vb_main.pack_start(Gtk::Alignment.new(1,0,0,0).add(hb_saveclose),false)
window.signal_connect('delete_event') { respond window.allocation.width; window_action = :exit }
window.add(vb_main)
window.show_all
window.keep_above = true # On windows keep_above is required AFTER show_all
}
before_dying { Gtk.queue { window.destroy } }
wait_while { window_action.nil? }
undo_before_dying # Don't ask me what this does - I stripped it from Tillmen's code
Gtk.queue { window.destroy }
clean_entry = proc { |entry|
entry.text = entry.text.strip
if entry.text.empty?
entry.text = nil
end
entry.text
}
if window_action == :save
gtk_globals.each_pair { |option,widget|
if widget.class == Gtk::CheckButton
UserVars.change(option,widget.active?,:char)
elsif widget.class == Gtk::Entry
UserVars.change(option,clean_entry.call(widget),:char)
else
echo "error: unknown global widget #{option} [#{widget.class}]"
end
}
gtk_locals.each_pair { |option,widget|
if widget.class == Gtk::CheckButton
settings[option] = widget.active?
elsif widget.class == Gtk::Entry
settings[option] = clean_entry.call(widget)
else
echo "error: unknown local widget #{option} [#{widget.class}]"
end
}
echo 'settings saved'
else
echo 'closed without saving'
end
}
#timer start
start_time = Time.now
# ******variable definitions******
if script.vars[0] == "setup"
setup.call
exit
elsif UserVars.lootsack != nil
lootsack = GameObj.inv.find do |item| item.name.include? UserVars.lootsack end
else
respond '*** ERROR ***'
respond '* You must set up a lootsack for your herbs.'
respond '* The script is not initialized.'
respond "* Run #{$clean_lich_char}#{Script.self} setup or set the variables manually."
end
#Set which hand is being used
righthand = checkright.nil? or settings['stow_stuff']
lefthand = !righthand
die_early = false
echo righthand, lefthand
herb_count = 0
location = false
#I love www.regexer.com; just sayin'.
if script.vars[0] =~ /^--(.*)=(.*)/
setting = $1
status = $2
setting_options = ['lootsack', 'sanct_rooms', 'kneel_to_forage', 'hide_to_forage', 'stow_stuff']
if setting_options.include?(setting)
if setting == 'lootsack'
UserVars.lootsack = status
echo "lootsack set to #{status}"
exit
elsif status =~ /true|yes|on/i
CharSettings.load
before_dying { CharSettings.save }
settings = CharSettings.to_hash
settings[setting] = true
echo "#{setting} is now on."
exit
elsif status =~ /false|no|off/i
CharSettings.load
before_dying { CharSettings.save }
settings = CharSettings.to_hash
settings[setting] = false
echo "#{setting} is now off."
exit
else
echo "#{status} is not a valid option for #{setting}."
exit
end
else
echo "#{setting} is not something you can set."
exit
end
elsif script.vars[0] =~ /^--(.*)/
setting = $1
setting_options = ['lootsack', 'sanct_rooms', 'kneel_to_forage', 'hide_to_forage', 'stow_stuff']
if setting_options.include?(setting)
if setting == 'lootsack'
echo "Your lootsack is currently set to #{UserVars.lootsack}"
exit
else
CharSettings.load
settings = CharSettings.to_hash
on_off = settings[setting] ? 'on' : 'off'
echo "#{setting} is currently #{on_off}."
exit
end
else
echo "#{setting} is not something you can set."
exit
end
elsif script.vars[0] == 'credits'
respond '* Zzherb was created by the late Ken Dumas, longtime player of Zzentar and others.'
respond '* If you got to play with him, you were lucky. If not, you missed out. Rest in peace.'
respond '*'
respond '* Location function added by Baswab/Gibreficul.'
respond '* Gnomad\'s added some extra features and is trying to just keep things working nicely.'
exit
end
if script.vars[0] =~ /^bounty/i
if bounty? =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb = $1
qty = $3.to_i
location = $2
elsif script.vars[0] =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb = $1
qty = $3.to_i
location = $2
else
echo 'This option only works if an herbalist has given you a bounty.'
echo 'Although right now, my matching code is probably messed up.'
echo 'Reach out and let me know what your current bounty is, word-for-word.'
echo 'Please use [code] tags if you paste to the thread.'
echo 'You can now paste in another character\' bounty.'
echo 'Make sure you paste the message from the BOUNTY verb.'
echo 'Pasting what the herbalist said won\'t work.'
exit
end
elsif script.vars[0] =~ /(?:a\s|an\s)?(.*?)\s+(\d+)\s+(.*)/
herb = $1
qty = $2.to_i
location = $3
elsif script.vars[0] =~ /(?:a\s|an\s)?(.*?)\s+(\d+)/
herb = $1
qty = $2.to_i
else
respond "*** ERROR ***"
respond "* Correct syntax for this script's usage is:"
respond "* #{$clean_lich_char}#{Script.self} <herbname> <number> <location (optional)>"
respond "* #{$clean_lich_char}#{Script.self} bounty <paste of BOUNTY command (optional)>"
respond "* #{$clean_lich_char}#{Script.self} setup for GUI setup"
respond "* #{$clean_lich_char}#{Script.self} credits"
respond '*'
respond '*'
respond "* #{$clean_lich_char}#{Script.self} --lootsack=<container noun> Container to hold your foraged herbs."
respond "* If you're using this for bounties, maybe don't choose an auto-bundler."
respond '*'
respond "* #{$clean_lich_char}#{Script.self} --sanct_rooms=<on|off> Cast minor sanctuary in each room before foraging?"
respond "* The script won't recast 213 if it fails for any reason or wears off. Does not sing Peace."
respond '*'
respond "* #{$clean_lich_char}#{Script.self} --kneel_to_forage=<on|off> Kneel before foraging?"
respond "* Remember, this script will not try to keep you alive."
respond '*'
respond "* #{$clean_lich_char}#{Script.self} --hide_to_forage=<on|off> Hide before foraging?"
respond "* Tries once per round, doesn't care if you succeed."
respond '*'
respond "* #{$clean_lich_char}#{Script.self} --stow_stuff=<on|off> Stow your gear before foraging?"
respond "* (In case you want to walk around with it out.)"
respond '*'
respond "* EXITING"
quiet_exit
exit
end
herb = 'ayana leaf' if herb =~ /ayana (weed|lichen|berry|root)/
herb = "ayana'al leaf" if herb =~ /ayana'al (weed|lichen|berry|root)/
if Room.tags.include?(herb)
respond "#{herb} is found"
else
echo "error: can't find #{herb}"
similiar = Room.tags.find_all { |tag| tag =~ /#{herb}/ }
echo "try: #{similiar.join(', ')}" unless similiar.empty?
exit
end
if location
echo "Number to find: #{qty} Item: #{herb} Location: #{location}"
else
echo "Number to find: #{qty} Item: #{herb}"
end
# ******HERB ROOM GENERATION******
target_list = Array.new
if herb == 'ayana leaf'
Room.list.each{|room| target_list.push(room.id) if room.tags.include?("ayana leaf") || room.tags.include?("ayana lichen") || room.tags.include?("ayana weed") || room.tags.include?("ayana berry")|| room.tags.include?("ayana root")}
elsif herb == "ayana'al leaf"
Room.list.each{|room| target_list.push(room.id) if room.tags.include?("ayana'al leaf") || room.tags.include?("ayana'al lichen") || room.tags.include?("ayana'al weed") || room.tags.include?("ayana'al berry")|| room.tags.include?("ayana'al root")}
else
Room.list.each { |room| target_list.push(room.id) if room.tags.include?(herb) }
end
previous, shortest_distances = Map.dijkstra(Room.current.id)
if location
target_list.delete_if { |room_num| (Room[room_num].location == nil && Room[room_num].title[0] !~ /#{location}/i) }
target_list.delete_if { |room_num| (Room[room_num].location != nil && Room[room_num].location !~ /#{location}/i) }
end
if location and target_list.size == 0
location_list = []
Room.list.each{|places| location_list.push(places.location) if places.tags.include?(herb)}
location_list = location_list.flatten.uniq
location_list.delete_if {|x| x == true}
location_list.delete_if {|x| x == nil}
puts "#{monsterbold_start} The location does not seem valid. Here is a list of locations that have that herb#{monsterbold_end}"
location_list.each{|locations| respond "#{locations}"}
exit
end
target_list.delete_if { |room_num| shortest_distances[room_num].nil? }
wait_time = 20 #was 20
wait_time += 580 if location
target_list.delete_if { |room_num| shortest_distances[room_num].to_i > wait_time }
target_list.sort! { |a,b| shortest_distances[a] <=> shortest_distances[b] }
echo "**"
target_list.each{ |item|
echo "#{Room[item].title}, #{item}"
}
room = Room.current.id
# Procedure to get to a specified room, even if script is killed or fails
get_to_dest = proc { |room|
while Room.current.id != room
start_script 'go2', [room.to_s]
wait_while {running?('go2') }
end
}
# Stows herb, opening and closing lootsack as required
stow_herb = proc { |herb|
stow_cmd = "put ##{herb.id} in ##{lootsack.id}"
line = dothistimeout stow_cmd, 3, /put|closed/
if line =~ /closed/
fput "open ##{lootsack.id}"
fput stow_cmd
fput "close ##{lootsack.id}"
end
}
# Heals self if foraging goes fumbly
heal_self = proc {
limb_repair = Spell[1102]
if limb_repair.known? and limb_repair.affordable?
limb_repair.cast
else
start_script 'useherbs'
wait_while { running? 'useherbs' }
end
}
get_foragename = proc {|herb|
foragename = herb
if foragename == 'twisted black mawflower' then foragename = 'mawflower'
elsif foragename == 'stem of freesia flowers' then foragename = 'freesia flowers'
elsif foragename == 'small green olive' then foragename = 'green olive'
elsif foragename == 'mass of congealed slime' then foragename = 'congealed slime'
elsif foragename == 'oozing fleshsore bulb' then foragename = 'fleshsore bulb'
elsif foragename == 'rotting bile green fleshbulb' then foragename = 'fleshbulb'
elsif foragename == 'discolored fleshbinder bud' then foragename = 'fleshbinder bud'
elsif foragename == 'slime-covered grave blossom' then foragename = 'grave blossom'
elsif foragename == "sprig of Imaera's Lace" then foragename = "Imaera's Lace"
elsif foragename == 'handful of elderberries' then foragename = 'elderberries'
elsif foragename == 'sprig of wild lilac' then foragename = 'lilac'
elsif foragename == 'fragrant white lily' then foragename = 'white lily'
elsif foragename == 'handful of huckleberries' then foragename = 'huckleberries'
elsif foragename == 'trollfear mushroom' then foragename = 'mushroom'
elsif foragename == 'bunch of wild grapes' then foragename = 'wild grapes'
elsif foragename == 'handful of blueberries' then foragename = 'blueberries'
elsif foragename == 'handful of raspberries' then foragename = 'raspberries'
elsif foragename == 'layer of onion skin' then foragename = 'onion skin'
elsif foragename == 'vermilion fire lily' then foragename = 'fire lily'
elsif foragename == 'handful of walnuts' then foragename = 'walnuts'
elsif foragename == 'orange tiger lily' then foragename = 'tiger lily'
elsif foragename == 'small branch of acacia' then foragename = 'branch of acacia'
elsif foragename == 'golden flaeshorn berry' then foragename = 'flaeshorn berry'
elsif foragename == 'white alligator lily' then foragename = 'alligator lily'
elsif foragename == 'dark pink rain lily' then foragename = 'pink rain lily'
elsif foragename == 'white spider lily' then foragename = 'spider lily'
elsif foragename =~ /(silver|bright blue|fiery red|snow white|pale violet|peach|soft orange|pink|yellow|lavender|ice blue|azure|bright red|pale green|soft yellow|bright green|light red) iceblossom/ then foragename = 'iceblossom'
elsif foragename =~ /(bent|short|heavy) stick/ then foragename = 'stick'
elsif foragename =~ /(blue|red|green|pink|purple|yellow|white) mold/ then foragename = 'mold'
elsif foragename == 'handful of snowberries' then foragename = 'snowberries'
elsif foragename == 'sprig of edelweiss' then foragename = 'edelweiss'
elsif foragename == 'handful of bearberries' then foragename = 'bearberries'
elsif foragename == 'cluster of woad leaves' then foragename = 'woad leaves'
elsif foragename == 'large black toadstool' then foragename = 'black toadstool'
elsif foragename == 'some glowing green lichen' then foragename = 'green lichen'
elsif foragename == 'luminescent green fungus' then foragename = 'green fungus'
elsif foragename == 'black-tipped wyrm thorn' then foragename = 'wyrm thorn'
elsif foragename == 'some fetid black slime' then foragename = 'black slime'
elsif foragename == 'sprig of sky-blue delphinuris' then foragename = 'delphinuris'
elsif foragename == 'handful of mustard seeds' then foragename = 'mustard seeds'
elsif foragename == 'handful of snowberries' then foragename = 'snowberries'
elsif foragename == 'sprig of wild phlox' then foragename = 'phlox'
elsif foragename == 'cluster of gorse' then foragename = 'gorse'
elsif foragename == 'giant glowing toadstool' then foragename = 'glowing toadstool'
elsif foragename == 'sprig of Imaera\'s Lace' then foragename = 'lace'
end
herb
}
foragename = get_foragename.call herb
target_list.each { |herb_room|
get_to_dest.call herb_room
if Spell[213].known? and settings['sanct_rooms']
need_sanct = true
fput "sense"
timeoutStart = Time.now
while line = get
case line
when /An obvious presence of peace saturates the area and a feeling of safety overwhelms you./
need_sanct = false
break
when /^Roundtime:/
break
end
if Time.now - timeoutStart > 3.0
break
end
end
waitrt?
if need_sanct and Spell[213].affordable?
Spell[213].cast
end
end
empty_hands if settings['stow_stuff']
## forage loop ##
# All bonuses pulled from GSWiki. Blame them, not me (or Zzentar)
loop {
if die_early or herb_count >= qty
echo "task done"
fill_hands if settings['stow_stuff']
break
end
if Spell[402].known? and not Spell[402].active?
Spell[402].cast #Presence, no effect if 2x perception
end
if Spell[506].known? and not Spell[506].active?
fput 'stop 506'
Spell[506].cast #Haste
end
if Spell[603].known? and not Spell[603].active?
Spell[603].cast #Foraging, +10 to roll
end
if Spell[1035].known? and not Spell[1035].active?
Spell[1035].cast #Song of Tonis
end
if Spell[9704].known? and not Spell[9704].active?
Spell[9704].cast #Sigil of Resolve, +GoS Ranks/3
end
if not kneeling? and settings['kneel_to_forage']
fput 'kneel' #Kneeling, +10 to roll
end
if not hiding? and settings['hide_to_forage']
fput 'hide'
end
#FIXME: This does not handle script pausing
forage_result = dothistimeout "forage for #{foragename}", 5, /^You forage|^You make so much noise that only the dead would not notice you thrashing about in your unsuccessful search\.$|^You stumble about in a fruitless attempt at foraging\.$|you are unable to find anything useful|^As you carefully forage around you (can find no hint|see no evidence) of what you are looking for\.|you are fairly certain this is where it can be found|^You begin to forage around when your hand comes into contact with something that stabs you in the finger\.$|^As you forage around you suddenly feel a sharp pain in your right hand!|^You begin to forage around when suddenly you feel a burning sensation in your hand\.$|^You fumble about so badly in your search that you can only hope no one was watching you\.$/
waitrt?
if forage_result =~ /^You forage briefly and manage to find/
if righthand
stow_herb.call GameObj.right_hand
else
stow_herb.call GameObj.left_hand
end
herb_count += 1
elsif forage_result =~ /^As you forage around you suddenly feel a sharp pain in your right hand!/
heal_self.call
elsif forage_result =~ /fairly certain this is where it can be found./
echo 'This is a night-only or day-only herb, and you are foraging at the wrong time of day for it.'
echo 'Try again later or earlier.'
fill_hands if settings['stow_stuff']
die_early = true
break
elsif forage_result =~ /you are unable to find anything useful|^As you carefully forage around you (can find no hint|see no evidence) of what you are looking for\./
echo "bad room or its foraged out"
fill_hands if settings['stow_stuff']
break
else #Uncertain, try again
sleep 0.5
end
}
#Quit while
if die_early or herb_count >= qty
echo "task done"
fill_hands if settings['stow_stuff']
break
end
}
#Return to original room
get_to_dest.call room
echo "Found " + herb_count.to_s + " of " + herb
total_time = Time.now.to_f - start_time.to_f
##respond "Time to forage: #{((Time.now.to_f - start_time.to_f) / 60.00).as_time}"
##respond (total_time/60.0).as_time
puts "#{monsterbold_start}It took #{Time.now.to_i - start_time.to_i} seconds to find #{herb_count} of #{foragename}#{monsterbold_end}"