aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDoctorKraft <DoctorKraft@users.noreply.github.com>2018-04-23 23:44:59 +0200
committerShauren <shauren.trinity@gmail.com>2018-04-24 00:44:59 +0300
commit8ca6a20e7303e942adfb6d97b9aa94fab7c6b895 (patch)
tree7a45e9c22521d4fff769d5f80b79d95877b527ad /src
parent6b9948857057cfe495807a61b6797c75d9fc7a6a (diff)
Core/Spells: Fix display for Shaman totems (#21848)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Totem/Totem.cpp13
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp98
-rw-r--r--src/server/game/Entities/Unit/Unit.h9
-rw-r--r--src/server/game/Spells/SpellMgr.cpp61
-rw-r--r--src/server/game/Spells/SpellMgr.h6
-rw-r--r--src/server/game/World/World.cpp3
6 files changed, 72 insertions, 118 deletions
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);