diff options
author | DoctorKraft <DoctorKraft@users.noreply.github.com> | 2018-04-23 23:44:59 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2018-04-24 00:44:59 +0300 |
commit | 8ca6a20e7303e942adfb6d97b9aa94fab7c6b895 (patch) | |
tree | 7a45e9c22521d4fff769d5f80b79d95877b527ad | |
parent | 6b9948857057cfe495807a61b6797c75d9fc7a6a (diff) |
Core/Spells: Fix display for Shaman totems (#21848)
-rw-r--r-- | sql/updates/world/master/2018_04_23_00_world.sql | 213 | ||||
-rw-r--r-- | src/server/game/Entities/Totem/Totem.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 98 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 9 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 61 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.h | 6 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 3 |
7 files changed, 285 insertions, 118 deletions
diff --git a/sql/updates/world/master/2018_04_23_00_world.sql b/sql/updates/world/master/2018_04_23_00_world.sql new file mode 100644 index 00000000000..9fcb3f6a954 --- /dev/null +++ b/sql/updates/world/master/2018_04_23_00_world.sql @@ -0,0 +1,213 @@ +-- +-- Table structure for table `spell_totem_model` +-- +DROP TABLE IF EXISTS `spell_totem_model`; +CREATE TABLE `spell_totem_model` ( + `SpellID` int(10) unsigned NOT NULL, + `RaceID` tinyint(3) unsigned NOT NULL, + `DisplayID` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`SpellID`,`RaceID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +DELETE FROM `spell_totem_model` WHERE `SpellID` IN (2484, 5394, 51485, 98008, 108280, 157153, 192058, 192077, 192222, 196932, 198838, 202188, 204330, 204331, 204332, 204336, 207399, 210651, 210657, 210660); +INSERT INTO `spell_totem_model` (`SpellID`, `RaceID`, `DisplayID`) VALUES +(2484, 2, 30757), +(2484, 3, 30753), +(2484, 6, 4588), +(2484, 8, 30761), +(2484, 9, 30782), +(2484, 11, 19073), +(2484, 24, 41669), +(2484, 25, 41669), +(2484, 26, 41669), +(2484, 28, 81443), +(5394, 2, 30759), +(5394, 3, 30755), +(5394, 6, 4587), +(5394, 8, 30763), +(5394, 9, 30784), +(5394, 11, 19075), +(5394, 24, 41671), +(5394, 25, 41671), +(5394, 26, 41671), +(5394, 28, 81442), +(51485, 2, 30757), +(51485, 3, 30753), +(51485, 6, 4588), +(51485, 8, 30761), +(51485, 9, 30782), +(51485, 11, 19073), +(51485, 24, 41669), +(51485, 25, 41669), +(51485, 26, 41669), +(51485, 28, 81443), +(98008, 2, 30756), +(98008, 3, 30736), +(98008, 6, 4590), +(98008, 8, 30760), +(98008, 9, 30781), +(98008, 11, 19071), +(98008, 24, 41668), +(98008, 25, 41668), +(98008, 26, 41668), +(98008, 28, 81441), +(108280, 2, 30759), +(108280, 3, 30755), +(108280, 6, 4587), +(108280, 8, 30763), +(108280, 9, 30784), +(108280, 11, 19075), +(108280, 24, 41671), +(108280, 25, 41671), +(108280, 26, 41671), +(108280, 28, 81442), +(157153, 2, 30759), +(157153, 3, 30755), +(157153, 6, 4587), +(157153, 8, 30763), +(157153, 9, 30784), +(157153, 11, 19075), +(157153, 24, 41671), +(157153, 25, 41671), +(157153, 26, 41671), +(157153, 28, 81442), +(192058, 2, 30756), +(192058, 3, 30736), +(192058, 6, 4590), +(192058, 8, 30760), +(192058, 9, 30781), +(192058, 11, 19071), +(192058, 24, 41668), +(192058, 25, 41668), +(192058, 26, 41668), +(192058, 28, 81441), +(192077, 2, 30756), +(192077, 3, 30736), +(192077, 6, 4590), +(192077, 8, 30760), +(192077, 9, 30781), +(192077, 11, 19071), +(192077, 24, 41668), +(192077, 25, 41668), +(192077, 26, 41668), +(192077, 28, 81441), +(192222, 2, 30758), +(192222, 3, 30754), +(192222, 6, 4589), +(192222, 8, 30762), +(192222, 9, 30783), +(192222, 11, 19074), +(192222, 24, 41670), +(192222, 25, 41670), +(192222, 26, 41670), +(192222, 28, 81444), +(196932, 2, 30758), +(196932, 3, 30754), +(196932, 6, 4589), +(196932, 8, 30762), +(196932, 9, 30783), +(196932, 11, 19074), +(196932, 24, 41670), +(196932, 25, 41670), +(196932, 26, 41670), +(196932, 28, 81444), +(198838, 2, 30757), +(198838, 3, 30753), +(198838, 6, 4588), +(198838, 8, 30761), +(198838, 9, 30782), +(198838, 11, 19073), +(198838, 24, 41669), +(198838, 25, 41669), +(198838, 26, 41669), +(198838, 28, 81443), +(202188, 2, 30757), +(202188, 3, 30753), +(202188, 6, 4588), +(202188, 8, 30761), +(202188, 9, 30782), +(202188, 11, 19073), +(202188, 24, 41669), +(202188, 25, 41669), +(202188, 26, 41669), +(202188, 28, 81443), +(204330, 2, 30758), +(204330, 3, 30754), +(204330, 6, 4589), +(204330, 8, 30762), +(204330, 9, 30783), +(204330, 11, 19074), +(204330, 24, 41670), +(204330, 25, 41670), +(204330, 26, 41670), +(204330, 28, 81444), +(204331, 2, 30756), +(204331, 3, 30736), +(204331, 6, 4590), +(204331, 8, 30760), +(204331, 9, 30781), +(204331, 11, 19071), +(204331, 24, 41668), +(204331, 25, 41668), +(204331, 26, 41668), +(204331, 28, 81441), +(204332, 2, 30756), +(204332, 3, 30736), +(204332, 6, 4590), +(204332, 8, 30760), +(204332, 9, 30781), +(204332, 11, 19071), +(204332, 24, 41668), +(204332, 25, 41668), +(204332, 26, 41668), +(204332, 28, 81441), +(204336, 2, 30756), +(204336, 3, 30736), +(204336, 6, 4590), +(204336, 8, 30760), +(204336, 9, 30781), +(204336, 11, 19071), +(204336, 24, 41668), +(204336, 25, 41668), +(204336, 26, 41668), +(204336, 28, 81441), +(207399, 2, 30757), +(207399, 3, 30753), +(207399, 6, 4588), +(207399, 8, 30761), +(207399, 9, 30782), +(207399, 11, 19073), +(207399, 24, 41669), +(207399, 25, 41669), +(207399, 26, 41669), +(207399, 28, 81443), +(210651, 2, 30759), +(210651, 3, 30755), +(210651, 6, 4587), +(210651, 8, 30763), +(210651, 9, 30784), +(210651, 11, 19075), +(210651, 24, 41671), +(210651, 25, 41671), +(210651, 26, 41671), +(210651, 28, 81442), +(210657, 2, 30758), +(210657, 3, 30754), +(210657, 6, 4589), +(210657, 8, 30762), +(210657, 9, 30783), +(210657, 11, 19074), +(210657, 24, 41670), +(210657, 25, 41670), +(210657, 26, 41670), +(210657, 28, 81444), +(210660, 2, 30756), +(210660, 3, 30736), +(210660, 6, 4590), +(210660, 8, 30760), +(210660, 9, 30781), +(210660, 11, 19071), +(210660, 24, 41668), +(210660, 25, 41668), +(210660, 26, 41668), +(210660, 28, 81441); diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 5c505a20482..2f8822aa7ec 100644 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -67,17 +67,8 @@ void Totem::InitStats(uint32 duration) } // set display id depending on caster's race - if (SpellInfo const* createdBySpell = sSpellMgr->GetSpellInfo(GetUInt32Value(UNIT_CREATED_BY_SPELL))) - { - SpellEffectInfoVector effects = createdBySpell->GetEffectsForDifficulty(DIFFICULTY_NONE); - auto summonEffect = std::find_if(effects.begin(), effects.end(), [](SpellEffectInfo const* effect) - { - return effect && effect->IsEffect(SPELL_EFFECT_SUMMON); - }); - - if (summonEffect != effects.end()) - SetDisplayId(owner->GetModelForTotem(PlayerTotemType((*summonEffect)->MiscValueB))); - } + if (uint32 totemDisplayId = sSpellMgr->GetModelForTotem(GetUInt32Value(UNIT_CREATED_BY_SPELL), owner->getRace())) + SetDisplayId(totemDisplayId); } Minion::InitStats(duration); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 94cfa7d68b6..1d54a154144 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12517,104 +12517,6 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const return modelid; } -uint32 Unit::GetModelForTotem(PlayerTotemType totemType) -{ - switch (getRace()) - { - case RACE_ORC: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 30758; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 30757; - case SUMMON_TYPE_TOTEM_WATER: // water - return 30759; - case SUMMON_TYPE_TOTEM_AIR: // air - return 30756; - } - break; - } - case RACE_DWARF: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 30754; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 30753; - case SUMMON_TYPE_TOTEM_WATER: // water - return 30755; - case SUMMON_TYPE_TOTEM_AIR: // air - return 30736; - } - break; - } - case RACE_TROLL: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 30762; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 30761; - case SUMMON_TYPE_TOTEM_WATER: // water - return 30763; - case SUMMON_TYPE_TOTEM_AIR: // air - return 30760; - } - break; - } - case RACE_TAUREN: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 4589; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 4588; - case SUMMON_TYPE_TOTEM_WATER: // water - return 4587; - case SUMMON_TYPE_TOTEM_AIR: // air - return 4590; - } - break; - } - case RACE_DRAENEI: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 19074; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 19073; - case SUMMON_TYPE_TOTEM_WATER: // water - return 19075; - case SUMMON_TYPE_TOTEM_AIR: // air - return 19071; - } - break; - } - case RACE_GOBLIN: - { - switch (totemType) - { - case SUMMON_TYPE_TOTEM_FIRE: // fire - return 30783; - case SUMMON_TYPE_TOTEM_EARTH: // earth - return 30782; - case SUMMON_TYPE_TOTEM_WATER: // water - return 30784; - case SUMMON_TYPE_TOTEM_AIR: // air - return 30781; - } - break; - } - } - return 0; -} - void Unit::JumpTo(float speedXY, float speedZ, bool forward) { float angle = forward ? 0 : float(M_PI); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 6d8f9c81cbd..8f9ed8d5e42 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -912,14 +912,6 @@ enum ReactiveType #define MAX_GAMEOBJECT_SLOT 4 -enum PlayerTotemType -{ - SUMMON_TYPE_TOTEM_FIRE = 63, - SUMMON_TYPE_TOTEM_EARTH = 81, - SUMMON_TYPE_TOTEM_WATER = 82, - SUMMON_TYPE_TOTEM_AIR = 83 -}; - // delay time next attack to prevent client attack animation problems #define ATTACK_DISPLAY_DELAY 200 #define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player @@ -1830,7 +1822,6 @@ class TC_GAME_API Unit : public WorldObject void RemovePetAura(PetAura const* petSpell); uint32 GetModelForForm(ShapeshiftForm form) const; - uint32 GetModelForTotem(PlayerTotemType totemType); // Redirect Threat void SetRedirectThreat(ObjectGuid guid, uint32 pct) { _redirectThreadInfo.Set(guid, pct); } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 5f29ef5eafe..5d05a3cbf2d 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3495,3 +3495,64 @@ void SpellMgr::LoadPetFamilySpellsStore() } } } + +void SpellMgr::LoadSpellTotemModel() +{ + uint32 oldMSTime = getMSTime(); + + QueryResult result = WorldDatabase.Query("SELECT SpellID, RaceID, DisplayID from spell_totem_model"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 spell totem model records. DB table `spell_totem_model` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 spellId = fields[0].GetUInt32(); + uint8 race = fields[1].GetUInt8(); + uint32 displayId = fields[2].GetUInt32(); + + SpellInfo const* spellEntry = GetSpellInfo(spellId); + if (!spellEntry) + { + TC_LOG_ERROR("sql.sql", "SpellID: %u in `spell_totem_model` table could not be found in dbc, skipped.", spellId); + continue; + } + + ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race); + if (!raceEntry) + { + TC_LOG_ERROR("sql.sql", "Race %u defined in `spell_totem_model` does not exists, skipped.", uint32(race)); + continue; + } + + CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(displayId); + if (!displayEntry) + { + TC_LOG_ERROR("sql.sql", "SpellID: %u defined in `spell_totem_model` has non-existing model (%u).", spellId, displayId); + continue; + } + + mSpellTotemModel[std::make_pair(spellId, race)] = displayId; + ++count; + + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u spell totem model records in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + +} + +uint32 SpellMgr::GetModelForTotem(uint32 spellId, uint8 race) const +{ + auto itr = mSpellTotemModel.find(std::make_pair(spellId, race)); + if (itr != mSpellTotemModel.end()) + return itr->second; + + TC_LOG_ERROR("spells", "Spell %u with RaceID (%u) have no totem model data defined, set to default model.", spellId, race); + return 0; +} diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index d2ac51be311..db49b577c3c 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -593,6 +593,8 @@ struct SpellInfoLoadHelper SpellTotemsEntry const* Totems = nullptr; }; +typedef std::map<std::pair<uint32 /*SpellId*/, uint8 /*RaceId*/>, uint32 /*DisplayId*/> SpellTotemModelMap; + class TC_GAME_API SpellMgr { // Constructors @@ -685,6 +687,8 @@ class TC_GAME_API SpellMgr void LoadPetFamilySpellsStore(); + uint32 GetModelForTotem(uint32 spellId, uint8 race) const; + private: SpellInfo* _GetSpellInfo(uint32 spellId) { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : NULL; } @@ -718,6 +722,7 @@ class TC_GAME_API SpellMgr void LoadSpellInfoSpellSpecificAndAuraState(); void LoadSpellInfoDiminishing(); void LoadSpellInfoImmunities(); + void LoadSpellTotemModel(); private: SpellDifficultySearcherMap mSpellDifficultySearcherMap; @@ -746,6 +751,7 @@ class TC_GAME_API SpellMgr PetLevelupSpellMap mPetLevelupSpellMap; PetDefaultSpellsMap mPetDefaultSpellsMap; // only spells not listed in related mPetLevelupSpellMap entry SpellInfoMap mSpellInfoMap; + SpellTotemModelMap mSpellTotemModel; }; #define sSpellMgr SpellMgr::instance() diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 25ca56325cb..e4e04040bfe 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1612,6 +1612,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading PetFamilySpellsStore Data..."); sSpellMgr->LoadPetFamilySpellsStore(); + TC_LOG_INFO("server.loading", "Loading Spell Totem models..."); + sSpellMgr->LoadSpellTotemModel(); + TC_LOG_INFO("server.loading", "Loading GameObject models..."); LoadGameObjectModelList(m_dataPath); |