aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-01-15 00:52:55 +0100
committerShauren <shauren.trinity@gmail.com>2022-01-15 00:52:55 +0100
commit72286dc5e4fa5db2aff012d9cd496a8a6fc514c3 (patch)
treea4835eda486b5796dc702c49430ff1438e6aa646 /src/server/game/Spells
parentccccf8a2b551ee1a998c3050ff7d600f69542b79 (diff)
Core/Conditions: Initial support for UnitCondition.db2
Diffstat (limited to 'src/server/game/Spells')
-rw-r--r--src/server/game/Spells/SpellInfo.cpp18
-rw-r--r--src/server/game/Spells/SpellInfo.h4
2 files changed, 14 insertions, 8 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index a8726bc1595..7044d665667 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -4285,21 +4285,27 @@ bool SpellInfo::IsHighRankOf(SpellInfo const* spellInfo) const
return false;
}
-uint32 SpellInfo::GetSpellXSpellVisualId(WorldObject const* caster /*= nullptr*/) const
+uint32 SpellInfo::GetSpellXSpellVisualId(WorldObject const* caster /*= nullptr*/, WorldObject const* viewer /*= nullptr*/) const
{
for (SpellXSpellVisualEntry const* visual : _visuals)
{
- PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(visual->CasterPlayerConditionID);
- if (!playerCondition || (caster && caster->GetTypeId() == TYPEID_PLAYER && sConditionMgr->IsPlayerMeetingCondition(caster->ToPlayer(), playerCondition)))
- return visual->ID;
+ if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(visual->CasterPlayerConditionID))
+ if (!caster || !caster->IsPlayer() || !ConditionMgr::IsPlayerMeetingCondition(caster->ToPlayer(), playerCondition))
+ continue;
+
+ if (UnitConditionEntry const* unitCondition = sUnitConditionStore.LookupEntry(visual->CasterUnitConditionID))
+ if (!caster || !caster->IsUnit() || !ConditionMgr::IsUnitMeetingCondition(caster->ToUnit(), viewer->ToUnit(), unitCondition))
+ continue;
+
+ return visual->ID;
}
return 0;
}
-uint32 SpellInfo::GetSpellVisual(WorldObject const* caster /*= nullptr*/) const
+uint32 SpellInfo::GetSpellVisual(WorldObject const* caster /*= nullptr*/, WorldObject const* viewer /*= nullptr*/) const
{
- if (SpellXSpellVisualEntry const* visual = sSpellXSpellVisualStore.LookupEntry(GetSpellXSpellVisualId(caster)))
+ if (SpellXSpellVisualEntry const* visual = sSpellXSpellVisualStore.LookupEntry(GetSpellXSpellVisualId(caster, viewer)))
{
//if (visual->LowViolenceSpellVisualID && forPlayer->GetViolenceLevel() operator 2)
// return visual->LowViolenceSpellVisualID;
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 7e29f202a73..420155343e0 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -573,8 +573,8 @@ class TC_GAME_API SpellInfo
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
bool IsHighRankOf(SpellInfo const* spellInfo) const;
- uint32 GetSpellXSpellVisualId(WorldObject const* caster = nullptr) const;
- uint32 GetSpellVisual(WorldObject const* caster = nullptr) const;
+ uint32 GetSpellXSpellVisualId(WorldObject const* caster = nullptr, WorldObject const* viewer = nullptr) const;
+ uint32 GetSpellVisual(WorldObject const* caster = nullptr, WorldObject const* viewer = nullptr) const;
std::vector<SpellEffectInfo> const& GetEffects() const { return _effects; }
SpellEffectInfo const& GetEffect(SpellEffIndex index) const { ASSERT(index < _effects.size()); return _effects[index]; }