refactor(Core/Spell): Use ApplySpellFix with SpellInfo (#9938)
This commit is contained in:
@@ -316,7 +316,7 @@ bool SpellTargetSelector::operator()(Unit const* target) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// copypasta from Spell::CheckRange
|
// copypasta from Spell::CheckRange
|
||||||
uint32 range_type = _spellInfo->RangeEntry ? _spellInfo->RangeEntry->type : 0;
|
uint32 range_type = _spellInfo->RangeEntry ? _spellInfo->RangeEntry->Flags : 0;
|
||||||
float max_range = _caster->GetSpellMaxRangeForTarget(target, _spellInfo);
|
float max_range = _caster->GetSpellMaxRangeForTarget(target, _spellInfo);
|
||||||
float min_range = _caster->GetSpellMinRangeForTarget(target, _spellInfo);
|
float min_range = _caster->GetSpellMinRangeForTarget(target, _spellInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ void Pet::Update(uint32 diff)
|
|||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
return;
|
return;
|
||||||
float max_range = GetSpellMaxRangeForTarget(tempspellTarget, spellInfo);
|
float max_range = GetSpellMaxRangeForTarget(tempspellTarget, spellInfo);
|
||||||
if (spellInfo->RangeEntry->type == SPELL_RANGE_MELEE)
|
if (spellInfo->RangeEntry->Flags == SPELL_RANGE_MELEE)
|
||||||
max_range -= 2 * MIN_MELEE_REACH;
|
max_range -= 2 * MIN_MELEE_REACH;
|
||||||
|
|
||||||
if (IsWithinLOSInMap(tempspellTarget) && GetDistance(tempspellTarget) < max_range)
|
if (IsWithinLOSInMap(tempspellTarget) && GetDistance(tempspellTarget) < max_range)
|
||||||
|
|||||||
@@ -14383,7 +14383,7 @@ float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spell
|
|||||||
{
|
{
|
||||||
if (!spellInfo->RangeEntry)
|
if (!spellInfo->RangeEntry)
|
||||||
return 0;
|
return 0;
|
||||||
if (spellInfo->RangeEntry->maxRangeFriend == spellInfo->RangeEntry->maxRangeHostile)
|
if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0])
|
||||||
return spellInfo->GetMaxRange();
|
return spellInfo->GetMaxRange();
|
||||||
if (target == nullptr)
|
if (target == nullptr)
|
||||||
return spellInfo->GetMaxRange(true);
|
return spellInfo->GetMaxRange(true);
|
||||||
@@ -14394,7 +14394,7 @@ float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spell
|
|||||||
{
|
{
|
||||||
if (!spellInfo->RangeEntry)
|
if (!spellInfo->RangeEntry)
|
||||||
return 0;
|
return 0;
|
||||||
if (spellInfo->RangeEntry->minRangeFriend == spellInfo->RangeEntry->minRangeHostile)
|
if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0])
|
||||||
return spellInfo->GetMinRange();
|
return spellInfo->GetMinRange();
|
||||||
return spellInfo->GetMinRange(!IsHostileTo(target));
|
return spellInfo->GetMinRange(!IsHostileTo(target));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6681,7 +6681,7 @@ SpellCastResult Spell::CheckRange(bool strict)
|
|||||||
if (m_spellInfo->RangeEntry->ID == 1)
|
if (m_spellInfo->RangeEntry->ID == 1)
|
||||||
return SPELL_CAST_OK;
|
return SPELL_CAST_OK;
|
||||||
|
|
||||||
range_type = m_spellInfo->RangeEntry->type;
|
range_type = m_spellInfo->RangeEntry->Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit* target = m_targets.GetUnitTarget();
|
Unit* target = m_targets.GetUnitTarget();
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ public:
|
|||||||
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode);
|
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode);
|
||||||
void HandleThreatSpells();
|
void HandleThreatSpells();
|
||||||
|
|
||||||
SpellInfo const* m_spellInfo;
|
SpellInfo const* const m_spellInfo;
|
||||||
Item* m_CastItem;
|
Item* m_CastItem;
|
||||||
Item* m_weaponItem;
|
Item* m_weaponItem;
|
||||||
ObjectGuid m_castItemGUID;
|
ObjectGuid m_castItemGUID;
|
||||||
@@ -574,7 +574,6 @@ public:
|
|||||||
Unit* GetCaster() const { return m_caster; }
|
Unit* GetCaster() const { return m_caster; }
|
||||||
Unit* GetOriginalCaster() const { return m_originalCaster; }
|
Unit* GetOriginalCaster() const { return m_originalCaster; }
|
||||||
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
|
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
|
||||||
void SetSpellInfo(SpellInfo const* info) { m_spellInfo = info; }
|
|
||||||
int32 GetPowerCost() const { return m_powerCost; }
|
int32 GetPowerCost() const { return m_powerCost; }
|
||||||
|
|
||||||
bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
|
bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
|
||||||
|
|||||||
@@ -2275,8 +2275,8 @@ float SpellInfo::GetMinRange(bool positive) const
|
|||||||
if (!RangeEntry)
|
if (!RangeEntry)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
if (positive)
|
if (positive)
|
||||||
return RangeEntry->minRangeFriend;
|
return RangeEntry->RangeMin[1];
|
||||||
return RangeEntry->minRangeHostile;
|
return RangeEntry->RangeMin[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const
|
float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const
|
||||||
@@ -2285,9 +2285,9 @@ float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
float range;
|
float range;
|
||||||
if (positive)
|
if (positive)
|
||||||
range = RangeEntry->maxRangeFriend;
|
range = RangeEntry->RangeMax[1];
|
||||||
else
|
else
|
||||||
range = RangeEntry->maxRangeHostile;
|
range = RangeEntry->RangeMax[0];
|
||||||
if (caster)
|
if (caster)
|
||||||
if (Player* modOwner = caster->GetSpellModOwner())
|
if (Player* modOwner = caster->GetSpellModOwner())
|
||||||
modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell);
|
modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell);
|
||||||
|
|||||||
@@ -310,8 +310,10 @@ private:
|
|||||||
static std::array<StaticData, TOTAL_SPELL_EFFECTS> _data;
|
static std::array<StaticData, TOTAL_SPELL_EFFECTS> _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpellInfo
|
class AC_GAME_API SpellInfo
|
||||||
{
|
{
|
||||||
|
friend class SpellMgr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32 Id;
|
uint32 Id;
|
||||||
SpellCategoryEntry const* CategoryEntry;
|
SpellCategoryEntry const* CategoryEntry;
|
||||||
@@ -518,13 +520,23 @@ public:
|
|||||||
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
|
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
|
||||||
bool IsHighRankOf(SpellInfo const* spellInfo) const;
|
bool IsHighRankOf(SpellInfo const* spellInfo) const;
|
||||||
|
|
||||||
// loading helpers
|
std::array<SpellEffectInfo, MAX_SPELL_EFFECTS> const& GetEffects() const { return Effects; }
|
||||||
void _InitializeExplicitTargetMask();
|
SpellEffectInfo const& GetEffect(SpellEffIndex index) const { ASSERT(index < Effects.size()); return Effects[index]; }
|
||||||
|
|
||||||
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
|
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
|
||||||
bool _IsPositiveSpell() const;
|
bool _IsPositiveSpell() const;
|
||||||
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
|
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// loading helpers
|
||||||
|
void _InitializeExplicitTargetMask();
|
||||||
|
|
||||||
AuraStateType LoadAuraState() const;
|
AuraStateType LoadAuraState() const;
|
||||||
SpellSpecificType LoadSpellSpecific() const;
|
SpellSpecificType LoadSpellSpecific() const;
|
||||||
|
|
||||||
|
std::array<SpellEffectInfo, MAX_SPELL_EFFECTS>& _GetEffects() { return Effects; }
|
||||||
|
SpellEffectInfo& _GetEffect(SpellEffIndex index) { ASSERT(index < Effects.size()); return Effects[index]; }
|
||||||
|
|
||||||
// unloading helpers
|
// unloading helpers
|
||||||
void _UnloadImplicitTargetConditionLists();
|
void _UnloadImplicitTargetConditionLists();
|
||||||
};
|
};
|
||||||
|
|||||||
+1252
-1237
File diff suppressed because it is too large
Load Diff
@@ -759,8 +759,8 @@ public:
|
|||||||
void LoadSpellInfoStore();
|
void LoadSpellInfoStore();
|
||||||
void UnloadSpellInfoStore();
|
void UnloadSpellInfoStore();
|
||||||
void UnloadSpellInfoImplicitTargetConditionLists();
|
void UnloadSpellInfoImplicitTargetConditionLists();
|
||||||
void LoadSpellCustomAttr();
|
void LoadSpellInfoCustomAttributes();
|
||||||
void LoadDbcDataCorrections();
|
void LoadSpellInfoCorrections();
|
||||||
void LoadSpellSpecificAndAuraState();
|
void LoadSpellSpecificAndAuraState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1530,15 +1530,15 @@ void World::SetInitialWorldSettings()
|
|||||||
LOG_INFO("server.loading", "Loading Game Graveyard...");
|
LOG_INFO("server.loading", "Loading Game Graveyard...");
|
||||||
sGraveyard->LoadGraveyardFromDB();
|
sGraveyard->LoadGraveyardFromDB();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading spell dbc data corrections...");
|
|
||||||
sSpellMgr->LoadDbcDataCorrections();
|
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Initializing PlayerDump tables...");
|
LOG_INFO("server.loading", "Initializing PlayerDump tables...");
|
||||||
PlayerDump::InitializeTables();
|
PlayerDump::InitializeTables();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading SpellInfo store...");
|
LOG_INFO("server.loading", "Loading SpellInfo store...");
|
||||||
sSpellMgr->LoadSpellInfoStore();
|
sSpellMgr->LoadSpellInfoStore();
|
||||||
|
|
||||||
|
LOG_INFO("server.loading", "Loading SpellInfo data corrections...");
|
||||||
|
sSpellMgr->LoadSpellInfoCorrections();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading Spell Rank Data...");
|
LOG_INFO("server.loading", "Loading Spell Rank Data...");
|
||||||
sSpellMgr->LoadSpellRanks();
|
sSpellMgr->LoadSpellRanks();
|
||||||
|
|
||||||
@@ -1548,8 +1548,8 @@ void World::SetInitialWorldSettings()
|
|||||||
LOG_INFO("server.loading", "Loading SkillLineAbilityMultiMap Data...");
|
LOG_INFO("server.loading", "Loading SkillLineAbilityMultiMap Data...");
|
||||||
sSpellMgr->LoadSkillLineAbilityMap();
|
sSpellMgr->LoadSkillLineAbilityMap();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading spell custom attributes...");
|
LOG_INFO("server.loading", "Loading SpellInfo custom attributes...");
|
||||||
sSpellMgr->LoadSpellCustomAttr();
|
sSpellMgr->LoadSpellInfoCustomAttributes();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading GameObject models...");
|
LOG_INFO("server.loading", "Loading GameObject models...");
|
||||||
LoadGameObjectModelList(m_dataPath);
|
LoadGameObjectModelList(m_dataPath);
|
||||||
|
|||||||
@@ -1715,16 +1715,14 @@ struct SpellRadiusEntry
|
|||||||
|
|
||||||
struct SpellRangeEntry
|
struct SpellRangeEntry
|
||||||
{
|
{
|
||||||
uint32 ID;
|
uint32 ID; // 0
|
||||||
float minRangeHostile;
|
float RangeMin[2]; // 1-2 [0] Hostile [1] Friendly
|
||||||
float minRangeFriend;
|
float RangeMax[2]; // 3-4 [0] Hostile [1] Friendly
|
||||||
float maxRangeHostile;
|
uint32 Flags; // 5
|
||||||
float maxRangeFriend;
|
// char const* DisplayName[16]; // 6-21
|
||||||
uint32 type;
|
// uint32 DisplayName_lang_mask; // 22
|
||||||
//char const* Name[16]; // 7-23 unused
|
// char const* DisplayNameShort[16]; // 23-38
|
||||||
// 24 string flags, unused
|
// uint32 DisplayNameShort_lang_mask; // 39
|
||||||
//char const* Name2[16]; // 25-40 unused
|
|
||||||
// 41 string flags, unused
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpellRuneCostEntry
|
struct SpellRuneCostEntry
|
||||||
|
|||||||
Reference in New Issue
Block a user