-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFishingForm.cs
4915 lines (4442 loc) · 225 KB
/
FishingForm.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.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Media;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
using FFACETools;
using Fishing.Properties;
namespace Fishing
{
internal partial class FishingForm : Form
{
#region Constants
// TODO These constant strings should be put into the settings resource stuff for translation purposes, if that ever happens.
private static readonly string[] MessageErrorFFACEVersion = {
"This program uses FFACE v4.0.0.9 or higher!",
"",
"Please download the latest version of FFACE and put it in this program's directory."
};
private static readonly string[] MessageVersionUpdate = {
"A new version of FishingForm is available.",
"Check https://bitbucket.org/FinalDoom/ffxi-fishingform/downloads ",
"or http://www.ffevo.net/files/file/214-fishingform-fd-edition/ for the new version."
};
private static readonly string[] MessageInventoryOther = {
"NOTE: You must enter the command below. {0} will be replaced with the any fish in the wanted list's name (as long as it's similar to the ingame name) in quotes, e.g.:",
"",
" /echo Caught too many {0}!",
"",
"You may also enter several commands, separated by semicolons or newlines. Fishing will attempt to resume after the number of seconds indicated in the number box to the right times the number of fish in the wanted list."
};
private static readonly string[] MessageBaitOther = {
"NOTE: You must enter the command below. {0} will be replaced with the bait name in quotes, e.g.:",
"",
" /echo Out of {0}!",
"",
"You may also enter several commands, separated by semicolons or newlines. Fishing will attempt to resume after the number of seconds indicated in the number box to the right."
};
private static readonly string[] MessageSaveLogs =
{
"Log names will be appended. eg.",
"",
"FF.rtf will result in FFLog.rtf, FFFish.rtf, FFTell.rtf, etc."
};
// These constants should never change--Don't use for language dependent strings
private static readonly char[] ExtensionSeparator = {'.'};
private const string DllNameFFACE = "FFACE.dll";
private const string DllNameHook = "hook.dll";
private const string DllNameItemizer = "itemizer.dll";
private const string DllNameItemTools = "itemtools.dll";
private const string FileWarningWav = "warning.wav";
private const string CommandCastSneak = "/ma Sneak <me>";
private const string CommandChatSay = "/s ";
private const string CommandChatLinkshell = "/l ";
private const string CommandChatParty = "/p ";
private const string CommandChatReply = "/t <r> ";
private const string CommandChatTell = "/t ";
private const string CommandFish = "/fish";
private const string CommandFormatItemizerGetStack = "/gets {0} {1}";
private const string CommandFormatItemtoolsGetStack = "/moveitem {0} {1} inventory 99";
private const string CommandFormatItemizerPutStack = "/puts {0} {1}";
private const string CommandFormatItemtoolsPutStack = "/moveitem {0} inventory {1} 12";
private const string CommandFormatItemMe = "/item \"{0}\" <me>";
private const string CommandFormatCancelStatus = "//cancel {0}";
private const string CommandPartCase = "case";
private const string CommandPartInventory = "inventory";
private const string CommandPartSack = "sack";
private const string CommandPartSatchel = "satchel";
private const string CommandWarp = "/ma \"Warp\" <me>";
private const string CommandLogout = "/logout";
private const string CommandShutdown = "/shutdown";
private const string EquipFormatRod = "/equip range \"{0}\"";
private const string EquipFormatBait = "/equip ammo \"{0}\"";
private const string EquipFormatBody = "/equip body \"{0}\"";
private const string EquipFormatHands = "/equip hands \"{0}\"";
private const string EquipFormatLegs = "/equip legs \"{0}\"";
private const string EquipFormatFeet = "/equip feet \"{0}\"";
private const string EquipFormatHead = "/equip head \"{0}\"";
private const string EquipFormatNeck = "/equip neck \"{0}\"";
private const string EquipFormatWaist = "/equip waist \"{0}\"";
private const string EquipFormatLRing = "/equip ring1 \"{0}\"";
private const string EquipFormatRRing = "/equip ring2 \"{0}\"";
private const string ExtensionRichText = "rtf";
private const string ExtensionUTF8Text = "txt";
private const string FormatLogTimestamp = "[hh:mm:ss] ";
private const string FormatTimestampVanaMinute = "00";
private const string FormatTimestampEarthTime = "MMM. d, yyyy h:mm:ss tt";
private const string FormatProgramTitleNoChar = "FishingForm v{0}-mC-FD";
private const string FormatProgramTitleLoggedIn = "FishingForm v{0}-mC-FD ({1})";
private const string FormatFishHP = "{0}/{1} [{2}s]";
private const string GUIChatDetectButtonAdd = "+";
private const string GUIChatDetectButtonRemove = "-";
private const string GUILblBlank = "--";
private const string GUIFormatLblBait = "{0} [{1}]";
private const string GUIFormatLblSkillDecimal = " (.{0})";
private const string GUIFormatLblSkillDecimalRange = " (.{0} - .{1})";
private const string GUILblNA = "N/A";
private const string GUIFormatLblInventory = "{0} / {1}";
private const string GUIFormatLblGil = "{0:#,#}";
private const string GUIFormatLblVanaClock = "{0}:{1}";
private const string GUIButtonResizeBig = ">";
private const string GUIButtonResizeSmall = "<";
private const string GUIFormatSaveTypes = "{0}|*.{1}|{2}|*.{3}";
private const string ProcessPOLName = "pol";
private const string RegexAllSpaces = @"^[\s]+$";
private const string RegexChatIncomingTell = @"^\w+>> ";
private const string RegexChatMode = @"(?:/(?:[slpt]|say|linkshell|party|tell)\b(?: <r>)? )?(.*)";
private const string RegexFormatChatLinkshell = @"^<(?!{0})\w+> ";
private const string RegexFormatChatParty = @"^\((?!{0})\w+\) ";
private const string RegexFormatChatSay = @"^(?!{0})\w+ :";
private const string TestChatGM = "[GM";
#endregion //Constants
#region Members
internal static FFACE _FFACE { get; private set; }
private static FFACE.PlayerTools _Player;
private static ProcessSelector.POLProcess _Process { get; set; }
private static Random rnd = new Random();
private static Thread workerThread;
private static SizeF currentScaleFactor = new SizeF(1f, 1f);
private static FishingFormDBLogger DBLogger;
private static Logger DebugLog;
private static bool ItemizerAvailable = false;
private static bool ItemToolsAvailable = false;
private static int skillLast = 0;
private static int skillDecimalMin = 0;
private static int skillDecimalMax = 0;
private static int skillDecimalTotal = 0;
private static int skillLevel = 0;
private static int consecutiveNoCatchCount = 0;
private static int consecutiveCatchCount = 0;
private static string currentFish = string.Empty;
private static string LastRodName;
private static string LastBaitName;
private static Status currentStatus;
private static Zone currentZone;
private static bool stopSound = false;
private static bool statusWarningColor = false;
private static bool chatbig = false;
private static bool OptionsConfigured = false;
private static List<Label> chatDetectLblOnList = new List<Label>();
private static List<ComboBox> chatDetectCmbChatTypeList = new List<ComboBox>();
private static List<Label> chatDetectLblReceivedList = new List<Label>();
private static List<ComboBox> chatDetectCmbChatActionList = new List<ComboBox>();
private static List<Button> chatDetectBtnChatRemoveList = new List<Button>();
private static int tellActions = 0;
private static int partyActions = 0;
private static int shellActions = 0;
private static int sayActions = 0;
private static Regex playerChatLinkshell;
private static Regex playerChatTell = new Regex(RegexChatIncomingTell);
private static Regex playerChatParty;
private static Regex playerChatSay;
private static Regex chatMode = new Regex(RegexChatMode);
internal enum FishResult
{
Error,
InventoryProblem,
LackSkill,
LineBreak,
LostCatch,
Monster,
// TODO Use this Quest value somewhere. It could be useful
Quest,
TooLarge,
TooSmall,
Released,
RodBreak,
Success,
Zoned
}
private enum FishSize
{
Large,
Small
}
private enum ChatAction
{
Stop = 1,
Note = 2,
Flash = 4
}
#endregion //Members
#region Constructor/Destructor
internal FishingForm(IEnumerable<string> arglist)
{
InitializeComponent();
#region DebugLogging
DebugLog = new DebugLogger((string message, Color color) =>
#if DEBUG
rtbDebug.UIThread(delegate
{
if (!string.IsNullOrEmpty(message))
{
try
{
rtbDebug.SelectionStart = rtbDebug.Text.Length;
rtbDebug.SelectionColor = Color.SlateBlue;
rtbDebug.SelectedText = DateTime.Now.ToString(FormatLogTimestamp);
rtbDebug.SelectionColor = FishChat.BrightenColor(color);
rtbDebug.SelectedText = message + Environment.NewLine;
rtbDebug.SelectionStart = rtbDebug.Text.Length - 1;
rtbDebug.ScrollToCaret();
}
catch (ArgumentOutOfRangeException)
{
}
}
})
#else
{ }
#endif
);
Thread.CurrentThread.Name = "UIThread";
#endregion //DebugLogging
RestoreLocation();
List<string> args = arglist.ToList(); //*golfandsurf* Formats <player> arg to match pol process
args[0] = args[0].Substring(0, 1).ToUpper() + args[0].Substring(1, args[0].Length - 1).ToLower();
ChooseProcess(args[0]);
if (args.Count > 1)
{
if (args[1].ToLower() == Resources.ArgumentStart) { btnStart_Click(btnStart, EventArgs.Empty); }
}
#region FormElements
timer.Enabled = true;
#region ToolTips
toolTip.SetToolTip(btnRefreshLists, "Refreshes the Wanted / Unwanted lists from your database, based on currently equipped rod / bait / zone." + Environment.NewLine + "If there are no entries after pressing this button, your database has no entries for the current combination.");
toolTip.SetToolTip(btnCastReset, "Reset cast wait to 3.0/3.5. This is a quick reset if you become fatigued and rezone.");
toolTip.SetToolTip(btnResize, "Resize chat log to fill dialog, click again to restore (will automatically restore if fishing terminates).");
toolTip.SetToolTip(cbAlwaysOnTop, "Set dialog to always visible.");
toolTip.SetToolTip(cbCatchUnknown, "Catch any unknown fish, those not shown in either the Wanted or Unwanted lists.");
toolTip.SetToolTip(cbReleaseLarge, "Fake fight unwanted large fish.");
toolTip.SetToolTip(cbReleaseSmall, "Fake fight unwanted small fish.");
toolTip.SetToolTip(lblCastWait, "Seconds until recasting after cast last attempt, time increases by 1 second when needed.");
toolTip.SetToolTip(cbReleaseLarge, "Sets the lower and upper HP% for randomly releasing a large fish.");
toolTip.SetToolTip(cbReleaseSmall, "Sets the lower and upper HP% for randomly releasing a small fish.");
toolTip.SetToolTip(lblMaxNoCatch, "Maximum number of no catch casts before stopping.");
toolTip.SetToolTip(cbMidnightRestart, "Restart fishing at Japanese midnight.");
toolTip.SetToolTip(lblNoCatchAtHeader, "Displays how many times you have not caught anything in a row.");
toolTip.SetToolTip(trackOpacity, "This bar controls the transparency of the dialog between 10% and 99%.");
toolTip.SetToolTip(cbReaction, "Delay before starting to fight a caught fish.");
toolTip.SetToolTip(lblUnwantedHeader, "A list of the known fish you do not want to catch for your current bait / rod / zone combination.");
toolTip.SetToolTip(lblWantedHeader, "A list of the known fish you want to catch for your current bait / rod / zone combination.");
toolTip.SetToolTip(cbExtend, "Extends time to reel-in by 30 seconds.");
toolTip.SetToolTip(cbAutoKill, "Sets fish HP to 0 automatically when there's 5 seconds left on the line.");
toolTip.SetToolTip(cbQuickKill, "Automatically kills fish after [#] of seconds elapse with fish on the line.");
toolTip.SetToolTip(cbIgnoreItem, "Ignore and release all items.");
toolTip.SetToolTip(cbIgnoreMonster, "Ignore and release all monsters.");
toolTip.SetToolTip(cbIgnoreSmallFish, "Ignore and release all small fish.");
toolTip.SetToolTip(cbIgnoreLargeFish, "Ignore and release all large fish.");
toolTip.SetToolTip(tbRodGear, "Automatically equip rod when none equipped or when one breaks. Will use currently equipped rod if not specified.");
toolTip.SetToolTip(tbBaitGear, "Automatically equip rod when none equipped or when exhausted. Will use currently equipped bait if not specified.");
toolTip.SetToolTip(cbLRingGear, "Automatically use left ring enchantment.");
toolTip.SetToolTip(cbRRingGear, "Automatically use right ring enchantment.");
toolTip.SetToolTip(cbWaistGear, "Automatically use belt enchantment.");
toolTip.SetToolTip(cbGMdetectAutostop, "Issue STOP on detection of a GM.");
toolTip.SetToolTip(cbBaitActionShutdown, "Shut down when out of bait, unless above command finds bait.");
toolTip.SetToolTip(cbBaitActionLogout, "Log out when out of bait, unless above command finds bait.");
toolTip.SetToolTip(cbBaitActionWarp, "Warp when out of bait, unless above command finds bait.");
toolTip.SetToolTip(cbBaitItemizerSack, "Fetch bait from sack.");
toolTip.SetToolTip(cbBaitItemizerSatchel, "Fetch bait from satchel.");
toolTip.SetToolTip(cbBaitItemizerCase, "Fetch bait from mog case.");
toolTip.SetToolTip(cbBaitItemizerItemTools, "Enables Itemizer plugin support to automatically grab current bait when none is found in inventory. This will attempt to fetch bait to prevent any warp, logout, or shutdown action.");
toolTip.SetToolTip(cbBaitactionOther, "Execute below command when out of bait. Wait for the number of seconds to the right. Warp, logout, or shutdown will occur if bait is still not found after executing this command.");
toolTip.SetToolTip(numBaitactionOtherTime, "Number of seconds to wait for command to execute.");
toolTip.SetToolTip(cbFatiguedActionShutdown, "Shut down when catch limit is reached.");
toolTip.SetToolTip(cbFatiguedActionLogout, "Log out when catch limit is reached.");
toolTip.SetToolTip(cbFatiguedActionWarp, "Warp when catch limit is reached.");
toolTip.SetToolTip(cbStopSound, "When fishing terminates unexpectedly, play warning.wav sound.");
toolTip.SetToolTip(cbTellDetect, "Changes status bar color and Tell tab name when receiving a message.");
toolTip.SetToolTip(cbFullactionShutdown, "Shut down when inventory is full.");
toolTip.SetToolTip(cbFullactionLogout, "Log out when inventory is full.");
toolTip.SetToolTip(cbFullactionWarp, "Warp when inventory is full.");
toolTip.SetToolTip(cbFullActionStop, "Stop fishing when inventory is full. If disabled, fishing will continue, but no shutdown, logout, or warp will occur.");
toolTip.SetToolTip(cbInventoryItemizerSack, "Put fish in sack.");
toolTip.SetToolTip(cbInventoryItemizerSatchel, "Put fish in satchel.");
toolTip.SetToolTip(cbInventoryItemizerCase, "Put fish in mog case.");
toolTip.SetToolTip(cbInventoryItemizerItemTools, "Enables Itemizer plugin support to automatically store fish when inventory is full.");
toolTip.SetToolTip(cbFullactionOther, "Execute below command when inventory is full. Wait for the number of seconds to the right for each fish in the wanted list.");
toolTip.SetToolTip(numFullactionOtherTime, "Number of seconds to wait for command to execute.");
toolTip.SetToolTip(cbMaxCatch, "Stops fishing when # of catches reached; value resets when limit is reached.");
toolTip.SetToolTip(cbSneakFishing, "Will cast the spell Sneak prior to casting.");
toolTip.SetToolTip(cbSkillCap, "Stop when skill reaches specified level.");
toolTip.SetToolTip(cbChatDetect, "Uncheck to disable all chat detectors set below.");
#endregion //ToolTips
#region Gear
tbBaitGear.Items.AddRange(Dictionaries.baitList.ToArray());
tbRodGear.Items.AddRange(Dictionaries.rodList.ToArray());
tbBodyGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.bodyIndex, Dictionaries.bodyCount).ToArray());
tbHandsGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.handsIndex, Dictionaries.handsCount).ToArray());
tbLegsGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.legsIndex, Dictionaries.legsCount).ToArray());
tbFeetGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.feetIndex, Dictionaries.feetCount).ToArray());
tbHeadGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.headIndex, Dictionaries.headCount).ToArray());
tbNeckGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.neckIndex, Dictionaries.neckCount).ToArray());
tbWaistGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.waistIndex, Dictionaries.waistCount).ToArray());
tbLRingGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.ringsIndex, Dictionaries.ringsCount).ToArray());
tbRRingGear.Items.AddRange(Dictionaries.gearList.GetRange(Dictionaries.ringsIndex, Dictionaries.ringsCount).ToArray());
#endregion //Gear
FishDB.OnChanged += new FishDB.DBChanged(PopulateLists);
FishStats.OnChanged += new FishStats.FishStatsChanged(UpdateStats);
#endregion //FormElements
#region Database
DBLogger = new FishingFormDBLogger((string message, Color color) => rtbDB.UIThread(delegate
{
if (!string.IsNullOrEmpty(message))
{
try
{
rtbDB.SelectionStart = rtbDB.Text.Length;
rtbDB.SelectionColor = Color.SlateBlue;
rtbDB.SelectedText = DateTime.Now.ToString(FormatLogTimestamp);
rtbDB.SelectionColor = FishChat.BrightenColor(color);
rtbDB.SelectedText = message + Environment.NewLine;
rtbDB.SelectionStart = rtbDB.Text.Length - 1;
rtbDB.ScrollToCaret();
}
catch (ArgumentOutOfRangeException)
{
}
}
}));
FishSQL.StatusDisplay = DBLogger;
Thread databaseInitThread = new Thread(new ThreadStart(CheckDatabase))
{
IsBackground = true,
Name = "DatabaseInitThread"
};
databaseInitThread.Start();
#endregion //Database
#region Debug
tabChat.Controls.Remove(tabChatPageDebug);
#if DEBUG || TEST
showDebugToolStripMenuItem.Visible = true;
#else
showDebugToolStripMenuItem.Visible = false;
#endif
#if DEBUG
toolStripSeparatorChatBoxes.Visible = true;
#else
toolStripSeparatorChatBoxes.Visible = false;
#endif
#if TEST
toolStripSeparatorChatBoxes.Visible = true;
#else
testToolStripMenuItem.Visible = false;
#endif
#endregion //Debug
}
~FishingForm()
{
timer.Enabled = false;
if (null != workerThread)
{
WinClear();
workerThread.Abort();
while (workerThread.IsAlive) { Thread.Sleep(100); }
workerThread = null;
}
_FFACE = null;
_Player = null;
FishSQL.CloseConnection();
FishSQL.CloseAllConnections();
}
#endregion //Constructor/Destructor
#region Methods
#region Methods_Form_Overrides
/// <summary>
/// Override method used to kep correct component locations when under different
/// viewing conditions than standard 96 dpi.
/// </summary>
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
{
base.ScaleControl(factor, specified);
//Record the running scale factor used
currentScaleFactor = new SizeF(
currentScaleFactor.Width * factor.Width,
currentScaleFactor.Height * factor.Height);
}
#endregion //Methods_Form_Overrides
#region Methods_Initialization
/// <summary>
/// Set the location of the window from stored options or from default
/// </summary>
private void RestoreLocation()
{
Point location = Settings.Default.WindowLocation;
if (location == Point.Empty)
{
return;
}
Point lowerRight = Settings.Default.WindowLocation;
lowerRight.Offset(Settings.Default.WindowSize.Width, Settings.Default.WindowSize.Height);
// Adjust lower right to be on screen
if (!FishUtils.ThisPointIsOnOneOfTheConnectedScreens(lowerRight))
{
Point offset1 = FishUtils.GetClosestOnScreenOffsetPoint(lowerRight);
location.Offset(offset1);
}
// Adjust upper left to be on screen
if (!FishUtils.ThisPointIsOnOneOfTheConnectedScreens(location))
{
Point offset2 = FishUtils.GetClosestOnScreenOffsetPoint(location);
location.Offset(offset2);
}
this.Location = location;
}
/// <summary>
/// Threaded function to check database for fish info changes and submit updates.
/// First checks version, then waits for _FFACE to be populated before doing fish checks.
/// </summary>
private void CheckDatabase()
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking Database");
try
{
if (!FishSQL.OpenConnection())
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Returning: Could not open connection");
return;
}
if (!FishSQL.IsProgramUpdated())
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"New Version Found");
string message = FishSQL.GetVersionMessage();
string[] messageArray = MessageVersionUpdate;
if (!string.IsNullOrEmpty(message))
{
messageArray = MessageVersionUpdate.Concat(new string[] { string.Empty, message }).ToArray();
}
MessageBox.Show(string.Join(Environment.NewLine, messageArray));
DBLogger.Info(string.Join(Environment.NewLine, messageArray));
}
// Make sure _FFACE is populated so we can actually resolve zone names and such
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking that FFACE is instantiated.");
while (_FFACE == null)
{
Thread.Sleep(1000);
}
while (!DBLogger.StartDBTransaction(Resources.MessageDBSyncStart))
{
Thread.Sleep(250);
}
try
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking for FishDB Updates");
FishDB.GetUpdates();
}
catch (Exception e)
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Error getting updates:");
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
e.ToString());
DBLogger.Error(Resources.MessageDBErrorXML);
DBLogger.Info(e.ToString());
}
try
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Uploading new fish, if they exist");
FishSQL.DoUploadFish();
}
catch (Exception e)
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Error uploading fish:");
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
e.ToString());
DBLogger.Error(Resources.MessageDBErrorUpload);
DBLogger.Info(e.ToString());
}
try
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Downloading new fish");
FishSQL.DoDownloadFish();
}
catch (Exception e)
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Error downloading fish:");
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
e.ToString());
DBLogger.Error(Resources.MessageDBErrorDownload);
DBLogger.Info(e.ToString());
}
}
catch (Exception e)
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Another error happened in DB transactions:");
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
e.ToString());
DBLogger.Error(Resources.MessageDBErrorGeneral);
DBLogger.Info(e.ToString());
}
finally
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Closing DB Connection");
FishSQL.CloseConnection();
DBLogger.EndDBTransaction(Resources.MessageDBSyncFinish);
}
}
/// <summary>
/// Choose a pol process to attach FFACE to, automatically or from passed
/// character name.
/// </summary>
/// <param name="characterName">Character name on desired process</param>
private void ChooseProcess(string characterName)
{
DebugLog.Info("({0}) [{1}] {2} {3}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Choosing FFXI Process for character:", characterName);
using (ProcessSelector chooseProcess = new ProcessSelector())
{
if (characterName != null && characterName != Resources.ArgumentNoArgs)
{
for (int i = 0; i <= Process.GetProcessesByName(ProcessPOLName).Length; i++)
{
if (Process.GetProcessesByName(ProcessPOLName)[i].MainWindowTitle == characterName)
{
chooseProcess.ThisProcess = new ProcessSelector.POLProcess(Process.GetProcessesByName(ProcessPOLName)[i].Id, Process.GetProcessesByName(ProcessPOLName)[i].MainWindowTitle);
break;
}
}
}
if (!chooseProcess.error && null == chooseProcess.ThisProcess)
{
chooseProcess.ShowDialog();
}
if (null == chooseProcess.ThisProcess)
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Failed to get FFXI Process");
_FFACE = null;
_Player = null;
string ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
this.Text = string.Format(FormatProgramTitleNoChar, ver);
_Process = null;
FFACE.WindowerPath = Resources.PathWindowerResourcesError;
return;
}
try //if you can't create an instance, there's probably no FFACE.dll, or an old FFACE version
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Setting up FFACE");
_FFACE = new FFACE(chooseProcess.ThisProcess.POLID);
_Player = new FFACE.PlayerTools(_FFACE._InstanceID);
playerChatLinkshell = new Regex(string.Format(RegexFormatChatLinkshell, _Player.Name));
playerChatParty = new Regex(string.Format(RegexFormatChatParty, _Player.Name));
playerChatSay = new Regex(string.Format(RegexFormatChatSay, _Player.Name));
string ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
this.Text = string.Format(FormatProgramTitleLoggedIn, ver, chooseProcess.ThisProcess.POLName);
//windower path
//_FFACE = new FFACE((int)PID);
Process pol = Process.GetProcessById(chooseProcess.ThisProcess.POLID);
foreach (ProcessModule mod in pol.Modules)
{
if (mod.ModuleName.ToLower() == DllNameHook)
{
FFACE.WindowerPath = Path.Combine(Path.GetDirectoryName(mod.FileName), Resources.PathWindowerResourcesFolder);
break;
}
}
foreach (ProcessModule mod in pol.Modules)
{
if (mod.ModuleName.ToLower() == DllNameItemizer)
{
ItemizerAvailable = true;
break;
}
if (mod.ModuleName.ToLower() == DllNameItemTools)
{
ItemToolsAvailable = true;
break;
}
}
if (String.IsNullOrEmpty(FFACE.WindowerPath))
{
FFACE.WindowerPath = Resources.PathWindowerResourcesError;
}
}
catch (DllNotFoundException) //occurs when FFACE.dll cannot be found
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Couldn't find FFACE.dll");
if (File.Exists(Path.Combine(Application.StartupPath, DllNameFFACE)))
{
MessageBox.Show(Resources.MessageErrorAdministratorNeeded, Resources.MessageTitleFishingFormError);
}
else
{
MessageBox.Show(Resources.MessageErrorFFACEMissing, Resources.MessageTitleFishingFormError);
}
// Consider not exiting for debug here
Environment.Exit(0);
}
catch (EntryPointNotFoundException) //occurs when 'CreateInstance' entry point in FFACE.dll cannot be found
{
DebugLog.Error("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"FFACE entry point could not be found.");
MessageBox.Show(string.Join(Environment.NewLine, MessageErrorFFACEVersion), Resources.MessageTitleFishingFormError);
Environment.Exit(0);
}
_Process = chooseProcess.ThisProcess; //store instanced property for possible need to Reattach()
}
}
#endregion
#region Methods_Fishing
#region Methods_Fishing_Major
/// <summary>
/// Threaded function that handles fishing loop
/// </summary>
// TODO This would be where to start/change if implementing a FSM paradigm for the bot
private void BackgroundFishing()
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Begin fishing loop");
while (_FFACE.Player.Zone == currentZone)
{
if (((int)numMaxNoCatch.Value < consecutiveNoCatchCount))
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Stopping because no-catch value has been exceeded.");
SetNoCatch(consecutiveNoCatchCount = 0);
Fatigued(Resources.StatusFatigueNoCatches);
return;
}
// Stop at skill level
if (cbSkillCap.Checked && numSkillCap.Value <= Math.Max(_FFACE.Player.GetCraftDetails(Craft.Fishing).Level, skillLevel))
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Stopping because skill cap has been reached.");
Stop(false, Resources.StatusErrorSkillCapped);
return;
}
if (Status.Fishing != currentStatus && Status.FishBite != currentStatus && Status.LostCatch != currentStatus)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Casting after random time: We're not currently fishing");
decimal randomCast = Math.Round((decimal)rnd.NextDouble() * (numCastIntervalHigh.Value - numCastIntervalLow.Value), 1);
decimal castWait = numCastIntervalLow.Value + randomCast;
SetStatus(string.Format(Resources.StatusFormatCastingSeconds, castWait));
SetLblHP(string.Empty);
Thread.Sleep((int)(castWait * 1000));
}
Fish();
}
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Stopping because zone has changed.");
Stop(true, Resources.StatusErrorZoneChanged);
} // @ private void BackgroundFishing()
/// <summary>
/// Get a specified bait type from satchel, sack, or mog case, based on options and
/// currently selected bait.
/// </summary>
/// <param name="bait">Name of the currently selected bait</param>
private void RetrieveBait(string bait)
{
DebugLog.Info("({0}) [{1}] {2} {3}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Attempting to retrieve bait", bait);
if (cbBaitItemizerItemTools.Checked)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Attempting to get bait using Itemizer or ItemTools.");
string baitLocation;
if (cbBaitItemizerSack.Checked && _FFACE.Item.GetSackItemCount((ushort)Dictionaries.baitDictionary[bait]) > 0)
{
baitLocation = CommandPartSack;
}
else if (cbBaitItemizerSatchel.Checked && _FFACE.Item.GetSatchelItemCount((ushort)Dictionaries.baitDictionary[bait]) > 0)
{
baitLocation = CommandPartSatchel;
}
else if (cbBaitItemizerCase.Checked && _FFACE.Item.GetCaseItemCount((ushort)Dictionaries.baitDictionary[bait]) > 0)
{
baitLocation = CommandPartCase;
}
else
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"No bait found in or none checked of sack, satchel, or case.");
return;
}
string quotedBait = string.Format(Resources.FormatQuoteArg, bait);
if (ItemizerAvailable)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Moving bait using Itemizer");
DoMoveItem(string.Format(CommandFormatItemizerGetStack, quotedBait, baitLocation), baitLocation, CommandPartInventory, (ushort)Dictionaries.baitDictionary[bait]);
}
else if (ItemToolsAvailable)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Moving bait using ItemTools");
DoMoveItem(string.Format(CommandFormatItemtoolsGetStack, quotedBait, baitLocation), baitLocation, CommandPartInventory, (ushort)Dictionaries.baitDictionary[bait]);
}
}
else if (cbBaitactionOther.Checked && !string.IsNullOrEmpty(tbBaitactionOther.Text))
{
DebugLog.Info("({0}) [{1}] {2} {3}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Attempting to get bait using oter command:", tbBaitactionOther.Text);
string quotedBait = string.Format(Resources.FormatQuoteArg, bait);
foreach (string command in tbBaitactionOther.Text.Split(new String[] {Resources.Semicolon, Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries))
{
_FFACE.Windower.SendString(string.Format(command, quotedBait));
Thread.Sleep((int)(numBaitactionOtherTime.Value * 1000)); //pause to give the game time to execute commands
}
}
}
/// <summary>
/// Check if bait and rod are set in options or equipped. Does not alter
/// game state (just program state), and stops if either is not equipped.
/// </summary>
/// <returns>true if rod and bait are set in options or equipped</returns>
private bool IsRodBaitSet()
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking that bait and rod are set in options or equipped in game.");
if (_FFACE == null)
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"FFACE not instantiated. No rod/bait found.");
return false;
}
string bait = tbBaitGear.Text;
if (string.IsNullOrEmpty(bait))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking for bait from ingame (not set in options).");
bait = FishUtils.GetBaitName(_FFACE.Item.GetEquippedItemID(EquipSlot.Ammo));
}
string rod = tbRodGear.Text;
if (string.IsNullOrEmpty(rod))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking for rod from ingame (not set in options).");
rod = FishUtils.GetRodName(_FFACE.Item.GetEquippedItemID(EquipSlot.Range));
}
currentZone = _FFACE.Player.Zone;
if ((!string.IsNullOrEmpty(rod)) && (!string.IsNullOrEmpty(bait)))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod, bait, and zone found.");
SetBait(bait);
SetRod(rod);
SetLblZone(FishUtils.GetZoneName(currentZone));
return true;
}
else
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod or bait not found, stopping.");
LastBaitName = LastRodName = string.Empty;
SetLblZone(string.Empty);
Stop(false, Resources.StatusErrorNoBaitOrRodEquipped);
ClearLists();
return false;
}
} // @ private bool RodBaitEquipped()
/// <summary>
/// Check if rod and bait are equipped (not if they are set in options).
/// </summary>
/// <returns>true if rod and bait are equipped</returns>
private bool IsRodBaitEquipped()
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking if rod and bait are equipped in game (did equip commands execute correctly?)");
if (_FFACE == null)
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"FFACE not instantiated. No rod/bait found.");
return false;
}
string bait = FishUtils.GetBaitName(_FFACE.Item.GetEquippedItemID(EquipSlot.Ammo));
string rod = FishUtils.GetRodName(_FFACE.Item.GetEquippedItemID(EquipSlot.Range));
if ((!string.IsNullOrEmpty(rod)) && (!string.IsNullOrEmpty(bait)))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod and bait found equipped ingame.");
SetBait(bait);
SetRod(rod);
return true;
}
else
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod or bait not equipped in game");
return false;
}
}
/// <summary>
/// Checks for and equips rod and bait based on what is set in options,
/// currently equipped, or previously used during program fishing.
/// </summary>
/// <returns>true if bait and rod equipped at end of function</returns>
private bool CheckRodAndBait()
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking for rod and bait in options or ingame, and equipping if necessary.");
string strZone = FishUtils.GetZoneName(_FFACE.Player.Zone);
string strBait = LastBaitName;
string strRod = LastRodName;
string rod = FishUtils.GetRodName(_FFACE.Item.GetEquippedItemID(EquipSlot.Range));
string bait = FishUtils.GetBaitName(_FFACE.Item.GetEquippedItemID(EquipSlot.Ammo));
string strRodEquipMessage = string.Format(EquipFormatRod, LastRodName);
string strBaitEquipMessage = string.Format(EquipFormatBait, LastBaitName);
// Just starting or zoned
if ((string.IsNullOrEmpty(lblZone.Text)) || (lblZone.Text != strZone))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Zone changed or just started program.");
SetLblZone(strZone);
PopulateLists();
}
// No rod or bait equipped. Try equipping
if (string.IsNullOrEmpty(rod) || string.IsNullOrEmpty(bait) || LastBaitName != bait || LastRodName != rod)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod or bait not equipped, sending equip commands.");
DoEquipping(strRodEquipMessage, (ushort)Dictionaries.rodDictionary[LastRodName], EquipSlot.Range);
DoEquipping(strBaitEquipMessage, (ushort)Dictionaries.baitDictionary[LastBaitName], EquipSlot.Ammo);
}
if (IsRodBaitEquipped()) //check to see if bait/rod changed since last loop
{
if ((LastBaitName != strBait) || (LastRodName != strRod) || (lblZone.Text != strZone))
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod, bait, or zone changed since last loop.");
PopulateLists();
}
}
else //if IsRodBaitEquipped returns false, most likely out of bait, try to get it from sack/satchel/case with itemizer/itemtools
{ //if that doesn't work, return false
RetrieveBait(LastBaitName);
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Attempting to equip retrieved bait");
DoEquipping(strRodEquipMessage, (ushort)Dictionaries.rodDictionary[LastRodName], EquipSlot.Range);
DoEquipping(strBaitEquipMessage, (ushort)Dictionaries.baitDictionary[LastBaitName], EquipSlot.Ammo);
if (!IsRodBaitEquipped())
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Bait or rod still not equipped.");
return false;
}
}
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod and bait checks out okay.");
return true;
}
/// <summary>
/// Part 3 of threaded fishing loop. Checks sneak, rod and bait
/// equip status, ring enchantment status, and casts rod.
/// </summary>
private void Cast()
{
if (cbSneakFishing.Checked)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Checking sneak status.");
if (!IsStatusEffectActive(StatusEffect.Sneak))
{
// Check to make sure we have enough MP
if (_FFACE.Player.MPCurrent >= 12)
{
DebugLog.Info("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Sending command to cast sneak.");
_FFACE.Windower.SendString(CommandCastSneak);
Thread.Sleep(500);
// While we are casting, sleep the thread.
while (_FFACE.Player.CastPercentEx < 95)
{
Thread.Sleep(100);
}
// Give it time to finish casting animation
Thread.Sleep(2000);
GearUp();
}
else
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Not enough MP to cast sneak. Stopping");
Stop(false, Resources.StatusErrorSneakLackMP);
return;
}
}
}
if (!CheckRodAndBait())
{
DebugLog.Warning("({0}) [{1}] {2}", DebugLogger.GetCurrentThread(), DebugLogger.GetCurrentMethod(),
"Rod and bait check failed. Stopping");
OutOfBait(Resources.StatusErrorNoBait);
return;
}
uint baitLeft = _FFACE.Item.GetInventoryItemCount((ushort) _FFACE.Item.GetEquippedItemID(EquipSlot.Ammo));
CheckEnchantment();
SetStatus(string.Format(Resources.StatusFormatCastingBait, LastBaitName, baitLeft));