-
Notifications
You must be signed in to change notification settings - Fork 177
/
drinfomon.lic
1498 lines (1331 loc) · 49.3 KB
/
drinfomon.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
Documentation: https://elanthipedia.play.net/Lich_script_development#drinfomon
=end
$DRINFOMON_VERSION = '2.0.36'
no_kill_all
no_pause_all
setpriority(0)
class DRStats
@@race = nil
@@guild = nil
@@gender = nil
@@age ||= 0
@@circle ||= 0
@@strength ||= 0
@@stamina ||= 0
@@reflex ||= 0
@@agility ||= 0
@@intelligence ||= 0
@@wisdom ||= 0
@@discipline ||= 0
@@charisma ||= 0
@@favors ||= 0
@@tdps ||= 0
@@encumbrance = nil
@@balance ||= 8
@@luck ||= 0
# Assume vitals are 100%. If they aren't then the game will rather quickly
# pulse with vitals updates and the correct values will be set.
# If you're already at 100% then the game may not send the vitals until
# you take an action to consume or restore a vital. Because of this, you
# can get stuck by common-arcana waiting for your concentration or mana
# to increase to at least 80% even though you logged in with 100%.
@@concentration ||= 100
@@health ||= 100
@@mana ||= 100
@@fatigue ||= 100
@@spirit ||= 100
def self.race
@@race
end
def self.race=(val)
@@race = val
end
def self.guild
@@guild
end
def self.guild=(val)
@@guild = val
end
def self.gender
@@gender
end
def self.gender=(val)
@@gender = val
end
def self.age
@@age
end
def self.age=(val)
@@age = val
end
def self.circle
@@circle
end
def self.circle=(val)
@@circle = val
end
def self.strength
@@strength
end
def self.strength=(val)
@@strength = val
end
def self.stamina
@@stamina
end
def self.stamina=(val)
@@stamina = val
end
def self.reflex
@@reflex
end
def self.reflex=(val)
@@reflex = val
end
def self.agility
@@agility
end
def self.agility=(val)
@@agility = val
end
def self.intelligence
@@intelligence
end
def self.intelligence=(val)
@@intelligence = val
end
def self.wisdom
@@wisdom
end
def self.wisdom=(val)
@@wisdom = val
end
def self.discipline
@@discipline
end
def self.discipline=(val)
@@discipline = val
end
def self.charisma
@@charisma
end
def self.charisma=(val)
@@charisma = val
end
def self.concentration
@@concentration
end
def self.concentration=(val)
@@concentration = val
end
def self.favors
@@favors
end
def self.favors=(val)
@@favors = val
end
def self.tdps
@@tdps
end
def self.tdps=(val)
@@tdps = val
end
def self.luck
@@luck
end
def self.luck=(val)
@@luck = val
end
def self.balance
@@balance
end
def self.balance=(val)
@@balance = val
end
def self.encumbrance
@@encumbrance
end
def self.encumbrance=(val)
@@encumbrance = val
end
def self.health
@@health
end
def self.health=(val)
@@health = val
end
def self.mana
@@mana
end
def self.mana=(val)
@@mana = val
end
def self.native_mana
case DRStats.guild
when 'Necromancer'
'arcane'
when 'Barbarian', 'Thief'
nil
when 'Moon Mage', 'Trader'
'lunar'
when 'Warrior Mage', 'Bard'
'elemental'
when 'Cleric', 'Paladin'
'holy'
when 'Empath', 'Ranger'
'life'
end
end
def self.fatigue
@@fatigue
end
def self.fatigue=(val)
@@fatigue = val
end
def self.spirit
@@spirit
end
def self.spirit=(val)
@@spirit = val
end
def self.serialize
[@@race, @@guild, @@gender, @@age, @@circle, @@strength, @@stamina, @@reflex, @@agility, @@intelligence, @@wisdom, @@discipline, @@charisma, @@concentration, @@favors, @@tdps, @@luck, @@encumbrance, @@health, @@mana, @@fatigue, @@spirit]
end
def self.load_serialized=(array)
@@race, @@guild, @@gender, @@age = array[0..3]
@@circle, @@strength, @@stamina, @@reflex, @@agility, @@intelligence, @@wisdom, @@discipline, @@charisma, @@concentration, @@favors, @@tdps, @@luck, @@encumbrance, @@health, @@mana, @@fatigue, @@spirit = array[5..21]
end
def self.barbarian?
@@guild == 'Barbarian'
end
def self.bard?
@@guild == 'Bard'
end
def self.cleric?
@@guild == 'Cleric'
end
def self.commoner?
@@guild == 'Commoner'
end
def self.empath?
@@guild == 'Empath'
end
def self.moon_mage?
@@guild == 'Moon Mage'
end
def self.necromancer?
@@guild == 'Necromancer'
end
def self.paladin?
@@guild == 'Paladin'
end
def self.ranger?
@@guild == 'Ranger'
end
def self.thief?
@@guild == 'Thief'
end
def self.trader?
@@guild == 'Trader'
end
def self.warrior_mage?
@@guild == 'Warrior Mage'
end
end
class DRSkill
@@skills_data ||= get_data('skills')
@@gained_skills ||= []
@@start_time ||= Time.now
@@list ||= []
@@exp_modifiers ||= {}
attr_reader :name, :rank, :exp, :percent, :current, :baseline, :skillset
attr_writer :rank, :exp, :percent, :current, :baseline
def initialize(name, rank, exp, percent)
@name = name # skill name like 'Evasion'
@rank = rank.to_i # earned ranks in the skill
# Skill mindstate x/34
# Hardcode caped skills to 34/34
@exp = rank.to_i >= 1750 ? 34 : exp.to_i
@percent = percent.to_i # percent to next rank from 0 to 100
@baseline = rank.to_i + (percent.to_i / 100.0)
@current = rank.to_i + (percent.to_i / 100.0)
@skillset = lookup_skillset(@name)
@@list.push(self) unless @@list.find { |skill| skill.name == @name }
end
def self.reset
@@gained_skills = []
@@start_time = Time.now
@@list.each { |skill| skill.baseline = skill.current }
end
# Primarily used by `learned` script to track how long it's
# been tracking your experience gains this session.
def self.start_time
@@start_time
end
# List of skills that have increased their learning rates.
# Primarily used by `exp-monitor` script to echo which skills
# gained experience after you performed an action.
def self.gained_skills
@@gained_skills
end
# Returns the amount of ranks that have been gained since
# the baseline was last reset. This allows you to track
# rank gain for a given play session.
#
# Note, don't confuse the 'exp' in this method name with DRSkill.getxp(..)
# which returns the current learning rate of the skill.
def self.gained_exp(val)
skill = self.find_skill(val)
if skill
return skill.current ? (skill.current - skill.baseline).round(2) : 0.00
end
end
# Updates DRStats.gained_skills if the learning rate increased.
# The original consumer of this data is the `exp-monitor` script.
def self.handle_exp_change(name, new_exp)
return unless UserVars.echo_exp
old_exp = DRSkill.getxp(name)
change = new_exp.to_i - old_exp.to_i
if change > 0
DRSkill.gained_skills << { skill: name, change: change }
end
end
def self.include?(val)
!self.find_skill(val).nil?
end
def self.update(name, rank, exp, percent)
self.handle_exp_change(name, exp)
skill = self.find_skill(name)
if skill
skill.rank = rank.to_i
skill.exp = skill.rank.to_i >= 1750 ? 34 : exp.to_i
skill.percent = percent.to_i
skill.current = rank.to_i + (percent.to_i / 100.0)
else
DRSkill.new(name, rank, exp, percent)
end
end
def self.update_mods(name, rank)
self.exp_modifiers[self.lookup_alias(name)] = rank.to_i
end
def self.exp_modifiers
@@exp_modifiers
end
def self.clear_mind(val)
self.find_skill(val).exp = 0
end
def self.getrank(val)
self.find_skill(val).rank.to_i
end
def self.getmodrank(val)
skill = self.find_skill(val)
if skill
rank = skill.rank.to_i
modifier = self.exp_modifiers[skill.name].to_i
rank + modifier
end
end
def self.getxp(val)
skill = self.find_skill(val)
skill.exp.to_i
end
def self.getpercent(val)
self.find_skill(val).percent.to_i
end
def self.getskillset(val)
self.find_skill(val).skillset
end
def self.listall
@@list.each do |i|
echo "#{i.name}: #{i.rank}.#{i.percent}% [#{i.exp}/34]"
end
end
def self.list
@@list
end
def self.find_skill(val)
@@list.find { |data| data.name == self.lookup_alias(val) }
end
# Some guilds rename skills, like Barbarians call "Primary Magic" as "Inner Fire".
# Given the canonical or colloquial name, this method returns the value
# that's usable with the other methods like `getxp(skill)` and `getrank(skill)`.
def self.lookup_alias(skill)
@@skills_data.guild_skill_aliases[DRStats.guild][skill] || skill
end
# This is an instance method, do not prefix with `self`.
# It is called from the initialize method (constructor).
# When it was defined as a class method then the initialize method
# complained that this method didn't yet exist.
def lookup_skillset(skill)
@@skills_data.skillsets.find { |_skillset, skills| skills.include?(skill) }.first
end
end
class DRRoom
@@npcs ||= []
@@pcs ||= []
@@group_members ||= []
@@pcs_prone ||= []
@@pcs_sitting ||= []
@@dead_npcs ||= []
@@room_objs ||= []
@@exits ||= []
@@title = ''
@@description = ''
def self.npcs
@@npcs
end
def self.npcs=(val)
@@npcs = val
end
def self.pcs
@@pcs
end
def self.pcs=(val)
@@pcs = val
end
def self.exits
@@exits
end
def self.exits=(val)
@@exits = val
end
def self.title
@@title
end
def self.title=(val)
@@title = val
end
def self.description
@@description
end
def self.description=(val)
@@description = val
end
def self.group_members
@@group_members
end
def self.group_members=(val)
@@group_members = val
end
def self.pcs_prone
@@pcs_prone
end
def self.pcs_prone=(val)
@@pcs_prone = val
end
def self.pcs_sitting
@@pcs_sitting
end
def self.pcs_sitting=(val)
@@pcs_sitting = val
end
def self.dead_npcs
@@dead_npcs
end
def self.dead_npcs=(val)
@@dead_npcs = val
end
def self.room_objs
@@room_objs
end
def self.room_objs=(val)
@@room_objs = val
end
end
def convert2copper(amt, denomination)
if denomination =~ /platinum/
(amt.to_i * 10_000)
elsif denomination =~ /gold/
(amt.to_i * 1000)
elsif denomination =~ /silver/
(amt.to_i * 100)
elsif denomination =~ /bronze/
(amt.to_i * 10)
else
amt
end
end
def convert2plats(copper)
denominations = [[10_000, 'platinum'], [1000, 'gold'], [100, 'silver'], [10, 'bronze'], [1, 'copper']]
denominations.inject([copper, []]) do |result, denomination|
remaining = result.first
display = result.last
if remaining / denomination.first > 0
display << "#{remaining / denomination.first} #{denomination.last}"
end
[remaining % denomination.first, display]
end.last.join(', ')
end
def clean_and_split(room_objs)
room_objs.sub(/You also see/, '').sub(/ with a [\w\s]+ sitting astride its back/, '').strip.split(/,|\sand\s/)
end
def find_pcs(room_players)
room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
.split(', ')
.map { |obj| obj.sub(/ (who|whose body)? ?(has|is|appears|glows) .+/, '').sub(/ \(.+\)/, '') }
.map { |obj| obj.strip.scan(/\w+$/).first }
end
def find_pcs_prone(room_players)
room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
.split(', ')
.select { |obj| obj =~ /who is lying down/i }
.map { |obj| obj.sub(/ who (has|is) .+/, '').sub(/ \(.+\)/, '') }
.map { |obj| obj.strip.scan(/\w+$/).first }
end
def find_pcs_sitting(room_players)
room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
.split(', ')
.select { |obj| obj =~ /who is sitting/i }
.map { |obj| obj.sub(/ who (has|is) .+/, '').sub(/ \(.+\)/, '') }
.map { |obj| obj.strip.scan(/\w+$/).first }
end
def find_npcs(room_objs)
room_objs.sub(/You also see/, '').sub(/ with a [\w\s]+ sitting astride its back/, '').strip
.scan(%r{<pushBold/>[^<>]*<popBold/> which appears dead|<pushBold/>[^<>]*<popBold/> \(dead\)|<pushBold/>[^<>]*<popBold/>})
.reject { |obj| obj =~ /which appears dead|\(dead\)/ }
.map { |obj| obj.sub(/.*alfar warrior.*/, 'alfar warrior') }
.map { |obj| obj.sub(/.*sinewy leopard.*/, 'sinewy leopard') }
.map { |obj| obj.sub(/.*lesser naga.*/, 'lesser naga') }
.map { |obj| obj.sub('<pushBold/>', '').sub(%r{<popBold/>.*}, '') }
.map { |obj| obj.split(/\sand\s/).last.sub(/(?:\sglowing)?\swith\s.*/, '') }
.map { |obj| obj.strip.scan(/[A-z'-]+$/).first }
end
def find_dead_npcs(room_objs)
room_objs.sub(/You also see/, '').sub(/ with a [\w\s]+ sitting astride its back/, '')
.strip.scan(%r{<pushBold/>[^<>]*<popBold/> which appears dead|<pushBold/>[^<>]*<popBold/> \(dead\)|<pushBold/>[^<>]*<popBold/>})
.select { |obj| obj =~ /which appears dead|\(dead\)/ }
.map { |obj| obj.sub('<pushBold/>', '').sub(%r{<popBold/>.*}, '') }
.map { |obj| obj.split(/\sand\s/).last.sub(/(?:\sglowing)?\swith\s.*/, '') }
.map { |obj| obj.strip.scan(/[A-z'-]+$/).first }
end
def find_objects(room_objs)
room_objs.sub!("<pushBold/>a domesticated gelapod<popBold/>", 'domesticated gelapod')
clean_and_split(room_objs)
.reject { |obj| obj =~ /pushBold/ }
.map { |obj| obj.sub(/\.$/, '').strip.sub(/^a /, '').strip.sub(/^some /, '') }
end
sleep(0.1) until Char.name && !Char.name.empty?
CharSettings['bank_accounts'] = {} unless CharSettings['bank_accounts'].class == Hash
CharSettings['vault_info'] = {} unless CharSettings['vault_info'].class == Hash
kronar_banks = ['Crossings', 'Dirge', 'Ilaya Taipa', 'Leth Deriel']
lirum_banks = ["Aesry Surlaenis'a", "Hara'jaal", "Mer'Kresh", "Muspar'i", "Ratha", "Riverhaven", "Rossman's Landing", "Therenborough", "Throne City"]
dokora_banks = ["Ain Ghazal", "Boar Clan", "Chyolvea Tayeu'a", "Hibarnhvidar", "Fang Cove", "Raven's Point", "Shard"]
bank_titles = {
"Aesry Surlaenis'a" => ["[[Tona Kertigen, Deposit Window]]"],
"Ain Ghazal" => ["[[Ain Ghazal, Private Depository]]"],
"Boar Clan" => ["[[Ranger Guild, Bank]]"],
"Chyolvea Tayeu'a" => ["[[Chyolvea Tayeu'a, Teller]]"],
"Crossings" => ["[[Provincial Bank, Teller]]"],
"Dirge" => ["[[Dirge, Traveller's Bank]]"],
"Fang Cove" => ["[[First Council Banking, Vault]]"],
"Hara'jaal" => ["[[Baron's Forset, Teller]]"],
"Hibarnhvidar" => ["[[Second Provincial Bank of Hibarnhvidar, Teller]]", "[[Hibarnhvidar, Teller Windows]]", "[[First Arachnid Bank, Lobby]]"],
"Ilaya Taipa" => ["[[Ilaya Taipa, Trader Outpost Bank]]"],
"Leth Deriel" => ["[[Imperial Depository, Domestic Branch]]"],
"Mer'Kresh" => ["[[Harti Clemois Bank, Teller's Window]]"],
"Muspar'i" => ["[[Old Lata'arna Keep, Teller Windows]]"],
"Ratha" => ["[[Lower Bank of Ratha, Cashier]]", "[[Sshoi-sson Palace, Grand Provincial Bank, Bursarium]]"],
"Raven's Point" => ["[[Bank of Raven's Point, Depository]]"],
"Riverhaven" => ["[[Bank of Riverhaven, Teller]]"],
"Rossman's Landing" => ["[[Traders' Guild Outpost, Depository]]"],
"Shard" => ["[[First Bank of Ilithi, Teller's Windows]]"],
"Therenborough" => ["[[Bank of Therenborough, Teller]]"],
"Throne City" => ["[[Faldesu Exchequer, Teller]]"]
}
vault_titles = {
"Crossings" => ["[[Crossing, Carousel Chamber]]"],
"Fang Cove" => ["[[Fang Cove, Carousel Chamber]]"],
"Leth Deriel" => ["[[Leth Deriel, Carousel Chamber]]"],
"Mer'Kresh" => ["[[Mer'Kresh, Carousel Square]]"],
"Muspar'i" => ["[[Muspar'i, Carousel Square]]"],
"Ratha" => ["[[Ratha, Carousel Square]]"],
"Riverhaven" => ["[[Riverhaven, Carousel Chamber]]"],
"Shard" => ["[[Shard, Carousel Chamber]]"],
"Therenborough" => ["[[Therenborough, Carousel Chamber]]"]
}
# Register ;banks ;vault commands
drinfomon_upstream_hook = proc do |client_string|
if client_string =~ /^(?:<c>)?#{$clean_lich_char}((?:banks|vault).*)/i
if (scr = Script.running.find { |val| val.name == 'drinfomon' })
scr.downstream_buffer.shove("#{$clean_lich_char}#{Regexp.last_match(1)}") # if this script is still running send the command
else
UpstreamHook.remove('drinfomon') # if the script isnt running remove the hook
end
nil # its a command that shouldnt be sent to the game
else
client_string # didnt find a command we should watch for send the string as normal
end
end
# For parsing `info` output
parsing_info_output = false
squelch_info_output = false
# For parsing `ltb info` output
parsing_ltb_info_output = false
squelch_ltb_info_output = false
# For parsing `played` output
parsing_played_output = false
squelch_played_output = false
# For parsing `exp all` output
parsing_exp_output = false
squelch_exp_output = false
# For parsing `exp mods` output
parsing_exp_mods_output = false
squelch_exp_mods_output = false
# How long to wait between info/exp checks.
drinfomon_passive_delay = get_settings.drinfomon_passive_delay
# To track when the last time was we checked experience/info.
info_check_interval = drinfomon_passive_delay
info_check_time = Time.now
# Experience learning rates in order from 0/34 to 34/34
learning_rates = [
'clear',
'dabbling',
'perusing',
'learning',
'thoughtful',
'thinking',
'considering',
'pondering',
'ruminating',
'concentrating',
'attentive',
'deliberative',
'interested',
'examining',
'understanding',
'absorbing',
'intrigued',
'scrutinizing',
'analyzing',
'studious',
'focused',
'very focused',
'engaged',
'very engaged',
'cogitating',
'fascinated',
'captivated',
'engrossed',
'riveted',
'very riveted',
'rapt',
'very rapt',
'enthralled',
'nearly locked',
'mind lock'
]
# We use this to right pad learning rate names when formatting
# the output to show gained ranks in the experience window in Wrayth/StormFront.
# This variable tells us how wide to make the column.
longest_learning_rate_length = learning_rates.sort_by(&:length).last.length
# Balance levels in order from 0/11 to 11/11
balance_values = [
'completely',
'hopelessly',
'extremely',
'very badly',
'badly',
'somewhat off',
'off',
'slightly off',
'solidly',
'nimbly',
'adeptly',
'incredibly'
]
# This hook parses `exp all` to track your experience.
#
# Sample XML:
#
# Note, depending on your frontend and possibly other settings,
# the <component> tags may include <preset> tags.
# The examples below show both variants.
#
# FLAG BRIEFEXP ON
regex_flag_briefexp_on = %r{<component id='exp .*?<d cmd='skill (?<skill>[a-zA-Z\s]+)'.*:\s+(?<rank>\d+)\s+(?<percent>\d+)%\s*\[\s?(?<rate>\d+)\/34\].*?<\/component>}
# <component id='exp Augmentation'><preset id='whisper'><d cmd='skill Augmentation'> Aug</d>: 565 39% [ 2/34]</preset></component>
# <component id='exp Utility'><d cmd='skill Utility'> Util</d>: 562 56% [ 3/34]</component>
# ---
# FLAG BRIEFEXP OFF
regex_flag_briefexp_off = %r{<component id='exp .*?\b(?<skill>[a-zA-Z\s]+)\b:\s+(?<rank>\d+)\s+(?<percent>\d+)%\s+\b(?<rate>[a-zA-Z\s]+)\b.*?<\/component>}
# <component id='exp Augmentation'><preset id='whisper'> Augmentation: 565 39% learning </preset></component>
# <component id='exp Utility'> Utility: 562 57% learning </component>
# ---
# Empty mindstate
regex_exp_clear_mindstate = %r{<component id='exp (?<skill>[a-zA-Z\s]+)'><\/component>}
# <component id='exp Augmentation'></component>
# ---
# EXP ALL
regex_exp_columns = /(?:\s*(?<skill>[a-zA-Z\s]+)\b:\s*(?<rank>\d+)\s+(?<percent>\d+)%\s+(?<rate>[a-zA-Z\s]+)\b)/
# <output class="mono"/>
# Circle: 80
# Showing all skills that you have skill in.
#
# SKILL: Rank/Percent towards next rank/Amount learning/Mindstate Fraction
# Shield Usage: 292 31% clear (0/34) Light Armor: 288 30% clear (0/34)
# Chain Armor: 289 77% clear (0/34) Brigandine: 231 58% clear (0/34)
# Plate Armor: 206 32% clear (0/34) Defending: 294 68% clear (0/34)
# Parry Ability: 310 19% clear (0/34) Small Edged: 317 46% clear (0/34)
# Large Edged: 295 03% clear (0/34) Twohanded Edged: 299 00% clear (0/34)
# Small Blunt: 308 20% clear (0/34) Large Blunt: 299 83% clear (0/34)
# Twohanded Blunt: 295 36% clear (0/34) Slings: 298 36% clear (0/34)
# Bow: 298 53% clear (0/34) Crossbow: 296 69% ruminating (8/34)
# Staves: 288 58% thinking (5/34) Polearms: 285 08% clear (0/34)
# Light Thrown: 286 62% clear (0/34) Heavy Thrown: 297 24% clear (0/34)
# Brawling: 287 45% clear (0/34) Offhand Weapon: 305 59% clear (0/34)
# Melee Mastery: 401 95% clear (0/34) Missile Mastery: 376 32% clear (0/34)
# Inner Magic: 569 68% thinking (5/34) Arcana: 431 54% engrossed (27/34)
# Augmentation: 565 39% thinking (5/34) Debilitation: 325 76% clear (0/34)
# Utility: 562 57% thoughtful (4/34) Warding: 436 62% learning (3/34)
# Evasion: 364 49% clear (0/34) Athletics: 499 10% clear (0/34)
# Perception: 425 25% clear (0/34) Stealth: 651 83% clear (0/34)
# Locksmithing: 547 06% clear (0/34) Thievery: 650 86% interested (12/34)
# First Aid: 423 60% clear (0/34) Outdoorsmanship: 375 03% clear (0/34)
# Skinning: 426 71% clear (0/34) Backstab: 361 96% clear (0/34)
# Forging: 136 30% learning (3/34) Engineering: 131 96% clear (0/34)
# Outfitting: 135 62% clear (0/34) Alchemy: 134 53% clear (0/34)
# Enchanting: 129 82% clear (0/34) Scholarship: 429 58% clear (0/34)
# Appraisal: 491 82% clear (0/34) Performance: 373 14% clear (0/34)
# Tactics: 325 63% clear (0/34)
#
# Total Ranks Displayed: 17032
# Time Development Points: 12 Favors: 10 Deaths: 1 Departs: 1
# Rested EXP Stored: 4:25 hours Usable This Cycle: 3:57 hours Cycle Refreshes: 1:11 hour
# Overall state of mind: clear
# EXP HELP for more information
# <output class=""/>
# ---
exp_hook = proc do |server_string|
# Due to non-thread safe issues with Ruby, Regexp.last_match, and procs,
# explicit match variables are defined and used instead.
# https://github.com/psu-libraries/psulib_traject/issues/132
# https://github.com/traject/traject/issues/139
match_briefexp_on = regex_flag_briefexp_on.match(server_string)
match_briefexp_off = regex_flag_briefexp_off.match(server_string)
match_exp_clear_mindstate = regex_exp_clear_mindstate.match(server_string)
# These sections are parsing xml tags sent to experience window.
# The game sends these tags automatically and we don't need
# to conditionally parse them based on value of `parsing_exp_output`.
if match_briefexp_on
skill = match_briefexp_on[:skill]
rank = match_briefexp_on[:rank]
rate = match_briefexp_on[:rate] # already a number
percent = match_briefexp_on[:percent]
DRSkill.update(skill, rank, rate, percent)
# Show to the right of the experience learning rate the gained ranks this session.
if UserVars.track_exp || UserVars.track_exp.nil?
# Historically, this feature to show gained exp was on by default
# and could be turned off by setting `UserVars.track_exp = false`.
# As of February 2022, we want features to be opt-in to minimize
# impact to players who don't want Lich to change out from under them.
# To get to that point with this feature, we need to correct the data
# and set to true if it was already nil. In a subsequent update we'll
# change the IF condition to only run if `UserVars.track_exp` is true
# as well as remove this comment block and the initialization assignment.
UserVars.track_exp ||= true
server_string.sub!(/(\/34\])/, "\\1 #{sprintf('%0.2f', DRSkill.gained_exp(skill))}")
end
elsif match_briefexp_off
skill = match_briefexp_off[:skill]
rank = match_briefexp_off[:rank]
rate_word = match_briefexp_off[:rate]
rate = learning_rates.index(rate_word) # convert word to number
percent = match_briefexp_off[:percent]
DRSkill.update(skill, rank, rate, percent)
# Show to the right of the experience learning rate the gained ranks this session.
if UserVars.track_exp
server_string.sub!(/(%\s+)(#{rate_word})/, "\\1 #{rate_word.ljust(longest_learning_rate_length)} #{sprintf('%0.2f', DRSkill.gained_exp(skill))}")
end
elsif match_exp_clear_mindstate
skill = match_exp_clear_mindstate[:skill]
DRSkill.clear_mind(skill)
end
case server_string
when /^(Circle: (\d+)|Showing all skills that you have skill in)/
parsing_exp_output = true
when regex_exp_columns
if parsing_exp_output
server_string.scan(regex_exp_columns) do |skill_value, rank_value, percent_value, rate_as_word|
rate_as_number = learning_rates.index(rate_as_word) # convert word to number
DRSkill.update(skill_value, rank_value, rate_as_number, percent_value)
end
end
when /^EXP HELP for more information/
if parsing_exp_output && squelch_exp_output
server_string = nil
end
if parsing_exp_output
parsing_exp_output = false
squelch_exp_output = false
end
when %r{^<output class=""/>}
# This signals the end of `exp all` but
# don't squelch this line because the frontends (e.g. Genie)
# need it to properly close out parsing the mono font.
if parsing_exp_output
parsing_exp_output = false
squelch_exp_output = false
# Don't remove the `exp all` hook here, leave it active.
# It's designed to parse the continuous stream of exp pulses.
end
end
if parsing_exp_output && squelch_exp_output
server_string = nil
end
server_string
end
# This hook parses `exp mods` to track your exp buffs or curses.
#
# Sample XML:
#
# Note, "speech" presets are positive modifiers and use one `+` plus sign.
# and "thought" presets are negative modifiers and use two `-` minus signs.
# Note, sometimes the phrase "The following skills..." is prefixed with another xml tag.
# ---
# The following skills are currently under the influence of a modifier:
# <output class="mono"/>
# <preset id="speech">+78 Athletics</preset>
# <preset id="speech">+84 Perception</preset>
# <preset id="thought">--11 First Aid</preset>
# <output class=""/>
# ---
# The following skills are currently under the influence of a modifier:
# <output class="mono"/>
# None
# <output class=""/>
# ---
exp_mods_hook = proc do |server_string|
case server_string
when /^(<.*?\/>)?The following skills are currently under the influence of a modifier/
parsing_exp_mods_output = true
DRSkill.exp_modifiers.clear
when %r{^<preset id="speech">}, %r{^<preset id="thought">}
if parsing_exp_mods_output
match = /(?<sign>\+|\-)+(?<value>\d+) \b(?<skill>[\w\s]+)\b/.match(server_string)
if match
skill = match[:skill]
sign = match[:sign]
value = match[:value].to_i
value = (value * -1) if sign == '-'
DRSkill.update_mods(skill, value)
end
end
when %r{^<output class=""/>}
# This signals the end of `exp mods` but
# don't squelch this line because the frontends (e.g. Genie)
# need it to properly close out parsing the mono font.
if parsing_exp_mods_output
parsing_exp_mods_output = false
squelch_exp_mods_output = false
# We've parsed what we need, remove this hook for performance.
DownstreamHook.remove('exp_mods_hook')
end
end
if parsing_exp_mods_output && squelch_exp_mods_output
server_string = nil
end
server_string
end
# This hook parses `info` to track your stats.
#
# Sample XML:
#
# ---
# <output class="mono"/>
# Name: Agonar Dokona Race: Human Guild: Barbarian
# Gender: Male Age: 44 Circle: 80
# You were born on the 36th day of the 3rd month of Lirisa the Archer in the year of the Iron Toad, 396 years after the victory of Lanival the Redeemer.
#
# Your birthday is more than 4 months away.
#
# <preset id="speech"> Strength : 50 +10</preset> Reflex : 62
# Agility : 62 Charisma : 27
# Discipline : 46 Wisdom : 46
# Intelligence : 46 Stamina : 50
#
# Concentration : 428 Max : 428
#
# Favors : 40
# TDPs : 438
# Encumbrance : None (0/11)
# Luck : Average (0/3)
#
# Wealth:
# No Kronars.
# No Lirums.
# No Dokoras.
#
# Debt: