Merge pull request #6491

Core/Spells: convert some spell effects to SpellScripts
Closes #6491
This commit is contained in:
QAston committed 2012-06-14 19:12:03 +02:00
commit e53b44b6ba
30 files changed
+1967 -991

No files matched your search

+22 -133
View File
@@ -1286,18 +1286,6 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
maxSize = m_caster->HasAura(62970) ? 6 : 5; // Glyph of Wild Growth
power = POWER_HEALTH;
}
else if (m_spellInfo->SpellFamilyFlags[2] == 0x0100) // Starfall
{
// Remove targets not in LoS or in stealth
for (std::list<Unit*>::iterator itr = unitTargets.begin(); itr != unitTargets.end();)
{
if ((*itr)->HasStealthAura() || (*itr)->HasInvisibilityAura() || !(*itr)->IsWithinLOSInMap(m_caster))
itr = unitTargets.erase(itr);
else
++itr;
}
break;
}
else
break;
@@ -1338,6 +1326,11 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
}
}
// todo: move to scripts, but we must call it before resize list by MaxAffectedTargets
// Intimidating Shout
if (m_spellInfo->Id == 5246 && effIndex != EFFECT_0)
unitTargets.remove(m_targets.GetUnitTarget());
// Other special target selection goes here
if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
{
@@ -1346,8 +1339,6 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
if ((*j)->IsAffectedOnSpell(m_spellInfo))
maxTargets += (*j)->GetAmount();
if (m_spellInfo->Id == 5246) //Intimidating Shout
unitTargets.remove(m_targets.GetUnitTarget());
Trinity::Containers::RandomResizeList(unitTargets, maxTargets);
}
@@ -2473,12 +2464,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
caster->ToPlayer()->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx);
}
// Haunt
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[1] & 0x40000 && m_spellAura && m_spellAura->GetEffect(1))
{
AuraEffect* aurEff = m_spellAura->GetEffect(1);
aurEff->SetAmount(CalculatePctU(aurEff->GetAmount(), damageInfo.damage));
}
m_damage = damageInfo.damage;
@@ -4858,19 +4843,9 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target))
return SPELL_FAILED_LINE_OF_SIGHT;
}
else
{
if (m_caster->GetTypeId() == TYPEID_PLAYER) // Target - is player caster
{
// Lay on Hands - cannot be self-cast on paladin with Forbearance or after using Avenging Wrath
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN && m_spellInfo->SpellFamilyFlags[0] & 0x0008000)
if (target->HasAura(61988)) // Immunity shield marker
return SPELL_FAILED_TARGET_AURASTATE;
}
}
}
//Check for line of sight for spells with dest
// Check for line of sight for spells with dest
if (m_targets.HasDst())
{
float x, y, z;
@@ -4969,7 +4944,8 @@ SpellCastResult Spell::CheckCast(bool strict)
bool hasDispellableAura = false;
bool hasNonDispelEffect = false;
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
uint32 dispelMask = 0;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DISPEL)
{
if (m_spellInfo->Effects[i].IsTargetingArea() || m_spellInfo->AttributesEx & SPELL_ATTR1_MELEE_COMBAT_START)
@@ -4977,17 +4953,8 @@ SpellCastResult Spell::CheckCast(bool strict)
hasDispellableAura = true;
break;
}
if (Unit* target = m_targets.GetUnitTarget())
{
DispelChargesList dispelList;
uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[i].MiscValue));
target->GetDispellableAuraList(m_caster, dispelMask, dispelList);
if (!dispelList.empty())
{
hasDispellableAura = true;
break;
}
}
dispelMask |= SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[i].MiscValue));
}
else if (m_spellInfo->Effects[i].IsEffect())
{
@@ -4995,34 +4962,22 @@ SpellCastResult Spell::CheckCast(bool strict)
break;
}
if (!hasNonDispelEffect && !hasDispellableAura && m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL) && !IsTriggered())
return SPELL_FAILED_NOTHING_TO_DISPEL;
if (!hasNonDispelEffect && !hasDispellableAura && dispelMask && !IsTriggered())
{
if (Unit* target = m_targets.GetUnitTarget())
{
DispelChargesList dispelList;
target->GetDispellableAuraList(m_caster, dispelMask, dispelList);
if (dispelList.empty())
return SPELL_FAILED_NOTHING_TO_DISPEL;
}
}
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
// for effects of spells that have only one target
switch (m_spellInfo->Effects[i].Effect)
{
case SPELL_EFFECT_DUMMY:
{
if (m_spellInfo->Id == 19938) // Awaken Peon
{
Unit* unit = m_targets.GetUnitTarget();
if (!unit || !unit->HasAura(17743))
return SPELL_FAILED_BAD_TARGETS;
}
else if (m_spellInfo->Id == 31789) // Righteous Defense
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_DONT_REPORT;
Unit* target = m_targets.GetUnitTarget();
if (!target || !target->IsFriendlyTo(m_caster) || target->getAttackers().empty())
return SPELL_FAILED_BAD_TARGETS;
}
break;
}
case SPELL_EFFECT_LEARN_SPELL:
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
@@ -5339,10 +5294,6 @@ SpellCastResult Spell::CheckCast(bool strict)
}
case SPELL_EFFECT_LEAP_BACK:
{
// Spell 781 (Disengage) requires player to be in combat
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->Id == 781 && !m_caster->isInCombat())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
if (m_caster->HasUnitState(UNIT_STATE_ROOT))
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -5364,66 +5315,10 @@ SpellCastResult Spell::CheckCast(bool strict)
}
}
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch (m_spellInfo->Effects[i].ApplyAuraName)
{
case SPELL_AURA_DUMMY:
{
//custom check
switch (m_spellInfo->Id)
{
// Tag Murloc
case 30877:
{
Unit* target = m_targets.GetUnitTarget();
if (!target || target->GetEntry() != 17326)
return SPELL_FAILED_BAD_TARGETS;
break;
}
case 61336:
if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_caster->ToPlayer()->IsInFeralForm())
return SPELL_FAILED_ONLY_SHAPESHIFT;
break;
case 1515:
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_BAD_TARGETS;
if (!m_targets.GetUnitTarget() || m_targets.GetUnitTarget()->GetTypeId() == TYPEID_PLAYER)
return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
Creature* target = m_targets.GetUnitTarget()->ToCreature();
if (target->getLevel() > m_caster->getLevel())
return SPELL_FAILED_HIGHLEVEL;
// use SMSG_PET_TAME_FAILURE?
if (!target->GetCreatureTemplate()->isTameable (m_caster->ToPlayer()->CanTameExoticPets()))
return SPELL_FAILED_BAD_TARGETS;
if (m_caster->GetPetGUID())
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
if (m_caster->GetCharmGUID())
return SPELL_FAILED_ALREADY_HAVE_CHARM;
break;
}
case 44795: // Parachute
{
float x, y, z;
m_caster->GetPosition(x, y, z);
float ground_Z = m_caster->GetMap()->GetHeight(m_caster->GetPhaseMask(), x, y, z);
if (fabs(ground_Z - z) < 0.1f)
return SPELL_FAILED_DONT_REPORT;
break;
}
default:
break;
}
break;
}
case SPELL_AURA_MOD_POSSESS_PET:
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
@@ -7183,12 +7078,6 @@ void Spell::PrepareTriggersExecutedOnHit()
// todo: move this to scripts
switch (m_spellInfo->SpellFamilyName)
{
case SPELLFAMILY_GENERIC:
{
if (m_spellInfo->Mechanic == MECHANIC_BANDAGE) // Bandages
m_preCastSpell = 11196; // Recently Bandaged
break;
}
case SPELLFAMILY_MAGE:
{
// Permafrost