private void ParseScriptsData(ScriptAI script) { _tbScriptID.Text = script.ID.ToString(); _tbEntryNpc.Text = script.NpcEntry.ToString(); _tbShance.Text = script.Chance.ToString(); _clbEventFlag.SetCheckedItemFromFlag((uint)script.Flags); _clbPhase.SetCheckedItemFromFlag((uint)script.Phase); _cbEventType.SelectedValue = script.EventType; _cbEventParametr1.SetValue(script.EventParam[0]); _cbEventParametr2.SetValue(script.EventParam[1]); _cbEventParametr3.SetValue(script.EventParam[2]); _cbEventParametr4.SetValue(script.EventParam[3]); _cbActionType1.SetValue(script.ActionType[0]); _cbActionParam1_1.SetValue(script.ActionParam[0, 0]); _cbActionParam1_2.SetValue(script.ActionParam[0, 1]); _cbActionParam1_3.SetValue(script.ActionParam[0, 2]); _cbActionType2.SetValue(script.ActionType[1]); _cbActionParam2_1.SetValue(script.ActionParam[1, 0]); _cbActionParam2_2.SetValue(script.ActionParam[1, 1]); _cbActionParam2_3.SetValue(script.ActionParam[1, 2]); _cbActionType3.SetValue(script.ActionType[2]); _cbActionParam3_1.SetValue(script.ActionParam[2, 0]); _cbActionParam3_2.SetValue(script.ActionParam[2, 1]); _cbActionParam3_3.SetValue(script.ActionParam[2, 2]); _tbComment.Text = script.Comment; }
public static void SelectAIScript(string query) { if (!IsConnected) { System.Windows.Forms.MessageBox.Show("No connection to database, please check settings", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (_conn = new MySqlConnection(ConnectionString)) { _command = new MySqlCommand(query, _conn); _conn.Open(); _AIScript.Clear(); using (var reader = _command.ExecuteReader()) { while (reader.Read()) { ScriptAI script = new ScriptAI(); script.ID = reader[0].ToInt32(); script.NpcEntry = reader[1].ToInt32(); script.EventType = reader[2].ToInt32(); script.Phase = reader[3].ToInt32(); script.Chance = reader[4].ToInt32(); script.Flags = reader[5].ToInt32(); script.EventParam[0] = reader[6].ToInt32(); script.EventParam[1] = reader[7].ToInt32(); script.EventParam[2] = reader[8].ToInt32(); script.EventParam[3] = reader[9].ToInt32(); script.ActionType[0] = reader[10].ToInt32(); script.ActionParam[0, 0] = reader[11].ToInt32(); script.ActionParam[0, 1] = reader[12].ToInt32(); script.ActionParam[0, 2] = reader[13].ToInt32(); script.ActionType[1] = reader[14].ToInt32(); script.ActionParam[1, 0] = reader[15].ToInt32(); script.ActionParam[1, 1] = reader[16].ToInt32(); script.ActionParam[1, 2] = reader[17].ToInt32(); script.ActionType[2] = reader[18].ToInt32(); script.ActionParam[2, 0] = reader[19].ToInt32(); script.ActionParam[2, 1] = reader[20].ToInt32(); script.ActionParam[2, 2] = reader[21].ToInt32(); script.Comment = reader[22].ToString(); _AIScript.Add(script); } } _conn.Close(); } }
public static void SelectAIScript(string query) { if (!IsConnected) { return; } using (_conn = new MySqlConnection(ConnectionString)) { _command = new MySqlCommand(query, _conn); _conn.Open(); _AIScript.Clear(); using (var reader = _command.ExecuteReader()) { while (reader.Read()) { ScriptAI script = new ScriptAI(); script.ID = reader[0].ToInt32(); script.NpcEntry = reader[1].ToInt32(); script.EventType = reader[2].ToInt32(); script.Phase = reader[3].ToInt32(); script.Chance = reader[4].ToInt32(); script.Flags = reader[5].ToInt32(); script.EventParam[0] = reader[6].ToInt32(); script.EventParam[1] = reader[7].ToInt32(); script.EventParam[2] = reader[8].ToInt32(); script.EventParam[3] = reader[9].ToInt32(); script.ActionType[0] = reader[10].ToInt32(); script.ActionParam[0, 0] = reader[11].ToInt32(); script.ActionParam[0, 1] = reader[12].ToInt32(); script.ActionParam[0, 2] = reader[13].ToInt32(); script.ActionType[1] = reader[14].ToInt32(); script.ActionParam[1, 0] = reader[15].ToInt32(); script.ActionParam[1, 1] = reader[16].ToInt32(); script.ActionParam[1, 2] = reader[17].ToInt32(); script.ActionType[2] = reader[18].ToInt32(); script.ActionParam[2, 0] = reader[19].ToInt32(); script.ActionParam[2, 1] = reader[20].ToInt32(); script.ActionParam[2, 2] = reader[21].ToInt32(); script.Comment = reader[22].ToString(); _AIScript.Add(script); } } } }
private void CreateAIScript_Click(object sender, EventArgs e) { err = false; rtbScriptOut.Clear(); rtbScriptOut.ForeColor = Color.Blue; ScriptAI script = new ScriptAI(); script.ID = _tbScriptID.Text.ToInt32(); script.NpcEntry = _tbEntryNpc.Text.ToInt32(); script.EventType = _cbEventType.GetIntValue(); script.Phase = _clbPhase.GetFlagsValue(); script.Chance = _tbShance.Text.ToInt32(); script.Flags = _clbEventFlag.GetFlagsValue(); script.EventParam[0] = _cbEventParametr1.GetIntValue(); script.EventParam[1] = _cbEventParametr2.GetIntValue(); script.EventParam[2] = _cbEventParametr3.GetIntValue(); script.EventParam[3] = _cbEventParametr4.GetIntValue(); script.ActionType[0] = _cbActionType1.GetIntValue(); script.ActionParam[0, 0] = _cbActionParam1_1.GetIntValue(); script.ActionParam[0, 1] = _cbActionParam1_2.GetIntValue(); script.ActionParam[0, 2] = _cbActionParam1_3.GetIntValue(); script.ActionType[1] = _cbActionType2.GetIntValue(); script.ActionParam[1, 0] = _cbActionParam2_1.GetIntValue(); script.ActionParam[1, 1] = _cbActionParam2_2.GetIntValue(); script.ActionParam[1, 2] = _cbActionParam2_3.GetIntValue(); script.ActionType[2] = _cbActionType3.GetIntValue(); script.ActionParam[2, 0] = _cbActionParam3_1.GetIntValue(); script.ActionParam[2, 1] = _cbActionParam3_2.GetIntValue(); script.ActionParam[2, 2] = _cbActionParam3_3.GetIntValue(); script.Comment = _tbComment.Text; #region Проверки if (script.ID < 1) LogOut("Номен скрипта должен быть больше 0!"); if (script.Chance == 0 || script.Chance > 100) LogOut("Шанс срабатывания должен быть 0 и не больше 100%!"); switch ((EventType)script.EventType) { case EventType.ПО_ТАЙМЕРУ_В_БОЮ: case EventType.ПО_ТАЙМЕРУ_ВНЕ_БОЯ: if (script.EventParam[0] > script.EventParam[1]) LogOut("Минимальное время до срабатывания не может быть больше максимального!"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ: case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ: case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ_ЦЕЛИ: case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ_У_ЦЕЛИ: if (script.EventParam[0] > 100 || script.EventParam[1] > 100) LogOut("Параметр 1 или 2 не могут быть болше 100%!"); if (script.EventParam[1] > script.EventParam[0]) LogOut("Минимальное значение жизни(маны) не может быть больше максимального!"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; case EventType.ПРИ_УБИЙСТВЕ_ЦЕЛИ: if (script.EventParam[0] > script.EventParam[1]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; case EventType.ПРИ_УРОНЕ_ЗАКЛИНАНИЕМ: if (script.EventParam[2] > script.EventParam[3]) LogOut("Минимальное время до повтора не может быть больше максимального!"); if (script.EventParam[0] > 0 && script.EventParam[1] > -1) LogOut("Если указано значение \"ID Заклинания\", тогда значение \"Школа\" должно быть (-1), иначе \"ИД заклинания\" должно быть (0)"); break; case EventType.ПРИ_ДИСТАНЦИИ: if (script.EventParam[0] > script.EventParam[1]) LogOut("Минимальная дистанция до цели не может быть больше максимальной!"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; case EventType.ПРИ_ПОЯВЛЕНИИ_В_ЗОНЕ_ВИДИМОСТИ: if (script.EventParam[2] > script.EventParam[3]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; case EventType.ЕСЛИ_ЦЕЛЬ_ЧИТАЕТ_ЗАКЛИНАНИЕ: if (script.EventParam[0] > script.EventParam[1]) LogOut("Минимальное время до повтора не может быть больше максимального!"); break; } if (err) { _bWriteFiles.Enabled = false; return; } #endregion StringBuilder sb = new StringBuilder(); sb.AppendFormatLine("UPDATE `creature_template` SET `AIName` = 'EventAI' WHERE `entry` = '{0}';", script.NpcEntry); sb.AppendFormatLine("DELETE FROM `creature_ai_scripts` WHERE (`id`='{0}');", script.ID); sb.AppendFormatLine("INSERT INTO `creature_ai_scripts` VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}');", script.ID, script.NpcEntry, script.EventType, script.Phase, script.Chance, script.Flags, script.EventParam[0], script.EventParam[1], script.EventParam[2], script.EventParam[3], script.ActionType[0], script.ActionParam[0, 0], script.ActionParam[0, 1], script.ActionParam[0, 2], script.ActionType[1], script.ActionParam[1, 0], script.ActionParam[1, 1], script.ActionParam[1, 2], script.ActionType[2], script.ActionParam[2, 0], script.ActionParam[2, 1], script.ActionParam[2, 2], script.Comment.RemExc()); rtbScriptOut.Text = sb.ToString(); _bWriteFiles.Enabled = true; }
private void CreateAIScript_Click(object sender, EventArgs e) { err = false; rtbScriptOut.Clear(); rtbScriptOut.ForeColor = Color.Blue; ScriptAI script = new ScriptAI(); script.ID = _tbScriptID.Text.ToInt32(); script.NpcEntry = _tbEntryNpc.Text.ToInt32(); script.EventType = _cbEventType.GetIntValue(); script.Phase = _clbPhase.GetFlagsValue(); script.Chance = _tbShance.Text.ToInt32(); script.Flags = _clbEventFlag.GetFlagsValue(); script.EventParam[0] = _cbEventParametr1.GetIntValue(); script.EventParam[1] = _cbEventParametr2.GetIntValue(); script.EventParam[2] = _cbEventParametr3.GetIntValue(); script.EventParam[3] = _cbEventParametr4.GetIntValue(); script.ActionType[0] = _cbActionType1.GetIntValue(); script.ActionParam[0, 0] = _cbActionParam1_1.GetIntValue(); script.ActionParam[0, 1] = _cbActionParam1_2.GetIntValue(); script.ActionParam[0, 2] = _cbActionParam1_3.GetIntValue(); script.ActionType[1] = _cbActionType2.GetIntValue(); script.ActionParam[1, 0] = _cbActionParam2_1.GetIntValue(); script.ActionParam[1, 1] = _cbActionParam2_2.GetIntValue(); script.ActionParam[1, 2] = _cbActionParam2_3.GetIntValue(); script.ActionType[2] = _cbActionType3.GetIntValue(); script.ActionParam[2, 0] = _cbActionParam3_1.GetIntValue(); script.ActionParam[2, 1] = _cbActionParam3_2.GetIntValue(); script.ActionParam[2, 2] = _cbActionParam3_3.GetIntValue(); script.Comment = _tbComment.Text; #region Check if (script.ID < 1) LogOut("Script must have value greater than 0!"); if (script.Chance == 0 || script.Chance > 100) LogOut("Proc must be 0 or greater than 100%!"); switch ((EventType)script.EventType) { case EventType.TIMER: case EventType.TIMER_OOC: if (script.EventParam[0] > script.EventParam[1]) LogOut("Minimum time can not be greater than the maximum!"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; case EventType.HP: case EventType.MANA: case EventType.TARGET_HP: case EventType.TARGET_MANA: if (script.EventParam[0] > 100 || script.EventParam[1] > 100) LogOut("Option 1 or 2 can not be greater 100%!"); if (script.EventParam[1] > script.EventParam[0]) LogOut("The minimum value of life (MP) can not be greater than the maximum!"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; case EventType.KILL: if (script.EventParam[0] > script.EventParam[1]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; case EventType.SPELLHIT: if (script.EventParam[2] > script.EventParam[3]) LogOut("Minimum time to repeat can not be greater than the maximum!"); if (script.EventParam[0] > 0 && script.EventParam[1] > -1) LogOut(@"If set to \ ID Spells \, then the value of \ School \ must be (-1), otherwise \ id spell \ must be (0)"); break; case EventType.RANGE: if (script.EventParam[0] > script.EventParam[1]) LogOut("The minimum distance to the target can not be greater than the maximum"); if (script.EventParam[2] > script.EventParam[3]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; case EventType.OOC_LOS: if (script.EventParam[2] > script.EventParam[3]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; case EventType.TARGET_CASTING: if (script.EventParam[0] > script.EventParam[1]) LogOut("Minimum time to repeat can not be greater than the maximum!"); break; } if (err) { _bWriteFiles.Enabled = false; return; } #endregion StringBuilder sb = new StringBuilder(); sb.AppendFormatLine("UPDATE `creature_template` SET `AIName` = 'EventAI', `ScriptName` = '' WHERE `entry` = '{0}';", script.NpcEntry); sb.AppendFormatLine("DELETE FROM `creature_ai_scripts` WHERE (`id`='{0}');", script.ID); sb.AppendFormatLine("INSERT INTO `creature_ai_scripts` VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}');", script.ID, script.NpcEntry, script.EventType, script.Phase, script.Chance, script.Flags, script.EventParam[0], script.EventParam[1], script.EventParam[2], script.EventParam[3], script.ActionType[0], script.ActionParam[0, 0], script.ActionParam[0, 1], script.ActionParam[0, 2], script.ActionType[1], script.ActionParam[1, 0], script.ActionParam[1, 1], script.ActionParam[1, 2], script.ActionType[2], script.ActionParam[2, 0], script.ActionParam[2, 1], script.ActionParam[2, 2], script.Comment.RemExc()); rtbScriptOut.Text = sb.ToString(); _bWriteFiles.Enabled = true; }
private void CreateAIScript_Click(object sender, EventArgs e) { err = false; rtbScriptOut.Clear(); rtbScriptOut.ForeColor = Color.Blue; ScriptAI script = new ScriptAI(); script.ID = _tbScriptID.Text.ToInt32(); script.NpcEntry = _tbEntryNpc.Text.ToInt32(); script.EventType = _cbEventType.GetIntValue(); script.Phase = _clbPhase.GetFlagsValue(); script.Chance = _tbShance.Text.ToInt32(); script.Flags = _clbEventFlag.GetFlagsValue(); script.EventParam[0] = _cbEventParametr1.GetIntValue(); script.EventParam[1] = _cbEventParametr2.GetIntValue(); script.EventParam[2] = _cbEventParametr3.GetIntValue(); script.EventParam[3] = _cbEventParametr4.GetIntValue(); script.ActionType[0] = _cbActionType1.GetIntValue(); script.ActionParam[0, 0] = _cbActionParam1_1.GetIntValue(); script.ActionParam[0, 1] = _cbActionParam1_2.GetIntValue(); script.ActionParam[0, 2] = _cbActionParam1_3.GetIntValue(); script.ActionType[1] = _cbActionType2.GetIntValue(); script.ActionParam[1, 0] = _cbActionParam2_1.GetIntValue(); script.ActionParam[1, 1] = _cbActionParam2_2.GetIntValue(); script.ActionParam[1, 2] = _cbActionParam2_3.GetIntValue(); script.ActionType[2] = _cbActionType3.GetIntValue(); script.ActionParam[2, 0] = _cbActionParam3_1.GetIntValue(); script.ActionParam[2, 1] = _cbActionParam3_2.GetIntValue(); script.ActionParam[2, 2] = _cbActionParam3_3.GetIntValue(); script.Comment = _tbComment.Text; #region Проверки if (script.ID < 1) { LogOut("Номен скрипта должен быть больше 0!"); } if (script.Chance == 0 || script.Chance > 100) { LogOut("Шанс срабатывания должен быть 0 и не больше 100%!"); } switch ((EventType)script.EventType) { case EventType.ПО_ТАЙМЕРУ_В_БОЮ: case EventType.ПО_ТАЙМЕРУ_ВНЕ_БОЯ: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Минимальное время до срабатывания не может быть больше максимального!"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ: case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ: case EventType.ПРИ_ЗНАЧЕНИИ_ЖИЗНИ_ЦЕЛИ: case EventType.ПРИ_ЗНАЧЕНИИ_МАНЫ_У_ЦЕЛИ: if (script.EventParam[0] > 100 || script.EventParam[1] > 100) { LogOut("Параметр 1 или 2 не могут быть болше 100%!"); } if (script.EventParam[1] > script.EventParam[0]) { LogOut("Минимальное значение жизни(маны) не может быть больше максимального!"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; case EventType.ПРИ_УБИЙСТВЕ_ЦЕЛИ: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; case EventType.ПРИ_УРОНЕ_ЗАКЛИНАНИЕМ: if (script.EventParam[2] > script.EventParam[3]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } if (script.EventParam[0] > 0 && script.EventParam[1] > -1) { LogOut("Если указано значение \"ID Заклинания\", тогда значение \"Школа\" должно быть (-1), иначе \"ИД заклинания\" должно быть (0)"); } break; case EventType.ПРИ_ДИСТАНЦИИ: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Минимальная дистанция до цели не может быть больше максимальной!"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; case EventType.ПРИ_ПОЯВЛЕНИИ_В_ЗОНЕ_ВИДИМОСТИ: if (script.EventParam[2] > script.EventParam[3]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; case EventType.ЕСЛИ_ЦЕЛЬ_ЧИТАЕТ_ЗАКЛИНАНИЕ: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Минимальное время до повтора не может быть больше максимального!"); } break; } if (err) { _bWriteFiles.Enabled = false; return; } #endregion StringBuilder sb = new StringBuilder(); sb.AppendFormatLine("UPDATE `creature_template` SET `AIName` = 'EventAI' WHERE `entry` = '{0}';", script.NpcEntry); sb.AppendFormatLine("DELETE FROM `creature_ai_scripts` WHERE (`id`='{0}');", script.ID); sb.AppendFormatLine("INSERT INTO `creature_ai_scripts` VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}');", script.ID, script.NpcEntry, script.EventType, script.Phase, script.Chance, script.Flags, script.EventParam[0], script.EventParam[1], script.EventParam[2], script.EventParam[3], script.ActionType[0], script.ActionParam[0, 0], script.ActionParam[0, 1], script.ActionParam[0, 2], script.ActionType[1], script.ActionParam[1, 0], script.ActionParam[1, 1], script.ActionParam[1, 2], script.ActionType[2], script.ActionParam[2, 0], script.ActionParam[2, 1], script.ActionParam[2, 2], script.Comment.RemExc()); rtbScriptOut.Text = sb.ToString(); _bWriteFiles.Enabled = true; }
public static void SelectAIScript(string query) { if (!IsConnected) return; using (_conn = new MySqlConnection(ConnectionString)) { _command = new MySqlCommand(query, _conn); _conn.Open(); _AIScript.Clear(); using (var reader = _command.ExecuteReader()) { while (reader.Read()) { ScriptAI script = new ScriptAI(); script.ID = reader[0].ToInt32(); script.NpcEntry = reader[1].ToInt32(); script.EventType = reader[2].ToInt32(); script.Phase = reader[3].ToInt32(); script.Chance = reader[4].ToInt32(); script.Flags = reader[5].ToInt32(); script.EventParam[0] = reader[6].ToInt32(); script.EventParam[1] = reader[7].ToInt32(); script.EventParam[2] = reader[8].ToInt32(); script.EventParam[3] = reader[9].ToInt32(); script.ActionType[0] = reader[10].ToInt32(); script.ActionParam[0, 0] = reader[11].ToInt32(); script.ActionParam[0, 1] = reader[12].ToInt32(); script.ActionParam[0, 2] = reader[13].ToInt32(); script.ActionType[1] = reader[14].ToInt32(); script.ActionParam[1, 0] = reader[15].ToInt32(); script.ActionParam[1, 1] = reader[16].ToInt32(); script.ActionParam[1, 2] = reader[17].ToInt32(); script.ActionType[2] = reader[18].ToInt32(); script.ActionParam[2, 0] = reader[19].ToInt32(); script.ActionParam[2, 1] = reader[20].ToInt32(); script.ActionParam[2, 2] = reader[21].ToInt32(); script.Comment = reader[22].ToString(); _AIScript.Add(script); } } } }
private void CreateAIScript_Click(object sender, EventArgs e) { err = false; rtbScriptOut.Clear(); rtbScriptOut.ForeColor = Color.Blue; ScriptAI script = new ScriptAI(); script.ID = _tbScriptID.Text.ToInt32(); script.NpcEntry = _tbEntryNpc.Text.ToInt32(); script.EventType = _cbEventType.GetIntValue(); script.Phase = _clbPhase.GetFlagsValue(); script.Chance = _tbShance.Text.ToInt32(); script.Flags = _clbEventFlag.GetFlagsValue(); script.EventParam[0] = _cbEventParametr1.GetIntValue(); script.EventParam[1] = _cbEventParametr2.GetIntValue(); script.EventParam[2] = _cbEventParametr3.GetIntValue(); script.EventParam[3] = _cbEventParametr4.GetIntValue(); script.ActionType[0] = _cbActionType1.GetIntValue(); script.ActionParam[0, 0] = _cbActionParam1_1.GetIntValue(); script.ActionParam[0, 1] = _cbActionParam1_2.GetIntValue(); script.ActionParam[0, 2] = _cbActionParam1_3.GetIntValue(); script.ActionType[1] = _cbActionType2.GetIntValue(); script.ActionParam[1, 0] = _cbActionParam2_1.GetIntValue(); script.ActionParam[1, 1] = _cbActionParam2_2.GetIntValue(); script.ActionParam[1, 2] = _cbActionParam2_3.GetIntValue(); script.ActionType[2] = _cbActionType3.GetIntValue(); script.ActionParam[2, 0] = _cbActionParam3_1.GetIntValue(); script.ActionParam[2, 1] = _cbActionParam3_2.GetIntValue(); script.ActionParam[2, 2] = _cbActionParam3_3.GetIntValue(); script.Comment = _tbComment.Text; #region Check if (script.ID < 1) { LogOut("Script must have value greater than 0!"); } if (script.Chance == 0 || script.Chance > 100) { LogOut("Proc must be 0 or greater than 100%!"); } switch ((EventType)script.EventType) { case EventType.TIMER: case EventType.TIMER_OOC: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Minimum time can not be greater than the maximum!"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; case EventType.HP: case EventType.MANA: case EventType.TARGET_HP: case EventType.TARGET_MANA: if (script.EventParam[0] > 100 || script.EventParam[1] > 100) { LogOut("Option 1 or 2 can not be greater 100%!"); } if (script.EventParam[1] > script.EventParam[0]) { LogOut("The minimum value of life (MP) can not be greater than the maximum!"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; case EventType.KILL: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; case EventType.SPELLHIT: if (script.EventParam[2] > script.EventParam[3]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } if (script.EventParam[0] > 0 && script.EventParam[1] > -1) { LogOut(@"If set to \ ID Spells \, then the value of \ School \ must be (-1), otherwise \ id spell \ must be (0)"); } break; case EventType.RANGE: if (script.EventParam[0] > script.EventParam[1]) { LogOut("The minimum distance to the target can not be greater than the maximum"); } if (script.EventParam[2] > script.EventParam[3]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; case EventType.OOC_LOS: if (script.EventParam[2] > script.EventParam[3]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; case EventType.TARGET_CASTING: if (script.EventParam[0] > script.EventParam[1]) { LogOut("Minimum time to repeat can not be greater than the maximum!"); } break; } if (err) { _bWriteFiles.Enabled = false; return; } #endregion StringBuilder sb = new StringBuilder(); sb.AppendFormatLine("UPDATE `creature_template` SET `AIName` = 'EventAI', `ScriptName` = '' WHERE `entry` = '{0}';", script.NpcEntry); sb.AppendFormatLine("DELETE FROM `creature_ai_scripts` WHERE (`id`='{0}');", script.ID); sb.AppendFormatLine("INSERT INTO `creature_ai_scripts` VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}');", script.ID, script.NpcEntry, script.EventType, script.Phase, script.Chance, script.Flags, script.EventParam[0], script.EventParam[1], script.EventParam[2], script.EventParam[3], script.ActionType[0], script.ActionParam[0, 0], script.ActionParam[0, 1], script.ActionParam[0, 2], script.ActionType[1], script.ActionParam[1, 0], script.ActionParam[1, 1], script.ActionParam[1, 2], script.ActionType[2], script.ActionParam[2, 0], script.ActionParam[2, 1], script.ActionParam[2, 2], script.Comment.RemExc()); rtbScriptOut.Text = sb.ToString(); _bWriteFiles.Enabled = true; }