-
Notifications
You must be signed in to change notification settings - Fork 8
/
loot-be-gone.lic
1796 lines (1716 loc) · 78.4 KB
/
loot-be-gone.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
This script gets rid of your loot.
gives heirlooms to a guard
gives bounty herbs to herbalist if the id's of the herbs are in the array $bounty_herbs
opens boxes (off by default)
bunldes herbs (off by default)
gives gold rings to the chronomage
stockpiles gems into jars in your locker (off by default)
gets gems from the stockpile for bounties (only if you have enough to complete the bounty)
saves scrolls that have spells you choose (list is empty by default)
appraise various types of items that you choose, and saves them if they're expensive
might possibly avoid selling gems and skins that you have a bounty for in the wrong town
sells stuff
deposits monies
;loot-be-gone help
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
tags: loot
version: 0.15
required: Lich >= 4.6.14
changelog:
0.15 (2020-10-10):
fix for commas in silver check
0.14 (2019-05-11):
improve regexes (austin-j)
0.13 (2018-09-04):
don't sell bounty gems in Sylvarrend
=end
=begin
0.12 (2018-08-30):
don't show trusted script warning on Ruby >= 2.3
0.11 (2017-09-23):
herb bundling function now works when the herbsack is also a lootsack
combine equivalent healing potions from different towns
0.10 (2016-09-17):
unhide before selling a container if invisible
0.9 (2015-12-10):
update bounty regex
0.8 (2015-10-13):
try to load gameobj-data.xml if it's not already loaded
0.7 (2015-03-23):
check silvers without prettynum script messing it up
use Vars[] instead of UserVars.send
start on GUI setup (not functional)
0.6 (2014-12-01):
bug fix when opening lootsacks
allow lootsacks and herbsack to be set using the script instead of ;vars or ;settings
0.5 (2014-11-09):
only remove and sell lootsacks if there are more than two items to sell in them
0.4 (2014-10-07):
Fix bug when depositing notes
0.3 (2014-10-05):
typo
0.2 (2014-10-05):
added stow-herbs option (for people with autobundle herb bags)
added option to fetch arbitrary stockpiled gems
sell container at gemshop and furrier if it doesn't have excluded items
empty a hand before depositing notes
=end
# fixme: large/small gold nuggets don't go in the same jar
# fixme: locker times out and object ids become invalid
if GameObj.type_data.empty? or GameObj.type_data.nil?
GameObj.load_data
if GameObj.type_data.empty? or GameObj.type_data.nil?
echo 'error: gameobj data is missing; you may need to download gameobj-data.xml'
exit
end
end
if ($SAFE == 0) and (RUBY_VERSION =~ /^2\.[012]\./)
echo "warning: this script is trusted, but it doesn't need to be"
end
silence_me unless $loot_be_gone_debug
withdraw_amount = 8000
save_value = { 'gemshop' => 15000, 'pawnshop' => 35000 }
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!$|^You need a free hand to pick that up\.|^Do you want to put that in or on/
get_regex = /^You (?:shield the opening of .*? from view as you |discreetly |carefully |deftly )?(?:remove|draw|grab|reach|slip|tuck|retrieve|already have|unsheathe|pick up)|^Get what\?$|^Why don't you leave some for others\?$|^You need a free hand|^I could not find what you were referring to\./
$loot_be_gone_ignore ||= Array.new
need_close_lootsack = Array.new
save_herb_list = { 'some torban leaf' => 1, 'some basal moss' => 1, 'some acantha leaf' => 1, 'some cactacae spine' => 1, 'some aloeas stem' => 1, 'some haphip root' => 1, 'some pothinir grass' => 1, 'some ephlox moss' => 1, 'some calamia fruit' => 1, 'some sovyn clove' => 1, 'some wolifrew lichen' => 1, 'some woth flower' => 1, 'some ambrominas leaf' => 3 }
save_potion_list = { 'rose-marrow potion' => 2, 'brostheras potion' => 2, 'wingstem potion' => 2, 'talneo potion' => 2, 'bolmara potion' => 2, 'white flask' => 1, 'bur-clover potion' => 1 }
equivalent_potions = [
[ 'rose-marrow potion', 'crystalline rose-marrow elixir', 'tincture of rose-marrow', 'elk horn potion', 'some feverfew tea', 'rusty red ale', "flagon of Semak's Smooth ale", "barrel of Semak's Smooth ale" ],
[ 'tiny cup of polar bear fat soup', 'brostheras potion', 'crystalline brostheras elixir', 'tincture of brostheras', 'pennyroyal potion', 'stone soot brew', "flagon of Reaper's Red ale", "barrel of Reaper's Red ale" ],
[ 'wingstem potion', 'crystalline wingstem elixir', 'tincture of wingstem', 'earthworm potion', 'wyrmwood root potion', 'dirty crevice brew', "flagon of Wort's Winter ale", "barrel of Wort's Winter ale" ],
[ 'rock lizard potion', 'talneo potion', 'crystalline talneo elixir', 'tincture of talneo', 'wyrmwood root tea', 'brown weedroot ale', "flagon of Gert's Homemade ale", "barrel of Gert's Homemade ale" ],
[ 'snowflake elixir', 'bolmara potion', 'crystalline bolmara elixir', 'tincture of bolmara', 'red lichen potion', 'glowing mold tea', "flagon of Kenar's Dropjaw ale", "barrel of Kenar's Dropjaw ale" ],
[ 'bur-clover potion', 'crystalline bur-clover elixir', 'tincture of bur-clover', 'starfish potion', 'daggit root potion', 'dirty rat fur potion', "flagon of Volcano Vision ale", "barrel of Volcano Vision ale" ],
]
herbalist_rooms = [ 3824, 1851, 10396, 640, 5722, 2406 ] # fixme: use tags
CharSettings['keep scrolls'] = Array.new unless CharSettings['keep scrolls'].class == Array
CharSettings['exclude types'] = 'weapon|armor|scroll|cursed' if CharSettings['exclude types'].nil?
CharSettings['appraise types'] = 'jewelry|weapon|armor|uncommon' if CharSettings['appraise types'].nil?
CharSettings['chronomage'] = true if CharSettings['chronomage'].nil?
notes = Array.new
if (Char.name == 'Tillmen') and (XMLData.game == 'GSIV')
# fixme: make this a setting so other people can use it
hoarding_jars = [
{ :name => 'a glossy black glass jar', :gem => 'tiny black pearl', :count => 13, :min_value => 3000, :max_value => 3099 },
{ :name => 'a glossy white glass jar', :gem => 'tiny white pearl', :count => 13, :min_value => 3000, :max_value => 3099 },
{ :name => 'a dingy grey glass jar', :gem => 'tiny grey pearl', :count => 13, :min_value => 3000, :max_value => 3099 },
{ :name => 'a pale pink glass jar', :gem => 'tiny pink pearl', :count => 13, :min_value => 2000 },
{ :name => 'a tall glass jar', :gem => 'uncut diamond', :count => 13 },
{ :name => 'a matte black glass bottle', :gem => 'black opal', :count => 13 },
# { :name => 'a burnt ochre glass bottle', :gem => 'dragonfire opal', :count => 20 },
# { :name => 'a bright scarlet glass jar', :gem => 'moonglae opal', :count => 20 },
]
else
hoarding_jars = Array.new
end
if script.vars[1] =~ /^stockpile=(on|off|yes|no|true|false|forget)$/
if $1 == 'forget'
CharSettings[:jars] = nil
echo 'stockpile tracking cleared'
else
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['stockpile'] = fix_option[$1]
echo 'setting saved'
end
exit
elsif script.vars[0] =~ /^lootsack([0-9]+)?=(.+)$/
num = $1
name = $2
if name == 'nil'
if num
Vars["lootsack#{num}"] = nil
else
Vars.lootsack = nil
end
echo 'setting cleared'
else
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
if num
Vars["lootsack#{num}"] = name
else
Vars.lootsack = name
end
echo 'setting saved'
end
end
exit
elsif script.vars[1] =~ /^herbsack=(.+)$/
name = $1
for x in 2..100
if script.vars[x]
name.concat " #{script.vars[x]}"
else
break
end
end
if name == 'nil'
Vars.herbsack = nil
echo 'setting cleared'
else
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
Vars.herbsack = name
echo 'setting saved'
end
end
exit
elsif script.vars[1] =~ /^locker=([0-9]+|nil)$/
if $1 == 'nil'
CharSettings['locker'] = nil
else
CharSettings['locker'] = $1
end
echo 'setting saved'
exit
elsif script.vars[1] =~ /^open(?:\-boxes)?=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['open boxes'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^bundle(?:\-herbs)?=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['bundle herbs'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^stow(?:\-herbs)?=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['stow-herbs'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^chronomage=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['chronomage'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^open\-cheap\-plinites=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['open-cheap-plinites'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^trash(?:\-herbs)?=(on|off|yes|no|true|false)$/
fix_option = { 'on' => true, 'true' => true, 'yes' => true, 'off' => false, 'false' => false, 'no' => false }
CharSettings['trash herbs'] = fix_option[$1]
echo 'setting saved'
exit
elsif script.vars[1] =~ /^(?:herb\-)?drop(?:\-room)?=(.+)$/
if $1 == 'nil'
CharSettings['herb drop room'] = nil
else
CharSettings['herb drop room'] = $1
end
echo 'setting saved'
exit
elsif script.vars[0] =~ /^exclude-names=(.+)$/
var = $1
if var == 'nil'
CharSettings['exclude regex'] = false
else
begin
Regexp.new(var)
rescue
echo "error: #{$!}"
echo 'ignoring setting'
exit
end
CharSettings['exclude regex'] = var
end
echo 'setting saved'
exit
elsif script.vars[0] =~ /^exclude\-types=(.+)$/
var = $1
if var == 'nil'
CharSettings['exclude types'] = false
else
begin
Regexp.new(var)
rescue
echo "error: #{$!}"
echo 'ignoring setting'
exit
end
CharSettings['exclude types'] = var
end
echo 'setting saved'
exit
elsif script.vars[0] =~ /^appraise\-types=(.+)$/
var = $1
if var == 'nil'
CharSettings['appraise types'] = false
else
begin
Regexp.new(var)
rescue
echo "error: #{$!}"
echo 'ignoring setting'
exit
end
CharSettings['appraise types'] = var
end
echo 'setting saved'
exit
elsif script.vars[1] =~ /^(?:keep\-)?scrolls=(.+)$/
option = $1
if option.downcase == 'nil'
CharSettings['keep scrolls'] = Array.new
echo 'setting saved'
elsif option =~ /^[0-9,]+$/
CharSettings['keep scrolls'] = option.split(',').collect { |num| num.to_i }
echo 'setting saved'
else
echo "You're doing it wrong."
end
exit
elsif script.vars[1] =~ /list/
if script.vars[2] =~ /stockpile/
output = " gem count full\n"
output.concat " --- ----- ----\n"
for jar in CharSettings[:jars].sort { |a,b| b[:count] <=> a[:count] }
output.concat "#{jar[:gem].rjust(30)} #{jar[:count].to_s.rjust(2)} #{jar[:full].to_s.rjust(8)}\n"
end
respond output
else
fix_option = { true => 'on', false => 'off', nil => 'off' }
output = "\n"
output.concat " stockpile: #{fix_option[CharSettings['stockpile']]}\n"
output.concat " locker: #{CharSettings['locker'] || 'nil'}\n"
output.concat " open-boxes: #{fix_option[CharSettings['open boxes']]}\n"
if CharSettings['keep scrolls'].empty?
output.concat " keep-scrolls: (none)\n"
else
output.concat " keep-scrolls: #{CharSettings['keep scrolls'].join(',')}\n"
end
output.concat " bundle-herbs: #{fix_option[CharSettings['bundle herbs']]}\n"
output.concat " stow-herbs: #{fix_option[CharSettings['stow-herbs']]}\n"
output.concat " trash-herbs: #{fix_option[CharSettings['trash herbs']]}\n"
output.concat " chronomage: #{fix_option[CharSettings['chronomage']]}\n"
output.concat "open-cheap-plinites: #{fix_option[CharSettings['open-cheap-plinites']]}\n"
output.concat " herb-drop-room: #{CharSettings['herb drop room'] || '(none)'}\n"
output.concat "\n"
output.concat " exclude-names: #{CharSettings['exclude regex'] || '(none)'}\n"
output.concat "\n"
output.concat " exclude-types: #{CharSettings['exclude types'] || '(none)'}\n"
output.concat "\n"
output.concat " appraise-types: #{CharSettings['appraise types'] || '(none)'}\n"
output.concat "\n"
output.concat " lootsack: #{Vars.lootsack || '(none)'}\n"
lootsack_num = 2
while (Vars["lootsack#{lootsack_num}"].class == String) and not Vars["lootsack#{lootsack_num}"].empty?
output.concat " lootsack#{lootsack_num}: #{Vars["lootsack#{lootsack_num}"]}\n"
lootsack_num += 1
end
output.concat "\n"
respond output
end
exit
elsif script.vars[1] =~ /get/i
nil
elsif script.vars[1] == 'setup'
echo "gui setup does not yet work"
settings = CharSettings.to_hash
window = nil
done = false
hook_proc = proc { |s|
if s =~ /^You are wearing|^I could not find|^You see nothing/
nil
else
s
end
}
DownstreamHook.add('loot-be-gone-container-search', hook_proc)
begin
script.want_downstream = false
script.want_downstream_xml = true
result = dothistimeout 'inventory containers', 5, /^You are wearing/
script.want_downstream_xml = false
script.want_downstream = true
container_ids = result.scan(/exist="(.*?)"/).flatten
containers = GameObj.inv.find_all { |obj| container_ids.include?(obj.id) }
container_usable_names = Array.new
containers.each { |c|
words = c.name.sub(/^some /, '').split(' ')
ni = words.index(c.noun)
adjs = words[0...ni]
if adjs.length == 0
container_usable_names.push(c.noun)
elsif adjs.length == 1
container_usable_names.push("#{adjs[0]} #{c.noun}")
else
for adj in adjs
result = dothistimeout "look my #{adj} #{c.noun}", 5, /^You see|^I could not find/
if result =~ /^You see/
container_usable_names.push("#{adj} #{c.noun}")
break
end
end
end
}
ensure
DownstreamHook.remove('loot-be-gone-container-search')
end
# container_usable_names = [ 'leather cloak', 'grey tunic', 'burlap sack' ]
Gtk.queue {
container_label = Gtk::Label.new.set_markup('<big><b>Get loot from these containers</b></big>')
container_label_box = Gtk::HBox.new
container_label_box.pack_start(container_label, false, false, 0)
lootsack1_label = Gtk::Label.new('lootsack')
lootsack1_label_box = Gtk::HBox.new
lootsack1_label_box.pack_end(lootsack1_label, false, false, 0)
lootsack1_entry = Gtk::ComboBoxEntry.new
if Vars.lootsack.class == String
lootsack1_entry.child.text = Vars.lootsack
end
lootsack1_color = nil
lootsack1_entry.child.signal_connect('changed') { |w|
report_errors {
if w.text.empty?
unless lootsack1_color == :grey
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#dddddd'))
lootsack1_color = :grey
end
else
obj_list = GameObj.inv.find_all { |obj| obj.noun == w.text }
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name == w.text }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{Regexp.escape(w.text)}$/i }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{w.text.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i }
end
if obj_list.empty? or (obj_list.length > 1)
unless lootsack1_color == :red
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffbbbb'))
lootsack1_color = :red
end
else
unless lootsack1_color == :white
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffffff'))
lootsack1_color == :white
end
end
end
}
}
lootsack1_entry.child.signal_emit('changed')
container_usable_names.each { |n| lootsack1_entry.append_text(n) }
container_table = Gtk::Table.new(2, 2)
container_table.attach(lootsack1_label_box, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 3, 3)
container_table.attach(lootsack1_entry, 1, 2, 0, 1, (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 3, 3)
extra_lootsacks = Array.new
add_new_lootsack = proc {
h = Hash.new
h[:label] = Gtk::Label.new("lootsack#{extra_lootsacks.length+2}")
h[:label_box] = Gtk::HBox.new
h[:label_box].pack_end(h[:label], false, false, 0)
h[:entry] = Gtk::ComboBoxEntry.new
if Vars["lootsack#{extra_lootsacks.length+2}"].class == String
h[:entry].child.text = Vars["lootsack#{extra_lootsacks.length+2}"]
end
container_usable_names.each { |n| h[:entry].append_text(n) }
container_table.attach(h[:label_box], 0, 1, (extra_lootsacks.length+1), (extra_lootsacks.length+2), Gtk::FILL, Gtk::FILL, 3, 3)
container_table.attach(h[:entry], 1, 2, (extra_lootsacks.length+1), (extra_lootsacks.length+2), (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 3, 3)
h[:entry].child.signal_connect('changed') { |w|
report_errors {
if extra_lootsacks[-1][:entry].child == w
add_new_lootsack.call
end
if w.text.empty?
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#dddddd'))
else
obj_list = GameObj.inv.find_all { |obj| obj.noun == w.text }
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name == w.text }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{Regexp.escape(w.text)}$/i }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{w.text.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i }
end
if obj_list.empty? or (obj_list.length > 1)
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffbbbb'))
else
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffffff'))
end
end
}
}
h[:entry].child.signal_emit('changed')
container_table.show_all
extra_lootsacks.push(h)
}
for num in 2..100
add_new_lootsack.call
break unless Vars["lootsack#{num}"].class == String
end
exclude_types_label = Gtk::Label.new.set_markup("<big><b>Don't sell these types of items</b></big>")
exclude_types_label_box = Gtk::HBox.new
exclude_types_label_box.pack_start(exclude_types_label, false, false, 0)
exclude_cbs = Hash.new
exclude_types_table = Gtk::Table.new(1, 5)
num = 0
GameObj.type_data.keys.each { |type|
next if type =~ /^(alchemy equipment|ammo|herb|junk|undead|bandit|lm tool|note|food|quest|jar|passive npc|grimswarm|aggressive npc|escort|lm trap)$/
row = num / 5
col = num % 5
cb = Gtk::CheckButton.new(type)
cb.active = ((type =~ /#{settings['exclude types']}/) ? true : false)
exclude_cbs[type] = cb
exclude_types_table.attach(cb, col, (col+1), row, (row+1), Gtk::FILL, Gtk::FILL, 3, 3)
num += 1
}
appraise_types_label = Gtk::Label.new.set_markup("<big><b>Appraise these types of items</b></big>")
appraise_types_label_box = Gtk::HBox.new
appraise_types_label_box.pack_start(appraise_types_label, false, false, 0)
appraise_cbs = Hash.new
appraise_types_table = Gtk::Table.new(1, 5)
num = 0
GameObj.type_data.keys.each { |type|
next if type =~ /^(alchemy equipment|ammo|herb|junk|undead|bandit|lm tool|note|food|quest|jar|passive npc|grimswarm|aggressive npc|escort|lm trap)$/
row = num / 5
col = num % 5
cb = Gtk::CheckButton.new(type)
cb.active = ((type =~ /#{settings['appraise types']}/) ? true : false)
appraise_cbs[type] = cb
appraise_types_table.attach(cb, col, (col+1), row, (row+1), Gtk::FILL, Gtk::FILL, 3, 3)
num += 1
}
appraise_types_label2 = Gtk::Label.new(" ...and sell them if they appraise for less than 15k (gemshop) or 35k (pawnshop)")
appraise_types_label2_box = Gtk::HBox.new
appraise_types_label2_box.pack_start(appraise_types_label2, false, false, 0)
exclude_names_label = Gtk::Label.new.set_markup("<big><b>Don't sell items with these names</b></big>")
exclude_names_label_box = Gtk::HBox.new
exclude_names_label_box.pack_start(exclude_names_label, false, false, 0)
herbsack_label = Gtk::Label.new('herbsack')
herbsack_label_box = Gtk::HBox.new
herbsack_label_box.pack_end(herbsack_label, false, false, 0)
herbsack_entry = Gtk::ComboBoxEntry.new
if Vars.herbsack.class == String
herbsack_entry.child.text = Vars.herbsack
end
herbsack_entry.child.signal_connect('changed') { |w|
report_errors {
if w.text.empty?
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#dddddd'))
else
obj_list = GameObj.inv.find_all { |obj| obj.noun == w.text }
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name == w.text }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{Regexp.escape(w.text)}$/i }
end
if obj_list.empty?
obj_list = GameObj.inv.find_all { |obj| obj.name =~ /\b#{w.text.split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i }
end
if obj_list.empty? or (obj_list.length > 1)
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffbbbb'))
else
w.modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse('#ffffff'))
end
end
}
}
herbsack_entry.child.signal_emit('changed')
container_usable_names.each { |n| herbsack_entry.append_text(n) }
# container_table.attach(herbsack_label_box, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 3, 3)
# container_table.attach(herbsack_entry, 1, 2, 1, 2, (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 3, 3)
stockpile_cbtn = Gtk::CheckButton.new('Stockpile gems in jars in locker')
stockpile_cbtn.active = (settings['stockpile'] ? true : false)
bundle_herbs_cbtn = Gtk::CheckButton.new('Bundle herbs')
bundle_herbs_cbtn.active = (settings['bundle herbs'] ? true : false)
stow_herbs_cbtn = Gtk::CheckButton.new('Stow herbs')
stow_herbs_cbtn.active = (settings['stow-herbs'] ? true : false)
trash_herbs_cbtn = Gtk::CheckButton.new('Throw away herbs found in boxes')
trash_herbs_cbtn.active = (settings['trash herbs'] ? true : false)
chronomage_cbtn = Gtk::CheckButton.new('Give gold rings to a chronomage')
chronomage_cbtn.active = (settings['chronomage'] ? true : false)
box = Gtk::VBox.new
box.pack_start(container_label_box, false, false, 8)
box.pack_start(container_table, false, false, 1)
box.pack_start(exclude_types_label_box, false, false, 8)
box.pack_start(exclude_types_table, false, false, 1)
box.pack_start(appraise_types_label_box, false, false, 8)
box.pack_start(appraise_types_table, false, false, 1)
box.pack_start(appraise_types_label2_box, false, false, 8)
box.pack_start(exclude_names_label_box, false, false, 8)
box.pack_start(stockpile_cbtn, false, false, 1)
box.pack_start(bundle_herbs_cbtn, false, false, 1)
box.pack_start(stow_herbs_cbtn, false, false, 1)
box.pack_start(trash_herbs_cbtn, false, false, 1)
box.pack_start(chronomage_cbtn, false, false, 1)
vp = Gtk::Viewport.new(nil, nil)
vp.add(box)
sw = Gtk::ScrolledWindow.new
sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
sw.add(vp)
window = Gtk::Window.new
window.title = "Lich - #{Char.name}'s loot-be-gone"
window.add(sw)
window.signal_connect('delete_event') {
report_errors {
done = true
}
}
window.set_default_size((Gdk.screen_width/2), (Gdk.screen_height/2))
window.set_window_position(Gtk::Window::POS_CENTER)
window.show_all
}
begin
wait_until { done }
ensure
Gtk.queue { window.destroy }
end
exit
elsif not script.vars[1].nil?
output = "\n"
output.concat " #{$clean_lich_char}#{script.name} list Shows current settings.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} list stockpile Shows stockpile contents.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} stockpile=<on|off> Stockpile gems in jars in your locker, and retrieve and sell them\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} when you have a gem bounty.\n"
output.concat " #{$clean_lich_char}#{script.name} locker=<room number> Room number of the room with a curtain or opening to get to your locker.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} stockpile=forget Clears the tracking info for the jars in your locker. Needed\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} if you manually add or remove gems or jars from your locker.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} get <#> <gem name> Retrieve gems from the stockpile.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} open-boxes=<on|off> Uses the town npc locksmith to open boxes before selling.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} keep-scrolls=nil Sell scrolls without reading them.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} keep-scrolls=<#,#,#> Read scrolls and save them only if they have a spell that's in the\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} given comma separated list. (Use exclude-types to save all scrolls.)\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} bundle-herbs=<on|off> Bundles herbs commonly found in the loot system with those\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} found in your herbsack. Keeps only one full bundle or two\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} full potions of each type, and drops the rest.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} stow-herbs=<on|off> Stow herbs commonly found in the loot system in your herbsack\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} without bundling them"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} trash-herbs=<on|off> Throw away herbs found in boxes\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} herb-drop-room=<room number> Sets the room where extra herbs will be dropped.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} herb-drop-room=<varname> If <varname> is \"rest_room\", the script will look up the drop\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} room from rest_room as shown in the ;vars command.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} herb-drop-room=nil Clears the setting. Extra herbs will be dropped where ever you\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} happen to be standing (could be the room the script was started\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} in, the locksmith, the herbalist, or the town guard)\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} chronomage=<on|off> Give gold rings to the chronomage.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} types=<regex> Only sell items whose type matches the given regex. (does not\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} stop items marked as new loot from being sold or dropped)\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} exclude-names=<regex> Any item names matching the given regex will not be sold.\n"
output.concat " #{$clean_lich_char}#{script.name} exclude-names=nil Clears the setting.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} exclude-types=<regex> Any item type matching the given regex will not be sold.\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} Meaningful types will change as gameobj-data.xml changes, but\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} here's a random list: gem, skin, reagent, jewelry, magic, uncommon,\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} herb, food, weapon, armor, clothing, alchemy product, cursed\n"
output.concat " #{$clean_lich_char}#{script.name} exclude-types=nil Clears the setting.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} appraise-types=<regex> Any item type matching the given regex will be appraised first,\n"
output.concat " #{''.rjust($clean_lich_char.length)}#{''.rjust(script.name.length)} and saved if it's expensive.\n"
output.concat " #{$clean_lich_char}#{script.name} appriase-types=nil Clears the setting.\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} lootsack=<container>\n"
output.concat " #{$clean_lich_char}#{script.name} lootsack2=<container>\n"
output.concat " #{$clean_lich_char}#{script.name} lootsack<num>=<container>\n"
output.concat " #{$clean_lich_char}#{script.name} herbsack=<container>\n"
output.concat "\n"
respond output
exit
end
lootsack_list = Array.new
lootsack_num = nil
while (Vars["lootsack#{lootsack_num}"].class == String) and not Vars["lootsack#{lootsack_num}"].empty?
if lootsack = (GameObj.inv.find { |obj| obj.noun == Vars["lootsack#{lootsack_num}"] } || GameObj.inv.find { |obj| obj.name == Vars["lootsack#{lootsack_num}"] } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars["lootsack#{lootsack_num}"])}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Vars["lootsack#{lootsack_num}"].split(' ').collect { |n| Regexp.escape(n) }.join(".*\\b")}/i })
lootsack_list.push(lootsack)
else
echo "warning: failed to find lootsack#{lootsack_num} (#{Vars["lootsack#{lootsack_num}"]})"
end
lootsack_num = 1 if lootsack_num.nil?
lootsack_num += 1
end
if lootsack_list.empty?
echo 'error: no lootsacks found'
exit
end
for lootsack in lootsack_list
if lootsack.contents.nil?
open_result = dothistimeout "open ##{lootsack.id}", 5, /^You open|^That is already open\.$/
if open_result =~ /^You open/
need_close_lootsack.push(lootsack.id)
else
dothistimeout "look in ##{lootsack.id}", 5, /In .*? you see/
if lootsack.contents.nil?
echo 'error: failed to find lootsack contents'
exit
end
end
end
end
lootsack_put = proc { |obj|
if obj.class == GameObj
cmd = "_drag ##{obj.id}"
elsif obj =~ /^[0-9]+$/
cmd = "_drag ##{obj}"
else
cmd = "put #{obj} in"
end
for lootsack in lootsack_list
result = dothistimeout "#{cmd} ##{lootsack.id}", 5, put_regex
break unless result =~ /won't fit/
end
}
if CharSettings['bundle herbs'] or CharSettings['stow-herbs']
if Vars.herbsack.nil? or Vars.herbsack.empty?
echo "herbsack is not set. (;#{script.name} herbsack=<container name>)"
exit
end
unless herbsack = (GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(Vars.herbsack.strip)}$/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(Vars.herbsack).sub(' ', ' .*')}$/i })
echo 'error: failed to find your herbsack'
exit
end
end
check_silvers = proc {
hook_proc = 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('go2_check_silvers')
nil
else
server_string
end
}
clear
DownstreamHook.add('go2_check_silvers', hook_proc)
silence_me unless undo_silence = silence_me
put 'info'
silence_me if undo_silence
start = Time.now
while (line = get)
if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9,]+)/
silvers = $1.gsub(',','').to_i
break
elsif (Time.now - start) > 15
silvers = 0
break
end
end
silvers
}
need_to_open_boxes = proc {
need = true
unless (GameObj.right_hand.type =~ /box/) or (GameObj.left_hand.type =~ /box/) or lootsack_list.any? { |lootsack| lootsack.contents.find { |obj| obj.type =~ /box/ } }
unless disk = GameObj.loot.find { |obj| obj.name =~ /#{Char.name} disk$/ }
if reget.any? { |line| line =~ /^Your disk arrives, following you dutifully\.\r?$/ }
50.times { break if GameObj.loot.any? { |obj| obj.name =~ /#{Char.name} disk$/ }; sleep 0.1 }
disk = GameObj.loot.find { |obj| obj.name =~ /#{Char.name} disk$/ }
end
end
if disk and disk.contents.nil?
dothistimeout "look in ##{disk.id}", 5, /^In the|^There is nothing in there\.$/
end
unless disk.contents.any? { |obj| obj.type =~ /box/ }
need = false
end
end
need
}
table = activator = trash = nil
open_box = proc { |box|
unless (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
dothistimeout "get ##{box.id}", 5, get_regex
end
if (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
fput 'unhide' if invisible?
activator_result = dothistimeout activator, 5, /^You .*? the .*? but .*? ignores you|I'm afraid that you can't pull that.|^You .*? the .*?, and ask .*?/
if activator_result =~ /^You .*? the .*? but .*? ignores you/
dothistimeout "drop ##{box.id}", 5, /flickers in and out of existence|^You drop/
dothistimeout "get ##{box.id}", 5, /^You already|^You pick up/
activator_result = dothistimeout activator, 5, /^You .*? the .*? but .*? ignores you|I'm afraid that you can't pull that.|^You .*? the .*?, and ask .*?/
end
if activator_result =~ /^You .*? the .*?, and ask .*?|^You .*? the .*? but .*? ignores you/
if activator_result =~ /^You .*? the .*? but .*? ignores you/
pay_result = 'accepts your silvers'
else
pay_result = dothistimeout 'pay', 5, /^But you don't have enough!|accepts your silvers/
end
if pay_result =~ /accepts your silvers/
open_result = dothistimeout "open ##{box.id}", 5, /^You open|^That is already open\.|^It appears to be locked\./
if open_result =~ /^You open|^That is already open\./
get_result = dothistimeout "get coins from ##{box.id}", 5, /^You gather the remaining|^Get what\?/
unless get_result =~ /^You gather the remaining/
echo 'fixme (9)'
end
waitrt?
drop_box = false
for obj in box.contents
if obj.type =~ /cursed/
drop_box = true
next
elsif (obj.type =~ /junk|food/) or (CharSettings['trash herbs'] and obj.type =~ /herb/)
if trash
dothistimeout "get ##{obj.id}", 5, /^You/
dothistimeout "put ##{obj.id} in ##{trash.id}", 5, /^You put|^As you place/
else
dothistimeout "_drag ##{obj.id} drop", 5, /^You drop/
end
elsif (obj.type =~ /herb/) and CharSettings['stow-herbs']
if herbsack.contents.nil?
open_result = dothistimeout "open ##{herbsack.id}", 5, /^You open|^That is already open\.$/
if open_result =~ /^You open/
close_herbsack = true
end
end
dothistimeout "_drag ##{obj.id} ##{herbsack.id}", 5, put_regex
else
lootsack_put.call(obj)
end
end
if drop_box
dothistimeout "drop ##{box.id}", 5, /^You drop/
else
unless box.contents.empty?
echo 'error: box is not empty'
lootsack_put.call(box)
end
if trash
dothistimeout "put ##{box.id} in ##{trash.id}", 5, /^You put|^As you place/
else
dothistimeout "drop ##{box.id}", 5, /^You drop/
end
end
sleep 0.1
elsif open_result =~ /^It appears to be locked\./
echo 'fixme (2382)'
else
echo 'fixme (8)'
end
elsif pay_result =~ /^But you don't have enough!/
Script.run('go2', 'bank --disable-confirm')
fput "withdraw #{withdraw_amount} silvers"
Script.run('go2', 'locksmith --disable-confirm')
open_box.call(box)
else
echo 'fixme (6)'
end
else
echo 'fixme (5)'
end
else
echo 'fixme (3)'
end
dothistimeout "close ##{herbsack.id}", 5, /^You close|^That is already closed\.$/ if close_herbsack
}
to_locker = proc {
silvers = check_silvers.call
if silvers < 526
Script.run('go2', 'bank --disable-confirm')
fput 'unhide' if invisible?
fput "withdraw #{526 - silvers}"
end
Script.run('go2', CharSettings['locker'])
if way_in = (GameObj.loot.to_a + GameObj.room_desc.to_a).find { |obj| obj.noun =~ /^(?:opening|curtain)$/ }
move "go #{way_in.noun}"
else
false
end
}
from_locker = proc {
if way_out = (GameObj.loot.to_a + GameObj.room_desc.to_a).find { |obj| obj.noun =~ /^(?:opening|curtain)$/ }
move "go #{way_out.noun}"
end
}
gem_in_jar_regex = proc { |gem|
# fixme
if gem =~ /pearl$/
/^#{gem.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/
else
/^#{gem.sub(/some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/
end
}
need_to_stockpile = proc {
can_start_new_jar = (CharSettings[:empty_jar_count] > 0) && lootsack_list.any? { |lootsack| lootsack.contents.any? { |obj| (obj.type =~ /gem/) and (obj.name !~ /oblivion quartz$/) and not CharSettings[:jars].any? { |jar| jar[:gem] =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/ } } }
can_add_to_jar = CharSettings[:jars].any? { |jar|
!jar[:full] && lootsack_list.any? { |lootsack|
lootsack.contents.any? { |obj|
jar[:gem] =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/
}
}
}
CharSettings[:jars].nil? || can_start_new_jar || can_add_to_jar
}
stockpile = proc {
status_tags
open_result = dothistimeout 'open locker', 5, /exist=".*?" noun="(?:locker|chest)"/
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|chest)"/
locker_id = $1
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 5, /^In the/
locker_contents = GameObj.containers[locker_id]
end
if locker_contents
if CharSettings[:jars].nil?
CharSettings[:jars] = Array.new
CharSettings[:empty_jar_count] = 0
locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|bottle|beaker)$/ }.each { |jar|
if jar.after_name.nil?
CharSettings[:empty_jar_count] = CharSettings[:empty_jar_count] + 1
else
look_result = dothistimeout "look in ##{jar.id} from ##{locker_id}", 5, /^Inside .*? you see [0-9]+ portion/
if look_result =~ /^Inside .*? you see ([0-9]+) portion/
count = $1.to_i
gem = jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '')
full = look_result.include?('It is full')
CharSettings[:jars].push(h={ :gem => gem, :count => count, :full => full })
end
end
}
end
empty_hands
not_suitable = Array.new
for jar in locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|beaker|bottle)$/ }
if jar.after_name =~ /^containing /
gem_list = Array.new
lootsack_list.each { |lootsack| gem_list.concat(lootsack.contents.find_all { |obj| (jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '') =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/) }) }
gem_list.delete_if { |obj| not_suitable.include?(obj.id) }
jar_hash = CharSettings[:jars].find { |j| j[:gem] == jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '') }
unless gem_list.empty? or jar_hash[:full]
dothistimeout "get ##{jar.id} from ##{locker_id}", 5, /^You remove/
for gem in gem_list
result = dothistimeout "_drag ##{gem.id} ##{jar.id}", 5, /^You add|is full|does not appear to be a suitable container for/
if result =~ /^You add .* filling it/
jar_hash[:count] = jar_hash[:count] + 1
jar_hash[:full] = true
elsif result =~ /^You add/
jar_hash[:count] = jar_hash[:count] + 1
elsif result =~ /is full/
jar_hash[:full] = true
lootsack_put.call(gem)
break
elsif result =~ /does not appear to be a suitable container for/
not_suitable.push(gem.id)
lootsack_put.call(gem)
else
lootsack_put.call(gem)
end
end
dothistimeout "put ##{jar.id} in ##{locker_id}", 5, /^You (?:put|place)/
end
else