-
Notifications
You must be signed in to change notification settings - Fork 8
/
alchemy.lic
3086 lines (3009 loc) · 149 KB
/
alchemy.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
Alchemy Script of Doom!!!1!one
;alchemy help
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
tags: alchemy, guild
version: 0.16
required: alchemy-recipes.lic >= 0.3
changelog:
0.16 (2020-10-20):
fix commas in silver check
0.15 (2018-09-15):
fix collecting water
0.14 (2017-11-11):
fix squelching of gld verb for inactive members
=end
=begin
0.13 (2017-01-14):
make grind task work with "set sortedview on"
0.12 (2015-07-08):
added support for more scripted containers
0.11 (2015-07-08):
fix a bug where the wrong version of a recipe might be used when a specific step is required
0.10 (2015-04-27):
add options to clear helper scripts
0.9 (2014-12-12):
fix sunlight detection
0.8 (2014-12-11):
bugfix for Ruby 1.8
0.7 (2014-12-10):
move equivalents and reagent values (not complete) into alchemy-recipes.lic
add time and value of each item to recipe check summary
allow containts to be set using the script instead of ;settings/;vars
0.6 (2014-11-12):
recognize gld messaging for inactive members
0.5 (2014-10-09):
added message for scripted container (You carefully attach)
0.4 (2014-10-07):
more Mist Harbor fixes
0.3 (2014-10-07):
use Mist Harbor promissory note on Mist Harbor
0.2 (2014-10-07):
fix issue with finding recipes for alchemy masters task
=end
# fixme: run outta money
# fixme: full containers
# fixme: jars with unneeded ingredients ;e GameObj['bag'].contents.find_all { |obj| obj.noun == 'jar' }.each { |jar| echo jar.after_name unless jar.after_name.sub(/^containing /, '') =~ /#{UserVars.needed_reagents.gsub('$|^', 's?$|^').gsub('tooth', '(?:tooth|teeth)').sub('leaf', '(?:leaf|leaves)').sub(/y\b/, '(?:y|ie)').gsub('some ', '(?:some )?').sub('handful of ', '(?:handful of )?').sub('sprig of ', '(?:sprig of )?').gsub(' ', 's? ')}/ }
# fixme: forage some mushrooms only certain times of day
# fixme: Khelorof says, "To rise to the top, you must diversify. You need to learn 2 rank(s) of other skills before I can promote you in this skill again."
# fixme: recast haste on armor hindrance
# fixme: option to use symbol of dreams when waiting for spirit
# fixme: use time verb for sunlight test
# fixme: The surface of the solution in the iron cauldron shimmers in response!
# fixme: The diamond lens shatters!
silence_me unless $alchemy_debug
unless defined?($alchemy_recipes) and ($alchemy_recipes.class == Array) and not $alchemy_recipes.empty?
unless Script.exists?('alchemy-recipes')
start_script 'repository', [ 'download', 'alchemy-recipes' ]
wait_while { running?('repository') }
unless Script.exists?('alchemy-recipes')
echo 'failed to download alchemy-recipes.lic'
exit
end
end
start_script 'alchemy-recipes'
wait_while { running?('alchemy-recipes') }
unless defined?($alchemy_recipes)
echo 'no recipes'
exit
end
unless defined?($alchemy_reagent_op_cost)
start_script 'repository', [ 'download', 'alchemy-recipes' ]
wait_while { running?('repository') }
start_script 'alchemy-recipes'
wait_while { running?('alchemy-recipes') }
unless defined?($alchemy_reagent_op_cost)
echo 'error: failed to download a new enough version of alchemy-recipes'
exit
end
end
end
CharSettings['hide-gld-check'] = true if CharSettings['hide-gld-check'].nil?
CharSettings['hide-bundle-check'] = true if CharSettings['hide-bundle-check'].nil?
CharSettings['hide-jar-check'] = true if CharSettings['hide-jar-check'].nil?
CharSettings['cast-sanctuary'] = true if CharSettings['cast-sanctuary'].nil?
CharSettings['buy-crap'] = false if CharSettings['buy-crap'].nil?
CharSettings['throw-away-crap'] = false if CharSettings['throw-away-crap'].nil?
CharSettings['sell-crap'] = false if CharSettings['sell-crap'].nil?
CharSettings['max-travel-time'] ||= 90
CharSettings['max-hunt-time'] ||= 300
CharSettings['max-forage-time'] ||= 300
CharSettings['cost-per-second'] ||= 15
CharSettings['favorite-recipes'] ||= Array.new
echo CharSettings['kill time'].inspect if $alchemy_debug
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!$/
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/
cauldron_noun = /^(?:cauldron|vat|kettle|boiler)$/
elusive_reagent_cost = {
'cluster of ayanad crystals' => 64,
'ayanad crystal' => 128,
'crystal core' => 128,
'elemental core' => 255,
"cluster of s'ayanad crystals" => 255,
'cracked soulstone' => 300, # fixme
"s'ayanad crystal" => 510,
'some essence of air' => 510,
'some essence of earth' => 510,
'some essence of fire' => 510,
'some essence of water' => 510,
"pristine nymph's hair" => 510,
'small troll tooth' => 638,
'glimmering blue essence shard' => 638,
'some glimmering blue essence dust' => 765,
'glimmering blue mote of essence' => 765,
"cluster of t'ayanad crystals" => 892,
'glowing violet essence shard' => 1275,
'crystalline globe' => 1530,
"t'ayanad crystal" => 1785,
"pristine sprite's hair" => 1785,
'glowing violet mote of essence' => 2295,
'some glowing violet essence dust' => 2295,
'perfect myklian belly scale' => 2550,
'large troll tooth' => 2550,
'vial of farlook vitreous humor' => 2550,
'inky necrotic core' => 2550,
'tiny golden seed' => 2550,
'radiant crimson essence shard' => 3825,
"pristine siren's hair" => 4080,
"n'ayanad crystal" => 5355,
'some radiant crimson essence dust' => 6885,
'radiant crimson mote of essence' => 6885,
}
if $alchemy_equivalents
equivalent = $alchemy_equivalents
else
equivalent = [
[ 'ayana leaf', 'ayana lichen', 'ayana weed', 'ayana berry', 'ayana root' ],
[ "ayana'al leaf", "ayana'al lichen", "ayana'al weed", "ayana'al berry", "ayana'al root" ],
[ 'some ground ayana', 'some ground ayana leaf', 'some ground ayana lichen', 'some ground ayana weed', 'some ground ayana berry', 'some ground ayana root' ],
[ 'myklian scale', 'orange myklian scale', 'red myklian scale', 'yellow myklian scale', 'green myklian scale' ],
[ 'white pearl', 'large white pearl', 'medium white pearl', 'small white pearl', 'tiny white pearl' ],
[ 'black pearl', 'large black pearl', 'medium black pearl', 'small black pearl', 'tiny black pearl' ],
[ 'pink pearl', 'tiny pink pearl', 'small pink pearl', 'medium pink pearl', 'large pink pearl' ],
[ 'stick', 'thick stick', 'stained stick', 'slender stick', 'pointed stick', 'twisted stick', 'long stick', 'slim stick', 'charred stick', 'flexible stick', 'sturdy stick', 'dark stick', 'hefty stick', 'cracked stick', 'thin stick', 'small stick', 'bent stick', 'short stick', 'heavy stick' ],
[ 'vial of concentrated firethorn essence', 'vial concentrated firethorn essence' ],
[ 'some powdered rhodochrosite stone', 'some powdered pink rhodochrosite stone' ],
[ 'some powdered chrysoberyl gem', 'some powdered bright chrysoberyl gem' ],
[ 'some powdered malachite stone', 'some powdered green malachite stone' ],
[ 'some powdered spessartine garnet', 'some powdered orange spessartine garnet' ],
[ 'some powdered pink coral', 'some powdered polished pink coral' ],
[ 'some powdered blue coral', 'some powdered polished blue coral' ],
[ 'some powdered red coral', 'some powdered polished red coral' ],
[ 'some powdered water sapphire', 'some powdered pale water sapphire' ],
[ 'some powdered fire pearl', 'some powdered billiant fire pearl' ],
[ 'some powdered cowrie shell', 'some powdered snake-head cowrie shell' ],
[ 'some powdered iridescent mother-of-pearl', 'some powdered iridescent piece of mother-of-pearl' ],
[ 'some powdered silvery conch shell', 'some powdered sparkling silvery conch shell' ],
[ 'some powdered imperial topaz', 'some powdered orange imperial topaz' ],
[ 'some powdered green moonstone', 'some powdered pale green moonstone' ],
[ 'some powdered pale blue moonstone', 'some powdered blue moonstone' ],
[ 'some powdered beryl gem', 'some powdered golden beryl gem' ],
[ 'crystalline globe', 'corked crystalline globe filled with glowing mineral water', ],
[ 'tkaro root', 'shiny tkaro root' ],
[ 'tufted hawk-owl ear', 'hawk-owl ear' ],
]
end
herb_doses = {
'some acantha leaf' => 10,
'some aloeas stem' => 2,
'some haphip root' => 4,
'some pothinir grass' => 2,
'some basal moss' => 4,
'some ephlox moss' => 4,
'some ambrominas leaf' => 4,
'some calamia fruit' => 2,
'some cactacae spine' => 4,
'some sovyn clove' => 1,
'some wolifrew lichen' => 4,
'some woth flower' => 2,
'some torban leaf' => 3,
}
sea_water_flask = /^(?:small|small opaque|faceted) crystal flask$|^dark sphene-inset flask$/
sea_water_vial = /^(?:clouded|warped|chipped|tapered|smoky|thick|slender|clear|blackened) glass vial$|^polished glaes vial$/
bundled_herb = /^some acantha leaf$|^some cactacae spine$|^some ambrominas leaf$|^some torban leaf$|^some wolifrew lichen$|^some sovyn clove$|^some ephlox moss$|^some pothinir grass$|^some haphip root$|^some calamia fruit$|^some aloeas stem$|^some basal moss$|^some woth flower$/
check_silvers = proc {
silvers = nil
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,]+)/
silvers = $1.gsub(',','').to_i
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
put 'info'
silence_me if undo_silence
wait_until { silvers }
silvers
}
wander_room_order = Array.new
wander_room_list = Array.new
wander = proc {
next_room_options = Room.current.wayto.keys & wander_room_list
next_room = next_room_options.find_all { |r| not wander_room_order.include?(r) }
if next_room.empty?
next_room = wander_room_order.find { |r| next_room_options.include?(r) }
else
next_room = next_room[rand(next_room.length)]
end
wander_room_order.delete(next_room)
wander_room_order.push(next_room)
way = Room.current.wayto[next_room]
if way.class == String
move(way)
else
way.call
end
}
gld_var = nil
gld = proc {
if gld_var.nil?
fix_type = { 'General Alchemy' => 'alchemy', 'Alchemic Potions' => 'potions', 'Alchemic Trinkets' => 'trinkets' }
script.want_downstream = false
script.want_downstream_xml = true
gld_var = Hash.new
type = nil
if CharSettings['hide-gld-check']
started = false
action = proc { |server_string|
if started
if server_string =~ /<output/
DownstreamHook.remove('hide_gld')
server_string
else
nil
end
else
if server_string =~ /^You are (?:a member|an inactive member|Guild Master)/
started = true
nil
else
server_string
end
end
}
DownstreamHook.add('hide_gld', action)
end
undo_silent = !script.silent
script.silent = true
result = dothistimeout 'gld', 15, /^You are (?:a member|an inactive member|Guild Master)|^You have no guild affiliation./
script.silent = false if undo_silent
if result =~ /^You have no guild affiliation./
echo 'join a guild'
exit
elsif result.nil?
echo 'fixme 20983238453'
end
while (line = get) and (line !~ /<prompt/)
if line =~ /^You currently have no ranks in any guild skills./
for type in fix_type.values
gld_var[type] = Hash.new
gld_var[type][:rank] = 0
gld_var[type][:task] = 'no task'
gld_var[type][:reps] = 0
end
elsif line =~ /^You have ([0-9]+|no) ranks? in the (General Alchemy|Alchemic Potions|Alchemic Trinkets) skill\.$/
rank = $1
type = fix_type[$2]
gld_var[type] = Hash.new
if rank =~ /^[0-9]+$/
gld_var[type][:rank] = rank.to_i
else
gld_var[type][:rank] = 0
end
elsif line =~ /^You are a Master of (General Alchemy|Alchemic Potions|Alchemic Trinkets)\.$/
type = fix_type[$1]
gld_var[type] = Hash.new
gld_var[type][:rank] = 63
elsif line =~ /^The Training Administrator told you to (.*)\.$/
gld_var[type][:task] = $1
elsif line =~ /^You have earned enough training points for your next rank\./
gld_var[type][:task] = 'promotion'
elsif line =~ /^You are not currently training in this skill\.$|^You have not yet obtained your first task for this skill rank\.$|^You have not been assigned a current task for this skill\.$/
gld_var[type][:task] = 'no task'
gld_var[type][:reps] = 0
elsif line == 'You have no repetitions remaining for this task.'
gld_var[type][:reps] = 0
elsif line =~ /^You have ([0-9]+) repetitions? remaining (?:for|to complete) this task\.$/
gld_var[type][:reps] = $1.to_i
end
end
script.want_downstream = true
script.want_downstream_xml = false
end
gld_var
}
invalid_gld = proc {
gld_var = nil
}
gld_suggestions = proc {
gld.call
if gld_var.values.any? { |hash| hash[:recipes].nil? }
for type in gld_var.keys
if gld_var[type][:task] =~ /(?:with your|that involve) (.*?)(?: ability| mana|ing spells|ing|ing mana|ing spirit)?$/
required_step = $1
if gld_var[type][:task] =~ /cauldron workshop/
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| recipe[:type].include?(type) and recipe[:rank] and gld_var[type][:rank] >= recipe[:rank].min and gld_var[type][:rank] <= recipe[:rank].max and recipe[:steps].any? { |step| step =~ /^#{required_step}/ } and not recipe[:steps].any? { |step| step =~ /^refract/ } }
else
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| recipe[:type].include?(type) and recipe[:rank] and gld_var[type][:rank] >= recipe[:rank].min and gld_var[type][:rank] <= recipe[:rank].max and recipe[:steps].any? { |step| step =~ /^#{required_step}/ } }
end
elsif gld_var[type][:task] =~ /follow some tough recipes and create some items|visit a skilled master for a lesson/
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| (recipe[:product] != 'flask of pure water') and recipe[:type].include?(type) and recipe[:rank] and gld_var[type][:rank] >= recipe[:rank].min and gld_var[type][:rank] <= recipe[:rank].max }
elsif gld_var[type][:task] == 'practice distilling for reagents'
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| recipe[:product] == 'flask of pure water' }
elsif gld_var[type][:task] == 'practice extracting for reagents'
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| recipe[:product] == 'handful of sea salt' }
else
gld_var[type][:recipes] = Array.new
end
end
end
gld_var
}
gld_suggestions2 = proc {
gld.call
if gld_var.values.any? { |hash| hash[:recipes].nil? }
for type in gld_var.keys
gld_var[type][:recipes] = $alchemy_recipes.find_all { |recipe| (recipe[:product] != 'flask of pure water') and recipe[:type].include?(type) and recipe[:rank] and gld_var[type][:rank] >= recipe[:rank].min and gld_var[type][:rank] <= recipe[:rank].max }.collect { |recipe| recipe[:product] }
gld_var[type][:recipes] = gld_var[type][:recipes] | gld_var[type][:recipes]
end
end
gld_var
}
alchemy_sack_var = nil
close_alchemy_sack_var = false
alchemy_sack = proc {
if alchemy_sack_var.nil?
if UserVars.alchemysack.nil? or UserVars.alchemysack.empty?
echo 'warning: alchemysack is not set (#{$clean_lich_char}#{script.name} set alchemysack <container name>)'
sleep 1
else
alchemy_sack_var = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.alchemysack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.alchemysack).sub(' ', ' .*')}/i }
if alchemy_sack_var.nil?
echo "warning: failed to find your alchemysack (#{UserVars.alchemysack})"
sleep 1
else
if alchemy_sack_var.contents.nil?
open_result = dothistimeout "open ##{alchemy_sack_var.id}", 10, /You open|already open/
close_alchemy_sack_var = true if open_result =~ /You open/
if alchemy_sack_var.contents.nil?
dothistimeout "look in ##{alchemy_sack_var.id}", 10, /In the .* you see/
if alchemy_sack_var.contents.nil?
echo "warning: failed to find the contents of your alchemysack (#{UserVars.alchemysack})"
sleep 1
end
end
end
end
end
end
alchemy_sack_var
}
loot_sack_var = nil
close_loot_sack_var = false
loot_sack = proc {
if loot_sack_var.nil?
if UserVars.lootsack.nil? or UserVars.lootsack.empty?
echo 'warning: lootsack is not set (#{$clean_lich_char}#{script.name} set lootsack <container name>)'
sleep 1
else
loot_sack_var = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}/i }
if loot_sack_var.nil?
echo "warning: failed to find your lootsack (#{UserVars.lootsack})"
sleep 1
else
if loot_sack_var.contents.nil?
open_result = dothistimeout "open ##{loot_sack_var.id}", 10, /You open|already open/
close_loot_sack_var = true if open_result =~ /You open/
if loot_sack_var.contents.nil?
dothistimeout "look in ##{loot_sack_var.id}", 10, /In the .* you see/
if loot_sack_var.contents.nil?
echo "warning: failed to find the contents of your lootsack (#{UserVars.lootsack})"
sleep 1
end
end
end
end
end
end
loot_sack_var
}
herb_sack_var = nil
close_herb_sack_var = false
herb_sack = proc {
if herb_sack_var.nil?
if UserVars.herbsack.nil? or UserVars.herbsack.empty?
echo 'warning: herbsack is not set (#{$clean_lich_char}#{script.name} set herbsack <container name>)'
sleep 1
else
herb_sack_var = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.herbsack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.herbsack).sub(' ', ' .*')}/i }
if herb_sack_var.nil?
echo "warning: failed to find your herbsack (#{UserVars.herbsack})"
sleep 1
else
if herb_sack_var.contents.nil?
open_result = dothistimeout "open ##{herb_sack_var.id}", 10, /You open|already open/
close_herb_sack_var = true if open_result =~ /You open/
if herb_sack_var.contents.nil?
dothistimeout "look in ##{herb_sack_var.id}", 10, /In the .* you see/
if herb_sack_var.contents.nil?
echo "warning: failed to find the contents of your herbsack (#{UserVars.herbsack})"
sleep 1
end
end
end
end
end
end
herb_sack_var
}
close_sacks = proc {
if close_alchemy_sack_var
fput "close ##{alchemy_sack_var.id}"
close_alchemy_sack_var = false
end
if close_loot_sack_var
fput "close ##{loot_sack_var.id}"
close_loot_sack_var = false
end
if close_herb_sack_var
fput "close ##{herb_sack_var.id}"
close_herb_sack_var = false
end
}
all_sack_contents = proc {
(alchemy_sack.call.contents.to_a | loot_sack.call.contents.to_a | herb_sack.call.contents.to_a)
}
cauldron = nil
drop_cauldron = proc {
error = false
unless (checkroom == '[A Secluded Corner]') or GameObj.room_desc.find { |obj| obj.noun == 'cauldron' } or GameObj.loot.find { |obj| obj.noun =~ cauldron_noun }
unless cauldron = all_sack_contents.call.find { |obj| obj.noun =~ cauldron_noun }
echo 'error: missing cauldron'
error = true
end
dothis "get ##{cauldron.id}", get_regex
# Upon further reflection, you decide it would be best if you just used the already present training cauldron.
dothis "drop ##{cauldron.id}", /^You drop/
put "drag #{cauldron.noun}"
end
!error
}
force_drop_cauldron = proc {
error = false
unless cauldron = all_sack_contents.call.find { |obj| obj.noun =~ cauldron_noun }
echo 'error: missing cauldron'
error = true
else
dothis "get ##{cauldron.id}", get_regex
# Upon further reflection, you decide it would be best if you just used the already present training cauldron.
dothis "drop ##{cauldron.id}", /^You drop/
put "drag #{cauldron.noun}"
end
!error
}
get_cauldron = proc {
if cauldron
dothis "_drag ##{cauldron.id} ##{alchemy_sack.call.id}", put_regex
fput 'drag stop'
cauldron = nil
end
}
where_is_previous_var = nil
where_is_shortest_distances_var = nil
where_is_history = Hash.new
where_is = proc { |place|
if where_is_history[place]
where_is_history[place]
elsif where_is_previous_var.nil?
if Room.current
if home_room = Room.current.find_nearest_by_tag("#{Char.prof.downcase} alchemy administrator")
home_room = Room[home_room]
else
echo 'warning: failed to find your guild'
home_room = Room.current
end
if (home_room == Room.current) or Map.estimate_time(Room.current.path_to(home_room)) <= CharSettings['max-travel-time']
where_is_previous_var, where_is_shortest_distances_var = home_room.dijkstra
else
echo 'warning: nearest guild exceeds max travel time'
where_is_previous_var = false
end
else
echo 'warning: your current room is not in the map database'
where_is_previous_var = false
end
end
if where_is_previous_var == false
Array.new
else
results = Array.new
Map.list.each { |room| results.push(room.id) if room.tags.include?(place) }
if place == 'ayana leaf'
["ayana berry", "ayana leaf", "ayana root", "ayana weed", "ayana lichen"].each { |other_place| Map.list.each { |room| results.push(room.id) if room.tags.include?(other_place) and not results.include?(room.id) } }
#"ayana'al berry", "ayana'al root", "ayana'al lichen"
end
results.delete_if { |room_id| where_is_shortest_distances_var[room_id].nil? or where_is_shortest_distances_var[room_id] > CharSettings['max-travel-time'] }
# ignore the Caravansary
results.delete_if { |room_id| Room[room_id].title.any? { |t| t =~ /^(?:\['Tain't Much Magic, Emporium\]|\['Tain't Much Magic, Consignment\]|\[Finders-Sellers Pawnshop\]|\[Clenchfist Bros. Banking, Lobby\])$/ } }
where_is_history[place] = results.sort { |a,b| where_is_shortest_distances_var[a] <=> where_is_shortest_distances_var[b] }
where_is_history[place]
end
}
go_empty_workshop = proc {
room_list = where_is.call("#{Char.prof.downcase} alchemy workshop")
unless room_list.empty? or room_list.include?(Room.current.id)
get_cauldron.call
for room_id in room_list
break if where_is_shortest_distances_var[room_id] > 15
start_script 'go2', [ room_id.to_s ]
wait_while { running?('go2') }
break unless checkpcs
end
end
}
is_workshop = proc {
Room.current.tags.include?("#{Char.prof.downcase} alchemy workshop")
}
tavel_time = proc { |room_id|
if where_is_shortest_distances_var.nil?
where_is.call
end
where_is_shortest_distances_var[room_id]
}
note_name_var = nil
note_name = proc {
if note_name_var.nil?
if (room_id = where_is.call("#{Char.prof.downcase} alchemy administrator").first) and (location = Room[room_id].location)
hash = {
'the town of Icemule Trace' => 'Icemule promissory note',
'Icemule Trace' => 'Icemule promissory note',
'Kharam-Dzu' => 'Borthuum Mining Company scrip',
"the town of Wehnimer's Landing" => "Wehnimer's promissory note",
"Wehnimer's Landing" => "Wehnimer's promissory note",
"the Coastal Cliffs" => "Wehnimer's promissory note",
"River's Rest" => 'Torren promissory note',
'Zul Logoth' => 'mining chit',
"Ta'Illistim" => 'City-States promissory note',
"Ta'Vaalor" => 'City-States promissory note',
'the free port of Solhaven' => 'Vornavis promissory note',
'Solhaven' => 'Vornavis promissory note',
'Mist Harbor' => 'Mist Harbor promissory note',
}
note_name_var = hash[location]
else
note_name_var = false
end
else
note_name_var
end
}
note_name_from_place = proc { |place|
if place =~ /Icemule/
'Icemule promissory note'
elsif place =~ /Ta'Illistim|Ta'Vaalor/
'City-States promissory note'
elsif place =~ /River's Rest/
'Torren promissory note'
elsif place =~ /Solhaven/
'Vornavis promissory note'
elsif place =~ /Kharam-Dzu/
'Borthuum Mining Company scrip'
elsif place =~ /Wehnimer's Landing/
"Wehnimer's promissory note"
elsif place =~ /Zul Logoth/
'mining chit'
elsif place =~ /Mist Harbor/
'Mist Harbor promissory note'
else
nil
end
}
is_sunlight_cache = nil
is_sunlight = proc {
# fixme: guessing times for light
# mid-morning: 11:26 - 11:26
# afternoon: 12:07 - 14:04 (sunlight)
# late afternoon: 14:23 - 16:48 (sunlight)
# evening twilight 16:49 - 17:33 (moonlight)
# late evening: 18:20 - 23:20
# after midnight: 00:01 - 04:33
# May 13-14, 2011
# late afternoon: ? - 18:50 (sunlight)
# evening twilight: 18:51 - 19:20 (moonlight)
# late evening: 19:21 - 23:59 (moonlight)
# after midnight: 00:00 - 04:37 (moonlight)
# morning twilight: 04:38 - 05:07
# early morning: 05:08 - 08:33 (sunlight)
# mid morning: 08:34 - 11:59 (sunlight)
# afternoon: 12:00 - ? (sunlight)
# June 3, 2014
# late afternoon: 15:37 - 19:13 (sunlight)
# evening twilight: 19:14 - 19:43 (moonlight)
# late evening: 19:44 - 23:59 (moonlight)
# after midnight: 0:00 - 4:14 (moonlight)
# morning twilight: 4:15 - 4:44
# early morning: 4:45 - 8:23 (sunlight)
# mid morning: 8:24 - 11:59 (sunlight)
# afternoon: 12:00 - 15:36 (sunlight)
# fixme: daylight savings time?
seconds = (XMLData.server_time - (5*60*60)) % (60*60*24) # seconds since midnight, elven time standard
hours = seconds/(60*60)
seconds = seconds % (60*60)
minutes = seconds/60
seconds = seconds % 60
if ((hours > 6) or ((hours == 6) and (minutes > 30))) and (hours < 18)
true
elsif (hours < 5) or (hours > 20)
false
elsif is_sunlight_cache and is_sunlight_cache[0] == "#{Time.now.hour}:#{Time.now.min}"
is_sunlight_cache[1]
else
result = dothis 'time', /^Today is /
if result =~ /early morning|mid morning|afternoon|late afternoon/
is_sunlight_cache = [ "#{Time.now.hour}:#{Time.now.min}", true ]
true
else
is_sunlight_cache = [ "#{Time.now.hour}:#{Time.now.min}", false ]
false
end
end
}
is_moonlight = proc { !is_sunlight.call }
set_needed_reagents = proc {
ingredient_list = Array.new
check_proc = proc { |recipe|
for step in recipe[:steps]
if step =~ /^(?:add|grind|extract|distill|separate)\s+(.*)/
ingredient_name = $1
ingredient_list.push(ingredient_name) unless ingredient_list.include?(ingredient_name)
if equivalent_names = equivalent.find { |list| list.include?(ingredient_name) }
for equivalent_name in equivalent_names
ingredient_list.push(equivalent_name) unless ingredient_list.include?(equivalent_name)
end
end
for sub_recipe in $alchemy_recipes.find_all { |r| r[:product] == ingredient_name }
check_proc.call(sub_recipe)
end
end
end
}
for type in gld.call.keys
for recipe in $alchemy_recipes.find_all { |recipe| CharSettings['favorite-recipes'].include?(recipe[:product]) or ((recipe[:product] != 'flask of pure water') and recipe[:type].include?(type) and recipe[:rank] and (gld.call[type][:rank] <= 62) and (gld.call[type][:rank] >= recipe[:rank].min) and (gld.call[type][:rank] <= recipe[:rank].max)) }
check_proc.call(recipe)
end
end
for product in CharSettings['favorite-recipes']
ingredient_list.push(product) unless ingredient_list.include?(product)
end
if ingredient_list.empty?
UserVars.delete('needed_reagents')
else
UserVars.needed_reagents = "^#{ingredient_list.join('$|^')}$"
end
nil
}
is_reagent_var = nil
is_reagent = proc { |test_name|
unless is_reagent_var
reagent_array = Array.new
$alchemy_recipes.each { |recipe|
recipe[:steps].each { |step|
if step =~ /^(?:add|grind|extract|distill|separate)\s+(.*)/
item = $1
equivalent.find { |r| r.include?(item) }.each { |i| reagent_array.push(i) unless reagent_array.include?(i) }
reagent_array.push(item) unless reagent_array.include?(item)
end
}
}
is_reagent_var = /^#{reagent_array.collect { |r| r.sub(/^some /, '(?:some )?').sub('faintly ', '(?:faintly )?') }.join('$|^')}$/
end
test_name =~ is_reagent_var
}
do_administrator = proc {
if gld.call.any? { |type,info| (info[:task] =~ /^(?:no task|promotion|gather alchemy ingredients for the guild's supply)$/ or info[:reps] == 0) and ((type == 'alchemy') or (info[:rank] < gld.call['alchemy'][:rank])) }
general_ranks = gld.call['alchemy'][:rank]
loop {
get_cauldron.call
if room_id = where_is.call("#{Char.prof.downcase} alchemy administrator").first
start_script 'go2', [ room_id.to_s ]
wait_while { running?('go2') }
did_something = false
if gld.call['alchemy'].nil?
dothistimeout "ask #{GameObj.npcs.last.noun} about training alchemy", 10, /^#{GameObj.npcs.last.noun} .*?, "/
invalid_gld.call
end
if gld.call['potions'].nil? and (gld.call['alchemy'][:rank].to_i > 0)
dothistimeout "ask #{GameObj.npcs.last.noun} about training potions", 10, /^#{GameObj.npcs.last.noun} .*?, "/
invalid_gld.call
end
if gld.call['trinkets'].nil? and (gld.call['alchemy'][:rank].to_i > 0)
dothistimeout "ask #{GameObj.npcs.last.noun} about training trinkets", 10, /^#{GameObj.npcs.last.noun} .*?, "/
invalid_gld.call
end
for type,info in gld.call
next if (type =~ /potions|trinkets/) and (info[:rank] == gld.call['alchemy'][:rank])
if info[:task] == 'no task'
result = dothistimeout "ask #{GameObj.npcs.last.noun} about training #{type}", 10, /^#{GameObj.npcs.last.noun} .*?, "/
invalid_gld.call
unless result =~ /your general alchemy skills are not quite up to snuff/
did_something = true
end
elsif (info[:task] == 'promotion')
if type != 'alchemy' or info[:rank].to_i != 5 or (gld.call['potions'][:rank].to_i >= 2 and gld.call['trinkets'][:rank].to_i >= 2)
if type != 'alchemy' or info[:rank].to_i != 10 or (gld.call['potions'][:rank].to_i >= 3 and gld.call['trinkets'][:rank].to_i >= 3)
if room_id = where_is.call("#{Char.prof.downcase} alchemy guildmaster").first
start_script 'go2', [ room_id.to_s ]
wait_while { running?('go2') }
result = dothistimeout "ask #{GameObj.npcs.last.noun} about next #{type}", 10, /^#{GameObj.npcs.last.noun} .*?, "/
unless result =~ /you must diversify/
did_something = true
invalid_gld.call
set_needed_reagents.call
end
room_id = where_is.call("#{Char.prof.downcase} alchemy administrator").first
start_script 'go2', [ room_id.to_s ]
wait_while { running?('go2') }
else
echo 'error: failed to find guildmaster'
end
end
end
elsif info[:reps] == 0
dothistimeout "ask #{GameObj.npcs.last.noun} about training #{type}", 10, /^#{GameObj.npcs.last.noun} .*?, "/
dothistimeout "ask #{GameObj.npcs.last.noun} about training #{type}", 10, /^#{GameObj.npcs.last.noun} .*?, "/
invalid_gld.call
did_something = true
elsif info[:task] == "gather alchemy ingredients for the guild's supply"
invalid_gld.call
dothistimeout "ask #{GameObj.npcs.last.noun} about trade #{type}", 10, /^#{GameObj.npcs.last.noun} .*?, "/
did_something = true
end
end
break unless did_something
else
echo 'error: failed to find training administrator'
break
end
}
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
}
add_commas = proc { |num|
num.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
}
trading_sell = proc { |silvers|
if Skills.trading > 6
(silvers*((((Skills.to_bonus(Skills.trading) + Stats.inf[1])/12)/100.0)+1)).floor
else
silvers
end
}
trading_buy = proc { |silvers|
if Skills.trading > 6
silvers - (silvers * (((Skills.to_bonus(Skills.trading) + Stats.inf[1])/12)/100.0)).floor
else
silvers
end
}
check_channel_spirit = proc {
needed_spirit = 3
needed_spirit += 1 if Spell[9912].active?
needed_spirit += 1 if Spell[9913].active?
needed_spirit += 1 if Spell[9914].active?
needed_spirit += 3 if Spell[9916].active?
checkspirit(needed_spirit)
}
ingredient_count = Hash.new
correct_herb_count = Array.new
check_ingredient = proc { |ingredient_name,temp_claimed_ingredients,temp_ingredient_count|
temp_claimed_ingredients ||= Array.new
if temp_ingredient_count.nil? or temp_ingredient_count.empty?
temp_ingredient_count = ingredient_count.dup
end
found = false
equivalent_ingredients = (equivalent.find { |list| list.include?(ingredient_name) } || [ ingredient_name ])
if ingredient = all_sack_contents.call.find { |obj| equivalent_ingredients.include?(obj.name) and (obj.name !~ bundled_herb) and not temp_claimed_ingredients.include?(obj.id) }
temp_claimed_ingredients.push(ingredient.id)
found = true
elsif bundle = all_sack_contents.call.find { |obj| equivalent_ingredients.include?(obj.name) and (obj.name =~ bundled_herb) and (temp_ingredient_count[obj.id].nil? or temp_ingredient_count[obj.id] > 0) }
if temp_ingredient_count[bundle.id].nil?
empty_hand
dothistimeout "get ##{bundle.id}", 10, get_regex
measure_result = dothistimeout "measure ##{bundle.id}", 10, /^(?:You can't tell exactly, but the|The) .*? (?:has 1 bite|has 2 bites|looks like it has a few bites|looks like it has several bites|seems to have plenty of bites) left\./
if measure_result =~ /1 bite/
temp_ingredient_count[bundle.id] = 1
ingredient_count[bundle.id] = 1
elsif measure_result =~ /2 bites/
temp_ingredient_count[bundle.id] = 2
ingredient_count[bundle.id] = 2
elsif measure_result =~ /a few bites/
temp_ingredient_count[bundle.id] = 3
ingredient_count[bundle.id] = 3
elsif measure_result =~ /several bites/
temp_ingredient_count[bundle.id] = 5
ingredient_count[bundle.id] = 5
elsif measure_result =~ /plenty of bites/
temp_ingredient_count[bundle.id] = 11
ingredient_count[bundle.id] = 11
else
temp_ingredient_count[bundle.id] = 1
ingredient_count[bundle.id] = 1
echo "error: unmatched measure result: #{measure_result.inspect}"
end
dothistimeout "put ##{bundle.id} in ##{herb_sack.call.id}", 10, put_regex
fill_hand
end
temp_ingredient_count[bundle.id] = temp_ingredient_count[bundle.id] - 1
found = true
elsif jar = all_sack_contents.call.find { |obj| (obj.after_name =~ /containing (?:#{equivalent_ingredients.collect { |name| name.sub('some ', '(?:some )?').sub('handful of ', '(?:handful of )?').sub('sprig of ', '(?:sprig of )?').sub('tooth', '(?:teeth|tooth)').sub('leaf', '(?:leaf|leaves)').sub(/y\b/, '(?:y|ie)').split(' ').join('s? ') }.join('|')})/) and (temp_ingredient_count[obj.id].nil? or temp_ingredient_count[obj.id] > 0) }
if temp_ingredient_count[jar.id].nil?
if CharSettings['hide-jar-check']
action = proc { |server_string|
if server_string =~ /^Inside the .*? you see [0-9]+ portions?/
DownstreamHook.remove('hide-jar-check')
nil
else
server_string
end
}
DownstreamHook.add('hide-jar-check', action)
end
look_result = dothistimeout "look in ##{jar.id}", 10, /^Inside .*? you see [0-9]+ portions?/
temp_ingredient_count[jar.id] = look_result.slice(/[0-9]+/).to_i
ingredient_count[jar.id] = look_result.slice(/[0-9]+/).to_i
end
temp_ingredient_count[jar.id] = temp_ingredient_count[jar.id] - 1
found = true
elsif bundle = all_sack_contents.call.find { |obj| (obj.name =~ /^bundle of (?:#{equivalent_ingredients.collect { |name| name.split(' ').join('s? ') }.join('|')})/) and (temp_ingredient_count[obj.id].nil? or temp_ingredient_count[obj.id] > 0) }
if temp_ingredient_count[bundle.id].nil?
if CharSettings['hide-bundle-check']
action = proc { |server_string|
if server_string =~ /^You.*?total of [0-9]+/
DownstreamHook.remove('hide-bundle-check')
nil
else
server_string
end
}
DownstreamHook.add('hide-bundle-check', action)
end
measure_result = dothis "measure ##{bundle.id}", /^You.*?total of [0-9]+/
temp_ingredient_count[bundle.id] = measure_result.slice(/[0-9]+/).to_i
ingredient_count[bundle.id] = measure_result.slice(/[0-9]+/).to_i
end
temp_ingredient_count[bundle.id] = temp_ingredient_count[bundle.id] - 1
found = true
end
[ found, temp_claimed_ingredients, temp_ingredient_count ]
}
get_ingredient = proc { |ingredient_name|
ingredient = nil
equivalent_ingredients = (equivalent.find { |list| list.include?(ingredient_name) } || [ ingredient_name ])
if ingredient = all_sack_contents.call.find { |obj| equivalent_ingredients.include?(obj.name) and (obj.name !~ bundled_herb) }
dothistimeout "get ##{ingredient.id}", 10, get_regex
elsif bundle = all_sack_contents.call.find { |obj| equivalent_ingredients.include?(obj.name) and (obj.name =~ bundled_herb) }
dothistimeout "get ##{bundle.id}", 10, get_regex
bundle_remove_result = dothistimeout 'bundle remove', 10, /^You (?:carefully )?remove|^Those were the last two|^You only have one/
if bundle_remove_result =~ /^You only have one/
correct_herb_count.delete(bundle.id)
ingredient_count.delete(bundle.id)
ingredient = bundle
elsif correct_herb_count.include?(bundle.id)
ingredient_count[bundle.id] = ingredient_count[bundle.id] - 1
dothistimeout "put ##{bundle.id} in ##{herb_sack.call.id}", 10, put_regex
if checkleft
ingredient = GameObj.left_hand
else
echo 'error: left hand unexpectedly empty'
end
else
measure_result = dothistimeout "measure ##{bundle.id}", 10, /^(?:You can't tell exactly, but the|The) .*? (?:has 1 bite|has 2 bites|looks like it has a few bites|looks like it has several bites|seems to have plenty of bites) left\./
if measure_result =~ /1 bite/
min_count = 1
correct_herb_count.push(bundle.id)
elsif measure_result =~ /2 bites/
min_count = 2
correct_herb_count.push(bundle.id)
elsif measure_result =~ /a few bites/
min_count = 3
if ingredient_count[bundle.id].to_i > 4
correct_herb_count.push(bundle.id)
end
elsif measure_result =~ /several bites/
min_count = 5
if ingredient_count[bundle.id].to_i > 10
correct_herb_count.push(bundle.id)
end
elsif measure_result =~ /plenty of bites/
min_count = 11
else
min_count = 0
echo "error: unmatched measure result: #{measure_result.inspect}"
end
if ingredient_count[bundle.id].nil?
ingredient_count[bundle.id] = min_count
else
ingredient_count[bundle.id] = [(ingredient_count[bundle.id] - 1), min_count].max
end
dothistimeout "put ##{bundle.id} in ##{herb_sack.call.id}", 10, put_regex
if checkleft
ingredient = GameObj.left_hand
else
echo 'error: left hand unexpectedly empty'
end
end
elsif jar = all_sack_contents.call.find { |obj| obj.after_name =~ /containing (?:#{equivalent_ingredients.collect { |name| name.sub('some ', '(?:some )?').sub('handful of ', '(?:handful of )?').sub('sprig of ', '(?:sprig of )?').sub('tooth', '(?:teeth|tooth)').sub('leaf', '(?:leaf|leaves)').sub(/y\b/, '(?:y|ie)').split(' ').join('s? ') }.join('|')})/ }
unless ingredient_count[jar.id].nil?
ingredient_count[jar.id] = ingredient_count[jar.id] - 1
ingredient_count.delete(jar.id) if ingredient_count[jar.id] < 1
end
dothistimeout "get ##{jar.id}", 10, get_regex
dothistimeout "shake ##{jar.id}", 10, /^You .*shake/
dothistimeout "put ##{jar.id} in ##{alchemy_sack.call.id}", 10, put_regex
if checkleft
ingredient = GameObj.left_hand
else