Пример #1
0
        public void OnDbLoad()
        {
            SetRespawn();
            this.Health.SetAll(this.Template.Health.Maximum);
            this.Mana.SetAll(this.Template.Mana.Maximum);
            this.BaseAttackTime = (uint)this.Template.AttackTime;
            this.DynamicFlags   = this.Template.DynamicFlags;
            this.NPCFlags       = (byte)this.Template.NPCFlags;
            this.Faction        = this.Template.Faction;
            this.VendorLoot     = this.Template.VendorItems;
            this.Level          = this.Template.Level.GetRandom();
            CreatureSpellsListTemplate spellListTemplate = Database.GetSpellsListForCreatureId(this.Template.SpellListID);

            this.spellsList = spellListTemplate != null ? new CreatureSpellsList(spellListTemplate) : null;

            CreatureModelInfo cmi = Database.CreatureModelInfo.TryGet(DisplayID);

            if (cmi != null)
            {
                this.BoundingRadius = cmi.BoundingRadius;
                this.CombatReach    = cmi.CombatReach;
            }

            GridManager.Instance.AddOrGet(this, true);
        }
Пример #2
0
        public static void LoadCreatureSpellLists()
        {
            Log.Message(LogType.NORMAL, "Loading creature spell lists ...");
            //                            0        1            2                3               4                 5                 6              7                    8                    9                   10                  11
            string queryString = "SELECT `entry`, `spellId_1`, `probability_1`, `castTarget_1`, `targetParam1_1`, `targetParam2_1`, `castFlags_1`, `delayInitialMin_1`, `delayInitialMax_1`, `delayRepeatMin_1`, `delayRepeatMax_1`, `scriptId_1`, " +
                                 //                                     12           13               14              15                16                17             18                   19                   20                  21                  22
                                 "`spellId_2`, `probability_2`, `castTarget_2`, `targetParam1_2`, `targetParam2_2`, `castFlags_2`, `delayInitialMin_2`, `delayInitialMax_2`, `delayRepeatMin_2`, `delayRepeatMax_2`, `scriptId_2`, " +
                                 //                                     23           24               25              26                27                28             29                   30                   31                  32                  33
                                 "`spellId_3`, `probability_3`, `castTarget_3`, `targetParam1_3`, `targetParam2_3`, `castFlags_3`, `delayInitialMin_3`, `delayInitialMax_3`, `delayRepeatMin_3`, `delayRepeatMax_3`, `scriptId_3`, " +
                                 //                                     34           35               36              37                38                39             40                   41                   42                  43                  44
                                 "`spellId_4`, `probability_4`, `castTarget_4`, `targetParam1_4`, `targetParam2_4`, `castFlags_4`, `delayInitialMin_4`, `delayInitialMax_4`, `delayRepeatMin_4`, `delayRepeatMax_4`, `scriptId_4`, " +
                                 //                                     45           46               47              48                49                50             51                   52                   53                  54                  55
                                 "`spellId_5`, `probability_5`, `castTarget_5`, `targetParam1_5`, `targetParam2_5`, `castFlags_5`, `delayInitialMin_5`, `delayInitialMax_5`, `delayRepeatMin_5`, `delayRepeatMax_5`, `scriptId_5`, " +
                                 //                                     56           57               58              59                60                61             62                   63                   64                  65                  66
                                 "`spellId_6`, `probability_6`, `castTarget_6`, `targetParam1_6`, `targetParam2_6`, `castFlags_6`, `delayInitialMin_6`, `delayInitialMax_6`, `delayRepeatMin_6`, `delayRepeatMax_6`, `scriptId_6`, " +
                                 //                                     67           68               69              70                71                72             73                   74                   75                  76                  77
                                 "`spellId_7`, `probability_7`, `castTarget_7`, `targetParam1_7`, `targetParam2_7`, `castFlags_7`, `delayInitialMin_7`, `delayInitialMax_7`, `delayRepeatMin_7`, `delayRepeatMax_7`, `scriptId_7`, " +
                                 //                                     78           79               80              81                82                83             84                   85                   86                  87                  88
                                 "`spellId_8`, `probability_8`, `castTarget_8`, `targetParam1_8`, `targetParam2_8`, `castFlags_8`, `delayInitialMin_8`, `delayInitialMax_8`, `delayRepeatMin_8`, `delayRepeatMax_8`, `scriptId_8` FROM `creature_spells`";
            string          connectionString = Globals.CONNECTION_STRING;
            MySqlConnection connection       = new MySqlConnection(connectionString);
            MySqlCommand    command          = new MySqlCommand(queryString, connection);

            command.Connection.Open();
            MySqlDataReader reader = command.ExecuteReader();

            // Number of spells in one template
            const byte CREATURE_SPELLS_MAX_SPELLS = 8;
            // Columns in the db for each spell
            const byte CREATURE_SPELLS_MAX_COLUMNS = 11;

            CreatureSpells = new List <CreatureSpellsListTemplate>();
            while (reader.Read())
            {
                CreatureSpellsListTemplate spellsList = new CreatureSpellsListTemplate();

                UInt32 entry = (UInt32)reader.GetInt32(0);
                spellsList.entry = entry;
                for (byte i = 0; i < CREATURE_SPELLS_MAX_SPELLS; i++)
                {
                    UInt16 spellId = (UInt16)reader.GetInt16(1 + i * CREATURE_SPELLS_MAX_COLUMNS);
                    if (spellId != 0)
                    {
                        byte   probability  = (byte)reader.GetByte(2 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        byte   castTarget   = (byte)reader.GetByte(3 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        UInt32 targetParam1 = (UInt32)reader.GetInt32(4 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        UInt32 targetParam2 = (UInt32)reader.GetInt32(5 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        byte   castFlags    = (byte)reader.GetByte(6 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        // in the database we store timers as seconds
                        // based on screenshot of blizzard creature spells editor
                        UInt32 delayInitialMin = (UInt32)reader.GetInt32(7 + i * CREATURE_SPELLS_MAX_COLUMNS) * 1000;
                        UInt32 delayInitialMax = (UInt32)reader.GetInt32(8 + i * CREATURE_SPELLS_MAX_COLUMNS) * 1000;
                        UInt32 delayRepeatMin  = (UInt32)reader.GetInt32(9 + i * CREATURE_SPELLS_MAX_COLUMNS) * 1000;
                        UInt32 delayRepeatMax  = (UInt32)reader.GetInt32(10 + i * CREATURE_SPELLS_MAX_COLUMNS) * 1000;
                        UInt32 scriptId        = (UInt32)reader.GetInt32(11 + i * CREATURE_SPELLS_MAX_COLUMNS);
                        spellsList.spells.Add(new CreatureSpellsEntryTemplate(spellId, probability, castTarget, targetParam1, targetParam2, castFlags, delayInitialMin, delayInitialMax, delayRepeatMin, delayRepeatMax, scriptId));
                    }
                }
                CreatureSpells.Add(spellsList);
            }
            reader.Close();
            connection.Close();
            Log.Message(LogType.NORMAL, "Loaded " + CreatureSpells.Count.ToString() + " creature spell lists.");
        }