mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
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;
|
||||
|
||||
// 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 min_range = _caster->GetSpellMinRangeForTarget(target, _spellInfo);
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ void Pet::Update(uint32 diff)
|
||||
if (!spellInfo)
|
||||
return;
|
||||
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;
|
||||
|
||||
if (IsWithinLOSInMap(tempspellTarget) && GetDistance(tempspellTarget) < max_range)
|
||||
|
||||
@@ -14383,7 +14383,7 @@ float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spell
|
||||
{
|
||||
if (!spellInfo->RangeEntry)
|
||||
return 0;
|
||||
if (spellInfo->RangeEntry->maxRangeFriend == spellInfo->RangeEntry->maxRangeHostile)
|
||||
if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0])
|
||||
return spellInfo->GetMaxRange();
|
||||
if (target == nullptr)
|
||||
return spellInfo->GetMaxRange(true);
|
||||
@@ -14394,7 +14394,7 @@ float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spell
|
||||
{
|
||||
if (!spellInfo->RangeEntry)
|
||||
return 0;
|
||||
if (spellInfo->RangeEntry->minRangeFriend == spellInfo->RangeEntry->minRangeHostile)
|
||||
if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0])
|
||||
return spellInfo->GetMinRange();
|
||||
return spellInfo->GetMinRange(!IsHostileTo(target));
|
||||
}
|
||||
|
||||
@@ -6681,7 +6681,7 @@ SpellCastResult Spell::CheckRange(bool strict)
|
||||
if (m_spellInfo->RangeEntry->ID == 1)
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
range_type = m_spellInfo->RangeEntry->type;
|
||||
range_type = m_spellInfo->RangeEntry->Flags;
|
||||
}
|
||||
|
||||
Unit* target = m_targets.GetUnitTarget();
|
||||
|
||||
@@ -517,7 +517,7 @@ public:
|
||||
void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode);
|
||||
void HandleThreatSpells();
|
||||
|
||||
SpellInfo const* m_spellInfo;
|
||||
SpellInfo const* const m_spellInfo;
|
||||
Item* m_CastItem;
|
||||
Item* m_weaponItem;
|
||||
ObjectGuid m_castItemGUID;
|
||||
@@ -574,7 +574,6 @@ public:
|
||||
Unit* GetCaster() const { return m_caster; }
|
||||
Unit* GetOriginalCaster() const { return m_originalCaster; }
|
||||
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
|
||||
void SetSpellInfo(SpellInfo const* info) { m_spellInfo = info; }
|
||||
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)
|
||||
|
||||
@@ -2275,8 +2275,8 @@ float SpellInfo::GetMinRange(bool positive) const
|
||||
if (!RangeEntry)
|
||||
return 0.0f;
|
||||
if (positive)
|
||||
return RangeEntry->minRangeFriend;
|
||||
return RangeEntry->minRangeHostile;
|
||||
return RangeEntry->RangeMin[1];
|
||||
return RangeEntry->RangeMin[0];
|
||||
}
|
||||
|
||||
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;
|
||||
float range;
|
||||
if (positive)
|
||||
range = RangeEntry->maxRangeFriend;
|
||||
range = RangeEntry->RangeMax[1];
|
||||
else
|
||||
range = RangeEntry->maxRangeHostile;
|
||||
range = RangeEntry->RangeMax[0];
|
||||
if (caster)
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell);
|
||||
|
||||
@@ -310,8 +310,10 @@ private:
|
||||
static std::array<StaticData, TOTAL_SPELL_EFFECTS> _data;
|
||||
};
|
||||
|
||||
class SpellInfo
|
||||
class AC_GAME_API SpellInfo
|
||||
{
|
||||
friend class SpellMgr;
|
||||
|
||||
public:
|
||||
uint32 Id;
|
||||
SpellCategoryEntry const* CategoryEntry;
|
||||
@@ -518,13 +520,23 @@ public:
|
||||
bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
|
||||
bool IsHighRankOf(SpellInfo const* spellInfo) const;
|
||||
|
||||
// loading helpers
|
||||
void _InitializeExplicitTargetMask();
|
||||
std::array<SpellEffectInfo, MAX_SPELL_EFFECTS> const& GetEffects() const { return Effects; }
|
||||
SpellEffectInfo const& GetEffect(SpellEffIndex index) const { ASSERT(index < Effects.size()); return Effects[index]; }
|
||||
|
||||
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
|
||||
bool _IsPositiveSpell() const;
|
||||
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
|
||||
|
||||
private:
|
||||
// loading helpers
|
||||
void _InitializeExplicitTargetMask();
|
||||
|
||||
AuraStateType LoadAuraState() 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
|
||||
void _UnloadImplicitTargetConditionLists();
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -759,8 +759,8 @@ public:
|
||||
void LoadSpellInfoStore();
|
||||
void UnloadSpellInfoStore();
|
||||
void UnloadSpellInfoImplicitTargetConditionLists();
|
||||
void LoadSpellCustomAttr();
|
||||
void LoadDbcDataCorrections();
|
||||
void LoadSpellInfoCustomAttributes();
|
||||
void LoadSpellInfoCorrections();
|
||||
void LoadSpellSpecificAndAuraState();
|
||||
|
||||
private:
|
||||
|
||||
@@ -1530,15 +1530,15 @@ void World::SetInitialWorldSettings()
|
||||
LOG_INFO("server.loading", "Loading Game Graveyard...");
|
||||
sGraveyard->LoadGraveyardFromDB();
|
||||
|
||||
LOG_INFO("server.loading", "Loading spell dbc data corrections...");
|
||||
sSpellMgr->LoadDbcDataCorrections();
|
||||
|
||||
LOG_INFO("server.loading", "Initializing PlayerDump tables...");
|
||||
PlayerDump::InitializeTables();
|
||||
|
||||
LOG_INFO("server.loading", "Loading SpellInfo store...");
|
||||
sSpellMgr->LoadSpellInfoStore();
|
||||
|
||||
LOG_INFO("server.loading", "Loading SpellInfo data corrections...");
|
||||
sSpellMgr->LoadSpellInfoCorrections();
|
||||
|
||||
LOG_INFO("server.loading", "Loading Spell Rank Data...");
|
||||
sSpellMgr->LoadSpellRanks();
|
||||
|
||||
@@ -1548,8 +1548,8 @@ void World::SetInitialWorldSettings()
|
||||
LOG_INFO("server.loading", "Loading SkillLineAbilityMultiMap Data...");
|
||||
sSpellMgr->LoadSkillLineAbilityMap();
|
||||
|
||||
LOG_INFO("server.loading", "Loading spell custom attributes...");
|
||||
sSpellMgr->LoadSpellCustomAttr();
|
||||
LOG_INFO("server.loading", "Loading SpellInfo custom attributes...");
|
||||
sSpellMgr->LoadSpellInfoCustomAttributes();
|
||||
|
||||
LOG_INFO("server.loading", "Loading GameObject models...");
|
||||
LoadGameObjectModelList(m_dataPath);
|
||||
|
||||
@@ -1715,16 +1715,14 @@ struct SpellRadiusEntry
|
||||
|
||||
struct SpellRangeEntry
|
||||
{
|
||||
uint32 ID;
|
||||
float minRangeHostile;
|
||||
float minRangeFriend;
|
||||
float maxRangeHostile;
|
||||
float maxRangeFriend;
|
||||
uint32 type;
|
||||
//char const* Name[16]; // 7-23 unused
|
||||
// 24 string flags, unused
|
||||
//char const* Name2[16]; // 25-40 unused
|
||||
// 41 string flags, unused
|
||||
uint32 ID; // 0
|
||||
float RangeMin[2]; // 1-2 [0] Hostile [1] Friendly
|
||||
float RangeMax[2]; // 3-4 [0] Hostile [1] Friendly
|
||||
uint32 Flags; // 5
|
||||
// char const* DisplayName[16]; // 6-21
|
||||
// uint32 DisplayName_lang_mask; // 22
|
||||
// char const* DisplayNameShort[16]; // 23-38
|
||||
// uint32 DisplayNameShort_lang_mask; // 39
|
||||
};
|
||||
|
||||
struct SpellRuneCostEntry
|
||||
|
||||
Reference in New Issue
Block a user