forked from vtcifer/g3-standalone-xp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEXPTracker.cs
More file actions
1653 lines (1480 loc) · 76.6 KB
/
EXPTracker.cs
File metadata and controls
1653 lines (1480 loc) · 76.6 KB
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
using System;
using System.Collections;
using GeniePlugin.Interfaces;
using System.Xml;
using System.Text.RegularExpressions;
namespace EXPTracker
{
public class EXPTracker : IPlugin
{
//Constant variable for the Properties of the plugin
//At the top for easy changes.
readonly string _NAME = "EXPTracker";
readonly string _VERSION = "3.4.45";
readonly string _AUTHOR = "VTCifer";
readonly string _DESCRIPTION = "Parses the XML output of skills in DragonRealms to create skill named global variables and emmulate the experience window of the StormFront Front End.";
public IHost _host; //Required for plugin
public System.Windows.Forms.Form _parent; //Required for plugin
#region EXPTracker Members
private const int MAX_SKILL = 69; //Total of 69 skills in game
private const int MAX_LEARNRATE = 35; //Max Learning rates: 0 - 34
private DateTime _startTime; //Used for TDP/Rank tracking to know how long tracking since
private Hashtable _skillList = new Hashtable(); //Used for storing/sorting skills for display in Exp Win
private int _TDP = 0; //Used for TDP tracking, this is current TDPs
private int _startTDP = 0; //Used for TDP tracking, this is set when first checking
private int pulseSeed = -1; //Used for adjusting what the 'start' pulse was
private int _RestedEXPStored = -1; //Used for tracking rested experience.
private int _RestedExpUsable = -1; //Used for tracking rested experience.
private bool _trackingTDP = false; //Used for TDP tracking, this it to know when the plugin has gathered TDP info
private bool _updateExp = false; //Used for know when next prompt is shown, to update EXPWindow
private bool _parsing = false; //Used for ParseText, to know if EXP command output is returned
private bool _expmods = false; //Used for ParseText, to know if should be checking against exp mods
private int _sleeping = -1; //Used for tracking if you are sleeping or not
private bool _report = false; //Used for ParseText, to know if you are running a report
private bool _ExpBrief = false;
private bool _enabled = true; //Used for "Pausing" the tracker, so no new data is input. Also used to disable from
private bool _needsexp0 = false; //Used to only send exp0 once when needed
//Plugins Window
private string EchoLearned = "";
private string EchoPulsed = "";
//The following hashtables are used as alternatives to switch statments using string data which can have rather bad run time.
private Hashtable MasterSkill;
private class ItemMasterSkill
{
public int SortLR;
public string ShortName;
}
private Hashtable MasterLearnRate;
//Class Skill
//Used for storing all skill related info
//Used in a hashtable whose key is the name of the skill
private class Skill
{
public double rank = 0; //Rank of the skill
public string learningRate = "clear"; //Text Learning rate
public int iLearningRate = 0; //Numerical Learning rate
public double startRank = -1; //When Rank tracking enabled, this is starting rank calculated for
public bool rankGained = false; //Used for displaying text in a specific color when rank gained - currently broken from DR XML
public bool learned = false; //Used for displaying text in a specific color when bits are added to pool
public int sortLR = 0; //Used for sorting As reading, Left to Right
public string shortname = ""; //Used for short name display instead of long name
public string output = ""; //Used for output of skill info -> Exp window and tracking
public string parseoutput = ""; //Used for output using #parse of skill info -> only used in tracking
}
//Class Sortskill
//Used for sorting the skills for display in the Experience window
//Used in an array list for sorting, which is fed from a hashtable
public class Sortskill
{
public string name = ""; //Name of skill
public string shortname = ""; //Shortened name of skill
public int sortLR = 0; //Ordered value based on Reading sort (Left to Right)
public int sortLearning = 0; //Ordered value based on top to bottom, THEN left to right
}
#endregion
#region IPlugin Properties
//Required for Plugin - Called when Genie needs the name of the plugin (On menu)
//Return Value:
// string: Text that is the name of the Plugin
public string Name
{
get { return _NAME; }
}
//Required for Plugin - Called when Genie needs the plugin version (error text
// or the plugins window)
//Return Value:
// string: Text that is the version of the plugin
public string Version
{
get { return _VERSION; }
}
//Required for Plugin - Called when Genie needs the plugin Author (plugins window)
//Return Value:
// string: Text that is the Author of the plugin
public string Author
{
get { return _AUTHOR; }
}
//Required for Plugin - Called when Genie needs the plugin Description (plugins window)
//Return Value:
// string: Text that is the description of the plugin
// This can only be up to 200 Characters long, else it will appear
// "truncated"
public string Description
{
get { return _DESCRIPTION; }
}
//Required for Plugin - Called when Genie needs disable/enable the plugin (Plugins window,
// and from the CLI), or when Genie needs to know the status of the
// plugin (???)
//Get:
// Not Known what it is used for
//Set:
// Used by Plugins Window + CLI
public bool Enabled
{
get
{
return _enabled;
}
set
{
_enabled = value;
}
}
#endregion
#region IPlugin Methods
//Required for Plugin - Called on first load
//Parameters:
// IHost Host: The host (instance of Genie) making the call
public void Initialize(IHost Host)
{
//Set Decimal Seperator to a period (.) if not set that way
if (System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
}
//Set _host variable to the Instance of Genie that started the plugin (so can call host API commands)
_host = Host;
//Set startTime to the time the plugin was called (used in how long tracking has been occuring)
_startTime = DateTime.Now;
//Create hash table for all skills
_skillList = new Hashtable(MAX_SKILL);
//Set Genie Variables if not already set
init_variables();
//create AND popluate the master hashtables
//This in theory should front load processing time for when Genie loads
//and speed up the time it takes to parse, and generate EXP window data.
//
MasterSkill = new Hashtable(MAX_SKILL)
{
//Armor skills - 7
{ "Shield Usage", new ItemMasterSkill { SortLR = 0, ShortName = "Shield" } },
{ "Light Armor", new ItemMasterSkill { SortLR = 1, ShortName = "Lt Armor" } },
{ "Chain Armor", new ItemMasterSkill { SortLR = 2, ShortName = "Chain" } },
{ "Brigandine", new ItemMasterSkill { SortLR = 3, ShortName = "Brigan" } },
{ "Plate Armor", new ItemMasterSkill { SortLR = 4, ShortName = "Plate" } },
{ "Defending", new ItemMasterSkill { SortLR = 5, ShortName = "Defend" } },
{ "Conviction", new ItemMasterSkill { SortLR = 6, ShortName = "Convict" } },
//Weapon Skills - 19
{ "Parry Ability", new ItemMasterSkill { SortLR = 100, ShortName = "Parry" } },
{ "Small Edged", new ItemMasterSkill { SortLR = 101, ShortName = "SE" } },
{ "Large Edged", new ItemMasterSkill { SortLR = 102, ShortName = "LE" } },
{ "Twohanded Edged", new ItemMasterSkill { SortLR = 103, ShortName = "2HE" } },
{ "Small Blunt", new ItemMasterSkill { SortLR = 104, ShortName = "SB" } },
{ "Large Blunt", new ItemMasterSkill { SortLR = 105, ShortName = "LB" } },
{ "Twohanded Blunt", new ItemMasterSkill { SortLR = 106, ShortName = "2HB" } },
{ "Slings", new ItemMasterSkill { SortLR = 107, ShortName = "Sling" } },
{ "Bow", new ItemMasterSkill { SortLR = 108, ShortName = "Bow" } },
{ "Crossbow", new ItemMasterSkill { SortLR = 109, ShortName = "XBow" } },
{ "Staves", new ItemMasterSkill { SortLR = 110, ShortName = "Staves" } },
{ "Polearms", new ItemMasterSkill { SortLR = 111, ShortName = "Polearm" } },
{ "Light Thrown", new ItemMasterSkill { SortLR = 112, ShortName = "LT" } },
{ "Heavy Thrown", new ItemMasterSkill { SortLR = 113, ShortName = "HT" } },
{ "Brawling", new ItemMasterSkill { SortLR = 114, ShortName = "Brawl" } },
{ "Offhand Weapon", new ItemMasterSkill { SortLR = 115, ShortName = "Offhand" } },
{ "Melee Mastery", new ItemMasterSkill { SortLR = 116, ShortName = "Melee" } },
{ "Missile Mastery", new ItemMasterSkill { SortLR = 117, ShortName = "Missile" } },
{ "Expertise", new ItemMasterSkill { SortLR = 118, ShortName = "Expert" } },
//Magic Skills - 18
{ "Arcane Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Elemental Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Holy Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Inner Fire", new ItemMasterSkill { SortLR = 200, ShortName = "IF" } },
{ "Inner Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Life Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Lunar Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" } },
{ "Attunement", new ItemMasterSkill { SortLR = 201, ShortName = "Attune" } },
{ "Arcana", new ItemMasterSkill { SortLR = 202, ShortName = "Arcana" } },
{ "Targeted Magic", new ItemMasterSkill { SortLR = 203, ShortName = "TM" } },
{ "Augmentation", new ItemMasterSkill { SortLR = 204, ShortName = "Augment" } },
{ "Debilitation", new ItemMasterSkill { SortLR = 205, ShortName = "Debilit" } },
{ "Utility", new ItemMasterSkill { SortLR = 206, ShortName = "Utility" } },
{ "Warding", new ItemMasterSkill { SortLR = 207, ShortName = "Warding" } },
{ "Sorcery", new ItemMasterSkill { SortLR = 208, ShortName = "Sorcery" } },
{ "Astrology", new ItemMasterSkill { SortLR = 209, ShortName = "Astro" } },
{ "Summoning", new ItemMasterSkill { SortLR = 209, ShortName = "Summon" } },
{ "Theurgy", new ItemMasterSkill { SortLR = 209, ShortName = "Theurgy" } },
//Survival Skills - 12
{ "Evasion", new ItemMasterSkill { SortLR = 300, ShortName = "Evade" } },
{ "Athletics", new ItemMasterSkill { SortLR = 301, ShortName = "Athletic" } },
{ "Perception", new ItemMasterSkill { SortLR = 302, ShortName = "Percep" } },
{ "Stealth", new ItemMasterSkill { SortLR = 303, ShortName = "Stealth" } },
{ "Locksmithing", new ItemMasterSkill { SortLR = 304, ShortName = "Locks" } },
{ "Thievery", new ItemMasterSkill { SortLR = 305, ShortName = "Thievery" } },
{ "First Aid", new ItemMasterSkill { SortLR = 306, ShortName = "FA" } },
{ "Outdoorsmanship", new ItemMasterSkill { SortLR = 307, ShortName = "Outdoor" } },
{ "Skinning", new ItemMasterSkill { SortLR = 308, ShortName = "Skin" } },
{ "Backstab", new ItemMasterSkill { SortLR = 309, ShortName = "BS" } },
{ "Scouting", new ItemMasterSkill { SortLR = 309, ShortName = "Scout" } },
{ "Thanatology", new ItemMasterSkill { SortLR = 309, ShortName = "Than" } },
//Lore Skills - 13
{ "Forging", new ItemMasterSkill { SortLR = 401, ShortName = "Forging" } },
{ "Engineering", new ItemMasterSkill { SortLR = 402, ShortName = "Engineer" } },
{ "Outfitting", new ItemMasterSkill { SortLR = 403, ShortName = "Outfit" } },
{ "Alchemy", new ItemMasterSkill { SortLR = 404, ShortName = "Alchemy" } },
{ "Enchanting", new ItemMasterSkill { SortLR = 405, ShortName = "Enchant" } },
{ "Scholarship", new ItemMasterSkill { SortLR = 406, ShortName = "Scholar" } },
{ "Mechanical Lore", new ItemMasterSkill { SortLR = 407, ShortName = "Mech" } },
{ "Appraisal", new ItemMasterSkill { SortLR = 408, ShortName = "App" } },
{ "Performance", new ItemMasterSkill { SortLR = 409, ShortName = "Perform" } },
{ "Tactics", new ItemMasterSkill { SortLR = 410, ShortName = "Tactics" } },
{ "Bardic Lore", new ItemMasterSkill { SortLR = 410, ShortName = "BardLore" } },
{ "Empathy", new ItemMasterSkill { SortLR = 410, ShortName = "Empathy" } },
{ "Trading", new ItemMasterSkill { SortLR = 410, ShortName = "Trading" } }
};
MasterLearnRate = new Hashtable(MAX_LEARNRATE)
{
{ "clear", 0 },
{ "dabbling", 1 },
{ "perusing", 2 },
{ "learning", 3 },
{ "thoughtful", 4 },
{ "thinking", 5 },
{ "considering", 6 },
{ "pondering", 7 },
{ "ruminating", 8 },
{ "concentrating", 9 },
{ "attentive", 10 },
{ "deliberative", 11 },
{ "interested", 12 },
{ "examining", 13 },
{ "understanding", 14 },
{ "absorbing", 15 },
{ "intrigued", 16 },
{ "scrutinizing", 17 },
{ "analyzing", 18 },
{ "studious", 19 },
{ "focused", 20 },
{ "very focused", 21 },
{ "engaged", 22 },
{ "very engaged", 23 },
{ "cogitating", 24 },
{ "fascinated", 25 },
{ "captivated", 26 },
{ "engrossed", 27 },
{ "riveted", 28 },
{ "very riveted", 29 },
{ "rapt", 30 },
{ "very rapt", 31 },
{ "enthralled", 32 },
{ "nearly locked", 33 },
{ "mind lock", 34 }
};
}
//Required for Plugin - Called when user enters text in the command box
//Parameters:
// string Text: The text the user entered in the command box
//Return Value:
// string: Text that will be sent to the game
public string ParseInput(string Text)
{
if (Text.StartsWith("/track ") || Text.StartsWith("/trackr") || Text.Equals("/track"))
{
//Reset all tracking, to current value for skills/TDPS
if (Text == "/trackreset" || Text == "/track reset")
{
ResetTracking();
return "";
}
//Resets all tracking to 0, as if Genie just launched
else if (Text == "/track clear")
{
ClearTracking();
return "";
}
else if (Text == "/track tdp reset")
{
ResetTDP();
return "";
}
//Pauses XP Tracker until /trackresume is seen
else if (Text == "/track pause")
{
_enabled = false;
_host.SendText("#echo");
_host.SendText("#echo XP Tracker paused.");
_host.SendText("#echo /track resume to un-pause");
return "";
}
//Resumes XP Tracker
else if (Text == "/track resume")
{
_enabled = true;
_host.SendText("#echo");
_host.SendText("#echo XP Tracker resumed.");
return "";
}
else if (Text == "/track report")
{
_report = true;
return "exp all";
}
else if (Text.ToLower().Trim() == "/track lowest")
{
_host.EchoText("[/track lowest] will #PARSE the lowest learning skill in a pipe, comma, or space delimited list.");
_host.EchoText("Where two skills are equal it will take the one with lower ranks.");
_host.EchoText("Output will be parsed as EXPTRACKER skill. This can be captured via RegEx as ^EXPTRACKER (\\w+)$");
_host.EchoText("EXAMPLE IN SCRIPT: ");
_host.EchoText("");
_host.EchoText("action var lowestSkill $1 when ^EXPTRACKER (\\w+)$");
_host.EchoText("put /track lowest Arcana|Slings|Attunement");
_host.EchoText("");
_host.EchoText("The result will be available as $1 from the label that matches.");
}
else if (Text.ToLower().StartsWith("/track lowest"))
{
_host.SendText("#parse EXPTRACKER " + GetLowestSkill(Text.Substring(14)));
}
//User asking for help with commands, or invalid command entered
else
{
_host.SendText("#echo");
_host.SendText(@"#echo Standlone EXPTracker (Ver:" + _VERSION + ") Usage:");
_host.SendText(@"#echo /track reset");
_host.SendText(@"#echo """" """" Used to reset tracking");
_host.SendText(@"#echo /track tdp reset");
_host.SendText(@"#echo """" """" Used to reset tdp tracking only");
_host.SendText(@"#echo /track clear");
_host.SendText(@"#echo """" """" Used to reset as if you just started Genie");
_host.SendText(@"#echo /track pause");
_host.SendText(@"#echo """" """" Used to pause Exp Tracker from tracking ANY Exp Changes");
_host.SendText(@"#echo /track resume");
_host.SendText(@"#echo """" """" Used to resume Exp Tracker");
_host.SendText(@"#echo /track report");
_host.SendText(@"#echo """" """" Produce a report ");
_host.SendText(@"#echo /track lowest {skills}");
_host.SendText(@"#echo """" """" Will #PARSE the lowest learning skill in a pipe, comma, or space delimited list.");
return "";
}
}
//means no special arguments, send command on to game
return Text;
}
//Required for Plugin -
//Parameters:
// string Text: The DIRECT text comes from the game (non-"xml")
// string Window: The Window the Text was received from
//Return Value:
// string: Text that will be sent to the main window
public string ParseText(string Text, string Window)
{
//check to see if tracker is paused or not. If paused, just return the text back to Genie
if (!_enabled)
return Text;
//Try/Catch used incase exception thrown, keeps plugin from being unloaded on bad data.
try
{
if (_host != null)
{
if (_parsing == true)
{
//Parsing of Plain text EXP is done at this point.
if (Text.StartsWith("EXP HELP for more information"))
{
_parsing = false;
//The following are set up to only modify the ExpTracker.Sleeping Variable IF it needs to be changed,
//since it forces a variable save
if (_sleeping == 1 && _host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "1")
{
_host.SendText("#var ExpTracker.Sleeping 1");
_host.SendText("#var save");
}
else if (_sleeping == 2 && _host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "2")
{
_host.SendText("#var ExpTracker.Sleeping 2");
_host.SendText("#var save");
}
else if (_sleeping == 0 && _host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "0")
{
_host.SendText("#var ExpTracker.Sleeping 0");
_host.SendText("#var save");
}
//once parsing is done, update the Experience Window
ShowExperience();
}
//If the line contains a % sign, it's a line with Experience info on it
else if (Text.Contains("%"))
{
//Format of EXP strings, 2 per line for most, possibility for 1 for line
// Power Perceive: 142 71% examining (13/34) Swimming: 93 61% scrutinizing (17/34)
// Arcana: 194 23% thoughtful (4/34)
//Get index of the first %, and grab 15 characters after that, since that is the length of
//the learning rate text. Send it to PArseExperience (assuming, and clear learned/ranked)
int i = Text.IndexOf("%");
string part = Text.Substring(0, i + 15).Trim();
ParseExperience(part, 0);
//Clear the just processed info from the string, and check for another set of experience data
part = Text.Substring(i + 23).Trim();
if (part.Contains("%"))
{
i = part.Contains("(") ? part.IndexOf("(") : part.Length;
part = part.Substring(0, i);
ParseExperience(part, 0);
}
}
//Parse the number of TDPs
else if (Text.StartsWith("Time Development Points:"))
{
_TDP = Convert.ToInt32(Text.Substring(24, Text.IndexOf("Favors") - 24).Trim());
if (_trackingTDP == false)
{
_startTDP = _TDP;
_trackingTDP = true;
}
}
//Get details of rested exp. Stored, Usable, reset
else if (Text.StartsWith("Rested EXP Stored: "))
{
//get details of rested exp
//Rested EXP Stored: 5:50 hours Usable This Cycle: 5:27 hours Cycle Refreshes: 20:36 hours
//Rested EXP Stored: 1:23 hour Usable This Cycle: 59 minutes Cycle Refreshes: 13:47 hours
//Rested EXP Stored: 24 minutes Usable This Cycle: 1 minute Cycle Refreshes: 12:43 hours
}
//string for sleeping
else if (Text.StartsWith("You are relaxed and your mind has entered a light state of rest."))
_sleeping = 1;
else if (Text.StartsWith("You are relaxed and your mind has entered a deep state of rest."))
_sleeping = 2;
}
//Signals the start of the Experience command response
else if (Text.StartsWith("Circle: "))
{
_parsing = true;
//Assume not sleeping, since there is no string when you're not.
_sleeping = 0;
}
//Report has been finished generated (String is last line of exp output)
if (_report == true && Text.StartsWith("EXP HELP for more information"))
{
_report = false;
DisplayReport();
}
//Following response strings are for when you sleeping/awake using sleep/awake commands
if (_host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "1" && Text.StartsWith("You relax and allow your mind to enter a state of rest") )
{
_host.SendText("#var ExpTracker.Sleeping 1");
_host.SendText("#var save");
_updateExp = true;
}
else if (_host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "2" && Text.StartsWith("You draw deeper into rest, trying to destress"))
{
_host.SendText("#var ExpTracker.Sleeping 2");
_host.SendText("#var save");
_updateExp = true;
}
else if (_host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "0" && (Text.StartsWith("You awaken from your reverie and begin to take in the world around you") || Text.StartsWith("You stir yourself from the depths of relaxation and prepare for another day") || Text.StartsWith("But you are not sleeping!")))
{
_host.SendText("#var ExpTracker.Sleeping 0");
_host.SendText("#var save");
_updateExp = true;
}
if (_parsing && ((_host.get_Variable("ExpTracker.GagExp") == "1") || (_report)) )
Text = "";
}
}
catch (Exception ex)
{
_host.SendText("#echo >Debug \" " + ex.ToString() + "\"");
}
if (_expmods)
{
Regex ExpModsRE = new Regex(@"(\+|--)(\d+) ([A-Za-z ]*)");
Match ExpModsMatch = ExpModsRE.Match(Text);
if (ExpModsMatch.Success)
{
string ExpModsType = ExpModsMatch.Groups[1].Value;
int ExpMods = Int32.Parse(ExpModsMatch.Groups[2].Value);
string ExpModsSkill = ExpModsMatch.Groups[3].Value;
if (ExpModsSkill.EndsWith("Magic") && !ExpModsSkill.StartsWith("Targeted"))
ExpModsSkill = "Primary Magic";
int ExpModsRank;
string ExpModsPct;
if (_skillList.ContainsKey(ExpModsSkill))
{
ExpModsRank = (int)((Skill)_skillList[ExpModsSkill]).rank;
if (ExpModsRank == 0 || ExpMods == 10)
{
if (ExpModsRank == 0 && ExpMods > 10)
{
_host.EchoText("Missing rank data - (" + ExpModsSkill + ")");
_needsexp0 = true;
}
ExpModsPct = "-";
}
else
ExpModsPct = Math.Round((double)((double)ExpMods / (double)ExpModsRank) * 100, MidpointRounding.AwayFromZero).ToString() + "%";
if (ExpModsType == "+")
ExpModsRank += ExpMods;
else
ExpModsRank -= ExpMods;
Text = ExpModsType + ExpMods.ToString() + "(" + ExpModsPct + ") " + ExpModsSkill + " (" + ExpModsRank.ToString() +" effective ranks)"+ "\n";
}
else
{
_host.EchoText("Missing rank data - (" + ExpModsSkill + ")");
_needsexp0 = true;
}
}
}
else if (Text.StartsWith("The following skills are currently under the influence of a modifier"))
_expmods = true;
return Text;
}
//Required for Plugin -
//Parameters:
// string Text: That "xml" text comes from the game
public void ParseXML(string XML)
{
//check to see if tracker is paused or not. If paused, just return the text back to Genie
if (_enabled == false)
return;
//trigger output of updates with XML prompt
if (XML.Contains("prompt"))
{
if (_expmods)
{
_expmods = false;
if (_needsexp0 == true)
{
_needsexp0 = false;
_host.SendText("exp 0");
}
}
//If it was detected that the exp brief toggle is used, turn it off and clear any garbage data in the plugin
if (_ExpBrief)
{
_host.SendText("#echo white,red The ExpBrief Toggle is not supported.");
_host.SendText("#echo white,red Turning it off and clearing tracking data:");
ClearTracking();
_host.SendText("FLAG BRIEFEXP OFF");
_host.SendText("EXP");
_ExpBrief = false;
}
if (EchoLearned != "" && _host.get_Variable("ExpTracker.EchoExp") == "1")
{
EchoLearned = EchoLearned.Substring(0, EchoLearned.Length - 2);
_host.SendText("#echo " + _host.get_Variable("ExpTracker.Color.EchoGained") + " Learned: " + EchoLearned);
_host.SendText("#parse Learned: " + EchoLearned);
_host.SendText("#log Learned: " + EchoLearned);
}
if (EchoLearned != "")
EchoLearned = "";
if (EchoPulsed != "" && _host.get_Variable("ExpTracker.EchoExp") == "1")
{
EchoPulsed = EchoPulsed.Substring(0, EchoPulsed.Length - 2);
_host.SendText("#echo " + _host.get_Variable("ExpTracker.Color.EchoPulsed") + " Pulsed: " + EchoPulsed);
}
if (EchoPulsed != "")
EchoPulsed = "";
//However, only ouptut the update, if there is an update
//for the exp window.
if (_updateExp == true)
{
ShowExperience();
_updateExp = false;
}
}
//XML data for Learning skills
//<component id='exp Light Chain'><preset id='whisper'> Light Chain: 282 22% mind lock </preset></component>
//XML data for pulsed skills
//<component id='exp Hiding'> Hiding: 398 33% rapt </component>
//XML data for ranked skills (always does it 2x):
//<component id='exp Utility'><b> Utility: 160 10% learning </b></component>
//<component id='exp Utility'> Utility: 160 10% learning </component>
//XML Data for plused to clear skills
//<component id='exp Climbing'></component>
//XML Data for skill when the unsupported ExpBrief Toggle is used:
//<component id='exp Foraging'><d cmd='skill Foraging'> Forage</d>: 402 65% [ 9/34]</component>
//Only care about exp window updates
if (XML.StartsWith("<component id='exp "))
{
//If xml xml output has a bracket, using unsupported Exp Brief toggle, track that to turn off)
if ( XML.Contains("[") )
{
_ExpBrief = true;
}
//setup a new XML doc for easier iterating through nodes
XmlDocument doc = new XmlDocument();
doc.LoadXml("<doc>" + XML + "</doc>");
//create a list of the nodes
XmlNodeList xnl = doc.ChildNodes.Item(0).ChildNodes;
for (int i = 0; i < xnl.Count; i++)
{
XmlNode xn = xnl.Item(i);
switch (xn.Name)
{
case "component":
if (XML.Contains("whisper") || XML.Contains("<b>"))
{
XmlNode xn2 = xn.ChildNodes.Item(0);
if (xn2.InnerText == "")
{
ParseClear(xn2.Attributes.GetNamedItem("id").Value.Substring(4));
}
else
{
if (XML.Contains("<b>"))
ParseExperience(xn2.InnerText.Trim(), 2, true);
else
ParseExperience(xn2.InnerText.Trim(), 1, true);
}
}
else
{
if (xn.InnerText == "")
{
ParseClear(xn.Attributes.GetNamedItem("id").Value.Substring(4));
}
else
{
ParseExperience(xn.InnerText.Trim(), 0, true);
}
}
break;
default:
break;
}
}
}
}
//Required for Plugin - This method is called when clicking on the plugin
//name from the Menu item Plugins
public void Show()
{
OpenSettingsWindow(_host.ParentForm);
}
//Required for Plugin - This method is called when a global variable in genie
// is changed
//Parameters:
// string Text: The variable name in Genie that changed
public void VariableChanged(string Variable)
{
if (Variable.StartsWith("ExpTracker."))
{
if ((Variable == "ExpTracker.Sleeping") || (Variable == "ExpTracker.NextPulse")|| (Variable == "ExpTracker.LearningSkills"))
return;
if (Variable == "ExpTracker.Window")
{
if (_host.get_Variable("ExpTracker.Window") == "1")
{
_host.SendText("#window show Experience");
}
else if (_host.get_Variable("ExpTracker.Window") == "0")
{
_host.SendText("#window hide Experience");
}
}
else if (Variable == "ExpTracker.CountMinMindstate")
{
set_min_mindstae();
return;
}
if (_host.get_Variable(Variable) == "")
init_variables(true, Variable);
}
/* Removed this due to needing a way to figure out the 'seed' for when game started.
if (Variable == "gametime")
{
uint pulseOffset = Convert.ToUInt32(_host.get_Variable("gametime")) % 200;
if (pulseOffset > 192 || pulseOffset <= 12)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Missile_Mastery|Primary_Magic|Attunement|Arcana|Targeted_Magic|Augmentation")
_host.set_Variable("ExpTracker.NextPulse", "Missile_Mastery|Primary_Magic|Attunement|Arcana|Targeted_Magic|Augmentation");
}
else if (pulseOffset > 172)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Staves|Polearms|Light_Thrown|Heavy_Thrown|Brawling|Offhand_Weapon|Melee_Mastery")
_host.set_Variable("ExpTracker.NextPulse", "Staves|Polearms|Light_Thrown|Heavy_Thrown|Brawling|Offhand_Weapon|Melee_Mastery");
}
else if (pulseOffset > 152)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Small_Blunt|Large_Blunt|Twohanded_Blunt|Slings|Bow|Crossbow")
_host.set_Variable("ExpTracker.NextPulse", "Small_Blunt|Large_Blunt|Twohanded_Blunt|Slings|Bow|Crossbow");
}
else if (pulseOffset > 132)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Parry_Ability|Small_Edged|Large_Edged|Twohanded_Edged")
_host.set_Variable("ExpTracker.NextPulse", "Parry_Ability|Small_Edged|Large_Edged|Twohanded_Edged");
}
else if (pulseOffset > 112)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Shield_Usage|Light_Armor|Chain_Armor|Brigandine|Plate_Armor|Defending")
_host.set_Variable("ExpTracker.NextPulse", "Shield_Usage|Light_Armor|Chain_Armor|Brigandine|Plate_Armor|Defending");
}
else if (pulseOffset > 92)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Performance|Tactics|Astrology|Empathy|Thanatology|Expertise|Summoning|Theurgy|Conviction")
_host.set_Variable("ExpTracker.NextPulse", "Performance|Tactics|Astrology|Empathy|Thanatology|Expertise|Summoning|Theurgy|Conviction");
}
else if (pulseOffset > 72)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Forging|Engineering|Outfitting|Alchemy|Enchanting|Scholarship|Mechanical_Lore|Appraisal|Bardic_Lore|Trading")
_host.set_Variable("ExpTracker.NextPulse", "Forging|Engineering|Outfitting|Alchemy|Enchanting|Scholarship|Mechanical_Lore|Appraisal|Bardic_Lore|Trading");
}
else if (pulseOffset > 52)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Skinning|Backstab")
_host.set_Variable("ExpTracker.NextPulse", "Skinning|Backstab");
}
else if (pulseOffset > 32)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Stealth|Locksmithing|Thievery|First_Aid|Outdoorsmanship")
_host.set_Variable("ExpTracker.NextPulse", "Stealth|Locksmithing|Thievery|First_Aid|Outdoorsmanship");
}
else if (pulseOffset > 12)
{
if (_host.get_Variable("ExpTracker.NextPulse") != "Debilitation|Utility|Warding|Sorcery|Evasion|Athletics|Perception|Scouting")
_host.set_Variable("ExpTracker.NextPulse", "Debilitation|Utility|Warding|Sorcery|Evasion|Athletics|Perception|Scouting");
}
}
*/
}
public void ParentClosing()
{
}
#endregion
#region Custom Parse/Display methods
public string GetLowestSkill(string SkillList)
{
string lowestSkill = "";
int lowestRate = 0;
double lowestRank = 0;
foreach (string skill in SkillList.Split(new char[] { '|', ' ', ',' }))
{
string skillName = skill.Replace("_", " ");
if (_skillList.ContainsKey(skillName))
{
if (lowestSkill == "" || lowestRate > (_skillList[skillName] as Skill).iLearningRate)
{
//if no skill has been named
//or the current lowest learning rate is higher than the current skill
//set as the new lowest
lowestSkill = skill;
lowestRate = (_skillList[skillName] as Skill).iLearningRate;
lowestRank = (_skillList[skillName] as Skill).rank;
}
else if ((_skillList[skillName] as Skill).iLearningRate == lowestRate && (_skillList[skillName] as Skill).rank < lowestRank)
{
//if the learning rate is the same
//but the current lowest rank is higher than the current skill's rank
//set as the new lowest
lowestSkill = skill;
lowestRate = (_skillList[skillName] as Skill).iLearningRate;
lowestRank = (_skillList[skillName] as Skill).rank;
}
}
else
{
if(lowestSkill == "")
{
lowestSkill = skill;
lowestRate = 0;
lowestRank = 0;
}
}
}
return lowestSkill.Trim();
}
//Opens the settings window. Called when a user clicks on the menu item for
//this plugin (via above call)
//
//Parameters:
// Form Parent: The parent form of the plugin. Genie in this case
public void OpenSettingsWindow(System.Windows.Forms.Form parent)
{
frmEXPTracker form = new frmEXPTracker(ref _host);
//All the following code reads the ExpTracker Global variables
//and sets the form to reflect the current setup.
//Done in reverse order
form.txtEchoGain.Text = _host.get_Variable("ExpTracker.Color.EchoGained");
form.txtEchoPulse.Text = _host.get_Variable("ExpTracker.Color.EchoPulsed");
if (_host.get_Variable("ExpTracker.EchoExp") == "1")
form.cbEchoExp.Checked = true;
else
form.cbEchoExp.Checked = false;
form.txtLearned.Text = _host.get_Variable("ExpTracker.Color.Learned");
form.txtRankGained.Text = _host.get_Variable("ExpTracker.Color.RankGained");
form.txtNormal.Text = _host.get_Variable("ExpTracker.Color.Normal");
if (_host.get_Variable("ExpTracker.ReportType") == "1")
form.comboReportSort.Text = "Left to Right";
else if (_host.get_Variable("ExpTracker.ReportType") == "2")
form.comboReportSort.Text = "Learning Rate";
else if (_host.get_Variable("ExpTracker.ReportType") == "3")
form.comboReportSort.Text = "Learning Rate Reverse";
else
form.comboReportSort.Text = "A to Z";
if (_host.get_Variable("ExpTracker.SortType") == "1")
form.comboExpSort.Text = "Left to Right";
else if (_host.get_Variable("ExpTracker.SortType") == "2")
form.comboExpSort.Text = "Learning Rate";
else if (_host.get_Variable("ExpTracker.SortType") == "3")
form.comboExpSort.Text = "Learning Rate Reverse";
else
form.comboExpSort.Text = "A to Z";
if (_host.get_Variable("ExpTracker.Persistent") == "1")
form.cbPersistent.Checked = true;
else
form.cbPersistent.Checked = false;
form.updownMinMindstate.Value = get_min_mindstate();
if (_host.get_Variable("ExpTracker.CountSkills") == "1")
form.cbCountSkills.Checked = true;
else
form.cbCountSkills.Checked = false;
if (_host.get_Variable("ExpTracker.ShortNames") == "1")
form.cbShort.Checked = true;
else
form.cbShort.Checked = false;
if (_host.get_Variable("ExpTracker.GagExp") == "1")
form.cbGagExp.Checked = true;
else
form.cbGagExp.Checked = false;
if (_host.get_Variable("ExpTracker.EchoSleep") == "1")
form.cbEchoSleep.Checked = true;
else
form.cbEchoSleep.Checked = false;
if (_host.get_Variable("ExpTracker.TrackSleep") == "1")
form.cbTrackSleep.Checked = true;
else
form.cbTrackSleep.Checked = false;
if (_host.get_Variable("ExpTracker.LearningRateNumber") == "1")
form.cbLearningRateNumber.Checked = true;
else
form.cbLearningRateNumber.Checked = false;
if (_host.get_Variable("ExpTracker.LearningRate") == "1")
form.cbLearningRate.Checked = true;
else
form.cbLearningRate.Checked = false;
if (_host.get_Variable("ExpTracker.ShowRankGain") == "1")
form.cbRankGain.Checked = true;
else
form.cbRankGain.Checked = false;
if (_host.get_Variable("ExpTracker.Window") == "1")
form.cbEnable.Checked = true;
else
form.cbEnable.Checked = false;
form.Text = "Experience Tracker v" + _VERSION;
if (parent != null)
form.MdiParent = parent;
form.Show();
}
private int GetLearningRateInt(string skillRate)
{
if (MasterLearnRate.Contains(skillRate))
return (int)MasterLearnRate[skillRate];
else
return -1;
}
//Helper function - called to extract data from experience line
//Parameters:
// string line: the string containing the exp data (from xml or game output)
// int type: If skill pulsed (0), learned (1) or ranked (2)
private void ParseExperience(string line, int type, bool IsXML = false)
{
//Ensure using decimal point instead of decimal comma or other
if (System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
}
//Get skill name, which always precedes the ':'
int i = line.IndexOf(":");
if (i == -1) return;
string name = line.Substring(0, i).Trim();
// Skip lines with broke names - Conny
if (name.Contains("(")) return;
//get learnirng rate, which always is after '%'
//if no %, nothing to do
int j = line.IndexOf("%");
if (j == -1) return;
string learningRate;
if (line.Contains("(")) //parsed text will contain a (nn/34) after the learning rate
learningRate = line.Substring(j + 1, line.IndexOf("(") - j - 1).Trim();
else //parsed Xml will not contain a (nn/34), and thus will just have whitespace after the learning rate
learningRate = line.Substring(j + 1).Trim();
//rank data will be between the ":" and the "%"
string rank = line.Substring(i + 1, j - i - 1).Trim();
//as exp data from game doesn't use decimal point, but rank + %, change the space to decimal
rank = rank.Replace(" ", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
//I have no idea what this code does...so it's been dummied out for now
//Leaving in, just in case something unexpected breaks
/*
int k = rank.IndexOf(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
if (k > -1)
{