diff options
author | QAston <none@none> | 2010-02-01 19:22:32 +0100 |
---|---|---|
committer | QAston <none@none> | 2010-02-01 19:22:32 +0100 |
commit | a1256d88ee4cb4295e38fcf5f85581e9b1d8c876 (patch) | |
tree | 5ba85162a48efeeedf9b31bd7dbf5fa18ca8488e | |
parent | 65705a16c148d06e1b7f029edd98756dbef24489 (diff) |
*drop spell_elixir table
*add spell_group table for storage of groups of spell (kinda obvious, isn't it?) and populate the table with converted spell_elixir table data
*the table is going to be maintained by core team
*fix percentage display at spell_ranks table loading
*add TARGET_UNIT_CASTER to allowed learn spell targets in npc_trainer table, thanks to Aokromes for noticing the issue.
--HG--
branch : trunk
-rw-r--r-- | sql/updates/7280_world_command.sql | 2 | ||||
-rw-r--r-- | sql/updates/7280_world_spell_elixir.sql | 1 | ||||
-rw-r--r-- | sql/updates/7280_world_spell_group.sql | 187 | ||||
-rw-r--r-- | sql/world.sql | 331 | ||||
-rw-r--r-- | src/game/Chat.cpp | 2 | ||||
-rw-r--r-- | src/game/Chat.h | 2 | ||||
-rw-r--r-- | src/game/Level3.cpp | 10 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 7 | ||||
-rw-r--r-- | src/game/SharedDefines.h | 2 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 60 | ||||
-rw-r--r-- | src/game/SpellMgr.cpp | 41 | ||||
-rw-r--r-- | src/game/SpellMgr.h | 85 | ||||
-rw-r--r-- | src/game/World.cpp | 2 |
13 files changed, 516 insertions, 216 deletions
diff --git a/sql/updates/7280_world_command.sql b/sql/updates/7280_world_command.sql new file mode 100644 index 00000000000..150370a298b --- /dev/null +++ b/sql/updates/7280_world_command.sql @@ -0,0 +1,2 @@ +DELETE FROM `command` WHERE `name` = 'reload spell_group'; +INSERT INTO `command` VALUES ('reload spell_group','3','Syntax: .reload spell_group\nReload spell_group table.'); diff --git a/sql/updates/7280_world_spell_elixir.sql b/sql/updates/7280_world_spell_elixir.sql new file mode 100644 index 00000000000..e2b24691fc6 --- /dev/null +++ b/sql/updates/7280_world_spell_elixir.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `spell_elixir`; diff --git a/sql/updates/7280_world_spell_group.sql b/sql/updates/7280_world_spell_group.sql new file mode 100644 index 00000000000..ee19c117ffe --- /dev/null +++ b/sql/updates/7280_world_spell_group.sql @@ -0,0 +1,187 @@ +DROP TABLE IF EXISTS `spell_group`; +CREATE TABLE `spell_group` ( + `id` int(11) unsigned NOT NULL DEFAULT 0, + `spell_id` int(11) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`, `spell_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; +INSERT INTO `spell_group` (`id`, `spell_id`) VALUES + -- SPELL_GROUP_ELIXIR_BATTLE +(1, 2367), +(1, 2374), +(1, 3160), +(1, 3164), +(1, 7844), +(1, 8212), +(1, 10667), +(1, 10669), +(1, 11328), +(1, 11334), +(1, 11390), +(1, 11405), +(1, 11406), +(1, 11474), +(1, 16322), +(1, 16323), +(1, 16329), +(1, 17038), +(1, 17537), +(1, 17538), +(1, 17539), +(1, 17624), +(1, 17626), +(1, 17627), +(1, 17628), +(1, 17629), +(1, 21920), +(1, 26276), +(1, 28486), +(1, 28488), +(1, 28490), +(1, 28491), +(1, 28493), +(1, 28497), +(1, 28501), +(1, 28503), +(1, 28518), +(1, 28519), +(1, 28520), +(1, 28521), +(1, 28540), +(1, 33720), +(1, 33721), +(1, 33726), +(1, 38954), +(1, 40567), +(1, 40568), +(1, 40572), +(1, 40573), +(1, 40575), +(1, 40576), +(1, 41608), +(1, 41609), +(1, 41610), +(1, 41611), +(1, 42735), +(1, 45373), +(1, 46837), +(1, 46839), +(1, 53746), +(1, 53748), +(1, 53749), +(1, 53752), +(1, 53755), +(1, 53758), +(1, 53760), +(1, 54212), +(1, 54452), +(1, 54494), +(1, 60340), +(1, 60341), +(1, 60344), +(1, 60345), +(1, 60346), +(1, 62380), +(1, 67016), +(1, 67017), +(1, 67018), + -- SPELL_GROUP_ELIXIR_GUARDIAN +(2, 673), +(2, 2378), +(2, 2380), +(2, 3166), +(2, 3219), +(2, 3220), +(2, 3222), +(2, 3223), +(2, 3593), +(2, 10668), +(2, 10692), +(2, 10693), +(2, 11319), +(2, 11348), +(2, 11349), +(2, 11364), +(2, 11371), +(2, 11396), +(2, 15231), +(2, 15233), +(2, 16321), +(2, 16325), +(2, 16326), +(2, 16327), +(2, 17535), +(2, 17624), +(2, 17626), +(2, 17627), +(2, 17628), +(2, 17629), +(2, 24361), +(2, 24363), +(2, 24382), +(2, 24383), +(2, 24417), +(2, 27652), +(2, 27653), +(2, 28502), +(2, 28509), +(2, 28514), +(2, 28518), +(2, 28519), +(2, 28520), +(2, 28521), +(2, 28540), +(2, 29348), +(2, 39625), +(2, 39626), +(2, 39627), +(2, 39628), +(2, 40567), +(2, 40568), +(2, 40572), +(2, 40573), +(2, 40575), +(2, 40576), +(2, 41608), +(2, 41609), +(2, 41610), +(2, 41611), +(2, 42735), +(2, 46837), +(2, 46839), +(2, 53747), +(2, 53751), +(2, 53752), +(2, 53755), +(2, 53758), +(2, 53760), +(2, 53763), +(2, 53764), +(2, 54212), +(2, 60343), +(2, 60347), +(2, 62380), +(2, 67016), +(2, 67017), +(2, 67018), + -- SPELL_GROUP_ELIXIR_UNSTABLE +(3, 40567), +(3, 40568), +(3, 40572), +(3, 40573), +(3, 40575), +(3, 40576), + -- SPELL_GROUP_ELIXIR_SHATTRATH +(4, 41608), +(4, 41609), +(4, 41610), +(4, 41611), +(4, 46837), +(4, 46839), + -- SPELL_GROUP_WELL_FED +(5, 18191), +(5, 18192), +(5, 18193), +(5, 18194), +(5, 18222), +(5, 22730), +(5, 25661);
\ No newline at end of file diff --git a/sql/world.sql b/sql/world.sql index 6f0961e6d87..05336b33a0b 100644 --- a/sql/world.sql +++ b/sql/world.sql @@ -606,7 +606,7 @@ INSERT INTO `command` VALUES ('reload spell_area','3','Syntax: .reload spell_area\nReload spell_area table.'), ('reload spell_bonus_data','3','Syntax: .reload spell_bonus_data\nReload spell_bonus_data table.'), ('reload spell_disabled','3','Syntax: .reload spell_disabled\nReload spell_disabled table.'), -('reload spell_elixir','3','Syntax: .reload spell_elixir\nReload spell_elixir table.'), +('reload spell_group','3','Syntax: .reload spell_group\nReload spell_group table.'), ('reload spell_learn_spell','3','Syntax: .reload spell_learn_spell\nReload spell_learn_spell table.'), ('reload spell_linked_spell','3','Usage: .reload spell_linked_spell\r\nReloads the spell_linked_spell DB table.'), ('reload spell_loot_template','3','Syntax: .reload spell_loot_template\nReload spell_loot_template table.'), @@ -5092,16 +5092,16 @@ LOCK TABLES `spell_disabled` WRITE; UNLOCK TABLES; -- --- Table structure for table `spell_elixir` +-- Table structure for table `spell_group` -- -DROP TABLE IF EXISTS `spell_elixir`; +DROP TABLE IF EXISTS `spell_group`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `spell_elixir` ( - `entry` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'SpellId of potion', - `mask` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'Mask 0x1 battle 0x2 guardian 0x3 flask 0x7 unstable flasks 0xB shattrath flasks', - PRIMARY KEY (`entry`) +CREATE TABLE `spell_group` ( + `id` int(11) unsigned NOT NULL DEFAULT 0, + `spell_id` int(11) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`, `spell_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -5109,141 +5109,190 @@ CREATE TABLE `spell_elixir` ( -- Dumping data for table `spell_elixir` -- -LOCK TABLES `spell_elixir` WRITE; +LOCK TABLES `spell_group` WRITE; /*!40000 ALTER TABLE `spell_elixir` DISABLE KEYS */; -INSERT INTO `spell_elixir` VALUES -(673, 0x2), -(2367, 0x1), -(2374, 0x1), -(2378, 0x2), -(2380, 0x2), -(3160, 0x1), -(3164, 0x1), -(3166, 0x2), -(3219, 0x2), -(3220, 0x2), -(3222, 0x2), -(3223, 0x2), -(3593, 0x2), -(7844, 0x1), -(8212, 0x1), -(10667, 0x1), -(10668, 0x2), -(10669, 0x1), -(10692, 0x2), -(10693, 0x2), -(11319, 0x2), -(11328, 0x1), -(11334, 0x1), -(11348, 0x2), -(11349, 0x2), -(11364, 0x2), -(11371, 0x2), -(11390, 0x1), -(11396, 0x2), -(11405, 0x1), -(11406, 0x1), -(11474, 0x1), -(15231, 0x2), -(15233, 0x2), -(16321, 0x2), -(16322, 0x1), -(16323, 0x1), -(16325, 0x2), -(16326, 0x2), -(16327, 0x2), -(16329, 0x1), -(17038, 0x1), -(17535, 0x2), -(17537, 0x1), -(17538, 0x1), -(17539, 0x1), -(17624, 0x3), -(17626, 0x3), -(17627, 0x3), -(17628, 0x3), -(17629, 0x3), -(21920, 0x1), -(24361, 0x2), -(24363, 0x2), -(24382, 0x2), -(24383, 0x2), -(24417, 0x2), -(26276, 0x1), -(27652, 0x2), -(27653, 0x2), -(28486, 0x1), -(28488, 0x1), -(28490, 0x1), -(28491, 0x1), -(28493, 0x1), -(28497, 0x1), -(28501, 0x1), -(28502, 0x2), -(28503, 0x1), -(28509, 0x2), -(28514, 0x2), -(28518, 0x3), -(28519, 0x3), -(28520, 0x3), -(28521, 0x3), -(28540, 0x3), -(29348, 0x2), -(33720, 0x1), -(33721, 0x1), -(33726, 0x1), -(38954, 0x1), -(39625, 0x2), -(39626, 0x2), -(39627, 0x2), -(39628, 0x2), -(40567, 0x7), -(40568, 0x7), -(40572, 0x7), -(40573, 0x7), -(40575, 0x7), -(40576, 0x7), -(41608, 0xB), -(41609, 0xB), -(41610, 0xB), -(41611, 0xB), -(42735, 0x3), -(45373, 0x1), -(46837, 0xB), -(46839, 0xB), -(53746, 0x1), -(53747, 0x2), -(53748, 0x1), -(53749, 0x1), -(53751, 0x2), -(53752, 0x3), -(53755, 0x3), -(53758, 0x3), -(53760, 0x3), -(53763, 0x2), -(53764, 0x2), -(54212, 0x3), -(54452, 0x1), -(54494, 0x1), -(60340, 0x1), -(60341, 0x1), -(60343, 0x2), -(60344, 0x1), -(60345, 0x1), -(60346, 0x1), -(60347, 0x2), -(62380, 0x3), -(18191,0x10), -(18192,0x10), -(18193,0x10), -(18194,0x10), -(18222,0x10), -(22730,0x10), -(25661,0x10), -(67016,0x3), -(67017,0x3), -(67018,0x3); -/*!40000 ALTER TABLE `spell_elixir` ENABLE KEYS */; +INSERT INTO `spell_group` (`id`, `spell_id`) VALUES + -- SPELL_GROUP_ELIXIR_BATTLE +(1, 2367), +(1, 2374), +(1, 3160), +(1, 3164), +(1, 7844), +(1, 8212), +(1, 10667), +(1, 10669), +(1, 11328), +(1, 11334), +(1, 11390), +(1, 11405), +(1, 11406), +(1, 11474), +(1, 16322), +(1, 16323), +(1, 16329), +(1, 17038), +(1, 17537), +(1, 17538), +(1, 17539), +(1, 17624), +(1, 17626), +(1, 17627), +(1, 17628), +(1, 17629), +(1, 21920), +(1, 26276), +(1, 28486), +(1, 28488), +(1, 28490), +(1, 28491), +(1, 28493), +(1, 28497), +(1, 28501), +(1, 28503), +(1, 28518), +(1, 28519), +(1, 28520), +(1, 28521), +(1, 28540), +(1, 33720), +(1, 33721), +(1, 33726), +(1, 38954), +(1, 40567), +(1, 40568), +(1, 40572), +(1, 40573), +(1, 40575), +(1, 40576), +(1, 41608), +(1, 41609), +(1, 41610), +(1, 41611), +(1, 42735), +(1, 45373), +(1, 46837), +(1, 46839), +(1, 53746), +(1, 53748), +(1, 53749), +(1, 53752), +(1, 53755), +(1, 53758), +(1, 53760), +(1, 54212), +(1, 54452), +(1, 54494), +(1, 60340), +(1, 60341), +(1, 60344), +(1, 60345), +(1, 60346), +(1, 62380), +(1, 67016), +(1, 67017), +(1, 67018), + -- SPELL_GROUP_ELIXIR_GUARDIAN +(2, 673), +(2, 2378), +(2, 2380), +(2, 3166), +(2, 3219), +(2, 3220), +(2, 3222), +(2, 3223), +(2, 3593), +(2, 10668), +(2, 10692), +(2, 10693), +(2, 11319), +(2, 11348), +(2, 11349), +(2, 11364), +(2, 11371), +(2, 11396), +(2, 15231), +(2, 15233), +(2, 16321), +(2, 16325), +(2, 16326), +(2, 16327), +(2, 17535), +(2, 17624), +(2, 17626), +(2, 17627), +(2, 17628), +(2, 17629), +(2, 24361), +(2, 24363), +(2, 24382), +(2, 24383), +(2, 24417), +(2, 27652), +(2, 27653), +(2, 28502), +(2, 28509), +(2, 28514), +(2, 28518), +(2, 28519), +(2, 28520), +(2, 28521), +(2, 28540), +(2, 29348), +(2, 39625), +(2, 39626), +(2, 39627), +(2, 39628), +(2, 40567), +(2, 40568), +(2, 40572), +(2, 40573), +(2, 40575), +(2, 40576), +(2, 41608), +(2, 41609), +(2, 41610), +(2, 41611), +(2, 42735), +(2, 46837), +(2, 46839), +(2, 53747), +(2, 53751), +(2, 53752), +(2, 53755), +(2, 53758), +(2, 53760), +(2, 53763), +(2, 53764), +(2, 54212), +(2, 60343), +(2, 60347), +(2, 62380), +(2, 67016), +(2, 67017), +(2, 67018), + -- SPELL_GROUP_ELIXIR_UNSTABLE +(3, 40567), +(3, 40568), +(3, 40572), +(3, 40573), +(3, 40575), +(3, 40576), + -- SPELL_GROUP_ELIXIR_SHATTRATH +(4, 41608), +(4, 41609), +(4, 41610), +(4, 41611), +(4, 46837), +(4, 46839), + -- SPELL_GROUP_WELL_FED +(5, 18191), +(5, 18192), +(5, 18193), +(5, 18194), +(5, 18222), +(5, 22730), +(5, 25661); +/*!40000 ALTER TABLE `spell_group` ENABLE KEYS */; UNLOCK TABLES; -- diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index abc047d7ecb..920a9416ed7 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -497,7 +497,7 @@ ChatCommand * ChatHandler::getCommandTable() { "spell_required", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellRequiredCommand, "", NULL }, { "spell_area", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellAreaCommand, "", NULL }, { "spell_bonus_data", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellBonusesCommand, "", NULL }, - { "spell_elixir", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellElixirCommand, "", NULL }, + { "spell_group", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellGroupsCommand, "", NULL }, { "spell_learn_spell", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", NULL }, { "spell_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesSpellCommand, "", NULL }, { "spell_linked_spell", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellLinkedSpellCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 817a9306eba..4edd705c5dd 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -410,7 +410,7 @@ class TRINITY_DLL_SPEC ChatHandler bool HandleReloadSkillFishingBaseLevelCommand(const char* args); bool HandleReloadSpellRequiredCommand(const char* args); bool HandleReloadSpellAreaCommand(const char* args); - bool HandleReloadSpellElixirCommand(const char* args); + bool HandleReloadSpellGroupsCommand(const char* args); bool HandleReloadSpellLearnSpellCommand(const char* args); bool HandleReloadSpellLinkedSpellCommand(const char* args); bool HandleReloadSpellProcEventCommand(const char* args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 3f71bbdfc16..75429eca352 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -651,7 +651,7 @@ bool ChatHandler::HandleReloadAllSpellCommand(const char*) HandleReloadSkillExtraItemTemplateCommand("a"); HandleReloadSpellRequiredCommand("a"); HandleReloadSpellAreaCommand("a"); - HandleReloadSpellElixirCommand("a"); + HandleReloadSpellGroupsCommand("a"); HandleReloadSpellLearnSpellCommand("a"); HandleReloadSpellLinkedSpellCommand("a"); HandleReloadSpellProcEventCommand("a"); @@ -1030,11 +1030,11 @@ bool ChatHandler::HandleReloadSpellRequiredCommand(const char*) return true; } -bool ChatHandler::HandleReloadSpellElixirCommand(const char*) +bool ChatHandler::HandleReloadSpellGroupsCommand(const char*) { - sLog.outString( "Re-Loading Spell Elixir types..." ); - spellmgr.LoadSpellElixirs(); - SendGlobalGMSysMessage("DB table `spell_elixir` (spell elixir types) reloaded."); + sLog.outString( "Re-Loading Spell Groups..." ); + spellmgr.LoadSpellGroups(); + SendGlobalGMSysMessage("DB table `spell_group` (spell elixir types) reloaded."); return true; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 4f9f2b1faa2..0fd304b9c3c 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -8020,14 +8020,15 @@ void ObjectMgr::LoadTrainerSpell() { if(spellinfo->Effect[i] != SPELL_EFFECT_LEARN_SPELL) continue; + if (trainerSpell.learnedSpell[0] == spell) + trainerSpell.learnedSpell[0] = 0; // player must be able to cast spell on himself - if (spellinfo->EffectImplicitTargetA[i] != 0 && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ALLY && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ANY) + if (spellinfo->EffectImplicitTargetA[i] != 0 && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ALLY + && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ANY && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_CASTER) { sLog.outErrorDb("Table `npc_trainer` has spell %u for trainer entry %u with learn effect which has incorrect target type, ignoring learn effect!", spell, entry); continue; } - if (trainerSpell.learnedSpell[0] == spell) - trainerSpell.learnedSpell[0] = 0; trainerSpell.learnedSpell[i] = spellinfo->EffectTriggerSpell[i]; } diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 23b7cf20f91..6733e73be25 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1085,7 +1085,7 @@ enum SpellImmunity enum Targets { TARGET_UNIT_CASTER = 1, - TARGET_UNIT_NEARBY_ENEMY = 2, // only one spell has that, but regardless, it's a target type after all + TARGET_UNIT_NEARBY_ENEMY = 2, TARGET_UNIT_NEARBY_ALLY = 3, TARGET_UNIT_NEARBY_ALLY_UNK = 4, TARGET_UNIT_PET = 5, diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 86339274962..7a61a717fe4 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3196,44 +3196,66 @@ void Spell::EffectEnergize(uint32 i) m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, damage, power); // Mad Alchemist's Potion - if (m_spellInfo->Id == 45051) + if (m_spellInfo->Id == SPELL_MAD_ALCHEMISTS_POTION_45051) { // find elixirs on target - uint32 elixir_mask = 0; + bool guardianFound = false; + bool battleFound = false; Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr) { uint32 spell_id = itr->second->GetBase()->GetId(); - if(uint32 mask = spellmgr.GetSpellElixirMask(spell_id)) - elixir_mask |= mask; + if (!guardianFound) + if(spellmgr.IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_GUARDIAN)) + guardianFound = true; + if (!battleFound) + if(spellmgr.IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_BATTLE)) + battleFound = true; + if (battleFound && guardianFound) + break; } - // get available elixir mask any not active type from battle/guardian (and flask if no any) - elixir_mask = (elixir_mask & ELIXIR_FLASK_MASK) ^ ELIXIR_FLASK_MASK; - // get all available elixirs by mask and spell level - std::vector<uint32> elixirs; - SpellElixirMap const& m_spellElixirs = spellmgr.GetSpellElixirMap(); - for (SpellElixirMap::const_iterator itr = m_spellElixirs.begin(); itr != m_spellElixirs.end(); ++itr) + std::list<uint32> avalibleElixirs; + if (!guardianFound) { - if (itr->second & elixir_mask) + SpellGroupSpellMapBounds guardianGroup = spellmgr.GetSpellGroupSpellMapBounds(SPELL_GROUP_ELIXIR_GUARDIAN); + for ( SpellGroupSpellMap::const_iterator itr = guardianGroup.first; itr != guardianGroup.second ; ++itr) { - if (itr->second & (ELIXIR_UNSTABLE_MASK | ELIXIR_SHATTRATH_MASK)) + SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->second); + if (spellInfo && (spellInfo->spellLevel < m_spellInfo->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) continue; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); + if(spellmgr.IsSpellMemberOfSpellGroup(itr->second, SPELL_GROUP_ELIXIR_SHATTRATH)) + continue; + if(spellmgr.IsSpellMemberOfSpellGroup(itr->second, SPELL_GROUP_ELIXIR_UNSTABLE)) + continue; + avalibleElixirs.push_back(itr->second); + } + } + if (!battleFound) + { + SpellGroupSpellMapBounds battleGroup = spellmgr.GetSpellGroupSpellMapBounds(SPELL_GROUP_ELIXIR_BATTLE); + for ( SpellGroupSpellMap::const_iterator itr = battleGroup.first; itr != battleGroup.second ; ++itr) + { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->second); if (spellInfo && (spellInfo->spellLevel < m_spellInfo->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) continue; - - elixirs.push_back(itr->first); + if(spellmgr.IsSpellMemberOfSpellGroup(itr->second, SPELL_GROUP_ELIXIR_SHATTRATH)) + continue; + if(spellmgr.IsSpellMemberOfSpellGroup(itr->second, SPELL_GROUP_ELIXIR_UNSTABLE)) + continue; + avalibleElixirs.push_back(itr->second); } } + avalibleElixirs.unique(); - if (!elixirs.empty()) + if (!avalibleElixirs.empty()) { // cast random elixir on target - uint32 rand_spell = urand(0,elixirs.size()-1); - m_caster->CastSpell(unitTarget,elixirs[rand_spell],true,m_CastItem); + uint32 rand_spell = urand(0,avalibleElixirs.size()-1); + std::list<uint32>::iterator itr = avalibleElixirs.begin(); + std::advance(itr, rand_spell); + m_caster->CastSpell(unitTarget,*itr,true,m_CastItem); } } } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 4049150baed..e233dc05691 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1465,14 +1465,15 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr return false; } -void SpellMgr::LoadSpellElixirs() +void SpellMgr::LoadSpellGroups() { - mSpellElixirs.clear(); // need for reload case + mSpellSpellGroup.clear(); // need for reload case + mSpellGroupSpell.clear(); uint32 count = 0; - // 0 1 - QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, mask FROM spell_elixir"); + // 0 1 + QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, spell_id FROM spell_group"); if( !result ) { @@ -1481,7 +1482,7 @@ void SpellMgr::LoadSpellElixirs() bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u spell elixir definitions", count ); + sLog.outString( ">> Loaded %u spell group definitions", count ); return; } @@ -1493,24 +1494,36 @@ void SpellMgr::LoadSpellElixirs() bar.step(); - uint32 entry = fields[0].GetUInt32(); - uint8 mask = fields[1].GetUInt8(); + uint32 group_id = fields[0].GetUInt32(); + uint32 spell_id = fields[1].GetUInt32(); - SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) { - sLog.outErrorDb("Spell %u listed in `spell_elixir` does not exist", entry); + sLog.outErrorDb("Spell %u listed in `spell_group` does not exist", spell_id); + continue; + } + + if (GetSpellRank(spell_id) > 1) + { + sLog.outErrorDb("Spell %u listed in `spell_group` is not first rank of spell", spell_id); continue; } - mSpellElixirs[entry] = mask; + if (IsSpellMemberOfSpellGroup(spell_id, (SpellGroup)group_id)) + { + sLog.outErrorDb("Spell %u listed in `spell_group` is added twice to one group %u", spell_id, group_id); + continue; + } + mSpellSpellGroup.insert(SpellSpellGroupMap::value_type(spell_id, (SpellGroup)group_id)); + mSpellGroupSpell.insert(SpellGroupSpellMap::value_type((SpellGroup)group_id, spell_id)); ++count; } while( result->NextRow() ); sLog.outString(); - sLog.outString( ">> Loaded %u spell elixir definitions", count ); + sLog.outString( ">> Loaded %u spell group definitions", count ); } void SpellMgr::LoadSpellStackMasks() @@ -3311,8 +3324,6 @@ void SpellMgr::LoadSpellRanks() // fill one chain while(currentSpell == lastSpell && !finished) { - bar.step(); - Field *fields = result->Fetch(); currentSpell = fields[0].GetUInt32(); @@ -3324,6 +3335,7 @@ void SpellMgr::LoadSpellRanks() // don't drop the row if we're moving to the next rank if (currentSpell == lastSpell) { + bar.step(); rankChain.push_back(std::make_pair(spell_id, rank)); if (!result->NextRow()) finished = true; @@ -3371,6 +3383,7 @@ void SpellMgr::LoadSpellRanks() std::list<std::pair<int32, int32> >::iterator itr = rankChain.begin(); do { + ++rows; int32 addedSpell = itr->first; mSpellChains[addedSpell].first = lastSpell; mSpellChains[addedSpell].last = rankChain.back().first; @@ -3387,8 +3400,6 @@ void SpellMgr::LoadSpellRanks() mSpellChains[addedSpell].next = itr->first; } while (true); - - ++rows; } while (!finished); sLog.outString(); diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 6034a9d10ce..a204789f7da 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -633,14 +633,23 @@ struct SpellEnchantProcEntry typedef UNORDERED_MAP<uint32, SpellEnchantProcEntry> SpellEnchantProcEventMap; typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap; -#define ELIXIR_BATTLE_MASK 0x01 -#define ELIXIR_GUARDIAN_MASK 0x02 -#define ELIXIR_FLASK_MASK (ELIXIR_BATTLE_MASK|ELIXIR_GUARDIAN_MASK) -#define ELIXIR_UNSTABLE_MASK 0x04 -#define ELIXIR_SHATTRATH_MASK 0x08 -#define ELIXIR_WELL_FED 0x10 // Some foods have SPELLFAMILY_POTION - -typedef std::map<uint32, uint8> SpellElixirMap; +enum SpellGroup +{ + SPELL_GROUP_ELIXIR_BATTLE = 1, + SPELL_GROUP_ELIXIR_GUARDIAN = 2, + SPELL_GROUP_ELIXIR_UNSTABLE = 3, + SPELL_GROUP_ELIXIR_SHATTRATH = 4, + SPELL_GROUP_WELL_FED = 5, +}; + +// spell_id, group_id +typedef std::multimap<uint32, SpellGroup> SpellSpellGroupMap; +typedef std::pair<SpellSpellGroupMap::const_iterator,SpellSpellGroupMap::const_iterator> SpellSpellGroupMapBounds; + +// group_id, spell_id +typedef std::multimap<SpellGroup, uint32> SpellGroupSpellMap; +typedef std::pair<SpellGroupSpellMap::const_iterator,SpellGroupSpellMap::const_iterator> SpellGroupSpellMapBounds; + typedef std::map<uint32, uint16> SpellThreatMap; typedef std::map<uint32, uint32> SpellStackMaskMap; @@ -860,30 +869,47 @@ class SpellMgr bool IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod) const; - SpellElixirMap const& GetSpellElixirMap() const { return mSpellElixirs; } - - uint32 GetSpellElixirMask(uint32 spellid) const + SpellSpellGroupMapBounds GetSpellSpellGroupMapBounds(uint32 spell_id) const { - SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid); - if(itr==mSpellElixirs.end()) - return 0x0; - - return itr->second; + spell_id = GetFirstSpellInChain(spell_id); + return SpellSpellGroupMapBounds(mSpellSpellGroup.lower_bound(spell_id),mSpellSpellGroup.upper_bound(spell_id)); + } + uint32 IsSpellMemberOfSpellGroup(uint32 spellid, SpellGroup groupid) const + { + SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellid); + for ( SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr) + { + if (itr->second == groupid) + return true; + } + return false; } + SpellGroupSpellMapBounds GetSpellGroupSpellMapBounds(SpellGroup group_id) const + { + return SpellGroupSpellMapBounds(mSpellGroupSpell.lower_bound(group_id),mSpellGroupSpell.upper_bound(group_id)); + } SpellSpecific GetSpellElixirSpecific(uint32 spellid) const { - uint32 mask = GetSpellElixirMask(spellid); - if((mask & ELIXIR_FLASK_MASK)==ELIXIR_FLASK_MASK) - return SPELL_SPECIFIC_FLASK_ELIXIR; - else if(mask & ELIXIR_BATTLE_MASK) - return SPELL_SPECIFIC_BATTLE_ELIXIR; - else if(mask & ELIXIR_GUARDIAN_MASK) - return SPELL_SPECIFIC_GUARDIAN_ELIXIR; - else if(mask & ELIXIR_WELL_FED) - return SPELL_SPECIFIC_WELL_FED; - else - return SPELL_SPECIFIC_NORMAL; + SpellSpecific spec = SPELL_SPECIFIC_NORMAL; + SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellid); + for ( SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr) + { + if (itr->second == SPELL_GROUP_ELIXIR_BATTLE + || itr->second == SPELL_GROUP_ELIXIR_GUARDIAN) + { + if (spec) + { + spec = SPELL_SPECIFIC_FLASK_ELIXIR; + break; + } + else if (itr->second == SPELL_GROUP_ELIXIR_BATTLE) + spec = SPELL_SPECIFIC_BATTLE_ELIXIR; + else if (itr->second == SPELL_GROUP_ELIXIR_GUARDIAN) + spec = SPELL_SPECIFIC_GUARDIAN_ELIXIR; + } + } + return spec; } // Used for stacking in spellmgr, and possibly in cancast checks @@ -1224,7 +1250,7 @@ class SpellMgr void LoadSpellLearnSkills(); void LoadSpellLearnSpells(); void LoadSpellScriptTarget(); - void LoadSpellElixirs(); + void LoadSpellGroups(); void LoadSpellProcEvents(); void LoadSpellBonusess(); void LoadSpellTargetPositions(); @@ -1251,7 +1277,8 @@ class SpellMgr SpellLearnSkillMap mSpellLearnSkills; SpellLearnSpellMap mSpellLearnSpells; SpellTargetPositionMap mSpellTargetPositions; - SpellElixirMap mSpellElixirs; + SpellSpellGroupMap mSpellSpellGroup; + SpellGroupSpellMap mSpellGroupSpell; SpellThreatMap mSpellThreatMap; SpellProcEventMap mSpellProcEventMap; SpellBonusMap mSpellBonusMap; diff --git a/src/game/World.cpp b/src/game/World.cpp index 939426d86d1..9f38e10e471 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1312,7 +1312,7 @@ void World::SetInitialWorldSettings() spellmgr.LoadSpellRequired(); sLog.outString("Loading Spell Elixir types..."); - spellmgr.LoadSpellElixirs(); + spellmgr.LoadSpellGroups(); sLog.outString("Loading Spell Learn Skills..."); spellmgr.LoadSpellLearnSkills(); // must be after LoadSpellRanks |