diff --git a/EventAI/DBC/DbcReader.cs b/EventAI/DBC/DbcReader.cs index fd9349e..c3ecc4e 100644 --- a/EventAI/DBC/DbcReader.cs +++ b/EventAI/DBC/DbcReader.cs @@ -14,7 +14,7 @@ static class DBCReader string fileName = Path.Combine(DBC.DBC_PATH, (typeof(T).Name).Replace("Entry", String.Empty) + ".dbc"); if (!File.Exists(fileName)) - throw new FileNotFoundException("Not found", fileName); + throw new FileNotFoundException("File not found: " + fileName); using (BinaryReader reader = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read), Encoding.UTF8)) { @@ -23,9 +23,9 @@ static class DBCReader int size = Marshal.SizeOf(typeof(T)); if (!header.IsDBC) - throw new FileNotFoundException("Is not DBC files", fileName); + throw new Exception("Is not DBC files " + fileName); if (header.RecordSize != size) - throw new AIException("Size of row in DBC file ({0}) != size of DBC struct ({1}) in DBC: {2}", header.RecordSize, size, fileName); + throw new Exception(string.Format("Size of row in DBC file ({0}) != size of DBC struct ({1}) in DBC: {2}", header.RecordSize, size, fileName)); // read dbc data for (int r = 0; r < header.RecordsCount; ++r) diff --git a/EventAI/Enums/AIEnums.cs b/EventAI/Enums/AIEnums.cs index 9a0e83d..3af587c 100644 --- a/EventAI/Enums/AIEnums.cs +++ b/EventAI/Enums/AIEnums.cs @@ -107,7 +107,7 @@ public enum EventType /// /// 16 /// - ЕСЛИ_ТЕРЯЕТ_БАФФ = 16, + ЕСЛИ_ДРУЖЕСТВЕННАЯ_ЦЕЛЬ_ТЕРЯЕТ_БАФФ = 16, /// /// 17 /// @@ -127,11 +127,11 @@ public enum EventType /// /// 23 /// - ПРИ_ЗНАЧЕНИИ_БАФФА = 23, + ПРИ_ЗНАЧЕНИИ_АУРЫ = 23, /// /// 24 /// - ПРИ_ЗНАЧЕНИИ_БАФФА_ЦЕЛИ = 24, + ПРИ_ЗНАЧЕНИИ_АУРЫ_ЦЕЛИ = 24, /// /// 25 /// @@ -139,7 +139,15 @@ public enum EventType /// /// 26 /// - ПРИ_ИСЧЕЗНОВЕНИИ_ВЫЗВАННОГО_СУЩЕСТВА = 26 + ПРИ_ИСЧЕЗНОВЕНИИ_ВЫЗВАННОГО_СУЩЕСТВА = 26, + /// + /// 27 + /// + ПРИ_ОТСУТСТВИИ_АУРЫ = 27, + /// + /// 28 + /// + ПРИ_ОТСУТСТВИИ_АУРЫ_ЦЕЛИ = 28, }; public enum ActionType @@ -313,6 +321,10 @@ public enum ActionType /// 42 /// НЕВОЗМОЖНОСТЬ_АТАКОВАТЬ = 42, + /// + /// 43 + /// + ОСЕДЛАТЬ_МАУНТА_ПО_ENTRY_ИЛИ_ИД_МОДЕЛИ = 43, }; public enum ConditionType diff --git a/EventAI/EventAI.csproj b/EventAI/EventAI.csproj index 0e7bfc9..53cf652 100644 --- a/EventAI/EventAI.csproj +++ b/EventAI/EventAI.csproj @@ -96,7 +96,6 @@ FormAboutBox.cs - diff --git a/EventAI/Extensions/AIException.cs b/EventAI/Extensions/AIException.cs deleted file mode 100644 index d474dee..0000000 --- a/EventAI/Extensions/AIException.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace EventAI -{ - class AIException : Exception - { - public AIException(string message, params object[] arg0) - : base(String.Format(message, arg0)) - { - MessageBox.Show(String.Format(message, arg0), - String.Format("{0} ERROR", DBC.VERSION), - MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } -} diff --git a/EventAI/Extensions/ComboBoxExtensions.cs b/EventAI/Extensions/ComboBoxExtensions.cs index abbb4b6..25f314d 100644 --- a/EventAI/Extensions/ComboBoxExtensions.cs +++ b/EventAI/Extensions/ComboBoxExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Data; +using System.Reflection; using System.Collections.Generic; using System.Windows.Forms; @@ -34,58 +35,54 @@ public static int GetIntValue(this TextBox tb) return tb.Text.ToInt32(); } - public static void SetEnumValues(this ComboBox cb, string NoValue="", string remove="", bool size = true) + public static void SetEnumValues(this ComboBox cb, string noValue = "", string remove = "", bool size = true) { - DataTable dt = new DataTable(); - dt.Columns.Add("ID"); - dt.Columns.Add("NAME"); + if (!typeof(T).IsEnum) + throw new ArgumentException("enumeratedType must be an enum"); + + Array enumeratedType = Enum.GetValues(typeof(T)); - if(NoValue!="") - dt.Rows.Add(new Object[] { -1, NoValue }); + if (enumeratedType == null) + throw new NullReferenceException(); - foreach (var str in Enum.GetValues(typeof(T))) - { - dt.Rows.Add(new Object[] - { - (int)str, - "(" + ((int)str).ToString("00") + ") " + str.ToString().NormaliseString(remove) - }); - } + var list = new List>(); + if (noValue != "") + list.Add(new KeyValuePair(-1, noValue)); - if(size) - cb.Size = new System.Drawing.Size(238, 21); + foreach (var value in enumeratedType) + list.Add(new KeyValuePair((int)value, + "(" + ((int)value).ToString("00") + ") " + value.ToString().NormaliseString(remove))); - cb.DropDownStyle = ComboBoxStyle.DropDownList; - cb.DataSource = dt; - cb.DisplayMember = "NAME"; - cb.ValueMember = "ID"; + if (size) cb.Size = new System.Drawing.Size(238, 21); + cb.DropDownStyle = ComboBoxStyle.DropDownList; + cb.DataSource = list; + cb.ValueMember = "Key"; + cb.DisplayMember = "Value"; } public static void SetDbcData(this ComboBox cb, Dictionary dict, string noValue = null) { - DataTable dt = new DataTable(); - dt.Columns.Add("ID"); - dt.Columns.Add("NAME"); - if (dict == null) return; + + var list = new List>(); if (noValue != null) - dt.Rows.Add(new Object[] { -1, noValue }); + list.Add(new KeyValuePair(-1, noValue)); foreach (var str in dict.Values) { - uint ID = str.GetType().GetField("ID").GetValue(str).ToUInt32(); - var Name = str.GetType().GetProperty("Name").GetValue(str, null); + int ID = str.GetType().GetField("ID").GetValue(str).ToInt32(); + var Name = str.GetType().GetProperty("Name").GetValue(str, null).ToString(); - dt.Rows.Add(new Object[] { ID, "(" + ID.ToString("000") + ") " + Name }); + list.Add(new KeyValuePair(ID, string.Format("({0:000}) {1}", ID, Name))); } - cb.DataSource = dt; - cb.DisplayMember = "NAME"; - cb.ValueMember = "ID"; cb.DropDownStyle = ComboBoxStyle.DropDownList; cb.Size = ComboboxSize; + cb.DataSource = list; + cb.ValueMember = "Key"; + cb.DisplayMember = "Value"; } } } diff --git a/EventAI/Forms/ButtonHandler.cs b/EventAI/Forms/ButtonHandler.cs index 56747e6..e2e1f70 100644 --- a/EventAI/Forms/ButtonHandler.cs +++ b/EventAI/Forms/ButtonHandler.cs @@ -36,7 +36,7 @@ private Size ComboboxSize get { return new Size(180, 21); } } - private FormMain MatherForm + private FormMain ParentForm { get { return (FormMain)_combobox.FindForm(); } } @@ -111,13 +111,13 @@ private void ShowForm(object sender, EventArgs e) case BType.TEXT: { MySQLConnenct.SelectAIText(); - MatherForm._tPanel.SelectedIndex = 1; + ParentForm._tPanel.SelectedIndex = 1; } break; case BType.SUMMON: { MySQLConnenct.SelectAIText(); - MatherForm._tPanel.SelectedIndex = 2; + ParentForm._tPanel.SelectedIndex = 2; } break; default: diff --git a/EventAI/Forms/FormMain.Designer.cs b/EventAI/Forms/FormMain.Designer.cs index 7ba2f0b..034319e 100644 --- a/EventAI/Forms/FormMain.Designer.cs +++ b/EventAI/Forms/FormMain.Designer.cs @@ -466,7 +466,7 @@ private void InitializeComponent() "4-Инстанс(Нормальный режим 25)", "8-Инстанс(Героический режим 10)", "16-Инстанс(Героический режим 25)", - "32-Зарезервировано(Не используется)", + "32-Случайное действие", "64-Зарезервировано(Не используется)", "128-Отладка(Debug)"}); this._clbEventFlag.Location = new System.Drawing.Point(3, 16); diff --git a/EventAI/Forms/FormMain.cs b/EventAI/Forms/FormMain.cs index af8ca46..ce1b750 100644 --- a/EventAI/Forms/FormMain.cs +++ b/EventAI/Forms/FormMain.cs @@ -128,9 +128,8 @@ private void _clbEventFlag_SelectedValueChanged(object sender, EventArgs e) private void clbEventFlag_SelectedIndexChanged(object sender, EventArgs e) { - if (_clbEventFlag.SelectedIndex == 5 || _clbEventFlag.SelectedIndex == 6) + if (_clbEventFlag.SelectedIndex == 6) { - _clbEventFlag.SetItemChecked(5, false); _clbEventFlag.SetItemChecked(6, false); MessageBox.Show("Нельзя использовать зарезирвированые флаги!"); } diff --git a/EventAI/Info/Inscription.cs b/EventAI/Info/Inscription.cs index 57274b5..7af1ccd 100644 --- a/EventAI/Info/Inscription.cs +++ b/EventAI/Info/Inscription.cs @@ -184,6 +184,11 @@ public static void ShowActionParametr(ComboBox combobox, ComboBox cb1, ComboBox l2.Text = "При значении жизни"; cb1.SetEnumValues(); break; + case ActionType.ОСЕДЛАТЬ_МАУНТА_ПО_ENTRY_ИЛИ_ИД_МОДЕЛИ: + l1.Text = "Существо"; + l2.Text = "Модель"; + new ButtonHandler(cb1, BType.CREATURE); + break; } cb1.Visible = l1.Text != string.Empty; @@ -257,7 +262,7 @@ public static void ShowEventType(ComboBox combobox, ComboBox cb1, ComboBox cb2, l3.Text = "Минимальное время до повтора (мс)"; l4.Text = "Максимальное время до повтора (мс)"; break; - case EventType.ЕСЛИ_ТЕРЯЕТ_БАФФ: + case EventType.ЕСЛИ_ДРУЖЕСТВЕННАЯ_ЦЕЛЬ_ТЕРЯЕТ_БАФФ: l1.Text = "ID спелла (заклинания)"; new ButtonHandler(cb1, BType.SPELL); l2.Text = "В радиусе"; @@ -276,8 +281,10 @@ public static void ShowEventType(ComboBox combobox, ComboBox cb1, ComboBox cb2, cb1.SetDbcData(DBC.Emotes); cb2.SetEnumValues(); break; - case EventType.ПРИ_ЗНАЧЕНИИ_БАФФА: - case EventType.ПРИ_ЗНАЧЕНИИ_БАФФА_ЦЕЛИ: + case EventType.ПРИ_ЗНАЧЕНИИ_АУРЫ: + case EventType.ПРИ_ЗНАЧЕНИИ_АУРЫ_ЦЕЛИ: + case EventType.ПРИ_ОТСУТСТВИИ_АУРЫ: + case EventType.ПРИ_ОТСУТСТВИИ_АУРЫ_ЦЕЛИ: l1.Text = "ID спелла"; new ButtonHandler(cb1, BType.SPELL); l2.Text = "Количество"; diff --git a/EventAI/Program.cs b/EventAI/Program.cs index d8e576c..1bf8b8e 100644 --- a/EventAI/Program.cs +++ b/EventAI/Program.cs @@ -25,16 +25,21 @@ static void Main() Application.Exit(); return; } - - new Thread(LoadDBC).Start(); - - Application.Run(new FormMain()); + try + { + LoadDBC(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return; + } + Application.Run(new FormMain()); } private static void LoadDBC() { DBC.Spell = DBCReader.ReadDBC(DBC._SpellStrings); - DBC.SkillLine = DBCReader.ReadDBC(DBC._SkillLineStrings); DBC.SpellRange = DBCReader.ReadDBC(DBC._SpellRangeStrings); DBC.Emotes = DBCReader.ReadDBC(DBC._EmotesStrings); @@ -44,29 +49,24 @@ private static void LoadDBC() DBC.CreatureFamily = DBCReader.ReadDBC(DBC._CreatureFamilyStrings); DBC.CreatureType = DBCReader.ReadDBC(DBC._CreatureTypeStrings); DBC.QuestType = DBCReader.ReadDBC(DBC._QuestInfoStrings); - DBC.SpellDuration = DBCReader.ReadDBC(); DBC.SkillLineAbility = DBCReader.ReadDBC(); DBC.SpellRadius = DBCReader.ReadDBC(); DBC.SpellCastTimes = DBCReader.ReadDBC(); - DBC.Locale = DetectedLocale; + DBC.Locale = DetectedLocale(); } - private static LocalesDBC DetectedLocale + private static LocalesDBC DetectedLocale() { - get + byte locale = 0; + while (DBC.Spell[1].GetName(locale) == String.Empty) { - byte locale = 0; - while (DBC.Spell[1].GetName(locale) == String.Empty) - { - ++locale; - - if (locale >= DBC.MAX_DBC_LOCALE) - throw new AIException("Detected unknown locale index {0}", locale); - } - return (LocalesDBC)locale; + ++locale; + if (locale >= DBC.MAX_DBC_LOCALE) + throw new Exception("Detected unknown locale index " + locale); } + return (LocalesDBC)locale; } } } diff --git a/EventAI/bin/Debug/EventAI.exe b/EventAI/bin/Debug/EventAI.exe index a2d4e95..264a40c 100644 Binary files a/EventAI/bin/Debug/EventAI.exe and b/EventAI/bin/Debug/EventAI.exe differ diff --git a/README b/README index d850d34..cc6545e 100644 --- a/README +++ b/README @@ -78,15 +78,17 @@ Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_E 13 EVENT_T_TARGET_CASTING RepeatMin, RepeatatMax Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2). 14 EVENT_T_FRIENDLY_HP HPDeficit, Radius, RepeatMin, RepeatMax Expires when a friendly unit in radius has at least (Param1) HP missing. Will repeat every (Param3) and (Param4). 15 EVENT_T_FRIENDLY_IS_CC DispelType, Radius, RepeatMin, RepeatMax Expires when a friendly unit is crowd controlled within the given radius (Param2). Will repeat every (Param3) and (Param4). -16 EVENT_T_MISSING_BUFF SpellId, Radius, RepeatMin, RepeatMax Expires when a friendly unit is missing aura(s) given by a spell (Param1) within radius (Param2). Will repeat every (Param3) and (Param4). +16 EVENT_T_FRIENDLY_MISSING_BUFF SpellId, Radius, RepeatMin, RepeatMax Expires when a friendly unit is missing aura(s) given by a spell (Param1) within radius (Param2). Will repeat every (Param3) and (Param4). 17 EVENT_T_SUMMONED_UNIT CreatureId, RepeatMin, RepeatMax Expires after creature with entry = (Param1) is spawned (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). 18 EVENT_T_TARGET_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax Expires when current target's Mana is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). 21 EVENT_T_REACHED_HOME NONE Expires when a creature reaches it's home (spawn) location after evade. 22 EVENT_T_RECEIVE_EMOTE EmoteId, Condition, CondValue1, CondValue2 Expires when a creature receives an emote with emote text id (enum TextEmotes) in (Param1). Conditions can be defined (Param2) with optional values (Param3,Param4), see enum ConditionType. -23 EVENT_T_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). -24 EVENT_T_TARGET_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a target unit has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). +23 EVENT_T_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). +24 EVENT_T_TARGET_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when the current target unit has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). 25 EVENT_T_SUMMONED_JUST_DIED CreatureId, RepeatMin, RepeatMax Expires after creature with entry = (Param1) is die (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). 26 EVENT_T_SUMMONED_JUST_DESPAWN CreatureId, RepeatMin, RepeatMax Expires before creature with entry = (Param1) is despawn (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). +27 EVENT_T_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). +28 EVENT_T_TARGET_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when when the current target unit not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). ========================================= @@ -142,6 +144,7 @@ For all ACTION_T_RANDOM, When a Particular Param is selected for the Event... Th 40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon). 41 ACTION_T_FORCE_DESPAWN Delay Despawns the creature, if delay = 0 immediate otherwise will despawn after delay time set in Param1 (in ms). 42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL HP_Level, HP_Percent Set min. health level for creature that can be set at damage as flat value or percent from max health +43 ACTION_T_MOUNT_TO_ENTRY_OR_MODEL CreatureEntry, ModelId Set mount model from creature_template.entry (Param1) OR explicit modelId (Param2). If (Param1) AND (Param2) are both 0, unmount. * = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2). @@ -829,9 +832,9 @@ Below is the list of current Event Flags that EventAI can handle. Event flags ar 2 4 EFLAG_DIFFICULTY_1 Event occurs in instance difficulty 1 (will not occur if not set) 3 8 EFLAG_DIFFICULTY_2 Event occurs in instance difficulty 2 (will not occur if not set) 4 16 EFLAG_DIFFICULTY_3 Event occurs in instance difficulty 3 (will not occur if not set) -5 32 +5 32 EFLAG_RANDOM_ACTION At event occur execute one random action from event actions instead all actions. 6 64 -7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. +7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. NOTE: You can add the numbers in the decimal column to combine flags. @@ -903,4 +906,4 @@ This is the Race Language that the text is native to (So it will display properl 35 DRAENEI Text in this language is understood ONLY by the Draenai Race. 36 ZOMBIE (not currently used?) 37 GNOMISH BINARY Binary language used by Alliance when drinking Binary Brew -38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew +38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew \ No newline at end of file