-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXPTracker.cs
1152 lines (1023 loc) · 54.6 KB
/
EXPTracker.cs
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.
string _NAME = "EXPTracker";
string _VERSION = "2.0.2";
string _AUTHOR = "VTCifer";
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 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; //Used for TDP tracking, this is current TDPs
private int _startTDP = 0; //Used for TDP tracking, this is set when first checking
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 _sleeping = false; //Used for tracking if you are sleeping or not
private string _mindState = ""; //Used for converting mindstate parsed to an integer for GenieVariable
private bool _report = false; //Used for ParseText, to know if you are running a report
private bool _enabled = true; //Used for "Pausing" the tracker, so no new data is input. Also used to disable from
//Plugins Window
//The following hashtables are used as alternatives to switch statments using string data
//which can have rather bad run time.
//****************************//
// This is still experimental //
//****************************//
private Hashtable MasterSkill;
private class ItemMasterSkill
{
public int SortLR;
public string ShortName;
}
private Hashtable MasterMindState;
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 = 0; //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
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 = "";
}
//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(67);
//Set Genie Variables if not already set
if (_host.get_Variable("ExpTracker.Window") == "")
_host.SendText("#var ExpTracker.Window 0");
if (_host.get_Variable("ExpTracker.ShowRankGain") == "")
_host.SendText("#var ExpTracker.ShowRankGain 1");
if (_host.get_Variable("ExpTracker.LearningRate") == "")
_host.SendText("#var ExpTracker.LearningRate 1");
if (_host.get_Variable("ExpTracker.LearningRateNumber") == "")
_host.SendText("#var ExpTracker.LearningRateNumber 0");
if (_host.get_Variable("ExpTracker.TrackSleep") == "")
_host.SendText("#var ExpTracker.TrackSleep 0");
if (_host.get_Variable("ExpTracker.EchoSleep") == "")
_host.SendText("#var ExpTracker.EchoSleep 0");
if (_host.get_Variable("ExpTracker.SortType") == "")
_host.SendText("#var ExpTracker.SortType 0");
if (_host.get_Variable("ExpTracker.GagExp") == "")
_host.SendText("#var ExpTracker.GagExp 0");
if (_host.get_Variable("ExpTracker.Color.Normal") == "")
_host.SendText("#var {ExpTracker.Color.Normal} {WhiteSmoke}");
if (_host.get_Variable("ExpTracker.Color.RankGained") == "")
_host.SendText("#var {ExpTracker.Color.RankGained} {WhiteSmoke}");
if (_host.get_Variable("ExpTracker.Color.Learned") == "")
_host.SendText("#var {ExpTracker.Color.Learned} {WhiteSmoke}");
if (_host.get_Variable("ExpTracker.ShortNames") == "")
_host.SendText("#var ExpTracker.ShortNames 0");
//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(72);
//Armor skills
MasterSkill.Add("Shield Usage", new ItemMasterSkill { SortLR = 0, ShortName = "Shield" });
MasterSkill.Add("Leather Armor", new ItemMasterSkill { SortLR = 1, ShortName = "Leather" });
MasterSkill.Add("Light Chain", new ItemMasterSkill { SortLR = 2, ShortName = "LC" });
MasterSkill.Add("Heavy Chain", new ItemMasterSkill { SortLR = 3, ShortName = "HC" });
MasterSkill.Add("Light Plate", new ItemMasterSkill { SortLR = 4, ShortName = "LP" });
MasterSkill.Add("Heavy Plate", new ItemMasterSkill { SortLR = 5, ShortName = "HP" });
MasterSkill.Add("Cloth Armor", new ItemMasterSkill { SortLR = 6, ShortName = "Cloth" });
MasterSkill.Add("Bone Armor", new ItemMasterSkill { SortLR = 7, ShortName = "Bone" });
//Weapon Skills
MasterSkill.Add("Parry Ability", new ItemMasterSkill { SortLR = 100, ShortName = "Parry" });
MasterSkill.Add("Multi Opponent", new ItemMasterSkill { SortLR = 101, ShortName = "MO" });
MasterSkill.Add("Light Edged", new ItemMasterSkill { SortLR = 102, ShortName = "LE" });
MasterSkill.Add("Medium Edged", new ItemMasterSkill { SortLR = 103, ShortName = "ME" });
MasterSkill.Add("Heavy Edged", new ItemMasterSkill { SortLR = 104, ShortName = "HE" });
MasterSkill.Add("Twohanded Edged", new ItemMasterSkill { SortLR = 105, ShortName = "2HE" });
MasterSkill.Add("Light Blunt", new ItemMasterSkill { SortLR = 106, ShortName = "LB" });
MasterSkill.Add("Medium Blunt", new ItemMasterSkill { SortLR = 107, ShortName = "MB" });
MasterSkill.Add("Heavy Blunt", new ItemMasterSkill { SortLR = 108, ShortName = "HB" });
MasterSkill.Add("Twohanded Blunt", new ItemMasterSkill { SortLR = 109, ShortName = "2HB" });
MasterSkill.Add("Slings", new ItemMasterSkill { SortLR = 110, ShortName = "Sling" });
MasterSkill.Add("Staff Sling", new ItemMasterSkill { SortLR = 111, ShortName = "S Sling" });
MasterSkill.Add("Short Bow", new ItemMasterSkill { SortLR = 112, ShortName = "S Bow" });
MasterSkill.Add("Long Bow", new ItemMasterSkill { SortLR = 113, ShortName = "L Bow" });
MasterSkill.Add("Composite Bow", new ItemMasterSkill { SortLR = 114, ShortName = "C Bow" });
MasterSkill.Add("Light Crossbow", new ItemMasterSkill { SortLR = 115, ShortName = "LX" });
MasterSkill.Add("Heavy Crossbow", new ItemMasterSkill { SortLR = 116, ShortName = "HX" });
MasterSkill.Add("Short Staff", new ItemMasterSkill { SortLR = 117, ShortName = "S Staff" });
MasterSkill.Add("Quarter Staff", new ItemMasterSkill { SortLR = 118, ShortName = "Q Staff" });
MasterSkill.Add("Pikes", new ItemMasterSkill { SortLR = 119, ShortName = "Pike" });
MasterSkill.Add("Halberds", new ItemMasterSkill { SortLR = 120, ShortName = "Halberd" });
MasterSkill.Add("Light Thrown", new ItemMasterSkill { SortLR = 121, ShortName = "LT" });
MasterSkill.Add("Heavy Thrown", new ItemMasterSkill { SortLR = 122, ShortName = "HT" });
MasterSkill.Add("Brawling", new ItemMasterSkill { SortLR = 123, ShortName = "Brawl" });
MasterSkill.Add("Offhand Weapon", new ItemMasterSkill { SortLR = 124, ShortName = "Offhand" });
//Magic Skills
MasterSkill.Add("Lunar Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Life Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Holy Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Elemental Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Inner Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Arcane Magic", new ItemMasterSkill { SortLR = 200, ShortName = "Magic" });
MasterSkill.Add("Harness Ability", new ItemMasterSkill { SortLR = 201, ShortName = "Harness" });
MasterSkill.Add("Power Perceive", new ItemMasterSkill { SortLR = 202, ShortName = "PP" });
MasterSkill.Add("Arcana", new ItemMasterSkill { SortLR = 203, ShortName = "Arcana" });
MasterSkill.Add("Targeted Magic", new ItemMasterSkill { SortLR = 204, ShortName = "TM" });
//Survival Skills
MasterSkill.Add("Evasion", new ItemMasterSkill { SortLR = 300, ShortName = "Evade" });
MasterSkill.Add("Climbing", new ItemMasterSkill { SortLR = 301, ShortName = "Climb" });
MasterSkill.Add("Perception", new ItemMasterSkill { SortLR = 302, ShortName = "Percep" });
MasterSkill.Add("Scouting", new ItemMasterSkill { SortLR = 303, ShortName = "Scout" });
MasterSkill.Add("Hiding", new ItemMasterSkill { SortLR = 304, ShortName = "Hide" });
MasterSkill.Add("Lockpicking", new ItemMasterSkill { SortLR = 305, ShortName = "Locks" });
MasterSkill.Add("Disarm Traps", new ItemMasterSkill { SortLR = 306, ShortName = "Disarm" });
MasterSkill.Add("Stalking", new ItemMasterSkill { SortLR = 307, ShortName = "Stalk" });
MasterSkill.Add("Stealing", new ItemMasterSkill { SortLR = 308, ShortName = "Steal" });
MasterSkill.Add("First Aid", new ItemMasterSkill { SortLR = 309, ShortName = "FA" });
MasterSkill.Add("Foraging", new ItemMasterSkill { SortLR = 310, ShortName = "Forage" });
MasterSkill.Add("Escaping", new ItemMasterSkill { SortLR = 311, ShortName = "Escape" });
MasterSkill.Add("Backstab", new ItemMasterSkill { SortLR = 312, ShortName = "BS" });
MasterSkill.Add("Skinning", new ItemMasterSkill { SortLR = 313, ShortName = "Skin" });
MasterSkill.Add("Swimming", new ItemMasterSkill { SortLR = 314, ShortName = "Swim" });
//Lore Skills
MasterSkill.Add("Scholarship", new ItemMasterSkill { SortLR = 400, ShortName = "Scholar" });
MasterSkill.Add("Mechanical Lore", new ItemMasterSkill { SortLR = 401, ShortName = "Mech" });
MasterSkill.Add("Musical Theory", new ItemMasterSkill { SortLR = 402, ShortName = "Music" });
MasterSkill.Add("Appraisal", new ItemMasterSkill { SortLR = 403, ShortName = "App" });
MasterSkill.Add("Teaching", new ItemMasterSkill { SortLR = 404, ShortName = "Teach" });
MasterSkill.Add("Trading", new ItemMasterSkill { SortLR = 405, ShortName = "Trade" });
MasterSkill.Add("Animal Lore", new ItemMasterSkill { SortLR = 406, ShortName = "Animal" });
MasterSkill.Add("Percussions", new ItemMasterSkill { SortLR = 407, ShortName = "Percuss" });
MasterSkill.Add("Strings", new ItemMasterSkill { SortLR = 408, ShortName = "Strings" });
MasterSkill.Add("Winds", new ItemMasterSkill { SortLR = 409, ShortName = "Winds" });
MasterSkill.Add("Vocals", new ItemMasterSkill { SortLR = 410, ShortName = "Vocals" });
MasterSkill.Add("Astrology", new ItemMasterSkill { SortLR = 411, ShortName = "Astro" });
MasterSkill.Add("Empathy", new ItemMasterSkill { SortLR = 412, ShortName = "Empathy" });
MasterSkill.Add("Thanatology", new ItemMasterSkill { SortLR = 413, ShortName = "Than" });
MasterMindState = new Hashtable(12);
MasterMindState.Add("clear", 0);
MasterMindState.Add("fluid", 1);
MasterMindState.Add("murky", 2);
MasterMindState.Add("very murky", 3);
MasterMindState.Add("thick", 4);
MasterMindState.Add("very thick", 5);
MasterMindState.Add("dense", 6);
MasterMindState.Add("very dense", 7);
MasterMindState.Add("stagnant", 8);
MasterMindState.Add("very stagnant", 9);
MasterMindState.Add("frozen", 10);
MasterMindState.Add("very frozen", 11);
MasterLearnRate = new Hashtable(35);
MasterLearnRate.Add("clear", 0);
MasterLearnRate.Add("dabbling", 1);
MasterLearnRate.Add("perusing", 2);
MasterLearnRate.Add("learning", 3);
MasterLearnRate.Add("thoughtful", 4);
MasterLearnRate.Add("thinking", 5);
MasterLearnRate.Add("considering", 6);
MasterLearnRate.Add("pondering", 7);
MasterLearnRate.Add("ruminating", 8);
MasterLearnRate.Add("concentrating", 9);
MasterLearnRate.Add("attentive", 10);
MasterLearnRate.Add("deliberative", 11);
MasterLearnRate.Add("interested", 12);
MasterLearnRate.Add("examining", 13);
MasterLearnRate.Add("understanding", 14);
MasterLearnRate.Add("absorbing", 15);
MasterLearnRate.Add("intrigued", 16);
MasterLearnRate.Add("scrutinizing", 17);
MasterLearnRate.Add("analyzing", 18);
MasterLearnRate.Add("studious", 19);
MasterLearnRate.Add("focused", 20);
MasterLearnRate.Add("very focused", 21);
MasterLearnRate.Add("engaged", 22);
MasterLearnRate.Add("very engaged", 23);
MasterLearnRate.Add("cogitating", 24);
MasterLearnRate.Add("fascinated", 25);
MasterLearnRate.Add("captivated", 26);
MasterLearnRate.Add("engrossed", 27);
MasterLearnRate.Add("riveted", 28);
MasterLearnRate.Add("very riveted", 29);
MasterLearnRate.Add("rapt", 30);
MasterLearnRate.Add("very rapt", 31);
MasterLearnRate.Add("enthralled", 32);
MasterLearnRate.Add("nearly locked", 33);
MasterLearnRate.Add("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")
{
//Reset TDP tracking
_TDP = 0;
_startTDP = 0;
//Reset "Tracking Since"
_startTime = DateTime.Now;
//Reset skill tracking to current values
IDictionaryEnumerator en = _skillList.GetEnumerator();
Hashtable ht = new Hashtable(67);
while (en.MoveNext())
{
Skill obj = (Skill)en.Value;
obj.startRank = obj.rank;
ht.Add(en.Key, obj);
}
_skillList.Clear();
_skillList = ht;
//Alert User Tracking is Reset
_host.SendText("#echo");
_host.SendText("#echo Rank tracking reset.");
return "";
}
//Resets all tracking to 0, as if Genie just launched
else if (Text == "/track clear")
{
//Reset TDP tracking
_TDP = 0;
_startTDP = 0;
//Reset "Tracking Since"
_startTime = DateTime.Now;
//Reset all skill tracking info to start values
_skillList.Clear();
_skillList = new Hashtable(67);
//Alert User of Reset:
_host.SendText("#echo");
_host.SendText("#echo XP Tracker reset to intial values");
return "";
}
else if (Text == "/track tdp reset")
{
_TDP = 0;
_startTDP = 0;
_host.SendText("#echo");
_host.SendText("#echo TDP tracking reset");
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";
}
//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 ");
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 == false)
return Text;
//Try/Catch used incase exception thrown, keeps plugin from being unloaded on bad data.
try
{
if (_host != null)
{
//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();
}
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 == true && _host.get_Variable("TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") != "1")
{
_host.SendText("#var ExpTracker.Sleeping 1");
_host.SendText("#var save");
}
else if (_sleeping == false && _host.get_Variable("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:
// Power Perceive: 142 71% examining (13/34) Swimming: 93 61% scrutinizing (17/34)
int i = Text.IndexOf("%");
string part = Text.Substring(0, i + 15).Trim();
ParseExperience(part, 0);
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 (_startTDP == 0)
_startTDP = _TDP;
}
//string for sleeping
else if (Text.StartsWith("You are relaxed and your mind has entered a state of rest."))
_sleeping = true;
}
//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 = false;
}
//Following two the response strings for when you sleeping/awake
if (_host.get_Variable("ExpTracker.TrackSleep") == "1" && _host.get_Variable("ExpTracker.Sleeping") == "0" && (Text.StartsWith("You relax and allow your mind to enter a state of rest.") || Text.StartsWith("You are already resting your mind!")))
{
_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") == "1" && (Text.StartsWith("You awaken from your reverie and begin to take in") || Text.StartsWith("But you are not sleeping!")))
{
_host.SendText("#var ExpTracker.Sleeping 0");
_host.SendText("#var save");
_updateExp = true;
}
//gets mindstate, since there is no XML for that.
if (Text.StartsWith("Overall state of mind:"))
ParseMindState(Text.Substring(Text.IndexOf(":") + 1).Trim());
else if (_parsing && _host.get_Variable("ExpTracker.GagExp") == "1")
Text = "";
}
}
catch (Exception ex)
{
_host.SendText("#echo >Debug \" " + ex.ToString() + "\"");
}
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 update checks with XML prompt
if (XML.Contains("prompt"))
{
//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 plused to clear skills
//<component id='exp Climbing'></component>
//if (XML.Contains("component") && XML.Contains("exp "))
//Trying out possibly better String function
if(XML.StartsWith("<component id='exp "))
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<doc>" + XML + "</doc>");
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);
else
ParseExperience(xn2.InnerText.Trim(), 1);
}
}
else
{
if (xn.InnerText == "")
{
ParseClear(xn.Attributes.GetNamedItem("id").Value.Substring(4));
}
else
{
ParseExperience(xn.InnerText.Trim(), 0);
}
}
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)
{
}
public void ParentClosing()
{
}
#endregion
#region Custom Parse/Display methods
//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.
form.txtNormal.Text = _host.get_Variable("ExpTracker.Color.Normal");
form.txtRankGained.Text = _host.get_Variable("ExpTracker.Color.RankGained");
form.txtLearned.Text = _host.get_Variable("ExpTracker.Color.Learned");
if (_host.get_Variable("ExpTracker.GagExp") == "1")
form.cbGagExp.Checked = true;
else
form.cbGagExp.Checked = false;
if (_host.get_Variable("ExpTracker.ShortNames") == "1")
form.cbShort.Checked = true;
else
form.cbShort.Checked = false;
if (_host.get_Variable("ExpTracker.SortType") == "1")
form.comboSort.Text = "Left to Right";
else if (_host.get_Variable("ExpTracker.SortType") == "2")
form.comboSort.Text = "Learning Rate";
else if (_host.get_Variable("ExpTracker.SortType") == "3")
form.comboSort.Text = "Learning Rate Reverse";
else
form.comboSort.Text = "A to Z";
form.txtEcho.Text = _host.get_Variable("ExpTracker.Echo");
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;
if (parent != null)
form.MdiParent = parent;
form.Show();
}
//Parses Mindstate into
//
//Parameters:
// string text: the p
private void ParseMindState(string text)
{
int mindState = 0;
_mindState = text;
if (MasterMindState.Contains(_mindState))
mindState = (int)MasterMindState[_mindState];
_host.set_Variable("MindState", mindState.ToString());
}
private int GetLearningRateInt(string skillRate)
{
if (MasterLearnRate.Contains(skillRate))
return (int)MasterLearnRate[skillRate];
else
return -1;
}
private void ParseExperience(string line, int type)
{
if (System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
}
if (line.StartsWith("Mind State"))
{
ParseMindState(line.Substring(12).Trim().ToLower());
return;
}
string name = "";
int i = line.IndexOf(":");
if (i == -1) return;
name = line.Substring(0, i).Trim();
// Skip lines with broke names - Conny
if (name.Contains("(")) return;
int j = line.IndexOf("%");
if (j == -1) return;
string learningRate = "";
if (line.Contains("("))
learningRate = line.Substring(j + 1, line.IndexOf("(") - j - 1).Trim();
else
learningRate = line.Substring(j + 1).Trim();
string rank = line.Substring(i + 1, j - i - 1).Trim();
rank = rank.Replace(" ", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
int k = rank.IndexOf(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
if (k > -1)
{
if (rank.Substring(k + 1).Length == 3)
{
rank = rank.Substring(0, k + 1) + rank.Substring(k + 2);
}
}
double dRank = Double.Parse(rank);
int SortLR = 0;
string ShortName = "";
if (MasterSkill.Contains(name))
{
SortLR = ((ItemMasterSkill)MasterSkill[name]).SortLR;
ShortName = ((ItemMasterSkill)MasterSkill[name]).ShortName;
if (ShortName == "Magic")
name = "Primary Magic";
}
else
{
SortLR = 500;
ShortName = "ERR!";
}
Skill skill;
if (_skillList.ContainsKey(name))
{
skill = (Skill)_skillList[name];
if ((learningRate != skill.learningRate) || (dRank != skill.rank) || (skill.learned == false && type == 1))
_updateExp = true;
skill.learningRate = learningRate;
skill.iLearningRate = GetLearningRateInt(learningRate);
skill.rank = dRank;
if (skill.startRank == 0)
skill.startRank = dRank;
skill.learned = false;
skill.rankGained = false;
if (type == 1)
skill.learned = true;
if (type == 2)
skill.rankGained = true;
skill.sortLR = SortLR;
skill.shortname = ShortName;
//Next section builds the output string. This will need to be recalucated for all skills if the
//output options are ever changed.
//Outputs name of skill (short or normal) & ranks
if (_host.get_Variable("ExpTracker.ShortNames") == "1")
skill.output = String.Format("{0,7:G}:{1,9}", skill.shortname, (skill.rank > 99.99 ? "" : " ") + String.Format("{0:0.00}", skill.rank).Replace(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator, " ") + "%");
else
skill.output = String.Format("{0,15:G}:{1,9}", name, (skill.rank > 99.99 ? "" : " ") + String.Format("{0:0.00}", skill.rank).Replace(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator, " ") + "%");
//Outputs Learning Rate NAME if set to
if (_host.get_Variable("ExpTracker.LearningRate") == "1")
skill.output += String.Format(" {0,-13}", skill.learningRate);
//Outputs Learning Rate NUMBER if set to
if (_host.get_Variable("ExpTracker.LearningRateNumber") == "1")
skill.output += String.Format("{0,8}", "(" + skill.iLearningRate + "/34)");
//Outputs Skill gain if set to
if (_host.get_Variable("ExpTracker.ShowRankGain") == "1")
{
//Calculate Skill gain
double rankGain = skill.rank - skill.startRank;
skill.output += " +" + String.Format("{0:0.00}", rankGain);
}
//Used for #echo >Window Options " Text "
//to preserve white space
skill.output = " \"" + skill.output + "\"";
//set color of text if ranked, or learned, or normal
if (skill.rankGained == true)
skill.output = _host.get_Variable("ExpTracker.Color.RankGained") + skill.output;
else if (skill.learned == true)
skill.output = _host.get_Variable("ExpTracker.Color.Learned") + skill.output;
else
skill.output = _host.get_Variable("ExpTracker.Color.Normal") + skill.output;
_skillList[name] = skill;
}
else
{
_updateExp = true;
skill = new Skill
{
learningRate = learningRate,
iLearningRate = GetLearningRateInt(learningRate),
rank = dRank,
startRank = dRank,
sortLR = SortLR,
shortname = ShortName
};
if (type == 1)
skill.learned = true;
if (type == 2)
skill.rankGained = true;
//Next section builds the output string. This will need to be recalucated for all skills if the
//output options are ever changed.
//Outputs name of skill (short or normal) & ranks
if (_host.get_Variable("ExpTracker.ShortNames") == "1")
skill.output = String.Format("{0,7:G}:{1,9}", skill.shortname, (skill.rank > 99.99 ? "" : " ") + String.Format("{0:0.00}", skill.rank).Replace(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator, " ") + "%");
else
skill.output = String.Format("{0,15:G}:{1,9}", name, (skill.rank > 99.99 ? "" : " ") + String.Format("{0:0.00}", skill.rank).Replace(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator, " ") + "%");
//Outputs Learning Rate NAME if set to
if (_host.get_Variable("ExpTracker.LearningRate") == "1")
skill.output += String.Format(" {0,-13}", skill.learningRate);
//Outputs Learning Rate NUMBER if set to
if (_host.get_Variable("ExpTracker.LearningRateNumber") == "1")
skill.output += String.Format("{0,8}", "(" + skill.iLearningRate + "/34)");
//Outputs Skill gain if set to
if (_host.get_Variable("ExpTracker.ShowRankGain") == "1")
{
//Calculate Skill gain
double rankGain = skill.rank - skill.startRank;
skill.output += " +" + String.Format("{0:0.00}", rankGain);
}
//Used for #echo >Window Options " Text "
//to preserve white space
skill.output = " \"" + skill.output + "\"";
//set color of text if ranked, or learned, or normal
if (skill.rankGained == true)
skill.output = _host.get_Variable("ExpTracker.Color.RankGained") + skill.output;
else if (skill.learned == true)
skill.output = _host.get_Variable("ExpTracker.Color.Learned") + skill.output;
else
skill.output = _host.get_Variable("ExpTracker.Color.Normal") + skill.output;
_skillList.Add(name, skill);
}
_host.set_Variable(name.Replace(" ", "_") + ".LearningRate", GetLearningRateInt(learningRate).ToString());
_host.set_Variable(name.Replace(" ", "_") + ".Ranks", dRank.ToString());
}
private void ParseClear(string name)
{
_updateExp = true;
if (name.EndsWith("Magic") && !name.StartsWith("Targeted"))
name = "Primary Magic";
Skill skill = new Skill();
if (_skillList.ContainsKey(name))
{
skill = (Skill)_skillList[name];
skill.learningRate = "clear";
_skillList[name] = skill;
}
else
_skillList.Add(name, skill);
_host.set_Variable(name.Replace(" ", "_") + ".LearningRate", "0");
}
public class MyComparer : IComparer
{
public int Compare(object x, object y)
{
return Comparer.Default.Compare(((Sortskill)x).name.ToString(), ((Sortskill)y).name.ToString());
}
}
public class MyComparerLR : IComparer
{
public int Compare(object x, object y)
{
return Comparer.Default.Compare(((Sortskill)x).sortLR, ((Sortskill)y).sortLR);
}
}
public class MyComparerLearning : IComparer
{
public int Compare(object x, object y)
{
return Comparer.Default.Compare(((Sortskill)y).sortLearning, ((Sortskill)x).sortLearning);
}
}
public class MyComparerLearningRev : IComparer
{
public int Compare(object x, object y)
{
return Comparer.Default.Compare(((Sortskill)x).sortLearning, ((Sortskill)y).sortLearning);
}
}
private void ShowExperience()
{
if (_host != null)
{
//If ExpTracker Window is enabled
if (_host.get_Variable("ExpTracker.Window") == "1")
{
//list for sorting
ArrayList sortList = new ArrayList();
//iterate through the list of all skills
foreach (DictionaryEntry sk in _skillList)
{
Skill skill = (Skill)sk.Value;
//for those that aren't at "clear" learning rate (0/34 )
if (skill.learningRate != "clear")
{
//add the skill + sort types to the list of items to be sorted
Sortskill sortSkill = new Sortskill
{
name = sk.Key.ToString(),
sortLR = ((Skill)sk.Value).sortLR,
sortLearning = ((Skill)sk.Value).iLearningRate
};
sortList.Add(sortSkill);
}
}
//Sort based on type of sort.