-
Notifications
You must be signed in to change notification settings - Fork 8
/
useherbs.lic
1430 lines (1396 loc) · 70.4 KB
/
useherbs.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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=begin
Script to heal yourself with herbs.
Will use herbs in your herbsack, or on a bench or something.
Works with any combination of herbs from any town.
Can buy herbs.
Might heal your traveller.
;useherbs help
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
tags: healing
version: 0.12
requried: Lich >= 4.6.0
changelog:
0.12 (2020-10-10):
response message for buying herbs now has commas
0.11 (2020-10-07):
changed fill function to go to closest herbalist instead of a single hardcoded one, update for commas
0.10 (2017-09-30):
add feature to fill your herbsack with herbs (;useherbs stock herbs)
=end
=begin
0.9 (2017-03-04):
remove 506 from the script, since it doesn't affect eating herbs anymore
0.8 (2017-01-14):
withdraw silvers first when using the "stock potions" command
0.7 (2015-04-26):
fix for working with hidden containers, like the basket in Ta'Vaalor
0.6 (2015-03-28):
remember to look on/under/behind a container instead of "in" if a second look is required
fix bug with finding a herbsack given on the command line
0.5 (2015-02-23):
better method of finding container from herbsack setting
0.4 (2014-12-12):
make "stock potions" track potion use instead of measuring every time
0.3 (2014-11-14):
set herbsack with ;useherbs set herbsack <container>
=end
# fixme: garland of sovyn cloves
# fixme: skip more better
# fixme: buy herbs/right hand full
# fixme: use bank note
$known_herbs = [
{ :name=>"some acantha leaf", :type=>"blood", :short_name => "acantha leaf", :store_doses=>10 },
{ :name=>"some spicy acantha leaf", :type=>"blood", :short_name => "spicy acantha leaf", :store_doses=>10 },
{ :name=>"tincture of acantha", :type=>"blood", },
{ :name=>"tincture of yabathilium", :type=>"blood", },
{ :name=>"yabathilium fruit", :type=>"blood", },
{ :name=>"iceberry tart", :type=>"blood", :store_doses=>10 },
{ :name=>"some acantha leaf tea", :type=>"blood", :short_name => "acantha leaf tea" },
{ :name=>"grey mushroom potion", :type=>"blood", },
{ :name=>"flagon of Olak's Ol'style ale", :type=>"blood", :short_name => "Olak's Ol'style ale" },
{ :name=>"barrel of Olak's Ol'style ale", :type=>"blood", :short_name => "Olak's Ol'style ale" },
{ :name=>"flagon of Bloody Krolvin ale", :type=>"blood", :short_name => "Bloody Krolvin ale" },
{ :name=>"barrel of Bloody Krolvin ale", :type=>"blood", :short_name => "Bloody Krolvin ale" },
{ :name=>"some aloeas stem", :type=>"major head wound", :short_name => "aloeas stem", :store_doses=>2 },
{ :name=>"some withered aloeas stem", :type=>"major head wound", :short_name => "withered aloeas stem", :store_doses=>2 },
{ :name=>"tincture of aloeas", :type=>"major head wound", },
{ :name=>"tiny ram's bladder tart", :type=>"major head wound", :short_name => "ram's bladder tart", :store_doses=>2 },
{ :name=>"feverfew potion", :type=>"major head wound", },
{ :name=>"sticky lichen tea", :type=>"major head wound", },
{ :name=>"flagon of Dark Swampwater ale", :type=>"major head wound", :short_name => "Dark Swampwater ale" },
{ :name=>"barrel of Dark Swampwater ale", :type=>"major head wound", :short_name => "Dark Swampwater ale" },
{ :name=>"rose-marrow potion", :type=>"minor head wound", :store_doses=>4 },
{ :name=>"crystalline rose-marrow elixir", :type=>"minor head wound", },
{ :name=>"tincture of rose-marrow", :type=>"minor head wound", },
{ :name=>"elk horn potion", :type=>"minor head wound", :store_doses=>4 },
{ :name=>"some feverfew tea", :type=>"minor head wound", :short_name => "feverfew tea" },
{ :name=>"rusty red ale", :type=>"minor head wound", },
{ :name=>"flagon of Semak's Smooth ale", :type=>"minor head wound", :short_name => "Semak's Smooth ale" },
{ :name=>"barrel of Semak's Smooth ale", :type=>"minor head wound", :short_name => "Semak's Smooth ale" },
{ :name=>"brostheras potion", :type=>"major head scar", :store_doses=>2 },
{ :name=>"crystalline brostheras elixir", :type=>"major head scar", },
{ :name=>"tincture of brostheras", :type=>"major head scar", },
{ :name=>"tiny cup of polar bear fat soup", :type=>"major head scar", :store_doses=>2, :short_name => 'polar bear fat soup' },
{ :name=>"pennyroyal potion", :type=>"major head scar", },
{ :name=>"stone soot brew", :type=>"major head scar", },
{ :name=>"flagon of Reaper's Red ale", :type=>"major head scar", :short_name => "Reaper's Red ale" },
{ :name=>"barrel of Reaper's Red ale", :type=>"major head scar", :short_name => "Reaper's Red ale" },
{ :name=>"some haphip root", :type=>"minor head scar", :short_name => "haphip root", :store_doses=>4 },
{ :name=>"some dirty haphip root", :type=>"minor head scar", :short_name => "dirty haphip root", :store_doses=>4 },
{ :name=>"tincture of haphip", :type=>"minor head scar", },
{ :name=>"slice of sparrowhawk pie", :type=>"minor head scar", :store_doses=>5, :short_name => 'sparrowhawk pie' },
{ :name=>"pennyroyal tea", :type=>"minor head scar", },
{ :name=>"dull crimson ale", :type=>"minor head scar", },
{ :name=>"flagon of Agrak's Amber ale", :type=>"minor head scar", :short_name => "Agrak's Amber ale" },
{ :name=>"barrel of Agrak's Amber ale", :type=>"minor head scar", :short_name => "Agrak's Amber ale" },
{ :name=>"some pothinir grass", :type=>"major organ wound", :short_name => "pothinir grass", :store_doses=>2 },
{ :name=>"some bright green pothinir grass", :type=>"major organ wound", :short_name => "pothinir grass", :store_doses=>2 },
{ :name=>"tincture of pothinir", :type=>"major organ wound", },
{ :name=>"tiny musk ox tart", :type=>"major organ wound", :short_name => 'musk ox tart', :store_doses=>2 },
{ :name=>"ginkgo nut potion", :type=>"major organ wound", },
{ :name=>"roasted ratweed tea", :type=>"major organ wound", },
{ :name=>"flagon of Aged Schooner ale", :type=>"major organ wound", :short_name => "Aged Schooner ale" },
{ :name=>"barrel of Aged Schooner ale", :type=>"major organ wound", :short_name => "Aged Schooner ale" },
{ :name=>"some basal moss", :type=>"minor organ wound", :short_name => "basal moss", :store_doses=>4 },
{ :name=>"tincture of moss", :type=>"minor organ wound", },
{ :name=>"sticky ball of basal moss", :type=>"minor organ wound", :store_doses=>4 },
{ :name=>"tincture of basal", :type=>"minor organ wound", },
{ :name=>"small egg and tundra grass tart", :type=>"minor organ wound", :store_doses=>5, :short_name => 'tundra grass tart' },
{ :name=>"some ginkgo nut tea", :type=>"minor organ wound", :short_name => "ginkgo nut tea" },
{ :name=>"chunky black ale", :type=>"minor organ wound", },
{ :name=>"flagon of Mama Dwarf's ale", :type=>"minor organ wound", :short_name => "Mama Dwarf's ale" },
{ :name=>"barrel of Mama Dwarf's ale", :type=>"minor organ wound", :short_name => "Mama Dwarf's ale" },
{ :name=>"wingstem potion", :type=>"major organ scar", :store_doses=>2 },
{ :name=>"crystalline wingstem elixir", :type=>"major organ scar", },
{ :name=>"tincture of wingstem", :type=>"major organ scar", },
{ :name=>"earthworm potion", :type=>"major organ scar", :store_doses=>2 },
{ :name=>"wyrmwood root potion", :type=>"major organ scar", },
{ :name=>"dirty crevice brew", :type=>"major organ scar", },
{ :name=>"flagon of Wort's Winter ale", :type=>"major organ scar", :short_name => "Wort's Winter ale" },
{ :name=>"barrel of Wort's Winter ale", :type=>"major organ scar", :short_name => "Wort's Winter ale" },
{ :name=>"talneo potion", :type=>"minor organ scar", :store_doses=>4 },
{ :name=>"crystalline talneo elixir", :type=>"minor organ scar", },
{ :name=>"tincture of talneo", :type=>"minor organ scar", },
{ :name=>"rock lizard potion", :type=>"minor organ scar", :store_doses=>4 },
{ :name=>"wyrmwood root tea", :type=>"minor organ scar", },
{ :name=>"brown weedroot ale", :type=>"minor organ scar", },
{ :name=>"flagon of Gert's Homemade ale", :type=>"minor organ scar", :short_name => "Gert's Homemade ale" },
{ :name=>"barrel of Gert's Homemade ale", :type=>"minor organ scar", :short_name => "Gert's Homemade ale" },
{ :name=>"bur-clover potion", :type=>"missing eye", :store_doses=>1 },
{ :name=>"crystalline bur-clover elixir", :type=>"missing eye", },
{ :name=>"tincture of bur-clover", :type=>"missing eye", },
{ :name=>"starfish potion", :type=>"missing eye", :store_doses=>1 },
{ :name=>"daggit root potion", :type=>"missing eye", },
{ :name=>"dirty rat fur potion", :type=>"missing eye", },
{ :name=>"flagon of Volcano Vision ale", :type=>"missing eye", :short_name => "Volcano Vision ale" },
{ :name=>"barrel of Volcano Vision ale", :type=>"missing eye", :short_name => "Volcano Vision ale" },
{ :name=>"some ephlox moss", :type=>"major limb wound", :short_name => "ephlox moss", :store_doses=>4 },
{ :name=>"gooey ball of ephlox moss", :type=>"major limb wound", },
{ :name=>"tincture of ephlox", :type=>"major limb wound", },
{ :name=>"some frog's bone porridge", :type=>"major limb wound", :store_doses=>4, :short_name => "frog's bone porridge" },
{ :name=>"sweetfern potion", :type=>"major limb wound", },
{ :name=>"crushed cavegrass tea", :type=>"major limb wound", },
{ :name=>"flagon of Golden Goose ale", :type=>"major limb wound", :short_name => "Golden Goose ale" },
{ :name=>"barrel of Golden Goose ale", :type=>"major limb wound", :short_name => "Golden Goose ale" },
{ :name=>"some ambrominas leaf", :type=>"minor limb wound", :short_name => "ambrominas leaf", :store_doses=>4 },
{ :name=>"some sugary ambrominas leaf", :type=>"minor limb wound", :short_name => "sugary ambrominas leaf" },
{ :name=>"tincture of ambrominas", :type=>"minor limb wound", },
{ :name=>"Dabbings Family special tart", :type=>"minor limb wound", :store_doses=>4, :short_name => 'Family special tart' },
{ :name=>"some sweetfern tea", :type=>"minor limb wound", :short_name => "sweetfern tea" },
{ :name=>"bubbling brown ale", :type=>"minor limb wound", },
{ :name=>"flagon of Lost Dogwater ale", :type=>"minor limb wound", :short_name => "Lost Dogwater ale" },
{ :name=>"barrel of Lost Dogwater ale", :type=>"minor limb wound", :short_name => "Lost Dogwater ale" },
{ :name=>"some calamia fruit", :type=>"major limb scar", :short_name => "calamia fruit", :store_doses=>2 },
{ :name=>"some ripe calamia fruit", :type=>"major limb scar", :short_name => "ripe calamia fruit" },
{ :name=>"tincture of calamia", :type=>"major limb scar", },
{ :name=>"slice of pickled walrus blubber", :type=>"major limb scar", :store_doses=>2, :short_name => 'pickled walrus blubber' },
{ :name=>"manroot potion", :type=>"major limb scar", },
{ :name=>"stalactite brew", :type=>"major limb scar", },
{ :name=>"flagon of Mad Mutt Frothy ale", :type=>"major limb scar", :short_name => "Mad Mutt Frothy ale" },
{ :name=>"barrel of Mad Mutt Frothy ale", :type=>"major limb scar", :short_name => "Mad Mutt Frothy ale" },
{ :name=>"some cactacae spine", :type=>"minor limb scar", :short_name => "cactacae spine", :store_doses=>4 },
{ :name=>"some prickly cactacae spine", :type=>"minor limb scar", :short_name => "prickly cactacae spine" },
{ :name=>"tincture of cactacae", :type=>"minor limb scar", },
{ :name=>"gelatinous elk fat tart", :type=>"minor limb scar", :short_name => 'elk fat tart', :store_doses=>10 },
{ :name=>"manroot tea", :type=>"minor limb scar", },
{ :name=>"spotted toadstool ale", :type=>"minor limb scar", },
{ :name=>"flagon of Bearded Ladies' ale", :type=>"minor limb scar", :short_name => "Bearded Ladies' ale" },
{ :name=>"barrel of Bearded Ladies' ale", :type=>"minor limb scar", :short_name => "Bearded Ladies' ale" },
# fixme
{ :name=>"some sovyn clove", :type=>"severed limb", :short_name => "sovyn clove", :store_doses=>1 },
{ :name=>"small sovyn clove", :type=>"severed limb", :short_name => "sovyn clove", :store_doses=>1 },
{ :name=>"sovyn clove", :type=>"severed limb", },
{ :name=>"tincture of sovyn", :type=>"severed limb", },
{ :name=>"candied ptarmigan feather", :type=>"severed limb", :short_name => 'ptarmigan feather', :store_doses=>1 },
{ :name=>"angelica root potion", :type=>"severed limb", },
{ :name=>"grainy black potion", :type=>"severed limb", },
{ :name=>"flagon of Captn' Pegleg's ale", :type=>"severed limb", :short_name => "Captn' Pegleg's ale" },
{ :name=>"barrel of Captn' Pegleg's ale", :type=>"severed limb", :short_name => "Captn' Pegleg's ale" },
{ :name=>"bolmara potion", :type=>"major nerve wound", :store_doses=>4 },
{ :name=>"crystalline bolmara elixir", :type=>"major nerve wound", },
{ :name=>"tincture of bolmara", :type=>"major nerve wound", },
{ :name=>"snowflake elixir", :type=>"major nerve wound", :store_doses=>4 },
{ :name=>"red lichen potion", :type=>"major nerve wound", },
{ :name=>"glowing mold tea", :type=>"major nerve wound", },
{ :name=>"flagon of Kenar's Dropjaw ale", :type=>"major nerve wound", :short_name => "Kenar's Dropjaw ale" },
{ :name=>"barrel of Kenar's Dropjaw ale", :type=>"major nerve wound", :short_name => "Kenar's Dropjaw ale" },
{ :name=>"some wolifrew lichen", :type=>"minor nerve wound", :short_name => "wolifrew lichen", :store_doses=>4 },
{ :name=>"some dry wolifrew lichen", :type=>"minor nerve wound", :short_name => "dry wolifrew lichen", },
{ :name=>"tincture of wolifrew", :type=>"minor nerve wound", },
{ :name=>"Leaftoe's lichen tart", :type=>"minor nerve wound", :store_doses=>4, :short_name => 'lichen tart' },
{ :name=>"some red lichen tea", :type=>"minor nerve wound", :short_name => "red lichen tea" },
{ :name=>"thick foggy ale", :type=>"minor nerve wound", },
{ :name=>"flagon of Orc's Head ale", :type=>"minor nerve wound", :short_name => "Orc's Head ale" },
{ :name=>"barrel of Orc's Head ale", :type=>"minor nerve wound", :short_name => "Orc's Head ale" },
{ :name=>"some woth flower", :type=>"major nerve scar", :short_name => "woth flower", :store_doses=>2 },
{ :name=>"some fragrant woth flower", :type=>"major nerve scar", :short_name => "fragrant woth flower" },
{ :name=>"tincture of woth", :type=>"major nerve scar", },
{ :name=>"tiny flower-shaped tart", :type=>"major nerve scar", :store_doses=>2, :short_name => 'flower-shaped tart' },
{ :name=>"valerian root potion", :type=>"major nerve scar", },
{ :name=>"stalagmite brew", :type=>"major nerve scar", },
{ :name=>"flagon of Dacra's Dream ale", :type=>"major nerve scar", :short_name => "Dacra's Dream ale" },
{ :name=>"barrel of Dacra's Dream ale", :type=>"major nerve scar", :short_name => "Dacra's Dream ale" },
{ :name=>"some torban leaf", :type=>"minor nerve scar", :short_name => "torban leaf", :store_doses=>3 },
{ :name=>"some fresh torban leaf", :type=>"minor nerve scar", :short_name => "fresh torban leaf" },
{ :name=>"tincture of torban", :type=>"minor nerve scar", },
{ :name=>"slice of Ma Leaftoe's Special", :type=>"minor nerve scar", :store_doses=>5, :short_name => "Ma Leaftoe's Special" },
{ :name=>"valerian root tea", :type=>"minor nerve scar", },
{ :name=>"dark frothing ale", :type=>"minor nerve scar", },
{ :name=>"flagon of Miner's Muddy ale", :type=>"minor nerve scar", :short_name => "Miner's Muddy ale" },
{ :name=>"barrel of Miner's Muddy ale", :type=>"minor nerve scar", :short_name => "Miner's Muddy ale" },
{ :name=>"dimly glowing sky-blue potion", :type=>"disease", },
{ :name=>"dimly glowing sea-green potion", :type=>"poison", },
]
#silence_me
drinkable = /potion|tea|elixir|brew|tincture|ale|soup/
skippable = Array.new
close_herbsack = false
preposition = 'in'
return_to_stow = false
herb_container = nil
right_hand_save = nil
left_hand_save = nil
buy_missing = CharSettings['buy_missing']
use_mending = CharSettings['use-mending']
start_room = Room.current
herb_shop_menu = nil
silvers = nil
withdraw_amount = 8000
should_deposit = false
used_herbs = Array.new
open_regex = /^You open|^That is already open\.$|^There doesn't seem to be any way to do that\.$|^What were you referring to\?|^I could not find what you were referring to\./
close_regex = /^You close|^That is already closed\.$/
put_regex = /^You (?:attempt to shield .*? from view as you |discreetly |carefully |absent-mindedly )?(?:put|place|slip|tuck|add|hang|drop|untie your|find an incomplete bundle|wipe off .*? and sheathe)|^A sigh of grateful pleasure can be heard as you feed .*? to your|^As you place|^I could not find what you were referring to\.$|^Your bundle would be too large|^The .+ is too large to be bundled\.|^As you place your|^The .*? is already a bundle|^Your .*? won't fit in .*?\.$|^You can't .+ It's closed!$/
put_fail_regex = /^Your .*? won't fit in .*?\.$|^You can't .+ It's closed!$||^I could not find what you were referring to\.$/
get_regex = /^You (?:shield the opening of .*? from view as you |discreetly |carefully |deftly )?(?:remove|draw|grab|reach|slip|tuck|retrieve|already have|unsheathe|detach)|^Get what\?$|^Why don't you leave some for others\?$|^You need a free hand|^You already have that/
get_from = nil
min_stock_doses = {
'major head scar' => 13,
'minor head wound' => 11,
'major nerve wound' => 11,
'minor organ scar' => 11,
'major organ scar' => 13,
'missing eye' => 7,
}
check_silvers = proc {
action = proc { |server_string|
if server_string =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
nil
elsif server_string =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+[0-9,]+/
DownstreamHook.remove("#{script.name}_check_silvers")
nil
else
server_string
end
}
DownstreamHook.add("#{script.name}_check_silvers", action)
silence_me unless undo_silence = silence_me
clear
put 'info'
silence_me if undo_silence
while line = get
if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9,]+)/
silvers = $1.gsub(',','').to_i
break
end
end
silvers
}
withdraw = proc {
Script.run('go2', 'bank --disable-confirm')
fput 'unhide' if invisible?
if XMLData.room_title == '[Pinefar, Depository]'
if GameObj.npcs.any? { |npc| npc.noun == 'banker' }
fput "ask banker for #{[withdraw_amount.to_i, 20].max} silvers"
# The banker nods and says, "Alright, here ye go. Ye understand I be takin' a little more than that from ye account in the 'Mule. I don't works for free!"
# The banker looks at you suspiciously and says, "Hmm, I don't think ye be havin' enough in ye account to cover that and my fee. Ye tryin' to pull one over on me?"
else
if icemule_bank = Room.list.find { |room| room.location == 'Icemule Trace' and room.tags.include?('bank') }
Script.run('go2', icemule_bank.id.to_s)
result = dothistimeout "withdraw #{withdraw_amount} silvers", 1, /debt collector/
if result =~ /debt collector/
fput "withdraw #{withdraw_amount} silvers"
end
else
echo 'waiting for banker...'
wait_until { GameObj.npcs.any? { |npc| npc.noun == 'banker' } }
fput "ask banker for #{[withdraw_amount.to_i, 20].max} silvers"
end
end
else
result = dothistimeout "withdraw #{withdraw_amount} silvers", 1, /debt collector/
if result =~ /debt collector/
fput "withdraw #{withdraw_amount} silvers"
end
end
silvers += withdraw_amount
should_deposit = true
}
deposit = proc {
if should_deposit
Script.run('go2', 'bank --disable-confirm')
if XMLData.room_title == '[Pinefar, Depository]'
if GameObj.npcs.any? { |npc| npc.noun == 'banker' }
fput "give banker #{check_silvers.call} silvers"
end
else
fput "deposit #{check_silvers.call}"
end
end
}
too_wounded_to_cast = proc {
([Wounds.head, Scars.head, Wounds.nsys, Scars.nsys].max > 1) or ([Wounds.leftArm, Wounds.leftHand, Wounds.rightArm, Wounds.rightHand, Scars.leftArm, Scars.leftHand, Scars.rightArm, Scars.rightHand].max > 2) or ( ([Wounds.leftArm, Wounds.leftHand, Scars.leftArm, Scars.leftHand].max > 0) and ([Wounds.rightArm, Wounds.rightHand, Scars.leftArm, Scars.leftHand].max > 0) )
}
go_to_herbalist = proc {
if working_herbalist = Room.current.find_nearest(Room.list.find_all { |room| room.tags.include?('herbalist') and not room.title.any? { |t| t =~ /Valina's Herbs and Tinctures|Marroux and Haert, Chirurgeons/ } })
Script.run('go2', working_herbalist.to_s)
else
Script.run('go2', 'herbalist --disable-confirm')
end
}
next_herb_type = proc {
herb_type = nil
#unless herb_type or skippable.include?('disease')
# if checkdisease
# herb_type = 'disease'
# end
#end
#unless herb_type or skippable.include?('poison')
# if checkpoison
# herb_type = 'poison'
# end
#end
unless herb_type
herb_type = 'blood' if (percenthealth < 50) and not skippable.include?('blood')
end
unless herb_type
for area in [ 'head', 'neck', 'torso', 'limbs', 'nerves' ] - skippable
if Wounds.send(area) > 1
area = 'head' if area == 'neck'
area = 'organ' if area == 'torso'
area = 'limb' if area == 'limbs'
area = 'nerve' if area == 'nerves'
herb_type = "major #{area} wound"
break
end
end
end
unless herb_type
for area in [ 'head', 'neck', 'torso', 'limbs', 'nerves' ] - skippable
if Wounds.send(area) == 1
area = 'head' if area == 'neck'
area = 'organ' if area == 'torso'
area = 'limb' if area == 'limbs'
area = 'nerve' if area == 'nerves'
herb_type = "minor #{area} wound"
break
end
end
end
unless herb_type
herb_type = 'severed limb' if (Scars.limbs == 3) and not skippable.include?('limbs')
end
unless herb_type
herb_type = 'missing eye' if (Scars.reye == 3 or Scars.leye == 3) and not skippable.include?('torso')
end
unless herb_type
for area in [ 'head', 'neck', 'torso', 'limbs', 'nerves' ] - skippable
if Scars.send(area) > 1
area = 'head' if area == 'neck'
area = 'organ' if area == 'torso'
area = 'limb' if area == 'limbs'
area = 'nerve' if area == 'nerves'
herb_type = "major #{area} scar"
break
end
end
end
unless herb_type
for area in [ 'head', 'neck', 'torso', 'limbs', 'nerves' ] - skippable
if Scars.send(area) == 1
area = 'head' if area == 'neck'
area = 'organ' if area == 'torso'
area = 'limb' if area == 'limbs'
area = 'nerve' if area == 'nerves'
herb_type = "minor #{area} scar"
break
end
end
end
unless herb_type
herb_type = 'blood' if (checkhealth + 7) < maxhealth and not skippable.include?('blood')
end
herb_type
}
stow_herb = proc {
if return_to_stow and (Room.current.id != start_room.id)
Script.run('go2', start_room.id.to_s)
end
if used_herbs.include?(GameObj.right_hand.id)
dothistimeout "put ##{GameObj.right_hand.id} #{preposition} ##{herb_container.id}", 10, put_regex
fput('stow right') if checkright
end
if used_herbs.include?(GameObj.left_hand.id)
dothistimeout "put ##{GameObj.left_hand.id} #{preposition} ##{herb_container.id}", 10, put_regex
fput('stow left') if checkleft
end
}
read_menu = proc {
status_tags
clear
fput 'unhide' if hidden? or invisible?
fput 'order'
menu = Hash.new
while (line = get) and (line !~ /ORDER|BUY/)
for item in line.scan(/<d.*?cmd=["']order ([0-9]+).*?>(.*?)<\/d>/)
menu[item[1].sub(/^a /, '')] = item[0]
end
end
status_tags
clear
menu
}
buy_herb = proc { |herb_type|
unless silvers
silvers = check_silvers.call
end
unless herb_shop_menu
herb_shop_menu = read_menu.call
end
herb_name = herb_shop_menu.keys.find { |name| $known_herbs.any? { |h| (h[:type] == herb_type) and (name =~ /#{h[:name]}/ or name =~ /#{h[:name].sub(/sticky |gooey | green| fragrant| shiny| dirty/, '')}/) } }
unless order_number = herb_shop_menu[herb_name]
echo "error: failed to find a herb for #{herb_type} in the menu"
exit
end
dothistimeout "order #{order_number}", 3, /BUY/
buy_result = dothistimeout 'buy', 3, /Sold for [0-9,]+ silver|^But you do not have enough silver!/
if buy_result =~ /Sold for ([0-9,]+) silver/
silvers -= $1.gsub(',','').to_i
elsif buy_result =~ /^But you do not have enough silver!/
withdraw.call
go_to_herbalist.call
redo
else
silvers = check_silvers.call
end
if checkright
GameObj.right_hand
else
nil
end
}
if script.vars[0] =~ /help/i
respond
respond 'To use the herbs in your herbsack (see below for setting your herbsack):'
respond
respond ' ;useherbs'
respond
respond 'To use the herbs on a bench or something:'
respond
respond ' ;useherbs on bench'
respond
respond ' ;useherbs behind altar'
respond
respond 'To use the herbs on a bench without picking up the edible herbs:'
respond
respond ' ;useherbs on bench --no-get'
respond
respond 'To look up what herbs heal what:'
respond
respond ' ;useherbs list'
respond
respond ' Append any combination of these to the previous example to narrow down the list: minor, major, severed, missing, head, organ, limb, nerve, eye, blood, wound, scar'
respond
respond "To heal your Adventurer's Guild escort (not well tested):"
respond
respond ' ;useherbs escort'
respond
respond 'Options (add these to the end of the command; these override default options):'
respond
respond ' --buy=<on/off> Go to the herbalist to buy herbs if needed'
respond ' --mending=<on/off> Use sigil of mending before using herbs'
respond
respond "Change default options (so you don't have to specify the option every time):"
respond
respond ' ;useherbs set buy <on/off> same as above'
respond ' ;useherbs set mending <on/off> same as above'
respond " ;useherbs set herbsack <container> sets which container you use if one isn't"
respond ' specified on the command line'
respond
exit
elsif script.vars[1] =~ /^list$/i
known_herbs = $known_herbs.dup
if (script.vars[0] =~ /major|severed|missing/i) and (script.vars[0] !~ /minor/i)
known_herbs.delete_if { |herb| herb[:type] !~ /major|severed|missing/i }
elsif (script.vars[0] =~ /minor/i) and (script.vars[0] !~ /major|severed|missing/i)
known_herbs.delete_if { |herb| herb[:type] !~ /minor/ }
end
if (script.vars[0] =~ /wound/i) and (script.vars[0] !~ /scar|missing|severed/i)
known_herbs.delete_if { |herb| herb[:type] !~ /wound/ }
elsif (script.vars[0] =~ /scar|missing|severed/i) and (script.vars[0] !~ /wound/i)
known_herbs.delete_if { |herb| herb[:type] !~ /scar|missing|severed/ }
end
if script.vars[0] =~ /head|neck|organ|limb|leg|arm|hand|nerve|eye|blood|health|poison|posion|disease/
known_herbs.delete_if { |herb| herb[:type] =~ /head/ } unless script.vars[0] =~ /head|neck/
known_herbs.delete_if { |herb| herb[:type] =~ /organ|eye/ } unless script.vars[0] =~ /organ|eye/
known_herbs.delete_if { |herb| herb[:type] =~ /limb/ } unless script.vars[0] =~ /limb|leg|arm|hand/
known_herbs.delete_if { |herb| herb[:type] =~ /nerve/ } unless script.vars[0] =~ /nerve/
known_herbs.delete_if { |herb| herb[:type] =~ /blood/ } unless script.vars[0] =~ /blood|health/
known_herbs.delete_if { |herb| herb[:type] =~ /poison/ } unless script.vars[0] =~ /poison|posion/
known_herbs.delete_if { |herb| herb[:type] =~ /disease/ } unless script.vars[0] =~ /disease/
end
list = Hash.new
for herb in $known_herbs
list[herb[:type]] ||= Array.new
list[herb[:type]].push(herb[:name])
end
output = "\n"
for type,herbs in list
output.concat "#{monsterbold_start}#{type}:#{monsterbold_end} #{herbs.join(', ')}\n"
end
output.concat "\n"
if defined?(_respond)
_respond output
else
puts output
end
exit
elsif script.vars[1] == 'set'
if script.vars[2] == 'buy'
if script.vars[3] =~ /^(?:on|true|yes)$/
CharSettings['buy_missing'] = true
echo 'setting saved'
elsif script.vars[3] =~ /^(?:off|false|no)$/
CharSettings['buy_missing'] = false
echo 'setting saved'
else
echo "error: bad setting value: #{script.vars[3]}"
end
elsif script.vars[2] == 'mending'
if script.vars[3] =~ /^(?:on|true|yes)$/
CharSettings['use-mending'] = true
echo 'setting saved'
elsif script.vars[3] =~ /^(?:off|false|no)$/
CharSettings['use-mending'] = false
echo 'setting saved'
else
echo "error: bad setting value: #{script.vars[3]}"
end
elsif script.vars[2] == 'herbsack'
if script.vars[3]
name = script.vars[3..-1].join(' ')
obj_list = GameObj.inv.find_all { |obj| obj.noun == name }
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name == name }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{Regexp.escape(name)}$/i }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{name.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i }
end
if obj_list.empty?
echo "error: failed to find a container in your inventory by the name of \"#{name}\""
elsif obj_list.length > 1
echo "error: multiple containers in your inventory match the name \"#{name}\""
else
UserVars.herbsack = name
echo 'setting saved'
end
else
echo 'error: no container name given'
end
else
echo "error: unknown setting: #{script.vars[2]}"
end
exit
elsif script.vars[1] =~ /^buy=(on|off|true|false|yes|no)$/ # depreciated
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['buy_missing'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^mending=(on|off|true|false|yes|no)$/ # depreciated
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['use-mending'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1].downcase == 'fill'
# 5-7 doses: There is a good bit left in the rose-marrow potion.
# 3-4 doses: There is a small amount in the rose-marrow potion.
# 1-2 doses: There is just a little left in the rose-marrow potion.
if UserVars.herbsack.nil? or UserVars.herbsack.empty?
echo 'herbsack is not set (;useherbs set herbsack <container name>)'
exit
end
unless herb_container = (GameObj.inv.find { |obj| obj.noun == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.herbsack)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{UserVars.herbsack.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i })
echo "error: unable to find container \"#{UserVars.herbsack}\" in your inventory."
exit
end
close_herbsack = false
if herb_container.contents.nil?
open_result = dothistimeout "open ##{herb_container.id}", 10, open_regex
if open_result =~ /^You open/
close_herbsack = true
else
dothistimeout "look in ##{herb_container.id}", 10, /In the .*? you see/
if herb_container.contents.nil?
echo 'fixme 2'
exit
end
end
end
unless silvers
silvers = check_silvers.call
end
unless silvers > 4000
withdraw.call
end
go_to_herbalist.call
herb_shop_menu = read_menu.call
for herb_type in [ 'blood', 'major head wound', 'minor head wound', 'major head scar', 'minor head scar', 'major organ wound', 'minor organ wound', 'major organ scar', 'minor organ scar', 'missing eye', 'major limb wound', 'minor limb wound', 'major limb scar', 'minor limb scar', 'severed limb', 'major nerve wound', 'minor nerve wound', 'major nerve scar', 'minor nerve scar' ]
unless herb_container.contents.any? { |obj| $known_herbs.any? { |herb| (herb[:name] == obj.name) and herb[:type] == herb_type } }
#echo "no herb for #{herb_type}"
herb_name = herb_shop_menu.keys.find { |name| $known_herbs.any? { |h| (h[:type] == herb_type) and (name =~ /#{h[:name]}/ or name =~ /#{h[:name].sub(/sticky |gooey | green| fragrant| shiny| dirty/, '')}/) } }
unless order_number = herb_shop_menu[herb_name]
echo "error: failed to find a herb for #{herb_type} in the menu"
exit
end
dothistimeout "order #{order_number}", 3, /BUY/
buy_result = dothistimeout 'buy', 3, /Sold for [0-9,]+ silver|^But you do not have enough silver!/
if buy_result =~ /Sold for ([0-9,]+) silver/
silvers -= $1.gsub(',','').to_i
elsif buy_result =~ /^But you do not have enough silver!/
withdraw.call
go_to_herbalist.call
redo
else
silvers = check_silvers.call
end
if checkright
herb = GameObj.right_hand
dothistimeout "put ##{herb.id} #{preposition} ##{herb_container.id}", 10, put_regex
if herb_info = $known_herbs.find { |h| h[:name] =~ /#{herb.name}$/ }
$count_herbs[herb.id] = herb_info[:store_doses]
end
end
end
end
fput "close ##{herb_container.id}" if close_herbsack
deposit.call
Script.run('go2', start_room.id.to_s)
exit
elsif script.vars[1].downcase == 'escort'
if script.vars[2]
unless escort = GameObj.npcs.find { |npc| (npc.id == script.vars[2]) or (npc.noun == script.vars[2]) }
echo "Failed to find an npc with id or noun #{script.vars[2]}."
exit
end
else
unless escort = GameObj.npcs.find { |npc| npc.type =~ /escort/ }
echo "Failed to find an escort."
exit
end
end
close_herbsack = false
unless herb_container = (GameObj.inv.find { |obj| obj.noun == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.herbsack)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{UserVars.herbsack.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i })
echo "error: unable to find container \"#{UserVars.herbsack}\" in your inventory."
exit
end
if herb_container.contents.nil?
open_result = dothistimeout "open ##{herb_container.id}", 10, open_regex
if open_result =~ /^You open/
close_herbsack = true
else
dothistimeout "look in ##{herb_container.id}", 10, /In the .*? you see|In the .*?\:/
if herb_container.contents.nil?
echo "error: failed to find herb container contents (#{herb_container.name}, #{herb_container.id})"
exit
end
end
end
look_result = dothistimeout "look ##{escort.id}", 10, /^(?:She|He) appears to be in good shape\.|^(?:She|He) has|^I could not find what you were referring to\./
if look_result.nil?
echo "error: timeout while trying to look at escort (#{escort.name}, #{escort.id})"
elsif look_result =~ /^I could not find what you were referring to\./
echo "error: can't see escort"
elsif look_result =~ /^(?:She|He) appears to be in good shape\./
echo 'nothing to do'
elsif look_result =~ /^(?:She|He) has/
escort_injuries = Array.new
if look_result =~ /severe head trauma and bleeding from the ears/
escort_injuries.push('major head wound')
escort_injuries.push('major head wound')
escort_injuries.push('minor head wound')
end
if look_result =~ /minor lacerations about the head and a possible mild concussion/
escort_injuries.push('major head wound')
escort_injuries.push('minor head wound')
end
if look_result =~ /snapped bones and serious bleeding from the neck/
escort_injuries.push('major head wound')
escort_injuries.push('major head wound')
escort_injuries.push('minor head wound')
end
if look_result =~ /moderate bleeding from (?:his|her) neck/
escort_injuries.push('major head wound')
escort_injuries.push('minor head wound')
end
if look_result =~ /deep gashes and serious bleeding from (?:his|her) chest/
escort_injuries.push('major organ wound')
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /deep lacerations across (?:his|her) chest/
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /deep gashes and serious bleeding from (?:his|her) abdomen/
escort_injuries.push('major organ wound')
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /deep lacerations across (?:his|her) abdomen/
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /deep gashes and serious bleeding from (?:his|her) back/
escort_injuries.push('major organ wound')
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /deep lacerations across (?:his|her) back/
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /a blinded right eye/
# escort_injuries.push('missing eye')
escort_injuries.push('major organ wound')
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /a blinded left eye/
# escort_injuries.push('missing eye')
escort_injuries.push('major organ wound')
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /a swollen right eye/
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /a swollen left eye/
escort_injuries.push('major organ wound')
escort_injuries.push('minor organ wound')
end
if look_result =~ /a completely severed right leg/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a completely severed left leg/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a completely severed right arm/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a completely severed left arm/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a completely severed right hand/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a completely severed left hand/
escort_injuries.push('major limb wound')
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding right leg/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding left leg/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding right arm/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding left arm/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding right hand/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a fractured and bleeding left hand/
escort_injuries.push('major limb wound')
escort_injuries.push('minor limb wound')
end
if look_result =~ /a case of uncontrollable convulsions/
escort_injuries.push('major nerve wound')
escort_injuries.push('minor nerve wound')
end
if look_result =~ /a case of sporadic convulsions/
escort_injuries.push('major nerve wound')
escort_injuries.push('minor nerve wound')
end
if look_result =~ /minor bruises about the head/
escort_injuries.push('minor head wound')
end
if look_result =~ /minor bruises on (?:his|her) neck/
escort_injuries.push('minor head wound')
end
if look_result =~ /minor cuts and bruises on (?:his|her) chest/
escort_injuries.push('minor organ wound')
end
if look_result =~ /minor cuts and bruises on (?:his|her) abdomen/
escort_injuries.push('minor organ wound')
end
if look_result =~ /minor cuts and bruises on (?:his|her) back/
escort_injuries.push('minor organ wound')
end
if look_result =~ /a bruised right eye/
escort_injuries.push('minor organ wound')
end
if look_result =~ /a bruised left eye/
escort_injuries.push('minor organ wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) right leg/
escort_injuries.push('minor limb wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) left leg/
escort_injuries.push('minor limb wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) right arm/
escort_injuries.push('minor limb wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) left arm/
escort_injuries.push('minor limb wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) right hand/
escort_injuries.push('minor limb wound')
end
if look_result =~ /some minor cuts and bruises on (?:his|her) left hand/
escort_injuries.push('minor limb wound')
end
if look_result =~ /a strange case of muscle twitching/
escort_injuries.push('minor nerve wound')
end
echo escort_injuries.inspect
empty_right_hand
for herb_type in escort_injuries
herb = nil
if $known_herbs.any? { |h| h[:type] == herb_type and (h[:name] == GameObj.right_hand.name or (h[:short_name] and h[:short_name] == GameObj.right_hand.name)) }
herb = GameObj.right_hand
elsif $known_herbs.any? { |h| h[:type] == herb_type and (h[:name] == GameObj.left_hand.name or (h[:short_name] and h[:short_name] == GameObj.left_hand.name)) }
herb = GameObj.left_hand
else
stow_herb.call
if herb = herb_container.contents.find { |i| $known_herbs.find { |h| (h[:name] == i.name) and h[:type] == herb_type } }
used_herbs.push(herb.id) unless used_herbs.include?(herb.id)
get_result = dothistimeout "get ##{herb.id}", 5, get_regex
if get_result.nil? or (get_result =~ /^Get what\?/)
echo "error: timeout while trying to get herb (#{herb.name}, #{herb.id})"
dothistimeout "close ##{herb_container.id}", 5, close_regex if close_herbsack
exit
elsif get_result =~ /^You need a free hand for that\./
echo 'fixme 28382'
dothistimeout "close ##{herb_container.id}", 5, close_regex if close_herbsack
exit
end
end
end
if herb
dothistimeout "give ##{escort.id}", 10, /accepts your .* hands it back to you|ignores your offer/
end
end
stow_herb.call
fill_right_hand
end
if close_herbsack
dothistimeout "close ##{herb_container.id}", 5, close_regex
end
exit
elsif script.vars[1].downcase == 'stock'
close_herbsack = false
if UserVars.herbsack.nil? or UserVars.herbsack.empty?
echo 'herbsack is not set (;useherbs set herbsack <container name>)'
exit
end
unless herb_container = (GameObj.inv.find { |obj| obj.noun == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name == UserVars.herbsack } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.herbsack)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{UserVars.herbsack.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i })
echo "error: unable to find container \"#{UserVars.herbsack}\" in your inventory."
exit
end
if herb_container.contents.nil?
open_result = dothistimeout "open ##{herb_container.id}", 10, open_regex
if open_result =~ /^You open/
close_herbsack = true
else
dothistimeout "look in ##{herb_container.id}", 10, /In the .*? you see|In the .*?\:/
if herb_container.contents.nil?
echo "error: timeout while trying to look in herb container (#{herb_container.name}, #{herb_container.id})"
exit
end
end
end
if $useherbs_measure.nil?
exec_string = "
hide_me
status_tags
$useherbs_measure = Hash.new
using = nil
last_left_hand_id = nil
begin
while line = get
if line =~ /<left exist=\"([0-9]+)\"/
last_left_hand_id = $1
end
if line =~ /<prompt/
using = nil
elsif using
if line =~ /^You have only about ([0-9]+) quaffs left\\./
$useherbs_measure[using] = $1.to_i
elsif line =~ /^You have (?:about )?([0-9]+) (?:doses|bites) left\\./
$useherbs_measure[using] = $1.to_i
elsif line =~ /^You (?:only )?have one bite left\\./
$useherbs_measure[using] = 1
elsif line =~ /^You have only about one quaff left\\.|You only have one (?:dose|quaff) left\\./
$useherbs_measure[using] = 1
elsif line =~ /^That was the last (?:drop|of it)\\./
$useherbs_measure[using] = 0
end
elsif line =~ /^You take a (?:drink from|bite of) your .*? exist=\"([0-9]+)\"/
using = $1
elsif line =~ /^You carefully pour a little bit from your .*? exist=\"([0-9]+)\" .*? into .*? exist=\"([0-9]+)\"/
using = $1
if $useherbs_measure[$2]
$useherbs_measure[$2] += 1
end
elsif line =~ /^The .*? exist=\"([0-9]+)\" .*? has several doses left\\./
if $useherbs_measure[$1].nil? or ($useherbs_measure[$1] < 5) or ($useherbs_measure[$1] > 10)
$useherbs_measure[$1] = 7
end
elsif line =~ /^The .*? exist=\"([0-9]+)\" .*? has a few doses left\\./
if $useherbs_measure[$1].nil? or ($useherbs_measure[$1] < 3) or ($useherbs_measure[$1] > 4)
$useherbs_measure[$1] = 4
end
elsif line =~ /^The .*? exist=\"([0-9]+)\" .*? has 2 doses left\\./
$useherbs_measure[$1] = 2
elsif line =~ /^The .*? exist=\"([0-9]+)\" .*? has 1 dose left\\./
$useherbs_measure[$1] = 1
elsif line =~ /^You can't tell exactly, but .*? exist=\"(.*?)\" .*? seems to have plenty of bites left\\.$/
if $useherbs_measure[$1].nil? or ($useherbs_measure[$1] < 11) or ($useherbs_measure[$1] > 50)
$useherbs_measure[$1] = 50
end
elsif line =~ /^The .*? exist=\"(.*?)\" .*? looks like it has several bites left\\.$/
if $useherbs_measure[$1].nil? or ($useherbs_measure[$1] < 5) or ($useherbs_measure[$1] > 10)
$useherbs_measure[$1] = 10
end
elsif line =~ /^The .*? exist=\"(.*?)\" .*? looks like it has a few bites left\\.$/
if $useherbs_measure[$1].nil? or ($useherbs_measure[$1] < 3) or ($useherbs_measure[$1] > 4)
$useherbs_measure[$1] = 4
end
elsif line =~ /^The .*? exist=\"(.*?)\" .*? has 2 bites left\\.$/
$useherbs_measure[$1] = 2
elsif line =~ /^The .*? exist=\"(.*?)\" .*? has one bite left\\.$/
$useherbs_measure[$1] = 1
elsif line =~ /^He hands you <a.*?exist=\"([0-9]+)\".*?>(#{$known_herbs.collect { |h| h[:name] }.join('|')})<\\/a> and says, \"Here's your purchase./o
doses = $known_herbs.find { |h| h[:name] == $2 }[:store_doses]
if doses.nil?
echo \"warning: no store_doses entry for \#{$2}\"
doses = 4
end
$useherbs_measure[$1] = doses
elsif line =~ /^Carefully, you combine all your <a exist=\"([0-9]+)\".*? into one bundle\\./