Core/Spells: convert some spell effects to SpellScripts

This commit is contained in:
joschiwald
2012-05-28 04:07:51 +02:00
parent 58f63509cd
commit ca07f30d03
26 changed files with 1099 additions and 455 deletions
-81
View File
@@ -3629,87 +3629,6 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId
// Call AfterDispel hook on AuraScript
aura->CallScriptAfterDispel(&dispelInfo);
switch (aura->GetSpellInfo()->SpellFamilyName)
{
case SPELLFAMILY_WARLOCK:
{
// Unstable Affliction (crash if before removeaura?)
if (aura->GetSpellInfo()->SpellFamilyFlags[1] & 0x0100)
{
Unit* caster = aura->GetCaster();
if (!caster)
break;
if (AuraEffect const* aurEff = aura->GetEffect(EFFECT_0))
{
int32 damage = aurEff->GetAmount() * 9;
// backfire damage and silence
caster->CastCustomSpell(dispeller, 31117, &damage, NULL, NULL, true, NULL, aurEff);
}
}
break;
}
case SPELLFAMILY_DRUID:
{
// Lifebloom
if (aura->GetSpellInfo()->SpellFamilyFlags[1] & 0x10)
{
if (AuraEffect const* aurEff = aura->GetEffect(EFFECT_1))
{
// final heal
int32 healAmount = aurEff->GetAmount();
if (Unit* caster = aura->GetCaster())
{
healAmount = caster->SpellHealingBonusDone(this, aura->GetSpellInfo(), healAmount, HEAL, dispelInfo.GetRemovedCharges());
healAmount = this->SpellHealingBonusTaken(aura->GetSpellInfo(), healAmount, HEAL, dispelInfo.GetRemovedCharges());
}
CastCustomSpell(this, 33778, &healAmount, NULL, NULL, true, NULL, NULL, aura->GetCasterGUID());
// mana
if (Unit* caster = aura->GetCaster())
{
int32 mana = CalculatePctU(caster->GetCreateMana(), aura->GetSpellInfo()->ManaCostPercentage) * chargesRemoved / 2;
caster->CastCustomSpell(caster, 64372, &mana, NULL, NULL, true, NULL, NULL, aura->GetCasterGUID());
}
}
}
break;
}
case SPELLFAMILY_SHAMAN:
{
// Flame Shock
if (aura->GetSpellInfo()->SpellFamilyFlags[0] & 0x10000000)
{
if (Unit* caster = aura->GetCaster())
{
uint32 triggeredSpellId = 0;
// Lava Flows
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 3087, 0))
{
switch (aurEff->GetId())
{
case 51482: // Rank 3
triggeredSpellId = 65264;
break;
case 51481: // Rank 2
triggeredSpellId = 65263;
break;
case 51480: // Rank 1
triggeredSpellId = 64694;
break;
default:
sLog->outError("Unit::RemoveAurasDueToSpellByDispel: Unknown rank of Lava Flows (%d) found", aurEff->GetId());
}
}
if (triggeredSpellId)
caster->CastSpell(caster, triggeredSpellId, true);
}
}
break;
}
default:
break;
}
return;
}
else
@@ -777,33 +777,18 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool create, bool load)
m_amplitude = 1 * IN_MILLISECONDS;
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_ENERGIZE:
case SPELL_AURA_OBS_MOD_HEALTH:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
case SPELL_AURA_PERIODIC_ENERGIZE:
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
case SPELL_AURA_PERIODIC_MANA_LEECH:
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
case SPELL_AURA_POWER_BURN:
m_isPeriodic = true;
break;
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
if (GetId() == 51912)
m_amplitude = 3000;
m_isPeriodic = true;
break;
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
case SPELL_AURA_PERIODIC_DUMMY:
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
m_isPeriodic = true;
break;
case SPELL_AURA_DUMMY:
// Haunting Spirits - perdiodic trigger demon
if (GetId() == 7057)
{
m_isPeriodic = true;
m_amplitude = irand (0, 60) + 30;
m_amplitude *= IN_MILLISECONDS;
}
break;
default:
break;
}
@@ -1099,14 +1084,6 @@ void AuraEffect::UpdatePeriodic(Unit* caster)
{
switch (GetAuraType())
{
case SPELL_AURA_DUMMY:
// Haunting Spirits
if (GetId() == 7057)
{
m_amplitude = irand (0, 60) + 30;
m_amplitude *= IN_MILLISECONDS;
}
break;
case SPELL_AURA_PERIODIC_DUMMY:
switch (GetSpellInfo()->SpellFamilyName)
{
@@ -1308,11 +1285,6 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit* caster)
case SPELL_AURA_POWER_BURN:
HandlePeriodicPowerBurnAuraTick(target, caster);
break;
case SPELL_AURA_DUMMY:
// Haunting Spirits
if (GetId() == 7057)
target->CastSpell((Unit*)NULL, GetAmount(), true);
break;
default:
break;
}
@@ -4804,38 +4776,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (Unit* spellTarget = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget()))
target->CastSpell(spellTarget, 51699, true);
break;
case 28832: // Mark of Korth'azz
case 28833: // Mark of Blaumeux
case 28834: // Mark of Rivendare
case 28835: // Mark of Zeliek
if (caster) // actually we can also use cast(this, originalcasterguid)
{
int32 damage;
switch (GetBase()->GetStackAmount())
{
case 1: damage = 0; break;
case 2: damage = 500; break;
case 3: damage = 1000; break;
case 4: damage = 1500; break;
case 5: damage = 4000; break;
case 6: damage = 12000; break;
default:damage = 20000 + 1000 * (GetBase()->GetStackAmount() - 7); break;
}
if (damage)
caster->CastCustomSpell(28836, SPELLVALUE_BASE_POINT0, damage, target);
}
break;
case 63322: // Saronite Vapors
{
if (caster)
{
int32 mana = int32(GetAmount() * pow(2.0f, GetBase()->GetStackAmount())); // mana restore - bp * 2^stackamount
int32 damage = mana * 2; // damage
caster->CastCustomSpell(target, 63337, &mana, NULL, NULL, true);
caster->CastCustomSpell(target, 63338, &damage, NULL, NULL, true);
}
break;
}
case 71563:
if (Aura* newAura = target->AddAura(71564, target))
newAura->SetStackAmount(newAura->GetSpellInfo()->StackAmount);
@@ -4929,57 +4869,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
break;
}
break;
case SPELLFAMILY_MAGE:
// Living Bomb
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000)
{
AuraRemoveMode removeMode = aurApp->GetRemoveMode();
if (caster && (removeMode == AURA_REMOVE_BY_ENEMY_SPELL || removeMode == AURA_REMOVE_BY_EXPIRE))
caster->CastSpell(target, GetAmount(), true);
}
break;
case SPELLFAMILY_PRIEST:
// Vampiric Touch
if (m_spellInfo->SpellFamilyFlags[1] & 0x0400 && aurApp->GetRemoveMode() == AURA_REMOVE_BY_ENEMY_SPELL && GetEffIndex() == 0)
if (AuraEffect const* aurEff = GetBase()->GetEffect(1))
{
int32 damage = aurEff->GetAmount() * 8;
// backfire damage
target->CastCustomSpell(target, 64085, &damage, NULL, NULL, true, NULL, NULL, GetCasterGUID());
}
break;
case SPELLFAMILY_WARLOCK:
// Haunt
if (m_spellInfo->SpellFamilyFlags[1] & 0x40000)
if (caster)
target->CastCustomSpell(caster, 48210, &m_amount, 0, 0, true, NULL, this, GetCasterGUID());
break;
case SPELLFAMILY_DRUID:
// Lifebloom
if (GetSpellInfo()->SpellFamilyFlags[1] & 0x10)
{
// Final heal only on duration end
if (aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
return;
// final heal
int32 stack = GetBase()->GetStackAmount();
int32 heal = m_amount;
if (caster)
{
heal = caster->SpellHealingBonusDone(target, GetSpellInfo(), heal, HEAL, stack);
heal = target->SpellHealingBonusTaken(GetSpellInfo(), heal, HEAL, stack);
}
target->CastCustomSpell(target, 33778, &heal, &stack, NULL, true, NULL, this, GetCasterGUID());
// restore mana
if (caster)
{
int32 returnmana = CalculatePctU(caster->GetCreateMana(), GetSpellInfo()->ManaCostPercentage) * stack / 2;
caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID());
}
}
break;
case SPELLFAMILY_DEATHKNIGHT:
// Summon Gargoyle (Dismiss Gargoyle at remove)
if (GetId() == 61777)
@@ -5087,16 +4976,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
break;
}
case 57723: // Exhaustion
case 57724: // Sated
{
switch (GetId())
{
case 57723: target->ApplySpellImmune(GetId(), IMMUNITY_ID, 32182, apply); break; // Heroism
case 57724: target->ApplySpellImmune(GetId(), IMMUNITY_ID, 2825, apply); break; // Bloodlust
}
break;
}
case 57819: // Argent Champion
case 57820: // Ebon Champion
case 57821: // Champion of the Kirin Tor
@@ -5884,14 +5763,6 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
if (caster)
caster->CastCustomSpell(29879, SPELLVALUE_BASE_POINT0, int32(target->CountPctFromMaxHealth(21)), target, true, NULL, this);
return;
// Detonate Mana
case 27819:
if (int32 mana = (int32)(target->GetMaxPower(POWER_MANA) / 10))
{
mana = target->ModifyPower(POWER_MANA, -mana);
target->CastCustomSpell(27820, SPELLVALUE_BASE_POINT0, -mana*10, target, true, NULL, this);
}
return;
// Inoculate Nestlewood Owlkin
case 29528:
if (target->GetTypeId() != TYPEID_UNIT) // prevent error reports in case ignored player target
+21 -83
View File
@@ -1288,18 +1288,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;
@@ -1340,6 +1328,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)
{
@@ -1348,8 +1341,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);
}
@@ -2477,12 +2468,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
caster->DealSpellDamage(&damageInfo, true);
// 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;
}
// Passive spell hits/misses or active spells only misses (only triggers)
@@ -4825,19 +4810,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;
@@ -4936,7 +4911,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)
@@ -4944,17 +4920,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())
{
@@ -4962,10 +4929,18 @@ 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)
@@ -4977,25 +4952,6 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_caster->IsInWater())
return SPELL_FAILED_ONLY_ABOVEWATER;
}
else if (m_spellInfo->SpellIconID == 156) // Holy Shock
{
// spell different for friends and enemies
// hurt version required facing
if (m_targets.GetUnitTarget() && !m_caster->IsFriendlyTo(m_targets.GetUnitTarget()) && !m_caster->HasInArc(static_cast<float>(M_PI), m_targets.GetUnitTarget()))
return SPELL_FAILED_UNIT_NOT_INFRONT;
}
else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo->SpellFamilyFlags[0] == 0x2000) // Death Coil (DeathKnight)
{
Unit* target = m_targets.GetUnitTarget();
if (!target || (target->IsFriendlyTo(m_caster) && target->GetCreatureType() != CREATURE_TYPE_UNDEAD))
return SPELL_FAILED_BAD_TARGETS;
}
else 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 == 52264) // Deliver Stolen Horse
{
if (!m_caster->FindNearestCreature(28653, 5))
@@ -5329,10 +5285,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)
@@ -5363,14 +5315,6 @@ SpellCastResult Spell::CheckCast(bool strict)
//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;
@@ -7173,12 +7117,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
-31
View File
@@ -368,28 +368,6 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
damage = (distance > radius) ? 0 : int32(m_spellInfo->Effects[EFFECT_0].CalcValue(m_caster) * ((radius - distance)/radius));
break;
}
// Loken Pulsing Shockwave
case 59837:
case 52942:
{
// don't damage self and only players
if (unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
float radius = m_spellInfo->Effects[EFFECT_0].CalcRadius(m_caster);
if (!radius)
return;
float distance = m_caster->GetDistance2d(unitTarget);
damage = (distance > radius) ? 0 : int32(m_spellInfo->Effects[EFFECT_0].CalcValue(m_caster) * distance);
break;
}
// TODO: add spell specific target requirement hook for spells
// Shadowbolts only affects targets with Shadow Mark (Gothik)
case 27831:
case 55638:
if (!unitTarget->HasAura(27825))
return;
break;
// Gargoyle Strike
case 51963:
{
@@ -3569,15 +3547,6 @@ void Spell::EffectHealMaxHealth(SpellEffIndex /*effIndex*/)
return;
int32 addhealth;
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN) // Lay on Hands
{
if (m_caster->GetGUID() == unitTarget->GetGUID())
{
m_caster->CastSpell(m_caster, 25771, true); // Forbearance
m_caster->CastSpell(m_caster, 61988, true); // Immune shield marker (serverside)
m_caster->CastSpell(m_caster, 61987, true); // Avenging Wrath marker
}
}
// damage == 0 - heal for caster max health
if (damage == 0)
+7 -12
View File
@@ -2960,8 +2960,10 @@ void SpellMgr::LoadDbcDataCorrections()
switch (spellInfo->Id)
{
case 40244: case 40245: // Simon Game Visual
case 40246: case 40247: // Simon Game Visual
case 40244: // Simon Game Visual
case 40245: // Simon Game Visual
case 40246: // Simon Game Visual
case 40247: // Simon Game Visual
case 42835: // Spout, remove damage effect, only anim is needed
spellInfo->Effect[0] = 0;
break;
@@ -3125,6 +3127,9 @@ void SpellMgr::LoadDbcDataCorrections()
case 51852: // The Eye of Acherus (no spawn in phase 2 in db)
spellInfo->EffectMiscValue[0] |= 1;
break;
case 51912: // Crafty's Ultra-Advanced Proto-Typical Shortening Blaster
spellInfo->EffectAmplitude[0] = 3000;
break;
case 29809: // Desecration Arm - 36 instead of 37 - typo? :/
spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_7_YARDS;
break;
@@ -3293,11 +3298,6 @@ void SpellMgr::LoadDbcDataCorrections()
// that will be clear if we get more spells with problem like this
spellInfo->AttributesEx |= SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY;
break;
case 62584: // Lifebinder's Gift
case 64185: // Lifebinder's Gift
spellInfo->EffectImplicitTargetB[1] = TARGET_UNIT_NEARBY_ENTRY;
spellInfo->EffectImplicitTargetB[2] = TARGET_UNIT_NEARBY_ENTRY;
break;
case 62301: // Cosmic Smash (Algalon the Observer)
spellInfo->MaxAffectedTargets = 1;
break;
@@ -3539,11 +3539,6 @@ void SpellMgr::LoadDbcDataCorrections()
switch (spellInfo->SpellFamilyName)
{
case SPELLFAMILY_DRUID:
// Starfall Target Selection
if (spellInfo->SpellFamilyFlags[2] & 0x100)
spellInfo->MaxAffectedTargets = 2;
break;
case SPELLFAMILY_PALADIN:
// Seals of the Pure should affect Seal of Righteousness
if (spellInfo->SpellIconID == 25 && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)