Ejemplo n.º 1
0
        public static bool Add(uint id)
        {
            summon temp = new summon(id);

            if (!map.ContainsKey(id))
            {
                map.Add(id, temp);
                return true;
            }
            else
                return false;
        }
Ejemplo n.º 2
0
        public static bool Add(uint id)
        {
            summon temp = new summon(id);

            if (!map.ContainsKey(id))
            {
                map.Add(id, temp);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        // Preview summon scripts
        public static string WriteSummonToWindow(summon script)
        {
            if (script == null)
                return "";

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("-- Summon id: " + script.id);
            sb.AppendLine(SQLcreator.CreateDeleteQuery(script, ""));
            sb.AppendLine(SQLcreator.CreateCreateQuery(script, ""));

            return sb.ToString();
        }
Ejemplo n.º 4
0
        // Create summon script
        public static bool WriteSummonToFile(summon script, string file, bool reihe)
        {
            if (script == null)
                return false;

            StreamWriter sqlpatchfile = new StreamWriter(file, reihe);
            sqlpatchfile.WriteLine("-- Summon id: " + script.id);
            sqlpatchfile.WriteLine(SQLcreator.CreateDeleteQuery(script, ""));
            sqlpatchfile.WriteLine(SQLcreator.CreateCreateQuery(script, ""));
            sqlpatchfile.Close();
            return true;
        }
Ejemplo n.º 5
0
        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();
            }
        }