public void AddEvent() { Event_dataset temp = new Event_dataset(); line.Add(temp); }
public EventControl(Event_dataset Data,Int32 ID,uint creatureid) { InitializeComponent(); this.Name = ID.ToString(); eventid = ID; creature_id = creatureid; this.eventnumber.Text = "Event: " + ID.ToString(); this.expand.Checked = true; for(int n=0; n < Info.EventListInfo.GetLength(0);n++) this.EventTypeCBox.Items.Add(Info.EventListInfo[n,0]); // set width EventTypeCBox.DropDownWidth = DropDownWidth(EventTypeCBox); for (int n = 0; n < Info.ActionListInfo.GetLength(0); n++) { this.Action1TypeCBox.Items.Add(Info.ActionListInfo[n, 0]); this.Action2TypeCBox.Items.Add(Info.ActionListInfo[n, 0]); this.Action3TypeCBox.Items.Add(Info.ActionListInfo[n, 0]); } this.Action1TypeCBox.SelectedIndex = Data.action1_type; this.Action1Param1Tbox.Text = Data.action1_param1.ToString(); this.Action1Param2Tbox.Text = Data.action1_param2.ToString(); this.Action1Param3Tbox.Text = Data.action1_param3.ToString(); this.Action2TypeCBox.SelectedIndex = Data.action2_type; this.Action2Param1Tbox.Text = Data.action2_param1.ToString(); this.Action2Param2Tbox.Text = Data.action2_param2.ToString(); this.Action2Param3Tbox.Text = Data.action2_param3.ToString(); this.Action3TypeCBox.SelectedIndex = Data.action3_type; this.Action3Param1Tbox.Text = Data.action3_param1.ToString(); this.Action3Param2Tbox.Text = Data.action3_param2.ToString(); this.Action3Param3Tbox.Text = Data.action3_param3.ToString(); this.EventTypeCBox.SelectedIndex = Data.event_type; this.EventParam1.Text = Data.event_param1.ToString(); this.EventParam2.Text = Data.event_param2.ToString(); this.EventParam3.Text = Data.event_param3.ToString(); this.EventParam4.Text = Data.event_param4.ToString(); this.EventChanceTBox.Text = Data.event_chance.ToString(); this.EventFlagTBox.Text = Data.event_flags.ToString(); this.txtBoxComment.Text = Data.comment; this.SetInversePhaseMask(Data.event_inverse_phase_mask); this.EventTypeCBox.DropDownStyle = ComboBoxStyle.DropDownList; this.Action1TypeCBox.DropDownStyle = ComboBoxStyle.DropDownList; this.Action2TypeCBox.DropDownStyle = ComboBoxStyle.DropDownList; this.Action3TypeCBox.DropDownStyle = ComboBoxStyle.DropDownList; // load event boxes if (EventTypeCBox.SelectedIndex == 30) EventParam1ComboBox.SelectedIndex = Convert.ToInt32(EventParam1.Text); // set width Action1TypeCBox.DropDownWidth = DropDownWidth(Action1TypeCBox); Action2TypeCBox.DropDownWidth = DropDownWidth(Action2TypeCBox); Action3TypeCBox.DropDownWidth = DropDownWidth(Action3TypeCBox); // load combo boxes switch (Action1TypeCBox.SelectedIndex) { case 11: // Cast case 12: // Summon case 13: // Threat single case 15: // Quest event case 18: // Set unit flag case 19: // Remove unit flag case 32: // Summon case 33: // Killed unit case 34: // Set instance data case 35: // Set instance data 64 case 36: // Update template Action1Param2Combobox.SelectedIndex = Convert.ToInt32(Action1Param2Tbox.Text); break; case 16: // Cast creature/go case 17: // Set unit field Action1Param3Combobox.SelectedIndex = Convert.ToInt32(Action1Param3Tbox.Text); break; case 20: // Auto attack case 28: // Remove aura case 40: // Set Sheat case 42: // Set invincibility level case 45: // Throw AI event Action1Param1Combobox.SelectedIndex = Convert.ToInt32(Action1Param1Tbox.Text); break; case 21: // Combat movement Action1Param1Combobox.SelectedIndex = Convert.ToInt32(Action1Param1Tbox.Text); Action1Param2Combobox.SelectedIndex = Convert.ToInt32(Action1Param2Tbox.Text); break; } switch (Action2TypeCBox.SelectedIndex) { case 11: // Cast case 12: // Summon case 13: // Threat single case 15: // Quest event case 18: // Set unit flag case 19: // Remove unit flag case 32: // Summon case 33: // Killed unit case 34: // Set instance data case 35: // Set instance data 64 case 36: // Update template Action2Param2Combobox.SelectedIndex = Convert.ToInt32(Action2Param2Tbox.Text); break; case 16: // Cast creature/go case 17: // Set unit field Action2Param3Combobox.SelectedIndex = Convert.ToInt32(Action2Param3Tbox.Text); break; case 20: // Auto attack case 28: // Remove aura case 40: // Set Sheat case 42: // Set invincibility level case 45: // Throw AI event Action2Param1Combobox.SelectedIndex = Convert.ToInt32(Action2Param1Tbox.Text); break; case 21: // Combat movement Action2Param1Combobox.SelectedIndex = Convert.ToInt32(Action2Param1Tbox.Text); Action2Param2Combobox.SelectedIndex = Convert.ToInt32(Action2Param2Tbox.Text); break; } switch (Action3TypeCBox.SelectedIndex) { case 11: // Cast case 12: // Summon case 13: // Threat single case 15: // Quest event case 18: // Set unit flag case 19: // Remove unit flag case 32: // Summon case 33: // Killed unit case 34: // Set instance data case 35: // Set instance data 64 case 36: // Update template Action3Param2Combobox.SelectedIndex = Convert.ToInt32(Action3Param2Tbox.Text); break; case 16: // Cast creature/go case 17: // Set unit field Action3Param3Combobox.SelectedIndex = Convert.ToInt32(Action3Param3Tbox.Text); break; case 20: // Auto attack case 28: // Remove aura case 40: // Set Sheat case 42: // Set invincibility level case 45: // Throw AI event Action3Param1Combobox.SelectedIndex = Convert.ToInt32(Action3Param1Tbox.Text); break; case 21: // Combat movement Action3Param1Combobox.SelectedIndex = Convert.ToInt32(Action3Param1Tbox.Text); Action3Param2Combobox.SelectedIndex = Convert.ToInt32(Action3Param2Tbox.Text); break; } locked = false; }
public static void ReloadDB() { if (!Datastores.dbused) return; MySqlDataReader reader = null; // Check for the creatureAI tables try { string sQuery = "SELECT information_schema.TABLES.table_name FROM information_schema.TABLES " + "where information_schema.TABLES.table_name IN ('creature_ai_scripts','creature_ai_summons','creature_ai_texts') and information_schema.TABLES.Table_schema='" + Properties.Settings.Default.DBMANGOS + "'"; MySqlCommand comm = new MySqlCommand(sQuery, SQLConnection.conn); reader = comm.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) { MessageBox.Show("Your database doesn't contain the eventAI tables. The application won't use the database anymore"); dbused = false; } } } catch (Exception e) { MessageBox.Show(e.Message); } reader.Close(); if (Datastores.dbused) { // Select all creature scripts and creature names MySqlCommand c = new MySqlCommand("SELECT a.*, b.name FROM creature_ai_scripts a join creature_template b on a.creature_id = b.entry;", SQLConnection.conn); reader = c.ExecuteReader(); creatures.npcList.Clear(); summons.map.Clear(); localized_texts.map.Clear(); try { while (reader.Read()) { if (!creatures.npcList.ContainsKey(reader.GetUInt32("creature_id"))) { creature temp = new creature(reader.GetUInt32("creature_id"), reader.GetString("name")); creatures.npcList.Add(reader.GetUInt32("creature_id"), temp); } Event_dataset item = new Event_dataset(); item.script_id = reader.GetInt32("id"); item.event_type = reader.GetInt32("event_type"); item.event_inverse_phase_mask = reader.GetUInt32("event_inverse_phase_mask"); item.event_chance = reader.GetInt32("event_chance"); item.event_flags = reader.GetInt32("event_flags"); item.event_param1 = reader.GetInt32("event_param1"); item.event_param2 = reader.GetInt32("event_param2"); item.event_param3 = reader.GetInt32("event_param3"); item.event_param4 = reader.GetInt32("event_param4"); item.action1_type = reader.GetInt32("action1_type"); item.action1_param1 = reader.GetInt32("action1_param1"); item.action1_param2 = reader.GetInt32("action1_param2"); item.action1_param3 = reader.GetInt32("action1_param3"); item.action2_type = reader.GetInt32("action2_type"); item.action2_param1 = reader.GetInt32("action2_param1"); item.action2_param2 = reader.GetInt32("action2_param2"); item.action2_param3 = reader.GetInt32("action2_param3"); item.action3_type = reader.GetInt32("action3_type"); item.action3_param1 = reader.GetInt32("action3_param1"); item.action3_param2 = reader.GetInt32("action3_param2"); item.action3_param3 = reader.GetInt32("action3_param3"); item.comment = reader.GetString("comment"); creatures.npcList[reader.GetUInt32("creature_id")].line.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); // Select all creature AI summons c.CommandText = "SELECT * FROM creature_ai_summons"; reader.Close(); reader = c.ExecuteReader(); try { while (reader.Read()) { summon item = new summon(reader.GetUInt32("id")); item.comment = reader.GetString("comment"); item.orientation = reader.GetFloat("orientation"); item.position_x = reader.GetFloat("position_x"); item.position_y = reader.GetFloat("position_y"); item.position_z = reader.GetFloat("position_z"); item.spawntimesecs = reader.GetInt32("spawntimesecs"); summons.map.Add(reader.GetUInt32("id"), item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } // Select all creature AI texts c.CommandText = "SELECT * FROM creature_ai_texts"; reader.Close(); reader = c.ExecuteReader(); try { while (reader.Read()) { localized_text item = new localized_text(reader.GetInt32("entry")); item.locale_0 = reader.GetString("content_default"); int colIndex = reader.GetOrdinal("content_loc1"); if (!reader.IsDBNull(colIndex)) item.locale_1 = reader.GetString("content_loc1"); else item.locale_1 = string.Empty; colIndex = reader.GetOrdinal("content_loc2"); if (!reader.IsDBNull(colIndex)) item.locale_2 = reader.GetString("content_loc2"); else item.locale_2 = string.Empty; colIndex = reader.GetOrdinal("content_loc3"); if (!reader.IsDBNull(colIndex)) item.locale_3 = reader.GetString("content_loc3"); else item.locale_3 = string.Empty; colIndex = reader.GetOrdinal("content_loc4"); if (!reader.IsDBNull(colIndex)) item.locale_4 = reader.GetString("content_loc4"); else item.locale_4 = string.Empty; colIndex = reader.GetOrdinal("content_loc5"); if (!reader.IsDBNull(colIndex)) item.locale_5 = reader.GetString("content_loc5"); else item.locale_5 = string.Empty; colIndex = reader.GetOrdinal("content_loc6"); if (!reader.IsDBNull(colIndex)) item.locale_6 = reader.GetString("content_loc6"); else item.locale_6 = string.Empty; colIndex = reader.GetOrdinal("content_loc7"); if (!reader.IsDBNull(colIndex)) item.locale_7 = reader.GetString("content_loc7"); else item.locale_7 = string.Empty; colIndex = reader.GetOrdinal("content_loc8"); if (!reader.IsDBNull(colIndex)) item.locale_8 = reader.GetString("content_loc8"); else item.locale_8 = string.Empty; item.sound = reader.GetInt32("sound"); item.type = reader.GetInt32("type"); item.language = reader.GetInt32("language"); item.emote = reader.GetInt32("emote"); colIndex = reader.GetOrdinal("comment"); if (!reader.IsDBNull(colIndex)) item.comment = reader.GetString("comment"); else item.comment = string.Empty; localized_texts.map.Add(reader.GetInt32("entry"), item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); // Select creature entries SQLConnection.conn.ChangeDatabase(SQLConnection.dbworld); c.CommandText = "SELECT distinct entry FROM creature_template WHERE AIName='EventAI';"; reader = c.ExecuteReader(); try { while (reader.Read()) { if (creatures.npcList.ContainsKey(reader.GetUInt32("entry"))) { creatures.npcList[reader.GetUInt32("entry")].activectemplate = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); c.CommandText = "SELECT distinct entry FROM creature_template;"; reader = c.ExecuteReader(); try { while (reader.Read()) { creatures.npcsAvailable.Add(reader.GetUInt32("entry")); } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); } }
public Event_dataset GetEventData() { Event_dataset Data = new Event_dataset(); Data.action1_type = this.Action1TypeCBox.SelectedIndex; if (Action1Param1Tbox.Text.Length != 0 && Action1Param1Tbox.Text != "-") Data.action1_param1 = System.Convert.ToInt64(this.Action1Param1Tbox.Text); if (Action1Param2Tbox.Text.Length != 0 && Action1Param2Tbox.Text != "-") Data.action1_param2 = System.Convert.ToInt32(this.Action1Param2Tbox.Text); if (Action1Param3Tbox.Text.Length != 0 && Action1Param3Tbox.Text != "-") Data.action1_param3 = System.Convert.ToInt32(this.Action1Param3Tbox.Text); Data.action2_type = this.Action2TypeCBox.SelectedIndex; if (Action2Param1Tbox.Text.Length != 0 && Action2Param1Tbox.Text != "-") Data.action2_param1 = System.Convert.ToInt64(this.Action2Param1Tbox.Text); if (Action2Param2Tbox.Text.Length != 0 && Action2Param2Tbox.Text != "-") Data.action2_param2 = System.Convert.ToInt32(this.Action2Param2Tbox.Text); if (Action2Param3Tbox.Text.Length != 0 && Action2Param3Tbox.Text != "-") Data.action2_param3 = System.Convert.ToInt32(this.Action2Param3Tbox.Text); Data.action3_type = this.Action3TypeCBox.SelectedIndex; if (Action3Param1Tbox.Text.Length != 0 && Action3Param1Tbox.Text != "-") Data.action3_param1 = System.Convert.ToInt64(this.Action3Param1Tbox.Text); if (Action3Param2Tbox.Text.Length != 0 && Action3Param2Tbox.Text != "-") Data.action3_param2 = System.Convert.ToInt32(this.Action3Param2Tbox.Text); if (Action3Param3Tbox.Text.Length != 0 && Action3Param3Tbox.Text != "-") Data.action3_param3 = System.Convert.ToInt32(this.Action3Param3Tbox.Text); Data.event_type = this.EventTypeCBox.SelectedIndex; if (EventParam1.Text.Length != 0 && EventParam1.Text != "-") Data.event_param1 = System.Convert.ToInt32(this.EventParam1.Text); if (EventParam2.Text.Length != 0 && EventParam2.Text != "-") Data.event_param2 = System.Convert.ToInt32(this.EventParam2.Text); if (EventParam3.Text.Length != 0 && EventParam3.Text != "-") Data.event_param3 = System.Convert.ToInt32(this.EventParam3.Text); if (EventParam4.Text.Length != 0 && EventParam4.Text != "-") Data.event_param4 = System.Convert.ToInt32(this.EventParam4.Text); if (EventChanceTBox.Text.Length != 0 && EventChanceTBox.Text != "-") Data.event_chance = System.Convert.ToInt32(this.EventChanceTBox.Text); if (EventFlagTBox.Text.Length != 0 && EventFlagTBox.Text != "-") Data.event_flags = System.Convert.ToInt32(this.EventFlagTBox.Text); if (txtBoxComment.Text.Length != 0 && txtBoxComment.Text != "-") Data.comment = this.txtBoxComment.Text; Data.event_inverse_phase_mask = 0; if (this.PhaseCheckBox01.Checked) Data.event_inverse_phase_mask += 1; if (this.PhaseCheckBox02.Checked) Data.event_inverse_phase_mask += 2; if (this.PhaseCheckBox03.Checked) Data.event_inverse_phase_mask += 4; if (this.PhaseCheckBox04.Checked) Data.event_inverse_phase_mask += 8; if (this.PhaseCheckBox05.Checked) Data.event_inverse_phase_mask += 16; if (this.PhaseCheckBox06.Checked) Data.event_inverse_phase_mask += 32; if (this.PhaseCheckBox07.Checked) Data.event_inverse_phase_mask += 64; if (this.PhaseCheckBox08.Checked) Data.event_inverse_phase_mask += 128; if (this.PhaseCheckBox09.Checked) Data.event_inverse_phase_mask += 256; if (this.PhaseCheckBox10.Checked) Data.event_inverse_phase_mask += 512; if (this.PhaseCheckBox11.Checked) Data.event_inverse_phase_mask += 1024; if (this.PhaseCheckBox12.Checked) Data.event_inverse_phase_mask += 2048; if (this.PhaseCheckBox13.Checked) Data.event_inverse_phase_mask += 4096; if (this.PhaseCheckBox14.Checked) Data.event_inverse_phase_mask += 8192; if (this.PhaseCheckBox15.Checked) Data.event_inverse_phase_mask += 16384; if (this.PhaseCheckBox16.Checked) Data.event_inverse_phase_mask += 32768; if (this.PhaseCheckBox17.Checked) Data.event_inverse_phase_mask += 65536; if (this.PhaseCheckBox18.Checked) Data.event_inverse_phase_mask += 131072; if (this.PhaseCheckBox19.Checked) Data.event_inverse_phase_mask += 262144; if (this.PhaseCheckBox20.Checked) Data.event_inverse_phase_mask += 524288; if (this.PhaseCheckBox21.Checked) Data.event_inverse_phase_mask += 1048576; if (this.PhaseCheckBox22.Checked) Data.event_inverse_phase_mask += 2097152; if (this.PhaseCheckBox23.Checked) Data.event_inverse_phase_mask += 4194304; if (this.PhaseCheckBox24.Checked) Data.event_inverse_phase_mask += 8388608; if (this.PhaseCheckBox25.Checked) Data.event_inverse_phase_mask += 16777216; if (this.PhaseCheckBox26.Checked) Data.event_inverse_phase_mask += 33554432; if (this.PhaseCheckBox27.Checked) Data.event_inverse_phase_mask += 67108864; if (this.PhaseCheckBox28.Checked) Data.event_inverse_phase_mask += 134217728; if (this.PhaseCheckBox29.Checked) Data.event_inverse_phase_mask += 268435456; if (this.PhaseCheckBox30.Checked) Data.event_inverse_phase_mask += 536870912; if (this.PhaseCheckBox31.Checked) Data.event_inverse_phase_mask += 1073741824; if (this.PhaseCheckBox32.Checked) Data.event_inverse_phase_mask += 2147483648; creatures.npcList[creature_id].line[eventid] = Data; creatures.npcList[creature_id].changed = true; return Data; }