Core/Spells: move more spells to spellscripts
This commit is contained in:
1 parent
5c36a50ed4
commit
fbddda52e7
7 files changed
+250
-112
No files matched your search
File renamed without changes.
@@ -0,0 +1,8 @@
|
||||
DELETE FROM `spell_script_names` WHERE `spell_id` IN (-34861,64844,64904,54968,71610,71641);
|
||||
INSERT INTO `spell_script_names` (`spell_id` ,`ScriptName`) VALUES
|
||||
(-34861,'spell_pri_circle_of_healing'),
|
||||
(64844, 'spell_pri_divine_hymn'),
|
||||
(64904, 'spell_pri_hymn_of_hope'),
|
||||
(54968, 'spell_pal_glyph_of_holy_light'),
|
||||
(71610, 'spell_item_echoes_of_light'),
|
||||
(71641, 'spell_item_echoes_of_light');
|
||||
@@ -1244,100 +1244,8 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
|
||||
CallScriptObjectAreaTargetSelectHandlers(targets, effIndex);
|
||||
|
||||
std::list<Unit*> unitTargets;
|
||||
std::list<GameObject*> gObjTargets;
|
||||
// for compability with older code - add only unit and go targets
|
||||
/// @todo remove this
|
||||
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
if (!targets.empty())
|
||||
{
|
||||
if (Unit* unitTarget = (*itr)->ToUnit())
|
||||
unitTargets.push_back(unitTarget);
|
||||
else if (GameObject* gObjTarget = (*itr)->ToGameObject())
|
||||
gObjTargets.push_back(gObjTarget);
|
||||
}
|
||||
|
||||
if (!unitTargets.empty())
|
||||
{
|
||||
// Special target selection for smart heals and energizes
|
||||
uint32 maxSize = 0;
|
||||
int32 power = -1;
|
||||
switch (m_spellInfo->SpellFamilyName)
|
||||
{
|
||||
case SPELLFAMILY_GENERIC:
|
||||
switch (m_spellInfo->Id)
|
||||
{
|
||||
case 52759: // Ancestral Awakening
|
||||
case 71610: // Echoes of Light (Althor's Abacus normal version)
|
||||
case 71641: // Echoes of Light (Althor's Abacus heroic version)
|
||||
maxSize = 1;
|
||||
power = POWER_HEALTH;
|
||||
break;
|
||||
case 54968: // Glyph of Holy Light
|
||||
maxSize = m_spellInfo->MaxAffectedTargets;
|
||||
power = POWER_HEALTH;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SPELLFAMILY_PRIEST:
|
||||
if (m_spellInfo->SpellFamilyFlags[0] == 0x10000000) // Circle of Healing
|
||||
{
|
||||
maxSize = m_caster->HasAura(55675) ? 6 : 5; // Glyph of Circle of Healing
|
||||
power = POWER_HEALTH;
|
||||
}
|
||||
else if (m_spellInfo->Id == 64844) // Divine Hymn
|
||||
{
|
||||
maxSize = 3;
|
||||
power = POWER_HEALTH;
|
||||
}
|
||||
else if (m_spellInfo->Id == 64904) // Hymn of Hope
|
||||
{
|
||||
maxSize = 3;
|
||||
power = POWER_MANA;
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
// Remove targets outside caster's raid
|
||||
for (std::list<Unit*>::iterator itr = unitTargets.begin(); itr != unitTargets.end();)
|
||||
{
|
||||
if (!(*itr)->IsInRaidWith(m_caster))
|
||||
itr = unitTargets.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (maxSize && power != -1)
|
||||
{
|
||||
if (Powers(power) == POWER_HEALTH)
|
||||
{
|
||||
if (unitTargets.size() > maxSize)
|
||||
{
|
||||
unitTargets.sort(Trinity::HealthPctOrderPred());
|
||||
unitTargets.resize(maxSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::list<Unit*>::iterator itr = unitTargets.begin(); itr != unitTargets.end();)
|
||||
if ((*itr)->getPowerType() != (Powers)power)
|
||||
itr = unitTargets.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
|
||||
if (unitTargets.size() > maxSize)
|
||||
{
|
||||
unitTargets.sort(Trinity::PowerPctOrderPred((Powers)power));
|
||||
unitTargets.resize(maxSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Other special target selection goes here
|
||||
if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
|
||||
{
|
||||
@@ -1346,27 +1254,16 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
if ((*j)->IsAffectedOnSpell(m_spellInfo))
|
||||
maxTargets += (*j)->GetAmount();
|
||||
|
||||
Trinity::Containers::RandomResizeList(unitTargets, maxTargets);
|
||||
Trinity::Containers::RandomResizeList(targets, maxTargets);
|
||||
}
|
||||
|
||||
for (std::list<Unit*>::iterator itr = unitTargets.begin(); itr != unitTargets.end(); ++itr)
|
||||
AddUnitTarget(*itr, effMask, false);
|
||||
}
|
||||
|
||||
if (!gObjTargets.empty())
|
||||
{
|
||||
if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
|
||||
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
{
|
||||
Unit::AuraEffectList const& Auras = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS);
|
||||
for (Unit::AuraEffectList::const_iterator j = Auras.begin(); j != Auras.end(); ++j)
|
||||
if ((*j)->IsAffectedOnSpell(m_spellInfo))
|
||||
maxTargets += (*j)->GetAmount();
|
||||
|
||||
Trinity::Containers::RandomResizeList(gObjTargets, maxTargets);
|
||||
if (Unit* unitTarget = (*itr)->ToUnit())
|
||||
AddUnitTarget(unitTarget, effMask, false);
|
||||
else if (GameObject* gObjTarget = (*itr)->ToGameObject())
|
||||
AddGOTarget(gObjTarget, effMask);
|
||||
}
|
||||
|
||||
for (std::list<GameObject*>::iterator itr = gObjTargets.begin(); itr != gObjTargets.end(); ++itr)
|
||||
AddGOTarget(*itr, effMask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1403,9 +1300,9 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
|
||||
float minDist = m_spellInfo->GetMinRange(true);
|
||||
float maxDist = m_spellInfo->GetMaxRange(true);
|
||||
float dist = frand(minDist, maxDist);
|
||||
float x, y, z, angle;
|
||||
float x, y, z;
|
||||
float angle = float(rand_norm()) * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
|
||||
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis, angle);
|
||||
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dist, angle);
|
||||
|
||||
float ground = z;
|
||||
float liquidLevel = m_caster->GetMap()->GetWaterOrGroundLevel(x, y, z, &ground);
|
||||
|
||||
@@ -349,6 +349,40 @@ class spell_item_deviate_fish : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
// 71610, 71641 - Echoes of Light (Althor's Abacus)
|
||||
class spell_item_echoes_of_light : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_item_echoes_of_light() : SpellScriptLoader("spell_item_echoes_of_light") { }
|
||||
|
||||
class spell_item_echoes_of_light_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_item_echoes_of_light_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
if (targets.size() < 2)
|
||||
return;
|
||||
|
||||
targets.sort(Trinity::HealthPctOrderPred());
|
||||
|
||||
WorldObject* target = targets.front();
|
||||
targets.clear();
|
||||
targets.push_back(target);
|
||||
}
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_item_echoes_of_light_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_item_echoes_of_light_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// http://www.wowhead.com/item=47499 Flask of the North
|
||||
// 67019 Flask of the North
|
||||
enum FlaskOfTheNorthSpells
|
||||
@@ -2571,6 +2605,7 @@ void AddSC_item_spell_scripts()
|
||||
new spell_item_defibrillate("spell_item_gnomish_army_knife", 33);
|
||||
new spell_item_desperate_defense();
|
||||
new spell_item_deviate_fish();
|
||||
new spell_item_echoes_of_light();
|
||||
new spell_item_flask_of_the_north();
|
||||
new spell_item_gnomish_death_ray();
|
||||
new spell_item_make_a_wish();
|
||||
|
||||
@@ -564,6 +564,39 @@ class spell_pal_eye_for_an_eye : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
// 54968 - Glyph of Holy Light
|
||||
class spell_pal_glyph_of_holy_light : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_pal_glyph_of_holy_light() : SpellScriptLoader("spell_pal_glyph_of_holy_light") { }
|
||||
|
||||
class spell_pal_glyph_of_holy_light_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pal_glyph_of_holy_light_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
uint32 const maxTargets = GetSpellInfo()->MaxAffectedTargets;
|
||||
|
||||
if (targets.size() > maxTargets)
|
||||
{
|
||||
targets.sort(Trinity::HealthPctOrderPred());
|
||||
targets.resize(maxTargets);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_glyph_of_holy_light_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_pal_glyph_of_holy_light_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 63521 - Guarded by The Light
|
||||
class spell_pal_guarded_by_the_light : public SpellScriptLoader
|
||||
{
|
||||
@@ -1142,6 +1175,7 @@ void AddSC_paladin_spell_scripts()
|
||||
new spell_pal_divine_storm_dummy();
|
||||
new spell_pal_exorcism_and_holy_wrath_damage();
|
||||
new spell_pal_eye_for_an_eye();
|
||||
new spell_pal_glyph_of_holy_light();
|
||||
new spell_pal_guarded_by_the_light();
|
||||
new spell_pal_hand_of_sacrifice();
|
||||
new spell_pal_hand_of_salvation();
|
||||
|
||||
@@ -31,6 +31,7 @@ enum PriestSpells
|
||||
{
|
||||
SPELL_PRIEST_DIVINE_AEGIS = 47753,
|
||||
SPELL_PRIEST_EMPOWERED_RENEW = 63544,
|
||||
SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING = 55675,
|
||||
SPELL_PRIEST_GLYPH_OF_LIGHTWELL = 55673,
|
||||
SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL = 56161,
|
||||
SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL = 48153,
|
||||
@@ -53,6 +54,82 @@ enum PriestSpellIcons
|
||||
PRIEST_ICON_ID_PAIN_AND_SUFFERING = 2874,
|
||||
};
|
||||
|
||||
class PowerCheck
|
||||
{
|
||||
public:
|
||||
explicit PowerCheck(Powers power) : _power(power) { }
|
||||
|
||||
bool operator()(WorldObject* obj) const
|
||||
{
|
||||
if (Unit* target = obj->ToUnit())
|
||||
return target->getPowerType() != _power;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Powers _power;
|
||||
};
|
||||
|
||||
class RaidCheck
|
||||
{
|
||||
public:
|
||||
explicit RaidCheck(Unit const* caster) : _caster(caster) { }
|
||||
|
||||
bool operator()(WorldObject* obj) const
|
||||
{
|
||||
if (Unit* target = obj->ToUnit())
|
||||
return !_caster->IsInRaidWith(target);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Unit const* _caster;
|
||||
};
|
||||
|
||||
// -34861 - Circle of Healing
|
||||
class spell_pri_circle_of_healing : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_pri_circle_of_healing() : SpellScriptLoader("spell_pri_circle_of_healing") { }
|
||||
|
||||
class spell_pri_circle_of_healing_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pri_circle_of_healing_SpellScript);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
|
||||
{
|
||||
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.remove_if(RaidCheck(GetCaster()));
|
||||
|
||||
uint32 const maxTargets = GetCaster()->HasAura(SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING) ? 6 : 5; // Glyph of Circle of Healing
|
||||
|
||||
if (targets.size() > maxTargets)
|
||||
{
|
||||
targets.sort(Trinity::HealthPctOrderPred());
|
||||
targets.resize(maxTargets);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_circle_of_healing_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_pri_circle_of_healing_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// -47509 - Divine Aegis
|
||||
class spell_pri_divine_aegis : public SpellScriptLoader
|
||||
{
|
||||
@@ -103,6 +180,41 @@ class spell_pri_divine_aegis : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
// 64844 - Divine Hymn
|
||||
class spell_pri_divine_hymn : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_pri_divine_hymn() : SpellScriptLoader("spell_pri_divine_hymn") { }
|
||||
|
||||
class spell_pri_divine_hymn_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pri_divine_hymn_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.remove_if(RaidCheck(GetCaster()));
|
||||
|
||||
uint32 const maxTargets = 3;
|
||||
|
||||
if (targets.size() > maxTargets)
|
||||
{
|
||||
targets.sort(Trinity::HealthPctOrderPred());
|
||||
targets.resize(maxTargets);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_divine_hymn_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_pri_divine_hymn_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 55680 - Glyph of Prayer of Healing
|
||||
class spell_pri_glyph_of_prayer_of_healing : public SpellScriptLoader
|
||||
{
|
||||
@@ -198,6 +310,42 @@ class spell_pri_guardian_spirit : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
// 64904 - Hymn of Hope
|
||||
class spell_pri_hymn_of_hope : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_pri_hymn_of_hope() : SpellScriptLoader("spell_pri_hymn_of_hope") { }
|
||||
|
||||
class spell_pri_hymn_of_hope_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pri_hymn_of_hope_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.remove_if(PowerCheck(POWER_MANA));
|
||||
targets.remove_if(RaidCheck(GetCaster()));
|
||||
|
||||
uint32 const maxTargets = 3;
|
||||
|
||||
if (targets.size() > maxTargets)
|
||||
{
|
||||
targets.sort(Trinity::PowerPctOrderPred(POWER_MANA));
|
||||
targets.resize(maxTargets);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_hymn_of_hope_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_pri_hymn_of_hope_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
// 37594 - Greater Heal Refund
|
||||
class spell_pri_item_greater_heal_refund : public SpellScriptLoader
|
||||
{
|
||||
@@ -703,9 +851,12 @@ class spell_pri_vampiric_touch : public SpellScriptLoader
|
||||
|
||||
void AddSC_priest_spell_scripts()
|
||||
{
|
||||
new spell_pri_circle_of_healing();
|
||||
new spell_pri_divine_aegis();
|
||||
new spell_pri_divine_hymn();
|
||||
new spell_pri_glyph_of_prayer_of_healing();
|
||||
new spell_pri_guardian_spirit();
|
||||
new spell_pri_hymn_of_hope();
|
||||
new spell_pri_item_greater_heal_refund();
|
||||
new spell_pri_lightwell_renew();
|
||||
new spell_pri_mana_burn();
|
||||
|
||||
@@ -79,6 +79,18 @@ class spell_sha_ancestral_awakening_proc : public SpellScriptLoader
|
||||
return true;
|
||||
}
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
if (targets.size() < 2)
|
||||
return;
|
||||
|
||||
targets.sort(Trinity::HealthPctOrderPred());
|
||||
|
||||
WorldObject* target = targets.front();
|
||||
targets.clear();
|
||||
targets.push_back(target);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
int32 damage = GetEffectValue();
|
||||
@@ -88,6 +100,7 @@ class spell_sha_ancestral_awakening_proc : public SpellScriptLoader
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_ancestral_awakening_proc_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_CASTER_AREA_RAID);
|
||||
OnEffectHitTarget += SpellEffectFn(spell_sha_ancestral_awakening_proc_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user