/******************************************************************************* File : ActNoDamage.cs Description : No damage plugin for ACT -------------------------------------------------------------------------------- Functions: -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ using System; using System.Text; using Advanced_Combat_Tracker; using System.IO; using System.Reflection; using System.Xml; using System.Threading; using System.Windows.Forms; using System.ComponentModel; using System.Text.RegularExpressions; using System.Drawing; using System.Collections.Generic; [assembly: AssemblyTitle("ACT No Damage")] [assembly: AssemblyDescription("An ACT plugin to say a message when doing No Damage")] [assembly: AssemblyCompany("Hiburp of Maj'Dul")] [assembly: AssemblyProduct("ActNoDamage")] [assembly: AssemblyVersion("20.02.24.1")] namespace ACTNoDamagePlugin { /******************************************************************************* Class : ACTNoDamage Description : -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ public class ACTNoDamage : UserControl, IActPluginV1 { const int PLUG_ID = 79; const int DEFAULT_NO_DAMAGE_DELAY = 10; /* seconds delay between no damage messages */ const int DEFAULT_DOING_DAMAGE_DELAY = 5; /* Seconds between doing damage messages */ const int DEFAULT_SKIP_CNT = 3; /* Skip first x no damage messages */ const int DEFAULT_FIGHT_SKIP_CNT = 5; const string DEFAULT_NO_DAMAGE_MSG = "No damage"; const string DEFAULT_DOING_DAMAGE_MSG = "Doing damage"; const string START_OF_FIGHT = "You start fighting."; const string END_OF_FIGHT = "You stop fighting."; Label LabelStatus; /* Status label that appears in ACT's Plugin tab */ string SettingsFile; SettingsSerializer xmlSettings; DateTime LastNoDmgMsgTime; /* Time No Damage message was last played */ DateTime LastDoingDamageMsgTime; /* Time Doing Damage message was last played */ int NoDamageDelay; /* Delay in seconds between messages */ int SkipMsgCnt; /* Don't act on 1st instance of message */ int CurrentSkipMsgCnt; int SkipFightMsgCnt; /* Skip x messages when starting fight */ int CurrentFightSkipCnt; string NoDamageMsg; /* Text to Speech message for Doing no damage */ string DoingDamageMsg; /* Text to Speech message for Doing Damage */ bool DoingDamage; /* Currently doing damage or not */ bool PlayDoingDamage; /* Play the doing damage message */ bool Fighting; /* In a fight or not */ string FightingWhat; /* Name of thing currently fighting */ ListIgnoreList; /* MOB to ignore */ Regex RegexDoingDmg1, RegexDoingDmg2; Regex RegexNoDmg1, RegexNoDmg2; Match RegexResult; /******************************************************************************/ #region Designer Created Code (Avoid editing) IContainer components = null; TextBox TextBoxDelay, TextBoxNoDmgMsg; Label LabelDelay, LabelNoDmgMsg; private Label LabelSkipNum; private TextBox TextBoxSkipNum; private TextBox TextBoxDoingDmgMsg; private CheckBox CheckBoxPlay; private Label LabelSkipFight; private TextBox TextBoxSkipFight; private GroupBox GroupBoxIgnore; private Button ButtonRemove; private Button ButtonAdd; private ListBox ListBoxIgnore; private TextBox TextBoxIgnore; private Label LabelDmgMsg; /******************************************************************************* Function : Dispose() Description : Clean up any resources being used Parameters : bool disposing - true if managed resources should be disposed; otherwise, false Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ protected override void Dispose(bool disposing) { if (disposing && (components != null)) components.Dispose(); base.Dispose(disposing); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { LabelDelay = new Label(); TextBoxDelay = new TextBox(); LabelNoDmgMsg = new Label(); TextBoxNoDmgMsg = new TextBox(); LabelSkipNum = new Label(); TextBoxSkipNum = new TextBox(); TextBoxDoingDmgMsg = new TextBox(); LabelDmgMsg = new Label(); CheckBoxPlay = new CheckBox(); LabelSkipFight = new Label(); TextBoxSkipFight = new TextBox(); GroupBoxIgnore = new GroupBox(); TextBoxIgnore = new TextBox(); ListBoxIgnore = new ListBox(); ButtonAdd = new Button(); ButtonRemove = new Button(); GroupBoxIgnore.SuspendLayout(); SuspendLayout(); // // LabelDelay // LabelDelay.AutoSize = true; LabelDelay.Location = new Point(16, 20); LabelDelay.Name = "LabelDelay"; LabelDelay.Size = new Size(245, 13); LabelDelay.TabIndex = 4; LabelDelay.Text = "Delay in seconds between No Damage messages:"; // // TextBoxDelay // TextBoxDelay.Location = new Point(269, 18); TextBoxDelay.Name = "TextBoxDelay"; TextBoxDelay.Size = new Size(30, 20); TextBoxDelay.TabIndex = 0; // // LabelNoDmgMsg // LabelNoDmgMsg.AutoSize = true; LabelNoDmgMsg.Location = new Point(16, 114); LabelNoDmgMsg.Name = "LabelNoDmgMsg"; LabelNoDmgMsg.Size = new Size(110, 13); LabelNoDmgMsg.TabIndex = 4; LabelNoDmgMsg.Text = "No Damage Message"; // // TextBoxNoDmgMsg // TextBoxNoDmgMsg.Location = new Point(20, 131); TextBoxNoDmgMsg.Name = "TextBoxNoDmgMsg"; TextBoxNoDmgMsg.Size = new Size(216, 20); TextBoxNoDmgMsg.TabIndex = 0; // // LabelSkipNum // LabelSkipNum.AutoSize = true; LabelSkipNum.Location = new Point(16, 46); LabelSkipNum.Name = "LabelSkipNum"; LabelSkipNum.Size = new Size(205, 13); LabelSkipNum.TabIndex = 6; LabelSkipNum.Text = "Skip first No Damage messages"; LabelSkipNum.UseMnemonic = false; // // TextBoxSkipNum // TextBoxSkipNum.Location = new Point(71, 43); TextBoxSkipNum.Name = "TextBoxSkipNum"; TextBoxSkipNum.Size = new Size(33, 20); TextBoxSkipNum.TabIndex = 7; // // TextBoxDoingDmgMsg // TextBoxDoingDmgMsg.Location = new Point(18, 182); TextBoxDoingDmgMsg.Name = "TextBoxDoingDmgMsg"; TextBoxDoingDmgMsg.Size = new Size(218, 20); TextBoxDoingDmgMsg.TabIndex = 8; // // LabelDmgMsg // LabelDmgMsg.AutoSize = true; LabelDmgMsg.Location = new Point(16, 165); LabelDmgMsg.Name = "LabelDmgMsg"; LabelDmgMsg.Size = new Size(124, 13); LabelDmgMsg.TabIndex = 9; LabelDmgMsg.Text = "Doing Damage Message"; // // CheckBoxPlay // CheckBoxPlay.AutoSize = true; CheckBoxPlay.Location = new Point(253, 184); CheckBoxPlay.Name = "CheckBoxPlay"; CheckBoxPlay.Size = new Size(46, 17); CheckBoxPlay.TabIndex = 10; CheckBoxPlay.Text = "Play"; CheckBoxPlay.UseVisualStyleBackColor = true; // // LabelSkipFight // LabelSkipFight.AutoSize = true; LabelSkipFight.Location = new Point(16, 75); LabelSkipFight.Name = "LabelSkipFight"; LabelSkipFight.Size = new Size(203, 13); LabelSkipFight.TabIndex = 11; LabelSkipFight.Text = "Skip first at beginning of a fight"; // // TextBoxSkipFight // TextBoxSkipFight.Location = new Point(71, 71); TextBoxSkipFight.Name = "TextBoxSkipFight"; TextBoxSkipFight.Size = new Size(33, 20); TextBoxSkipFight.TabIndex = 12; // // GroupBoxIgnore // GroupBoxIgnore.Controls.Add(ButtonRemove); GroupBoxIgnore.Controls.Add(ButtonAdd); GroupBoxIgnore.Controls.Add(ListBoxIgnore); GroupBoxIgnore.Controls.Add(TextBoxIgnore); GroupBoxIgnore.Location = new Point(341, 18); GroupBoxIgnore.Name = "GroupBoxIgnore"; GroupBoxIgnore.Size = new Size(209, 160); GroupBoxIgnore.TabIndex = 13; GroupBoxIgnore.TabStop = false; GroupBoxIgnore.Text = "Ignore MOB containing the word"; // // TextBoxIgnore // TextBoxIgnore.Location = new Point(9, 120); TextBoxIgnore.Name = "TextBoxIgnore"; TextBoxIgnore.Size = new Size(120, 20); TextBoxIgnore.TabIndex = 0; // // ListBoxIgnore // ListBoxIgnore.FormattingEnabled = true; ListBoxIgnore.Location = new Point(9, 19); ListBoxIgnore.Name = "ListBoxIgnore"; ListBoxIgnore.Size = new Size(120, 95); ListBoxIgnore.TabIndex = 1; // // ButtonAdd // ButtonAdd.Location = new Point(135, 117); ButtonAdd.Name = "ButtonAdd"; ButtonAdd.Size = new Size(61, 23); ButtonAdd.TabIndex = 2; ButtonAdd.Text = "Add"; ButtonAdd.UseVisualStyleBackColor = true; // // ButtonRemove // ButtonRemove.Location = new Point(137, 57); ButtonRemove.Name = "ButtonRemove"; ButtonRemove.Size = new Size(59, 23); ButtonRemove.TabIndex = 3; ButtonRemove.Text = "Remove"; ButtonRemove.UseVisualStyleBackColor = true; // // ACTNoDamage // AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; Controls.Add(GroupBoxIgnore); Controls.Add(TextBoxSkipFight); Controls.Add(LabelSkipFight); Controls.Add(CheckBoxPlay); Controls.Add(LabelDmgMsg); Controls.Add(TextBoxDoingDmgMsg); Controls.Add(TextBoxSkipNum); Controls.Add(LabelSkipNum); Controls.Add(TextBoxDelay); Controls.Add(LabelDelay); Controls.Add(LabelNoDmgMsg); Controls.Add(TextBoxNoDmgMsg); Name = "ACTNoDamage"; Size = new Size(685, 504); GroupBoxIgnore.ResumeLayout(false); GroupBoxIgnore.PerformLayout(); ResumeLayout(false); PerformLayout(); } #endregion /******************************************************************************* Constructor : ActDoDamage() Description : Constructor Parameters : None -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ public ACTNoDamage() { /* Defaults */ NoDamageDelay = DEFAULT_NO_DAMAGE_DELAY; SkipMsgCnt = DEFAULT_SKIP_CNT; CurrentSkipMsgCnt = 0; NoDamageMsg = DEFAULT_NO_DAMAGE_MSG; DoingDamageMsg = DEFAULT_DOING_DAMAGE_MSG; DoingDamage = true; PlayDoingDamage = true; Fighting = false; FightingWhat = ""; SkipFightMsgCnt = DEFAULT_FIGHT_SKIP_CNT; CurrentFightSkipCnt = 0; // YOU hit Nerobahan for a Mythical critical of 47316543 piercing damage. // YOU hit Rhag'Voreth for a critical of 47316543 piercing damage. RegexDoingDmg1 = new Regex("YOU (?:multi attack|hit) ([a-zA-Z ']+) for ([a-zA-Z ]+) critical of ([0-9]+)"); // YOUR Divine Vengeance hits Rhag'Voreth for a critical of 157649985 magic damage. // YOUR Divine Vengeance hits Nerobahan for a critical of 157649985 magic damage. RegexDoingDmg2 = new Regex("YOUR ([a-zA-Z ']+) hits ([a-zA-Z ']+) for ([a-zA-Z ]+) critical of ([0-9]+)"); // YOU hit Nerobahan but fail to inflict any damage. // YOU hit Rhag'Voreth but fail to inflict any damage. RegexNoDmg1 = new Regex("YOU hit ([a-zA-Z ']+) but fail to inflict any damage."); // YOUR Field Commander's Charge hits Nerobahan but fails to inflict any damage. // YOUR Marr's Fury hits Rhag'Voreth but fails to inflict any damage. RegexNoDmg2 = new Regex("YOUR ([a-zA-Z ']+) hits ([a-zA-Z ']+) but fails to inflict any damage."); SettingsFile = Path.Combine(ActGlobals.oFormActMain.AppDataFolder.FullName, "Config\\ActNoDamage.config.xml"); LastNoDmgMsgTime = DateTime.Now; LastDoingDamageMsgTime = DateTime.Now; InitializeComponent(); TextBoxNoDmgMsg.TextChanged += TextBoxGetNoDmgMsg_TextChanged; TextBoxDelay.TextChanged += TextBoxDamageDelay_TextChanged; TextBoxDoingDmgMsg.TextChanged += TextBoxDoingDmgMsg_TextChanged; TextBoxSkipNum.TextChanged += TextBoxSkipNum_TextChanged; TextBoxSkipFight.TextChanged += TextBoxSkipFight_TextChanged; CheckBoxPlay.CheckedChanged += CheckBoxPlay_CheckedChanged; ButtonAdd.Click += ButtonAdd_Click; ButtonRemove.Click += ButtonRemove_Click; TextBoxDelay.Text = NoDamageDelay.ToString(); TextBoxNoDmgMsg.Text = NoDamageMsg; TextBoxDoingDmgMsg.Text = DoingDamageMsg; TextBoxSkipNum.Text = SkipMsgCnt.ToString(); TextBoxSkipFight.Text = SkipFightMsgCnt.ToString(); CheckBoxPlay.Checked = PlayDoingDamage; } /******************************************************************************* Function : InitPlugin() Description : Plugin startup Parameters : TabPage pluginScreenSpace - : Label pluginStatusText - Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) { /* Stuff needed for ACT */ pluginScreenSpace.Controls.Add(this); LabelStatus = pluginStatusText; Dock = DockStyle.Fill; xmlSettings = new SettingsSerializer(this); /*----------------------------------------------------------------------------*/ LoadSettings(); /* Get setting from user interface */ GetIgnoreList(); /* Get MOBS to ignore */ GetDelay(); /* Get Delay between no damage messags in log file */ GetNoDmgMsg(); /* Get No Damage message to say */ GetDoingDmgMsg(); /* Get Doing Damage message to say */ GetSkipNum(); /* Get number of no damage log messages to skip before saying message */ GetSkipFightNum(); /* Get number of no damage log messages to skip at start of fight */ GetPlayed(); /* Play or not play Doing Damage message */ ActGlobals.oFormActMain.OnLogLineRead += new LogLineEventDelegate(FormActMain_OnLogLineRead); /* Stuff for ACT updater */ if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed()) new Thread(new ThreadStart(oFormActMain_UpdateCheckClicked)).Start(); LabelStatus.Text = "Plugin Started"; } /******************************************************************************* Function : DeInitPlugin() Description : Leaving plugin Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ public void DeInitPlugin() { ActGlobals.oFormActMain.OnLogLineRead -= FormActMain_OnLogLineRead; SaveSettings(); /* Save settings to config file */ LabelStatus.Text = "Plugin Stopped"; } /******************************************************************************* Function : OFormActMain_OnLogLineRead() Description : Parse a log line Parameters : bool isImport - : LogLineEventArgs logInfo - Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ private void FormActMain_OnLogLineRead(bool isImport, LogLineEventArgs logInfo) { if (isImport) return; CheckFightStatus(logInfo.logLine); /* Are we starting/ending a fight */ if (logInfo.detectedType == 0 || !logInfo.inCombat) return; CheckForNoDmg(logInfo); /* Are we doing no damage */ CheckForDoingDmg(logInfo); /* Are we doing damage */ } /******************************************************************************* Function : CheckForDoingDmg() Description : Check if we are doing damage after a no damage state occurred Parameters : LogLineEventArgs logInfo - Returns : bool -------------------------------------------------------------------------------- History: 2020/01/17 Hiburp Created *******************************************************************************/ bool CheckForDoingDmg(LogLineEventArgs logInfo) { string Name; if (DoingDamage || string.IsNullOrEmpty(FightingWhat)) return(false); Name = ""; RegexResult = RegexDoingDmg1.Match(logInfo.logLine); if (RegexResult.Success) { if (RegexResult.Groups.Count < 1) return(false); Name = RegexResult.Groups[1].Value; /* Get name of MOB fighting */ } else { RegexResult = RegexDoingDmg2.Match(logInfo.logLine); if (!RegexResult.Success) return(false); if (RegexResult.Groups.Count < 2) return(false); Name = RegexResult.Groups[2].Value; /* Get name of MOB fighting */ } if (!FightingWhat.Equals(Name)) /* Not fighting same MOB */ return(false); /*----------------------------------------------------------------------------*/ /* Catch for non hit messages */ if (logInfo.logLine.EndsWith("threat.")) return(false); LabelStatus.Text = string.Format("Doing damage again to {0}", FightingWhat); DoingDamage = true; FightingWhat = ""; CurrentSkipMsgCnt = 0; /* Check for x second delay between saying message */ if (logInfo.detectedTime - LastDoingDamageMsgTime <= new TimeSpan(0, 0, DEFAULT_DOING_DAMAGE_DELAY)) return(true); LastDoingDamageMsgTime = logInfo.detectedTime; if (PlayDoingDamage) /* Play Doing Damage message */ ActGlobals.oFormActMain.TTS(DoingDamageMsg); return(true); } /******************************************************************************* Function : CheckFightStatus() Description : Check if we are in a fight or not Parameters : LogLineEventArgs logInfo Returns : bool -------------------------------------------------------------------------------- History: 2020/01/17 Hiburp Created *******************************************************************************/ bool CheckFightStatus(string logLine) { if (logLine.Contains(START_OF_FIGHT)) /* Started fighting */ { DoingDamage = false; Fighting = true; FightingWhat = ""; LabelStatus.Text = ""; CurrentSkipMsgCnt = 0; CurrentFightSkipCnt = 0; return(true); } if (logLine.Contains(END_OF_FIGHT)) /* Stopped fighting */ { DoingDamage = false; Fighting = false; FightingWhat = ""; LabelStatus.Text = ""; CurrentSkipMsgCnt = 0; CurrentFightSkipCnt = 0; return(false); } return(Fighting); } /******************************************************************************* Function : CheckForNoDmg() Description : Check if we are not doing damage Parameters : LogLineEventArgs logInfo - Returns : bool -------------------------------------------------------------------------------- History: 2020/01/17 Hiburp Created *******************************************************************************/ bool CheckForNoDmg(LogLineEventArgs logInfo) { string Name; if (!Fighting) /* Not in a fight so don't check for damage */ return(false); /* Check for not doing damage message */ RegexResult = RegexNoDmg1.Match(logInfo.logLine); if (RegexResult.Success) { if (RegexResult.Groups.Count < 1) return(false); Name = RegexResult.Groups[1].Value; /* Get name of MOB fighting */ } else { RegexResult = RegexNoDmg2.Match(logInfo.logLine); if (!RegexResult.Success) return(false); if (RegexResult.Groups.Count < 2) return(false); Name = RegexResult.Groups[2].Value; /* Get name of MOB fighting */ } /*----------------------------------------------------------------------------*/ CurrentFightSkipCnt ++; /* Skip first X no damage message right after a fight starts */ if (CurrentFightSkipCnt < SkipFightMsgCnt) return(false); CurrentSkipMsgCnt ++; if (CurrentSkipMsgCnt < SkipMsgCnt) /* Don't act on first X 0 damage found message */ return(false); /*----------------------------------------------------------------------------*/ /* MOBs to skip that give plugin issues */ foreach (string I in IgnoreList) { if (Name.ToLower().Contains(I)) { LabelStatus.Text = string.Format("Skipping no damage checking on [{0}]", Name); return(false); } } /*----------------------------------------------------------------------------*/ FightingWhat = Name; DoingDamage = false; LabelStatus.Text = string.Format("Not doing damage on {0}", FightingWhat); /* Check for x second delay between saying message */ if (logInfo.detectedTime - LastNoDmgMsgTime <= new TimeSpan(0, 0, NoDamageDelay)) return(false); LastNoDmgMsgTime = logInfo.detectedTime; ActGlobals.oFormActMain.TTS(NoDamageMsg); /* Play No Damage done message */ return(true); } /******************************************************************************* Function : LoadSettings() Description : Load setting from config file Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ void LoadSettings() { FileStream FS; XmlTextReader TxtReader; if (!File.Exists(SettingsFile)) return; FS = new FileStream(SettingsFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); TxtReader = new XmlTextReader(FS); try { xmlSettings.AddControlSetting(TextBoxDelay.Name, TextBoxDelay); xmlSettings.AddControlSetting(TextBoxNoDmgMsg.Name, TextBoxNoDmgMsg); xmlSettings.AddControlSetting(TextBoxDoingDmgMsg.Name, TextBoxDoingDmgMsg); xmlSettings.AddControlSetting(TextBoxSkipNum.Name, TextBoxSkipNum); xmlSettings.AddControlSetting(CheckBoxPlay.Name, CheckBoxPlay); xmlSettings.AddControlSetting(ListBoxIgnore.Name, ListBoxIgnore); while (TxtReader.Read()) { if (TxtReader.NodeType == XmlNodeType.Element) { if (TxtReader.LocalName == "SettingsSerializer") { xmlSettings.ImportFromXml(TxtReader); break; } } } } catch (Exception ex) { LabelStatus.Text = "Error loading settings for No Damage Plugin: " + ex.Message; } finally { TxtReader.Close(); } } /******************************************************************************* Function : SaveSettings() Description : Save setting to config file Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ void SaveSettings() { FileStream FS; XmlTextWriter TxtWriter; FS = new FileStream(SettingsFile, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); TxtWriter = new XmlTextWriter(FS, Encoding.UTF8); try { TxtWriter.Formatting = Formatting.Indented; TxtWriter.Indentation = 1; TxtWriter.IndentChar = '\t'; TxtWriter.WriteStartDocument(true); TxtWriter.WriteStartElement("Config"); // TxtWriter.WriteStartElement("SettingsSerializer"); // xmlSettings.ExportToXml(TxtWriter); // Fill the SettingsSerializer XML TxtWriter.WriteEndElement(); // TxtWriter.WriteEndElement(); // TxtWriter.WriteEndDocument(); TxtWriter.Flush(); TxtWriter.Close(); } catch (Exception ex) { LabelStatus.Text = "Error saving settings for No Damage Plugin: " + ex.Message; } } /******************************************************************************* Function : TextBoxDamageDelay_TextChanged() Description : Get delay between no damage message Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ private void TextBoxDamageDelay_TextChanged(object sender, EventArgs e) { GetDelay(); } /******************************************************************************* Function : TextBoxGetNoDmgMsg_TextChanged() Description : Get not doing damage text to play Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ private void TextBoxGetNoDmgMsg_TextChanged(object sender, EventArgs e) { GetNoDmgMsg(); } /******************************************************************************* Function : TextBoxDoingDmgMsg_TextChanged() Description : Get doing damage text to play Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ private void TextBoxDoingDmgMsg_TextChanged(object sender, EventArgs e) { GetDoingDmgMsg(); } /******************************************************************************* Function : TextBoxSkipNum_TextChanged() Description : Get number of messages to skip Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ private void TextBoxSkipNum_TextChanged(object sender, EventArgs e) { GetSkipNum(); } /******************************************************************************* Function : TextBoxSkipFight_TextChanged() Description : Get number of messages to skip at start of fight Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/19 Hiburp Created *******************************************************************************/ private void TextBoxSkipFight_TextChanged(object sender,EventArgs e) { GetSkipFightNum(); } /******************************************************************************* Function : CheckBoxPlay_CheckedChanged() Description : Get check box for Play Doing damage message Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/16 Hiburp Created *******************************************************************************/ private void CheckBoxPlay_CheckedChanged(object sender,EventArgs e) { GetPlayed(); } /******************************************************************************* Function : GetDelay() Description : Get delay between messages Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ void GetDelay() { string Str; Str = TextBoxDelay.Text.Trim(); if (!int.TryParse(Str, out NoDamageDelay)) NoDamageDelay = DEFAULT_NO_DAMAGE_DELAY; } /******************************************************************************* Function : GetDoingDmgMsg() Description : Get message to say when doing damage Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ void GetDoingDmgMsg() { string Str; Str = TextBoxDoingDmgMsg.Text.Trim(); if (string.IsNullOrEmpty(Str)) DoingDamageMsg = DEFAULT_DOING_DAMAGE_MSG; else DoingDamageMsg = Str; } /******************************************************************************* Function : GetSkipNum() Description : Skip first x messages Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ void GetSkipNum() { string Str; Str = TextBoxSkipNum.Text.Trim(); if (!int.TryParse(Str, out SkipMsgCnt)) SkipMsgCnt = DEFAULT_SKIP_CNT; } /******************************************************************************* Function : GetSkipFightNum() Description : Get number of messages to skip at start of fight Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/19 Hiburp Created *******************************************************************************/ void GetSkipFightNum() { string Str; Str = TextBoxSkipFight.Text.Trim(); if (!int.TryParse(Str, out SkipFightMsgCnt)) SkipFightMsgCnt = DEFAULT_FIGHT_SKIP_CNT; } /******************************************************************************* Function : GetNoDmgMsg() Description : Get message to say when doing no damage Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/15 Hiburp Created *******************************************************************************/ void GetNoDmgMsg() { string Str; Str = TextBoxNoDmgMsg.Text.Trim(); if (string.IsNullOrEmpty(Str)) NoDamageMsg = DEFAULT_NO_DAMAGE_MSG; else NoDamageMsg = Str; } /******************************************************************************* Function : GetPlayed() Description : Get play doing damage message status Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/16 Hiburp Created *******************************************************************************/ void GetPlayed() { if (CheckBoxPlay.CheckState == CheckState.Checked) PlayDoingDamage = true; else PlayDoingDamage = false; } /******************************************************************************* Function : ButtonRemove_Click() Description : Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/24 Hiburp Created *******************************************************************************/ void ButtonRemove_Click(object sender,EventArgs e) { string RemoveMOB; if (ListBoxIgnore.SelectedIndex == -1) { MessageBox.Show("Item to remove not selected"); return; } RemoveMOB = ListBoxIgnore.SelectedItem as string; if (MessageBox.Show(string.Format("Remove {0}", RemoveMOB), "Remove MOB", MessageBoxButtons.YesNo) != DialogResult.Yes) return; ListBoxIgnore.Items.Remove(ListBoxIgnore.SelectedItem); GetIgnoreList(); } /******************************************************************************* Function : ButtonAdd_Click() Description : Parameters : object sender - : EventArgs e - Returns : void -------------------------------------------------------------------------------- History: 2020/01/24 Hiburp Created *******************************************************************************/ void ButtonAdd_Click(object sender,EventArgs e) { string IgnoreMOB; IgnoreMOB = TextBoxIgnore.Text.Trim().ToLower(); if (string.IsNullOrEmpty(IgnoreMOB)) { MessageBox.Show("Name to ignore and entered"); return; } ListBoxIgnore.Items.Add(IgnoreMOB); TextBoxIgnore.Text = ""; GetIgnoreList(); } /******************************************************************************* GetIgnoreListDescription : Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/24 Hiburp Created *******************************************************************************/ void GetIgnoreList() { IgnoreList = new List(); foreach (string I in ListBoxIgnore.Items) IgnoreList.Add(I); if (IgnoreList.Count == 0) /* Add default ignore mobs */ { ListBoxIgnore.Items.Add("rockhopper"); /* 'All' rockhoppers */ ListBoxIgnore.Items.Add("zethon"); /* Blood of Luclin PQ */ ListBoxIgnore.Items.Add("venomrock"); /* Blood of Luclin PQ */ GetIgnoreList(); } } /******************************************************************************* Function : oFormActMain_UpdateCheckClicked() Description : Check for plugin updates Parameters : None Returns : void -------------------------------------------------------------------------------- History: 2020/01/13 Hiburp Created *******************************************************************************/ void oFormActMain_UpdateCheckClicked() { ActPluginData PluginData; DateTime LocalDate, RemoteDate; FileInfo FInfo; try { LocalDate = ActGlobals.oFormActMain.PluginGetSelfDateUtc(this); RemoteDate = ActGlobals.oFormActMain.PluginGetRemoteDateUtc(PLUG_ID); if (LocalDate.AddHours(2) >= RemoteDate) return; if (MessageBox.Show("There is an updated version of the ActNoDamage Plugin. Update it now?\n\n(If there is an update to ACT, you should click No and update ACT first.)", "New Version", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return; FInfo = ActGlobals.oFormActMain.PluginDownload(PLUG_ID); PluginData = ActGlobals.oFormActMain.PluginGetSelfData(this); PluginData.pluginFile.Delete(); FInfo.MoveTo(PluginData.pluginFile.FullName); ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, PluginData.cbEnabled, false); // Deinit the old plugin Application.DoEvents(); ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, PluginData.cbEnabled, true); // Init the new version } catch (Exception ex) { ActGlobals.oFormActMain.WriteExceptionLog(ex, "No Damage Plugin Update Check"); } } } /* End Of Class ACTNoDamage */ } /* End Of NameSpace ACTNoDamagePlugin */