From acc27152eb6ae994c5a9da4e587884b6f95ee330 Mon Sep 17 00:00:00 2001 From: Kid10 Date: Tue, 12 Jun 2012 23:15:07 +0200 Subject: [PATCH] [12000] Implement server side spells Add exemplarily support for spells 21387(used with Ragnaros) and 62388(related to Demonic Circle) Further table columns can be added as required. Signed-off-by: Schmoozerd --- sql/mangos.sql | 34 +++++++++++- .../12000_01_mangos_spell_template.sql | 22 ++++++++ src/game/ObjectMgr.cpp | 53 +++++++++++++++++++ src/game/ObjectMgr.h | 1 + src/game/SQLStorages.cpp | 6 ++- src/game/SQLStorages.h | 1 + src/game/World.cpp | 3 ++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 9 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 sql/updates/12000_01_mangos_spell_template.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 107301a90..d7119f347 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_11994_01_mangos_creature_linking` bit(1) default NULL + `required_12000_01_mangos_spell_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -17987,6 +17987,38 @@ LOCK TABLES `spell_target_position` WRITE; /*!40000 ALTER TABLE `spell_target_position` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `spell_template` +-- + +DROP TABLE IF EXISTS `spell_template`; +CREATE TABLE `spell_template` ( + `id` int(11) unsigned NOT NULL DEFAULT '0', + `proc_flags` int(11) unsigned NOT NULL DEFAULT '0', + `proc_chance` int(11) unsigned NOT NULL DEFAULT '0', + `duration_index` int(11) unsigned NOT NULL DEFAULT '0', + `effect0` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_implicit_target_a` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_radius_idx` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_apply_aura_name` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_misc_value` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_trigger_spell` int(11) unsigned NOT NULL DEFAULT '0', + `comments` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='MaNGOS server side spells'; + +-- +-- Dumping data for table `spell_template` +-- +LOCK TABLES `spell_template` WRITE; +/*!40000 ALTER TABLE `spell_template` DISABLE KEYS */; +INSERT INTO `spell_template` VALUES +-- ID proc_flags chnce dur ef0 tarA0 rad aur misc trigger +(21387, 0x00000028, 15, 21, 6, 1, 0, 42, 0, 21388, 'Melt-Weapon trigger aura related used by Ragnaros'), +(62388, 0x00000000, 101, 21, 6, 1, 0, 4, 0, 0, 'Aura required for Demonic Circle 48020'); +/*!40000 ALTER TABLE `spell_template` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `spell_threat` -- diff --git a/sql/updates/12000_01_mangos_spell_template.sql b/sql/updates/12000_01_mangos_spell_template.sql new file mode 100644 index 000000000..9dd4c68c7 --- /dev/null +++ b/sql/updates/12000_01_mangos_spell_template.sql @@ -0,0 +1,22 @@ +ALTER TABLE db_version CHANGE COLUMN required_11994_01_mangos_creature_linking required_12000_01_mangos_spell_template bit; + +DROP TABLE IF EXISTS `spell_template`; +CREATE TABLE `spell_template` ( + `id` int(11) unsigned NOT NULL DEFAULT '0', + `proc_flags` int(11) unsigned NOT NULL DEFAULT '0', + `proc_chance` int(11) unsigned NOT NULL DEFAULT '0', + `duration_index` int(11) unsigned NOT NULL DEFAULT '0', + `effect0` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_implicit_target_a` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_radius_idx` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_apply_aura_name` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_misc_value` int(11) unsigned NOT NULL DEFAULT '0', + `effect0_trigger_spell` int(11) unsigned NOT NULL DEFAULT '0', + `comments` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='MaNGOS server side spells'; + +INSERT INTO spell_template VALUES +-- ID proc_flags chnce dur ef0 tarA0 rad aur misc trigger +(21387, 0x00000028, 15, 21, 6, 1, 0, 42, 0, 21388, 'Melt-Weapon trigger aura related used by Ragnaros'), +(62388, 0x00000000, 101, 21, 6, 1, 0, 4, 0, 0, 'Aura required for Demonic Circle 48020'); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 180142b35..8716aca40 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -6751,6 +6751,59 @@ void ObjectMgr::LoadNPCSpellClickSpells() sLog.outString(">> Loaded %u spellclick definitions", count); } +static char* SERVER_SIDE_SPELL = "MaNGOS server-side spell"; + +struct SQLSpellLoader : public SQLStorageLoaderBase +{ + template + void default_fill(uint32 field_pos, S src, D &dst) + { + if (field_pos == 65) // EquippedItemClass + dst = D(-1); + else + dst = D(src); + } + + void default_fill_to_str(uint32 field_pos, char const* /*src*/, char * & dst) + { + if (field_pos == 132) // SpellName[0] + { + dst = SERVER_SIDE_SPELL; + } + else + { + dst = new char[1]; + *dst = 0; + } + } +}; + +void ObjectMgr::LoadSpellTemplate() +{ + SQLSpellLoader loader; + loader.Load(sSpellTemplate); + + sLog.outString(">> Loaded %u spell definitions", sSpellTemplate.RecordCount); + sLog.outString(); + + for (uint32 i = 1; i < sSpellTemplate.MaxEntry; ++i) + { + // check data correctness + SpellEntry const* spellEntry = sSpellTemplate.LookupEntry(i); + if (!spellEntry) + continue; + + // insert serverside spell data + if (sSpellStore.GetNumRows() <= i) + { + sLog.outErrorDb("Loading Spell Template for spell %u, index out of bounds (max = %)", i, sSpellStore.GetNumRows()); + continue; + } + else + sSpellStore.InsertEntry(const_cast(spellEntry), i); + } +} + void ObjectMgr::LoadWeatherZoneChances() { uint32 count = 0; diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 229d9b2c3..632e697a7 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -715,6 +715,7 @@ class ObjectMgr void LoadQuestPOI(); void LoadNPCSpellClickSpells(); + void LoadSpellTemplate(); void LoadWeatherZoneChances(); void LoadGameTele(); diff --git a/src/game/SQLStorages.cpp b/src/game/SQLStorages.cpp index 9a93eb320..f703763af 100644 --- a/src/game/SQLStorages.cpp +++ b/src/game/SQLStorages.cpp @@ -39,7 +39,10 @@ const char WorldTemplatesrcfmt[]="is"; const char WorldTemplatedstfmt[]="ii"; const char ConditionsSrcFmt[]="iiii"; const char ConditionsDstFmt[]="iiii"; - +const char SpellTemplatesrcfmt[]="iiiiiiiiiix"; +// 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 185 +const char SpellTemplatedstfmt[]="ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixxxxixxxxxxFxxxxxxxxxxxxxxxxxxxxxxixxxxxFFFxxxxxxixxxxxixxixxxxxFFFxxxxxxixxxxxixxFFFxxxxxxxxxxxxxppppppppppppppppppppppppppppppppxxxxxxxxxxxFFFxxxxxx"; +// Id proc DurationIndex Effect0 tarA0 effectAura0 triggerSpell0 SpellName[16] Rank[16] SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info"); @@ -52,3 +55,4 @@ SQLStorage sPageTextStore(PageTextfmt,"entry","page_text"); SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template"); SQLStorage sWorldTemplate(WorldTemplatesrcfmt, WorldTemplatedstfmt, "map","world_template"); SQLStorage sConditionStorage(ConditionsSrcFmt, ConditionsDstFmt, "condition_entry", "conditions"); +SQLStorage sSpellTemplate(SpellTemplatesrcfmt, SpellTemplatedstfmt, "id", "spell_template"); diff --git a/src/game/SQLStorages.h b/src/game/SQLStorages.h index 7d313b995..efb8bc242 100644 --- a/src/game/SQLStorages.h +++ b/src/game/SQLStorages.h @@ -34,5 +34,6 @@ extern SQLStorage sItemStorage; extern SQLStorage sInstanceTemplate; extern SQLStorage sWorldTemplate; extern SQLStorage sConditionStorage; +extern SQLStorage sSpellTemplate; #endif diff --git a/src/game/World.cpp b/src/game/World.cpp index 528b94050..b8e4e4b35 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -953,6 +953,9 @@ void World::SetInitialWorldSettings() DetectDBCLang(); sObjectMgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) + sLog.outString( "Loading SpellTemplate..." ); + sObjectMgr.LoadSpellTemplate(); + sLog.outString( "Loading Script Names..."); sScriptMgr.LoadScriptNames(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bb0d118be..e95ea5f12 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11999" + #define REVISION_NR "12000" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 901a7be8a..58f31705e 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_11785_02_characters_instance" - #define REVISION_DB_MANGOS "required_11994_01_mangos_creature_linking" + #define REVISION_DB_MANGOS "required_12000_01_mangos_spell_template" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__