mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Core/Spells: Adding SpellTargetObjectTypes to spell target checker to early-eliminate alive units (#26028)
* Added object type into checker that is used by grid search to early eliminate alive units when looking for corpses * Removed script 'spell_hun_pet_carrion_feeder'. Ability doesn't exist anymore
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DELETE FROM spell_script_names WHERE ScriptName='spell_hun_pet_carrion_feeder';
|
||||
@@ -657,8 +657,8 @@ namespace Trinity
|
||||
class TC_GAME_API AnyDeadUnitSpellTargetInRangeCheck : public AnyDeadUnitObjectInRangeCheck
|
||||
{
|
||||
public:
|
||||
AnyDeadUnitSpellTargetInRangeCheck(Unit* searchObj, float range, SpellInfo const* spellInfo, SpellTargetCheckTypes check)
|
||||
: AnyDeadUnitObjectInRangeCheck(searchObj, range), i_spellInfo(spellInfo), i_check(searchObj, searchObj, spellInfo, check, nullptr)
|
||||
AnyDeadUnitSpellTargetInRangeCheck(Unit* searchObj, float range, SpellInfo const* spellInfo, SpellTargetCheckTypes check, SpellTargetObjectTypes objectType)
|
||||
: AnyDeadUnitObjectInRangeCheck(searchObj, range), i_spellInfo(spellInfo), i_check(searchObj, searchObj, spellInfo, check, nullptr, objectType)
|
||||
{ }
|
||||
bool operator()(Player* u);
|
||||
bool operator()(Corpse* u);
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
|
||||
if (uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList))
|
||||
{
|
||||
Trinity::WorldObjectSpellConeTargetCheck check(DegToRad(m_spellInfo->ConeAngle), m_spellInfo->Width ? m_spellInfo->Width : m_caster->GetCombatReach(), radius, m_caster, m_spellInfo, selectionType, condList);
|
||||
Trinity::WorldObjectSpellConeTargetCheck check(DegToRad(m_spellInfo->ConeAngle), m_spellInfo->Width ? m_spellInfo->Width : m_caster->GetCombatReach(), radius, m_caster, m_spellInfo, selectionType, condList, objectType);
|
||||
Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellConeTargetCheck> searcher(m_caster, targets, check, containerTypeMask);
|
||||
SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellConeTargetCheck> >(searcher, containerTypeMask, m_caster, m_caster, radius);
|
||||
|
||||
@@ -1630,7 +1630,7 @@ void Spell::SelectImplicitTrajTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
|
||||
SpellEffectInfo const* effect = m_spellInfo->GetEffect(effIndex);
|
||||
std::list<WorldObject*> targets;
|
||||
Trinity::WorldObjectSpellTrajTargetCheck check(dist2d, &srcPos, m_caster, m_spellInfo, targetType.GetCheckType(), effect->ImplicitTargetConditions);
|
||||
Trinity::WorldObjectSpellTrajTargetCheck check(dist2d, &srcPos, m_caster, m_spellInfo, targetType.GetCheckType(), effect->ImplicitTargetConditions, TARGET_OBJECT_TYPE_NONE);
|
||||
Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> searcher(m_caster, targets, check, GRID_MAP_TYPE_MASK_ALL);
|
||||
SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> > (searcher, GRID_MAP_TYPE_MASK_ALL, m_caster, &srcPos, dist2d);
|
||||
if (targets.empty())
|
||||
@@ -1856,7 +1856,7 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objec
|
||||
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
|
||||
if (!containerTypeMask)
|
||||
return nullptr;
|
||||
Trinity::WorldObjectSpellNearbyTargetCheck check(range, m_caster, m_spellInfo, selectionType, condList);
|
||||
Trinity::WorldObjectSpellNearbyTargetCheck check(range, m_caster, m_spellInfo, selectionType, condList, objectType);
|
||||
Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> searcher(m_caster, target, check, containerTypeMask);
|
||||
SearchTargets<Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> > (searcher, containerTypeMask, m_caster, m_caster, range);
|
||||
return target;
|
||||
@@ -1867,7 +1867,7 @@ void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Pos
|
||||
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
|
||||
if (!containerTypeMask)
|
||||
return;
|
||||
Trinity::WorldObjectSpellAreaTargetCheck check(range, position, m_caster, referer, m_spellInfo, selectionType, condList);
|
||||
Trinity::WorldObjectSpellAreaTargetCheck check(range, position, m_caster, referer, m_spellInfo, selectionType, condList, objectType);
|
||||
Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> searcher(m_caster, targets, check, containerTypeMask);
|
||||
SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> > (searcher, containerTypeMask, m_caster, position, range);
|
||||
}
|
||||
@@ -7882,8 +7882,8 @@ namespace Trinity
|
||||
{
|
||||
|
||||
WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo,
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList) : _caster(caster), _referer(referer), _spellInfo(spellInfo),
|
||||
_targetSelectionType(selectionType), _condList(condList)
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType) :
|
||||
_caster(caster), _referer(referer), _spellInfo(spellInfo), _targetSelectionType(selectionType), _condList(condList), _objectType(objectType)
|
||||
{
|
||||
if (condList)
|
||||
_condSrcInfo = new ConditionSourceInfo(nullptr, caster);
|
||||
@@ -7964,6 +7964,17 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (_objectType)
|
||||
{
|
||||
case TARGET_OBJECT_TYPE_CORPSE:
|
||||
case TARGET_OBJECT_TYPE_CORPSE_ALLY:
|
||||
case TARGET_OBJECT_TYPE_CORPSE_ENEMY:
|
||||
if (unitTarget->IsAlive())
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!_condSrcInfo)
|
||||
return true;
|
||||
@@ -7972,8 +7983,8 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target)
|
||||
}
|
||||
|
||||
WorldObjectSpellNearbyTargetCheck::WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo,
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList)
|
||||
: WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList), _range(range), _position(caster) { }
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType)
|
||||
: WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList, objectType), _range(range), _position(caster) { }
|
||||
|
||||
bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target)
|
||||
{
|
||||
@@ -7987,8 +7998,8 @@ bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target)
|
||||
}
|
||||
|
||||
WorldObjectSpellAreaTargetCheck::WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster,
|
||||
Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
|
||||
: WorldObjectSpellTargetCheck(caster, referer, spellInfo, selectionType, condList), _range(range), _position(position) { }
|
||||
Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType)
|
||||
: WorldObjectSpellTargetCheck(caster, referer, spellInfo, selectionType, condList, objectType), _range(range), _position(position) { }
|
||||
|
||||
bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
|
||||
{
|
||||
@@ -8010,8 +8021,8 @@ bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
|
||||
}
|
||||
|
||||
WorldObjectSpellConeTargetCheck::WorldObjectSpellConeTargetCheck(float coneAngle, float lineWidth, float range, Unit* caster,
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
|
||||
: WorldObjectSpellAreaTargetCheck(range, caster, caster, caster, spellInfo, selectionType, condList), _coneAngle(coneAngle), _lineWidth(lineWidth) { }
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType)
|
||||
: WorldObjectSpellAreaTargetCheck(range, caster, caster, caster, spellInfo, selectionType, condList, objectType), _coneAngle(coneAngle), _lineWidth(lineWidth) { }
|
||||
|
||||
bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target)
|
||||
{
|
||||
@@ -8036,8 +8047,8 @@ bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target)
|
||||
return WorldObjectSpellAreaTargetCheck::operator ()(target);
|
||||
}
|
||||
|
||||
WorldObjectSpellTrajTargetCheck::WorldObjectSpellTrajTargetCheck(float range, Position const* position, Unit* caster, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
|
||||
: WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList), _range(range), _position(position) { }
|
||||
WorldObjectSpellTrajTargetCheck::WorldObjectSpellTrajTargetCheck(float range, Position const* position, Unit* caster, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType)
|
||||
: WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList, objectType), _range(range), _position(position) { }
|
||||
|
||||
bool WorldObjectSpellTrajTargetCheck::operator()(WorldObject* target)
|
||||
{
|
||||
|
||||
@@ -911,9 +911,10 @@ namespace Trinity
|
||||
SpellTargetCheckTypes _targetSelectionType;
|
||||
ConditionSourceInfo* _condSrcInfo;
|
||||
ConditionContainer* _condList;
|
||||
SpellTargetObjectTypes _objectType;
|
||||
|
||||
WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo,
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList);
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType);
|
||||
~WorldObjectSpellTargetCheck();
|
||||
bool operator()(WorldObject* target);
|
||||
};
|
||||
@@ -923,7 +924,7 @@ namespace Trinity
|
||||
float _range;
|
||||
Position const* _position;
|
||||
WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo,
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList);
|
||||
SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType);
|
||||
bool operator()(WorldObject* target);
|
||||
};
|
||||
|
||||
@@ -932,7 +933,7 @@ namespace Trinity
|
||||
float _range;
|
||||
Position const* _position;
|
||||
WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster,
|
||||
Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
|
||||
Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType);
|
||||
bool operator()(WorldObject* target);
|
||||
};
|
||||
|
||||
@@ -941,7 +942,7 @@ namespace Trinity
|
||||
float _coneAngle;
|
||||
float _lineWidth;
|
||||
WorldObjectSpellConeTargetCheck(float coneAngle, float lineWidth, float range, Unit* caster,
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType);
|
||||
bool operator()(WorldObject* target);
|
||||
};
|
||||
|
||||
@@ -950,7 +951,7 @@ namespace Trinity
|
||||
float _range;
|
||||
Position const* _position;
|
||||
WorldObjectSpellTrajTargetCheck(float range, Position const* position, Unit* caster,
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
|
||||
SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList, SpellTargetObjectTypes objectType);
|
||||
bool operator()(WorldObject* target);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -589,12 +589,12 @@ bool IsWeaponSkill(uint32 skill);
|
||||
|
||||
inline bool IsProfessionSkill(uint32 skill)
|
||||
{
|
||||
return IsPrimaryProfessionSkill(skill) || skill == SKILL_FISHING || skill == SKILL_COOKING;
|
||||
return IsPrimaryProfessionSkill(skill) || skill == SKILL_FISHING || skill == SKILL_COOKING;
|
||||
}
|
||||
|
||||
inline bool IsProfessionOrRidingSkill(uint32 skill)
|
||||
{
|
||||
return IsProfessionSkill(skill) || skill == SKILL_RIDING;
|
||||
return IsProfessionSkill(skill) || skill == SKILL_RIDING;
|
||||
}
|
||||
|
||||
bool IsPartOfSkillLine(uint32 skillId, uint32 spellId);
|
||||
|
||||
@@ -1748,7 +1748,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader
|
||||
{
|
||||
// use 99 because it is 3d search
|
||||
std::list<WorldObject*> targetList;
|
||||
Trinity::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, nullptr);
|
||||
Trinity::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, nullptr, TARGET_OBJECT_TYPE_UNIT);
|
||||
Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> searcher(GetCaster(), targetList, check);
|
||||
Cell::VisitAllObjects(GetCaster(), searcher, 99.0f);
|
||||
float minDist = 99 * 99;
|
||||
|
||||
@@ -588,7 +588,7 @@ class spell_gen_cannibalize : public SpellScript
|
||||
float max_range = GetSpellInfo()->GetMaxRange(false);
|
||||
WorldObject* result = nullptr;
|
||||
// search for nearby enemy corpse in range
|
||||
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
|
||||
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY, TARGET_OBJECT_TYPE_CORPSE_ENEMY);
|
||||
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
|
||||
Cell::VisitWorldObjects(caster, searcher, max_range);
|
||||
if (!result)
|
||||
|
||||
@@ -606,63 +606,6 @@ class spell_hun_multi_shot : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
// 54044 - Pet Carrion Feeder
|
||||
class spell_hun_pet_carrion_feeder : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_hun_pet_carrion_feeder() : SpellScriptLoader("spell_hun_pet_carrion_feeder") { }
|
||||
|
||||
class spell_hun_pet_carrion_feeder_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_hun_pet_carrion_feeder_SpellScript);
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
if (!GetCaster()->IsPet())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_HUNTER_PET_CARRION_FEEDER_TRIGGERED });
|
||||
}
|
||||
|
||||
SpellCastResult CheckIfCorpseNear()
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
float max_range = GetSpellInfo()->GetMaxRange(false);
|
||||
WorldObject* result = nullptr;
|
||||
// search for nearby enemy corpse in range
|
||||
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
|
||||
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
|
||||
Cell::VisitWorldObjects(caster, searcher, max_range);
|
||||
if (!result)
|
||||
Cell::VisitGridObjects(caster, searcher, max_range);
|
||||
if (!result)
|
||||
return SPELL_FAILED_NO_EDIBLE_CORPSES;
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
caster->CastSpell(caster, SPELL_HUNTER_PET_CARRION_FEEDER_TRIGGERED, false);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHit += SpellEffectFn(spell_hun_pet_carrion_feeder_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
OnCheckCast += SpellCheckCastFn(spell_hun_pet_carrion_feeder_SpellScript::CheckIfCorpseNear);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const override
|
||||
{
|
||||
return new spell_hun_pet_carrion_feeder_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 55709 - Pet Heart of the Phoenix
|
||||
class spell_hun_pet_heart_of_the_phoenix : public SpellScriptLoader
|
||||
{
|
||||
@@ -1150,7 +1093,6 @@ void AddSC_hunter_spell_scripts()
|
||||
new spell_hun_misdirection();
|
||||
new spell_hun_misdirection_proc();
|
||||
new spell_hun_multi_shot();
|
||||
new spell_hun_pet_carrion_feeder();
|
||||
new spell_hun_pet_heart_of_the_phoenix();
|
||||
new spell_hun_readiness();
|
||||
new spell_hun_ready_set_aim();
|
||||
|
||||
Reference in New Issue
Block a user