diff options
author | Kandera <KanderaDev@gmail.com> | 2012-02-18 12:12:49 +0100 |
---|---|---|
committer | QAston <qaston@gmail.com> | 2012-02-18 12:12:49 +0100 |
commit | c517806a23751dd92d6a064b7f721507f182bc75 (patch) | |
tree | e74b5c99a83b78eae49d8c085de37c0c077d5e74 /src | |
parent | d55c8c7cc422fb75a669c2e337c02690266ca7af (diff) |
Scripts/Spells: Convert code from Spell::EffectDummy to spell scripts.
Diffstat (limited to 'src')
22 files changed, 4315 insertions, 2906 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7bcd993192e..4670a976e42 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9768,6 +9768,7 @@ void Unit::SetMinion(Minion *minion, bool apply) { // Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL)); + if (spellInfo && (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE)) ToPlayer()->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL, true); } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 4112711ad3c..12e3fda0484 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -530,26 +530,24 @@ namespace Trinity class RaiseDeadObjectCheck { public: - RaiseDeadObjectCheck(Unit* source, float range) : _source(source), i_range(range) {} + RaiseDeadObjectCheck(Unit* source, float range) : _source(source), _range(range) {} bool operator()(Creature* u) { if (_source->GetTypeId() != TYPEID_PLAYER || !((Player*)_source)->isHonorOrXPTarget(u) || - u->getDeathState() != CORPSE || + u->getDeathState() != CORPSE || (u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1))) == 0 || (u->GetDisplayId() != u->GetNativeDisplayId())) return false; - return _source->IsWithinDistInMap(u, i_range); + return _source->IsWithinDistInMap(u, _range); } - bool operator()(Player* u) { if (_source == u || _source->GetTypeId() != TYPEID_PLAYER || !((Player*)_source)->isHonorOrXPTarget(u) || u->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) || u->isInFlight() || !u->isDead() || (u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1))) == 0) return false; - - return _source->IsWithinDistInMap(u, i_range); + return _source->IsWithinDistInMap(u, _range); } bool operator()(Corpse* u) @@ -557,12 +555,12 @@ namespace Trinity if (_source->GetTypeId() != TYPEID_PLAYER || u->GetType() == CORPSE_BONES) return false; - return _source->IsWithinDistInMap(u, i_range); + return _source->IsWithinDistInMap(u, _range); } template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; } private: Unit* const _source; - float i_range; + float _range; }; class ExplodeCorpseObjectCheck diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 837133c141f..407ddbf6b21 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -751,600 +751,6 @@ void Spell::EffectDummy(SpellEffIndex effIndex) // selection by spell family switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_GENERIC: - { - switch (m_spellInfo->Id) - { - case 31225: // Shimmering Vessel (restore creature to life) - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; - unitTarget->ToCreature()->setDeathState(JUST_ALIVED); - return; - } - case 12162: // Deep wounds - case 12850: // (now good common check for this spells) - case 12868: - { - if (!unitTarget) - return; - - // apply percent damage mods - damage = m_caster->SpellDamageBonus(unitTarget, m_spellInfo, damage, SPELL_DIRECT_DAMAGE); - - switch (m_spellInfo->Id) - { - case 12162: ApplyPctN(damage, 16); break; // Rank 1 - case 12850: ApplyPctN(damage, 32); break; // Rank 2 - case 12868: ApplyPctN(damage, 48); break; // Rank 3 - default: - sLog->outError("Spell::EffectDummy: Spell %u not handled in DW", m_spellInfo->Id); - return; - } - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(12721); - uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude; - - // Add remaining ticks to damage done - if (AuraEffect const* aurEff = unitTarget->GetAuraEffect(12721, EFFECT_0, m_caster->GetGUID())) - damage += aurEff->GetAmount() * (ticks - aurEff->GetTickNumber()); - - damage = damage / ticks; - m_caster->CastCustomSpell(unitTarget, 12721, &damage, NULL, NULL, true); - return; - } - case 13567: // Dummy Trigger - { - // can be used for different aura triggering, so select by aura - if (!m_triggeredByAuraSpell || !unitTarget) - return; - - switch (m_triggeredByAuraSpell->Id) - { - case 26467: // Persistent Shield - m_caster->CastCustomSpell(unitTarget, 26470, &damage, NULL, NULL, true); - break; - default: - sLog->outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u", m_triggeredByAuraSpell->Id); - break; - } - return; - } - case 17251: // Spirit Healer Res - { - if (!unitTarget || !m_originalCaster) - return; - - if (m_originalCaster->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); - data << uint64(unitTarget->GetGUID()); - m_originalCaster->ToPlayer()->GetSession()->SendPacket(&data); - } - return; - } - case 23019: // Crystal Prison Dummy DND - { - if (!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || unitTarget->ToCreature()->isPet()) - return; - - Creature* creatureTarget = unitTarget->ToCreature(); - - m_caster->SummonGameObject(179644, creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetOrientation(), 0, 0, 0, 0, uint32(creatureTarget->GetRespawnTime()-time(NULL))); - sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "SummonGameObject at SpellEfects.cpp EffectDummy for Spell 23019"); - - creatureTarget->DespawnOrUnsummon(); - - return; - } - case 23448: // Transporter Arrival - Ultrasafe Transporter: Gadgetzan - backfires - { - int32 r = irand(0, 119); - if (r < 20) // Transporter Malfunction - 1/6 polymorph - m_caster->CastSpell(m_caster, 23444, true); - else if (r < 100) // Evil Twin - 4/6 evil twin - m_caster->CastSpell(m_caster, 23445, true); - else // Transporter Malfunction - 1/6 miss the target - m_caster->CastSpell(m_caster, 36902, true); - return; - } - case 23453: // Gnomish Transporter - Ultrasafe Transporter: Gadgetzan - if (roll_chance_i(50)) // Gadgetzan Transporter - success - m_caster->CastSpell(m_caster, 23441, true); - else // Gadgetzan Transporter Failure - failure - m_caster->CastSpell(m_caster, 23446, true); - return; - case 25860: // Reindeer Transformation - { - if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) - return; - - float flyspeed = m_caster->GetSpeedRate(MOVE_FLIGHT); - float speed = m_caster->GetSpeedRate(MOVE_RUN); - - m_caster->RemoveAurasByType(SPELL_AURA_MOUNTED); - - //5 different spells used depending on mounted speed and if mount can fly or not - if (flyspeed >= 4.1f) - // Flying Reindeer - m_caster->CastSpell(m_caster, 44827, true); //310% flying Reindeer - else if (flyspeed >= 3.8f) - // Flying Reindeer - m_caster->CastSpell(m_caster, 44825, true); //280% flying Reindeer - else if (flyspeed >= 1.6f) - // Flying Reindeer - m_caster->CastSpell(m_caster, 44824, true); //60% flying Reindeer - else if (speed >= 2.0f) - // Reindeer - m_caster->CastSpell(m_caster, 25859, true); //100% ground Reindeer - else - // Reindeer - m_caster->CastSpell(m_caster, 25858, true); //60% ground Reindeer - - return; - } - case 26074: // Holiday Cheer - // implemented at client side - return; - // Polarity Shift - case 28089: - if (unitTarget) - unitTarget->CastSpell(unitTarget, roll_chance_i(50) ? 28059 : 28084, true, NULL, NULL, m_caster->GetGUID()); - break; - // Polarity Shift - case 39096: - if (unitTarget) - unitTarget->CastSpell(unitTarget, roll_chance_i(50) ? 39088 : 39091, true, NULL, NULL, m_caster->GetGUID()); - break; - case 29200: // Purify Helboar Meat - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - spell_id = roll_chance_i(50) - ? 29277 // Summon Purified Helboar Meat - : 29278; // Summon Toxic Helboar Meat - - m_caster->CastSpell(m_caster, spell_id, true, NULL); - return; - } - case 29858: // Soulshatter - if (unitTarget && unitTarget->CanHaveThreatList() - && unitTarget->getThreatManager().getThreat(m_caster) > 0.0f) - m_caster->CastSpell(unitTarget, 32835, true); - return; - case 30458: // Nigh Invulnerability - if (!m_CastItem) return; - if (roll_chance_i(86)) // Nigh-Invulnerability - success - m_caster->CastSpell(m_caster, 30456, true, m_CastItem); - else // Complete Vulnerability - backfire in 14% casts - m_caster->CastSpell(m_caster, 30457, true, m_CastItem); - return; - case 30507: // Poultryizer - if (!m_CastItem) return; - if (roll_chance_i(80)) // Poultryized! - success - m_caster->CastSpell(unitTarget, 30501, true, m_CastItem); - else // Poultryized! - backfire 20% - m_caster->CastSpell(unitTarget, 30504, true, m_CastItem); - return; - case 35745: // Socrethar's Stone - { - switch (m_caster->GetAreaId()) - { - case 3900: - spell_id = 35743; - break; // Socrethar Portal - case 3742: - spell_id = 35744; - break; // Socrethar Portal - default: - return; - } - - m_caster->CastSpell(m_caster, spell_id, true); - return; - } - case 37674: // Chaos Blast - { - if (!unitTarget) - return; - - int32 basepoints0 = 100; - m_caster->CastCustomSpell(unitTarget, 37675, &basepoints0, NULL, NULL, true); - return; - } - // Wrath of the Astromancer - case 42784: - { - uint32 count = 0; - for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->effectMask & (1<<effIndex)) - ++count; - - damage = 12000; // maybe wrong value - damage /= count; - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(42784); - - // now deal the damage - for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->effectMask & (1<<effIndex)) - { - if (Unit* casttarget = Unit::GetUnit((*unitTarget), ihit->targetGUID)) - m_caster->DealDamage(casttarget, damage, NULL, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_ARCANE, spellInfo, false); - } - - return; - } - // Demon Broiled Surprise - case 43723: - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player* player = (Player*)m_caster; - - if (player && player->GetQuestStatus(11379) == QUEST_STATUS_INCOMPLETE) - { - Creature* creature = player->FindNearestCreature(19973, 10, false); - if (!creature) - { - SendCastResult(SPELL_FAILED_NOT_HERE); - return; - } - - player->CastSpell(player, 43753, false); - } - return; - } - case 44875: // Complete Raptor Capture - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; - - unitTarget->ToCreature()->DespawnOrUnsummon(); - - //cast spell Raptor Capture Credit - m_caster->CastSpell(m_caster, 42337, true, NULL); - return; - } - case 47170: // Impale Leviroth - { - if (!unitTarget || (unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95))) - return; - - m_caster->DealDamage(unitTarget, unitTarget->CountPctFromMaxHealth(93)); - return; - } - case 49357: // Brewfest Mount Transformation - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) - return; - m_caster->RemoveAurasByType(SPELL_AURA_MOUNTED); - // Ram for Alliance, Kodo for Horde - if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) - { - if (m_caster->GetSpeedRate(MOVE_RUN) >= 2.0f) - // 100% Ram - m_caster->CastSpell(m_caster, 43900, true); - else - // 60% Ram - m_caster->CastSpell(m_caster, 43899, true); - } - else - { - if (m_caster->ToPlayer()->GetSpeedRate(MOVE_RUN) >= 2.0f) - // 100% Kodo - m_caster->CastSpell(m_caster, 49379, true); - else - // 60% Kodo - m_caster->CastSpell(m_caster, 49378, true); - } - return; - case 52845: // Brewfest Mount Transformation (Faction Swap) - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) - return; - m_caster->RemoveAurasByType(SPELL_AURA_MOUNTED); - // Ram for Horde, Kodo for Alliance - if (m_caster->ToPlayer()->GetTeam() == HORDE) - { - if (m_caster->GetSpeedRate(MOVE_RUN) >= 2.0f) - // 100% Ram - m_caster->CastSpell(m_caster, 43900, true); - else - // 60% Ram - m_caster->CastSpell(m_caster, 43899, true); - } - else - { - if (m_caster->ToPlayer()->GetSpeedRate(MOVE_RUN) >= 2.0f) - // 100% Kodo - m_caster->CastSpell(m_caster, 49379, true); - else - // 60% Kodo - m_caster->CastSpell(m_caster, 49378, true); - } - return; - case 55004: // Nitro Boosts - if (!m_CastItem) - return; - if (roll_chance_i(95)) // Nitro Boosts - success - m_caster->CastSpell(m_caster, 54861, true, m_CastItem); - else // Knocked Up - backfire 5% - m_caster->CastSpell(m_caster, 46014, true, m_CastItem); - return; - case 50243: // Teach Language - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - // spell has a 1/3 chance to trigger one of the below - if (roll_chance_i(66)) - return; - if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) - { - // 1000001 - gnomish binary - m_caster->CastSpell(m_caster, 50242, true); - } - else - { - // 01001000 - goblin binary - m_caster->CastSpell(m_caster, 50246, true); - } - - return; - } - case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite) - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if (Battleground* bg = m_caster->ToPlayer()->GetBattleground()) - bg->EventPlayerDroppedFlag(m_caster->ToPlayer()); - - m_caster->CastSpell(m_caster, 30452, true, NULL); - return; - } - case 52759: // Ancestral Awakening - if (!unitTarget) - return; - m_caster->CastCustomSpell(unitTarget, 52752, &damage, NULL, NULL, true); - return; - case 54171: // Divine Storm - { - if (m_UniqueTargetInfo.size()) - { - int32 heal = damage / m_UniqueTargetInfo.size(); - m_caster->CastCustomSpell(unitTarget, 54172, &heal, NULL, NULL, true); - } - return; - } - case 58418: // Portal to Orgrimmar - case 58420: // Portal to Stormwind - return; // implemented in EffectScript[0] - case 62324: // Throw Passenger - { - if (m_targets.HasTraj()) - { - if (Vehicle* vehicle = m_caster->GetVehicleKit()) - if (Unit* passenger = vehicle->GetPassenger(damage - 1)) - { - std::list<Unit*> unitList; - // use 99 because it is 3d search - SearchAreaTarget(unitList, 99, PUSH_DST_CENTER, SPELL_TARGETS_ENTRY, 33114); - float minDist = 99 * 99; - Unit* target = NULL; - for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - { - if (Vehicle* seat = (*itr)->GetVehicleKit()) - if (!seat->GetPassenger(0)) - if (Unit* device = seat->GetPassenger(2)) - if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - { - float dist = (*itr)->GetExactDistSq(m_targets.GetDst()); - if (dist < minDist) - { - minDist = dist; - target = (*itr); - } - } - } - if (target && target->IsWithinDist2d(m_targets.GetDst(), m_spellInfo->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct - passenger->EnterVehicle(target, 0); - else - { - passenger->ExitVehicle(); - float x, y, z; - m_targets.GetDst()->GetPosition(x, y, z); - passenger->GetMotionMaster()->MoveJump(x, y, z, m_targets.GetSpeedXY(), m_targets.GetSpeedZ()); - } - } - } - return; - } - case 64385: // Unusual Compass - { - m_caster->SetOrientation(float(urand(0, 62832)) / 10000.0f); - WorldPacket data; - m_caster->BuildHeartBeatMsg(&data); - m_caster->SendMessageToSet(&data, true); - return; - } - case 53808: // Pygmy Oil - { - Aura* pAura = m_caster->GetAura(53806); - if (pAura) - pAura->RefreshDuration(); - else - { - pAura = m_caster->GetAura(53805); - if (!pAura || pAura->GetStackAmount() < 5 || !roll_chance_i(50)) - m_caster->CastSpell(m_caster, 53805, true); - else - { - pAura->Remove(); - m_caster->CastSpell(m_caster, 53806, true); - } - } - return; - } - case 54577: // U.D.E.D. - { - if (unitTarget->GetEntry() != 29402) - return; - - m_caster->SummonGameObject(192693, unitTarget->GetPositionX(), unitTarget->GetPositionY(), - unitTarget->GetPositionZ(), unitTarget->GetOrientation(), 0, 0, 0, 0, 100); - - for (uint8 i = 0; i < 4; ++i) - m_caster->SummonGameObject(191567, float(unitTarget->GetPositionX() + irand(-7, 7)), - float(unitTarget->GetPositionY() + irand(-7, 7)), unitTarget->GetPositionZ(), unitTarget->GetOrientation(), - 0, 0, 0, 0, 100); - - unitTarget->Kill(unitTarget); - return; - } - case 51961: // Captured Chicken Cover - Quest 12702 & 12532 - { - if (m_caster->GetTypeId() != TYPEID_PLAYER - || !unitTarget->HasAura(51959) - || !(m_caster->ToPlayer()->GetQuestStatus(12702) == QUEST_STATUS_INCOMPLETE || m_caster->ToPlayer()->GetQuestStatus(12532) == QUEST_STATUS_INCOMPLETE)) - return; - - m_caster->CastSpell(m_caster, 51037, true); - unitTarget->Kill(unitTarget); - return; - } - } - - break; - } - case SPELLFAMILY_WARRIOR: - // Charge - if (m_spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_WARRIOR_CHARGE && m_spellInfo->SpellVisual[0] == 867) - { - int32 chargeBasePoints0 = damage; - m_caster->CastCustomSpell(m_caster, 34846, &chargeBasePoints0, NULL, NULL, true); - - //Juggernaut crit bonus - if (m_caster->HasAura(64976)) - m_caster->CastSpell(m_caster, 65156, true); - return; - } - // Slam - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_WARRIOR_SLAM && m_spellInfo->SpellIconID == 559) - { - int32 bp0 = damage; - m_caster->CastCustomSpell(unitTarget, 50783, &bp0, NULL, NULL, true, 0); - return; - } - // Execute - if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & SPELLFAMILYFLAG_WARRIOR_EXECUTE) - { - if (!unitTarget) - return; - - spell_id = 20647; - - int32 rageUsed = std::min<int32>(300 - m_powerCost, m_caster->GetPower(POWER_RAGE)); - int32 newRage = std::max<int32>(0, m_caster->GetPower(POWER_RAGE) - rageUsed); - - // Sudden Death rage save - if (AuraEffect* aurEff = m_caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_GENERIC, 1989, EFFECT_0)) - { - int32 ragesave = aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue() * 10; - newRage = std::max(newRage, ragesave); - } - - m_caster->SetPower(POWER_RAGE, uint32(newRage)); - - // Glyph of Execution bonus - if (AuraEffect* aurEff = m_caster->GetAuraEffect(58367, EFFECT_0)) - rageUsed += aurEff->GetAmount() * 10; - - bp = damage + int32(rageUsed * m_spellInfo->Effects[effIndex].DamageMultiplier + m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.2f); - break; - } - // Concussion Blow - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_WARRIOR_CONCUSSION_BLOW) - { - m_damage += CalculatePctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK)); - return; - } - switch (m_spellInfo->Id) - { - // Bloodthirst - case 23881: - { - m_caster->CastCustomSpell(unitTarget, 23885, &damage, NULL, NULL, true, NULL); - return; - } - } - break; - case SPELLFAMILY_WARLOCK: - // Life Tap - if ((m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_WARLOCK_LIFETAP) && m_caster->ToPlayer()) - { - float spFactor = 0.0f; - switch (m_spellInfo->Id) - { - case 11689: spFactor = 0.2f; break; - case 27222: - case 57946: spFactor = 0.5f; break; - } - int32 damage = int32(m_spellInfo->Effects[EFFECT_0].CalcValue() + (6.3875 * m_spellInfo->BaseLevel)); - int32 mana = int32(damage + (m_caster->ToPlayer()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+SPELL_SCHOOL_SHADOW) * spFactor)); - - if (unitTarget && (int32(unitTarget->GetHealth()) > damage)) - { - // Shouldn't Appear in Combat Log - unitTarget->ModifyHealth(-damage); - - // Improved Life Tap mod - if (AuraEffect const* aurEff = m_caster->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 208, 0)) - AddPctN(mana, aurEff->GetAmount()); - - m_caster->CastCustomSpell(unitTarget, 31818, &mana, NULL, NULL, false); - - // Mana Feed - int32 manaFeedVal = 0; - if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_WARLOCK, 1982, 0)) - manaFeedVal = aurEff->GetAmount(); - - if (manaFeedVal > 0) - { - ApplyPctN(manaFeedVal, mana); - m_caster->CastCustomSpell(m_caster, 32553, &manaFeedVal, NULL, NULL, true, NULL); - } - } - else - SendCastResult(SPELL_FAILED_FIZZLE); - return; - } - break; - case SPELLFAMILY_DRUID: - // Starfall - if (m_spellInfo->SpellFamilyFlags[2] & SPELLFAMILYFLAG2_DRUID_STARFALL) - { - //Shapeshifting into an animal form or mounting cancels the effect. - if (m_caster->GetCreatureType() == CREATURE_TYPE_BEAST || m_caster->IsMounted()) - { - if (m_triggeredByAuraSpell) - m_caster->RemoveAurasDueToSpell(m_triggeredByAuraSpell->Id); - return; - } - - //Any effect which causes you to lose control of your character will supress the starfall effect. - if (m_caster->HasUnitState(UNIT_STATE_CONTROLLED)) - return; - - m_caster->CastSpell(unitTarget, damage, true); - return; - } - break; case SPELLFAMILY_PALADIN: switch (m_spellInfo->Id) { @@ -1378,128 +784,40 @@ void Spell::EffectDummy(SpellEffIndex effIndex) } } break; - case SPELLFAMILY_SHAMAN: - // Cleansing Totem Pulse - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_SHAMAN_TOTEM_EFFECTS && m_spellInfo->SpellIconID == 1673) - { - int32 bp1 = 1; - // Cleansing Totem Effect - if (unitTarget) - m_caster->CastCustomSpell(unitTarget, 52025, NULL, &bp1, NULL, true, NULL, NULL, m_originalCasterGUID); - return; - } - // Healing Stream Totem - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_SHAMAN_HEALING_STREAM) - { - if (!unitTarget) - return; - if (Unit* owner = m_caster->GetOwner()) - { - if (m_triggeredByAuraSpell) - damage = int32(owner->SpellHealingBonus(unitTarget, m_triggeredByAuraSpell, damage, HEAL)); - - // Restorative Totems - if (AuraEffect* dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 338, 1)) - AddPctN(damage, dummy->GetAmount()); - - // Glyph of Healing Stream Totem - if (AuraEffect const* aurEff = owner->GetAuraEffect(55456, EFFECT_0)) - AddPctN(damage, aurEff->GetAmount()); - } - m_caster->CastCustomSpell(unitTarget, 52042, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); - return; - } - // Mana Spring Totem - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_SHAMAN_MANA_SPRING) - { - if (!unitTarget || unitTarget->getPowerType() != POWER_MANA) - return; - m_caster->CastCustomSpell(unitTarget, 52032, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); - return; - } - // Lava Lash - if (m_spellInfo->SpellFamilyFlags[2] & SPELLFAMILYFLAG2_SHAMAN_LAVA_LASH) - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if (m_caster->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - { - // Damage is increased by 25% if your off-hand weapon is enchanted with Flametongue. - if (m_caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0x200000, 0, 0)) - AddPctN(m_damage, damage); - } - return; - } - break; case SPELLFAMILY_DEATHKNIGHT: - // Death strike - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE) - { - uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID()); - bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier))); - // Improved Death Strike - if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0)) - AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellInfo(), 2)); - m_caster->CastCustomSpell(m_caster, 45470, &bp, NULL, NULL, false); - return; - } - // Death Coil - if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_COIL) - { - if (m_caster->IsFriendlyTo(unitTarget)) - { - bp = int32(damage * 1.5f); - m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true); - } - else - { - bp = damage; - m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true); - } - return; - } switch (m_spellInfo->Id) { - case 49560: // Death Grip - Position pos; - GetSummonPosition(effIndex, pos); - if (Unit* unit = unitTarget->GetVehicleBase()) // what is this for? - unit->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), damage, true); - else if (!unitTarget->HasAuraType(SPELL_AURA_DEFLECT_SPELLS)) // Deterrence - unitTarget->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), damage, true); - return; - case 46584: // Raise Dead - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; + case 46584: // Raise Dead + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; - // Do we have talent Master of Ghouls? - if (m_caster->HasAura(52143)) - // summon as pet - bp = 52150; - else - // or guardian - bp = 46585; + // Do we have talent Master of Ghouls? + if (m_caster->HasAura(52143)) + // summon as pet + bp = 52150; + else + // or guardian + bp = 46585; - if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDst()); - else - { - targets.SetDst(*m_caster); - // Corpse not found - take reagents (only not triggered cast can take them) - triggered = false; - } - // Remove cooldown - summon spellls have category - m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); - spell_id = 48289; - break; - // Raise dead - take reagents and trigger summon spells - case 48289: - if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDst()); + if (m_targets.HasDst()) + targets.SetDst(*m_targets.GetDst()); + else + { + targets.SetDst(*m_caster); + // Corpse not found - take reagents (only not triggered cast can take them) + triggered = false; + } + // Remove cooldown - summon spellls have category + m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); + spell_id = 48289; + break; + // Raise dead - take reagents and trigger summon spells + case 48289: + if (m_targets.HasDst()) + targets.SetDst(*m_targets.GetDst()); - spell_id = CalculateDamage(0, NULL); - break; + spell_id = CalculateDamage(0, NULL); + break; } break; } diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 8a58ce3c52a..14dd32a71b6 100755 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -468,6 +468,16 @@ void SpellScript::PreventHitAura() m_spell->m_spellAura->Remove(); } +void SpellScript::GetSummonPosition(uint32 i, Position &pos, float radius = 0.0f, uint32 count = 0) +{ + m_spell->GetSummonPosition(i, pos, radius, count); +} + +void SpellScript::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNotifyPushType type, SpellTargets TargetType, uint32 entry) +{ + m_spell->SearchAreaTarget(TagUnitMap, radius, type, TargetType, entry); +} + void SpellScript::PreventHitEffect(SpellEffIndex effIndex) { if (!IsInHitPhase() && !IsInEffectHook()) diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 945a62674d9..09b9eaebd62 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -21,6 +21,7 @@ #include "Util.h" #include "SharedDefines.h" #include "SpellAuraDefines.h" +#include "Spell.h" #include <stack> class Unit; @@ -333,7 +334,9 @@ class SpellScript : public _SpellScript int32 GetHitHeal(); void SetHitHeal(int32 heal); void PreventHitHeal() { SetHitHeal(0); } - + Spell* GetSpell() { return m_spell; } + void GetSummonPosition(uint32 i, Position &pos, float radius, uint32 count); + void SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNotifyPushType type, SpellTargets TargetType, uint32 entry); // returns current spell hit target aura Aura* GetHitAura(); // prevents applying aura on current spell hit target diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index 7977fa4df8a..e308cc59708 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -15,7 +15,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "ScriptPCH.h" #include "naxxramas.h" //Stalagg @@ -87,7 +86,9 @@ enum ThaddiusSpells SPELL_POSITIVE_CHARGE = 28062, SPELL_POSITIVE_CHARGE_STACK = 29659, SPELL_NEGATIVE_CHARGE = 28085, - SPELL_NEGATIVE_CHARGE_STACK = 29660 + SPELL_NEGATIVE_CHARGE_STACK = 29660, + SPELL_POSITIVE_POLARITY = 28059, + SPELL_NEGATIVE_POLARITY = 28084, }; enum Events @@ -503,6 +504,41 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader } }; +class spell_thaddius_polarity_shift : public SpellScriptLoader +{ + public: + spell_thaddius_polarity_shift() : SpellScriptLoader("spell_thaddius_polarity_shift") { } + + class spell_thaddius_polarity_shift_SpellScript : public SpellScript + { + PrepareSpellScript(spell_thaddius_polarity_shift_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_POLARITY) || !sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_POLARITY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, NULL, NULL, caster->GetGUID()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_thaddius_polarity_shift_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_thaddius_polarity_shift_SpellScript(); + } +}; + class achievement_polarity_switch : public AchievementCriteriaScript { public: @@ -520,5 +556,6 @@ void AddSC_boss_thaddius() new mob_stalagg(); new mob_feugen(); new spell_thaddius_pos_neg_charge(); + new spell_thaddius_polarity_shift(); new achievement_polarity_switch(); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 2bc2284a246..8c637bc4e90 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -34,6 +34,7 @@ #include "Vehicle.h" #include "VehicleDefines.h" #include "ulduar.h" +#include "Spell.h" enum Spells { @@ -1718,6 +1719,67 @@ class spell_pursue : public SpellScriptLoader } }; +class spell_vehicle_throw_passenger : public SpellScriptLoader +{ + public: + spell_vehicle_throw_passenger() : SpellScriptLoader("spell_vehicle_throw_passenger") {} + + class spell_vehicle_throw_passenger_SpellScript : public SpellScript + { + PrepareSpellScript(spell_vehicle_throw_passenger_SpellScript); + void HandleScript(SpellEffIndex effIndex) + { + Spell* baseSpell = GetSpell(); + SpellCastTargets targets = baseSpell->m_targets; + int32 damage = GetEffectValue(); + if (targets.HasTraj()) + if (Vehicle* vehicle = GetCaster()->GetVehicleKit()) + if (Unit* passenger = vehicle->GetPassenger(damage - 1)) + { + std::list<Unit*> unitList; + // use 99 because it is 3d search + SearchAreaTarget(unitList, 99, PUSH_DST_CENTER, SPELL_TARGETS_ENTRY, NPC_SEAT); + float minDist = 99 * 99; + Unit* target = NULL; + for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr) + { + if (Vehicle* seat = (*itr)->GetVehicleKit()) + if (!seat->GetPassenger(0)) + if (Unit* device = seat->GetPassenger(2)) + if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + { + float dist = (*itr)->GetExactDistSq(targets.GetDst()); + if (dist < minDist) + { + minDist = dist; + target = (*itr); + } + } + } + if (target && target->IsWithinDist2d(targets.GetDst(), GetSpellInfo()->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct + passenger->EnterVehicle(target, 0); + else + { + passenger->ExitVehicle(); + float x, y, z; + targets.GetDst()->GetPosition(x, y, z); + passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ()); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_vehicle_throw_passenger_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_vehicle_throw_passenger_SpellScript(); + } +}; + void AddSC_boss_flame_leviathan() { new boss_flame_leviathan(); @@ -1752,4 +1814,5 @@ void AddSC_boss_flame_leviathan() new spell_auto_repair(); new spell_systems_shutdown(); new spell_pursue(); + new spell_vehicle_throw_passenger(); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index 218c5a122f1..4917fb25153 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -23,7 +23,6 @@ SDComment: SDCategory: Tempest Keep, The Eye EndScriptData */ -#include "ScriptPCH.h" #include "the_eye.h" enum eEnums @@ -40,6 +39,7 @@ enum eEnums SPELL_ARCANE_MISSILES = 33031, SPELL_WRATH_OF_THE_ASTROMANCER = 42783, + SPELL_WRATH_OF_THE_ASTROMANCER_DOT = 42784, SPELL_BLINDING_LIGHT = 33009, SPELL_FEAR = 34322, SPELL_VOID_BOLT = 39329, @@ -491,9 +491,74 @@ class mob_solarium_priest : public CreatureScript return new mob_solarium_priestAI (Creature); } }; + +class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader +{ + public: + spell_astromancer_wrath_of_the_astromancer() : SpellScriptLoader("spell_astromancer_wrath_of_the_astromancer") { } + + class spell_astromancer_wrath_of_the_astromancer_SpellScript : public SpellScript + { + PrepareSpellScript(spell_astromancer_wrath_of_the_astromancer_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_WRATH_OF_THE_ASTROMANCER_DOT)) + return false; + return true; + } + + bool Load() + { + _targetCount = 0; + return true; + } + + void CountTargets(std::list<Unit*>& targetList) + { + _targetCount = targetList.size(); + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (Unit* caster = GetOriginalCaster()) + if (Unit* target = GetHitUnit()) + { + if (!target->isAlive() || !_targetCount) + return; + + int32 damage = 10000 / _targetCount; + + SpellNonMeleeDamage damageInfo(caster, target, GetSpellInfo()->Id, GetSpellInfo()->SchoolMask); + damageInfo.damage = damage; + + caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &damageInfo.absorb, &damageInfo.resist, GetSpellInfo()); + caster->DealDamageMods(target, damageInfo.damage, &damageInfo.absorb); + caster->SendSpellNonMeleeDamageLog(&damageInfo); + caster->DealSpellDamage(&damageInfo, false); + } + } + + private: + int32 _targetCount; + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_astromancer_wrath_of_the_astromancer_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_astromancer_wrath_of_the_astromancer_SpellScript::CountTargets, EFFECT_0, TARGET_DEST_CASTER_RADIUS); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_astromancer_wrath_of_the_astromancer_SpellScript(); + } +}; + void AddSC_boss_high_astromancer_solarian() { new boss_high_astromancer_solarian(); new mob_solarium_priest(); + new spell_astromancer_wrath_of_the_astromancer(); } diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp index ed818fb13be..3579a7d697b 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -22,20 +22,22 @@ enum Spells { - SPELL_POSITIVE_CHARGE = 39090, + SPELL_POSITIVE_POLARITY = 39088, SPELL_POSITIVE_CHARGE_STACK = 39089, + SPELL_POSITIVE_CHARGE = 39090, + SPELL_NEGATIVE_POLARITY = 39091, + SPELL_NEGATIVE_CHARGE_STACK = 39092, SPELL_NEGATIVE_CHARGE = 39093, - SPELL_NEGATIVE_CHARGE_STACK = 39092 }; -class spell_capacitus_polarity_shift : public SpellScriptLoader +class spell_capacitus_polarity_charge : public SpellScriptLoader { public: - spell_capacitus_polarity_shift() : SpellScriptLoader("spell_capacitus_polarity_shift") { } + spell_capacitus_polarity_charge() : SpellScriptLoader("spell_capacitus_polarity_charge") { } - class spell_capacitus_polarity_shift_SpellScript : public SpellScript + class spell_capacitus_polarity_charge_SpellScript : public SpellScript { - PrepareSpellScript(spell_capacitus_polarity_shift_SpellScript); + PrepareSpellScript(spell_capacitus_polarity_charge_SpellScript); bool Validate(SpellInfo const* /*spell*/) { @@ -85,8 +87,44 @@ class spell_capacitus_polarity_shift : public SpellScriptLoader void Register() { - OnEffectHitTarget += SpellEffectFn(spell_capacitus_polarity_shift_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - OnUnitTargetSelect += SpellUnitTargetFn(spell_capacitus_polarity_shift_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + OnEffectHitTarget += SpellEffectFn(spell_capacitus_polarity_charge_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnUnitTargetSelect += SpellUnitTargetFn(spell_capacitus_polarity_charge_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_capacitus_polarity_charge_SpellScript(); + } +}; + +class spell_capacitus_polarity_shift : public SpellScriptLoader +{ + public: + spell_capacitus_polarity_shift() : SpellScriptLoader("spell_capacitus_polarity_shift") { } + + class spell_capacitus_polarity_shift_SpellScript : public SpellScript + { + PrepareSpellScript(spell_capacitus_polarity_shift_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_POLARITY) || !sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_POLARITY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* target = GetHitUnit(); + Unit* caster = GetCaster(); + + target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, NULL, NULL, caster->GetGUID()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_capacitus_polarity_shift_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; @@ -98,5 +136,6 @@ class spell_capacitus_polarity_shift : public SpellScriptLoader void AddSC_boss_mechano_lord_capacitus() { + new spell_capacitus_polarity_charge(); new spell_capacitus_polarity_shift(); } diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 5c0f6bcce59..2d90b5346a4 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_dk_". */ -#include "ScriptPCH.h" #include "Spell.h" enum DeathKnightSpells @@ -103,7 +102,9 @@ class spell_dk_anti_magic_shell_self : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - return sSpellMgr->GetSpellInfo(DK_SPELL_RUNIC_POWER_ENERGIZE); + if (!sSpellMgr->GetSpellInfo(DK_SPELL_RUNIC_POWER_ENERGIZE)) + return false; + return true; } void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) @@ -160,17 +161,16 @@ class spell_dk_anti_magic_zone : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - return sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT); + if (!sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT)) + return false; + return true; } void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) { SpellInfo const* talentSpell = sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT); amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster()); - Unit* caster = GetCaster(); - if (!caster) - return; - if (Player* player = caster->ToPlayer()) + if (Player* player = GetCaster()->ToPlayer()) amount += int32(2 * player->GetTotalAttackPowerValue(BASE_ATTACK)); } @@ -204,9 +204,7 @@ class spell_dk_corpse_explosion : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(DK_SPELL_CORPSE_EXPLOSION_TRIGGERED)) - return false; - if (!sSpellMgr->GetSpellInfo(DK_SPELL_GHOUL_EXPLODE)) + if (!sSpellMgr->GetSpellInfo(DK_SPELL_CORPSE_EXPLOSION_TRIGGERED) || !sSpellMgr->GetSpellInfo(DK_SPELL_GHOUL_EXPLODE)) return false; if (!sSpellMgr->GetSpellInfo(DK_SPELL_CORPSE_EXPLOSION_VISUAL)) return false; @@ -257,6 +255,13 @@ class spell_dk_ghoul_explode : public SpellScriptLoader { PrepareSpellScript(spell_dk_ghoul_explode_SpellScript); + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(DK_SPELL_CORPSE_EXPLOSION_TRIGGERED)) + return false; + return true; + } + void Suicide(SpellEffIndex /*effIndex*/) { if (Unit* unitTarget = GetHitUnit()) @@ -301,9 +306,8 @@ class spell_dk_death_gate : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; - GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValue(), false); + if (Unit* target = GetHitUnit()) + target->CastSpell(target, GetEffectValue(), false); } void Register() @@ -567,12 +571,11 @@ public: class spell_dk_improved_blood_presence_AuraScript : public AuraScript { - PrepareAuraScript(spell_dk_improved_blood_presence_AuraScript) + PrepareAuraScript(spell_dk_improved_blood_presence_AuraScript); + bool Validate(SpellInfo const* /*entry*/) { - if (!sSpellMgr->GetSpellInfo(DK_SPELL_BLOOD_PRESENCE)) - return false; - if (!sSpellMgr->GetSpellInfo(DK_SPELL_IMPROVED_BLOOD_PRESENCE_TRIGGERED)) + if (!sSpellMgr->GetSpellInfo(DK_SPELL_BLOOD_PRESENCE) || !sSpellMgr->GetSpellInfo(DK_SPELL_IMPROVED_BLOOD_PRESENCE_TRIGGERED)) return false; return true; } @@ -615,12 +618,11 @@ public: class spell_dk_improved_unholy_presence_AuraScript : public AuraScript { - PrepareAuraScript(spell_dk_improved_unholy_presence_AuraScript) + PrepareAuraScript(spell_dk_improved_unholy_presence_AuraScript); + bool Validate(SpellInfo const* /*entry*/) { - if (!sSpellMgr->GetSpellInfo(DK_SPELL_UNHOLY_PRESENCE)) - return false; - if (!sSpellMgr->GetSpellInfo(DK_SPELL_IMPROVED_UNHOLY_PRESENCE_TRIGGERED)) + if (!sSpellMgr->GetSpellInfo(DK_SPELL_UNHOLY_PRESENCE) || !sSpellMgr->GetSpellInfo(DK_SPELL_IMPROVED_UNHOLY_PRESENCE_TRIGGERED)) return false; return true; } @@ -656,6 +658,141 @@ public: } }; +enum DeathStrike +{ + ICON_ID_IMPROVED_DEATH_STRIKE = 2751, + SPELL_DEATH_STRIKE_HEAL = 45470, +}; + +class spell_dk_death_strike : public SpellScriptLoader +{ + public: + spell_dk_death_strike() : SpellScriptLoader("spell_dk_death_strike") { } + + class spell_dk_death_strike_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dk_death_strike_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DEATH_STRIKE_HEAL)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + uint32 count = target->GetDiseasesByCaster(caster->GetGUID()); + int32 bp = int32(count * caster->CountPctFromMaxHealth(int32(GetSpellInfo()->Effects[EFFECT_0].DamageMultiplier))); + // Improved Death Strike + if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, ICON_ID_IMPROVED_DEATH_STRIKE, 0)) + AddPctN(bp, caster->CalculateSpellDamage(caster, aurEff->GetSpellInfo(), 2)); + caster->CastCustomSpell(caster, SPELL_DEATH_STRIKE_HEAL, &bp, NULL, NULL, false); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_dk_death_strike_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY); + } + + }; + + SpellScript* GetSpellScript() const + { + return new spell_dk_death_strike_SpellScript(); + } +}; + +enum DeathCoil +{ + SPELL_DEATH_COIL_DAMAGE = 47632, + SPELL_DEATH_COIL_HEAL = 47633, +}; + +class spell_dk_death_coil : public SpellScriptLoader +{ + public: + spell_dk_death_coil() : SpellScriptLoader("spell_dk_death_coil") { } + + class spell_dk_death_coil_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dk_death_coil_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DEATH_COIL_DAMAGE) || !sSpellMgr->GetSpellInfo(SPELL_DEATH_COIL_HEAL)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + if (caster->IsFriendlyTo(target)) + { + int32 bp = int32(damage * 1.5f); + caster->CastCustomSpell(target, SPELL_DEATH_COIL_HEAL, &bp, NULL, NULL, true); + } + else + caster->CastCustomSpell(target, SPELL_DEATH_COIL_DAMAGE, &damage, NULL, NULL, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_dk_death_coil_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + + }; + + SpellScript* GetSpellScript() const + { + return new spell_dk_death_coil_SpellScript(); + } +}; + +class spell_dk_death_grip : public SpellScriptLoader +{ + public: + spell_dk_death_grip() : SpellScriptLoader("spell_dk_death_grip") { } + + class spell_dk_death_grip_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dk_death_grip_SpellScript); + + void HandleDummy(SpellEffIndex effIndex) + { + int32 damage = GetEffectValue(); + Spell* baseSpell = GetSpell(); + Position pos; + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + GetSummonPosition(effIndex, pos, 0.0f, 0); + + if (!target->HasAuraType(SPELL_AURA_DEFLECT_SPELLS)) // Deterrence + target->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), damage, true); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_dk_death_grip_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + + }; + + SpellScript* GetSpellScript() const + { + return new spell_dk_death_grip_SpellScript(); + } +}; + void AddSC_deathknight_spell_scripts() { new spell_dk_anti_magic_shell_raid(); @@ -671,4 +808,7 @@ void AddSC_deathknight_spell_scripts() new spell_dk_will_of_the_necropolis(); new spell_dk_improved_blood_presence(); new spell_dk_improved_unholy_presence(); + new spell_dk_death_strike(); + new spell_dk_death_coil(); + new spell_dk_death_grip(); } diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 130f61565f7..58e63a7eb66 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_dru_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" enum DruidSpells @@ -42,9 +41,7 @@ class spell_dru_glyph_of_starfire : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(DRUID_INCREASED_MOONFIRE_DURATION)) - return false; - if (!sSpellMgr->GetSpellInfo(DRUID_NATURES_SPLENDOR)) + if (!sSpellMgr->GetSpellInfo(DRUID_INCREASED_MOONFIRE_DURATION) || !sSpellMgr->GetSpellInfo(DRUID_NATURES_SPLENDOR)) return false; return true; } @@ -305,14 +302,16 @@ class spell_dru_swift_flight_passive : public SpellScriptLoader { PrepareAuraScript(spell_dru_swift_flight_passive_AuraScript); - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + bool Load() { - Unit* caster = GetCaster(); - if (!caster || !caster->ToPlayer()) - return; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - if (caster->ToPlayer()->Has310Flyer(false)) - amount = 310; + void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + { + if (Player* caster = GetCaster()->ToPlayer()) + if (caster->Has310Flyer(false)) + amount = 310; } void Register() @@ -327,6 +326,47 @@ class spell_dru_swift_flight_passive : public SpellScriptLoader } }; +class spell_dru_starfall_dummy : public SpellScriptLoader +{ + public: + spell_dru_starfall_dummy() : SpellScriptLoader("spell_dru_starfall_dummy") { } + + class spell_dru_starfall_dummy_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dru_starfall_dummy_SpellScript); + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (GetTriggeringSpell()) + sLog->outString("triggering spell = %u",GetTriggeringSpell()->Id); + + Unit* caster = GetCaster(); + if (caster->IsInDisallowedMountForm() || caster->IsMounted()) + { + if (SpellInfo const* spellInfo = GetTriggeringSpell()) + caster->RemoveAurasDueToSpell(spellInfo->Id); + return; + } + + //Any effect which causes you to lose control of your character will supress the starfall effect. + if (caster->HasUnitState(UNIT_STATE_CONTROLLED)) + return; + + caster->CastSpell(GetHitUnit(), GetEffectValue(), true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_dru_starfall_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_dru_starfall_dummy_SpellScript(); + } +}; + void AddSC_druid_spell_scripts() { new spell_dru_glyph_of_starfire(); @@ -336,4 +376,5 @@ void AddSC_druid_spell_scripts() new spell_dru_t10_restoration_4p_bonus(); new spell_dru_starfall_aoe(); new spell_dru_swift_flight_passive(); + new spell_dru_starfall_dummy(); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 4529e7b049d..a34b16a9c22 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -22,7 +22,6 @@ * Scriptnames of files in this file should be prefixed with "spell_gen_" */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" #include "SkillDiscovery.h" #include "GridNotifiers.h" @@ -236,9 +235,7 @@ class spell_gen_parachute : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_PARACHUTE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_PARACHUTE_BUFF)) + if (!sSpellMgr->GetSpellInfo(SPELL_PARACHUTE) || !sSpellMgr->GetSpellInfo(SPELL_PARACHUTE_BUFF)) return false; return true; } @@ -246,13 +243,11 @@ class spell_gen_parachute : public SpellScriptLoader void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) { if (Player* target = GetTarget()->ToPlayer()) - { if (target->IsFalling()) { target->RemoveAurasDueToSpell(SPELL_PARACHUTE); target->CastSpell(target, SPELL_PARACHUTE_BUFF, true); } - } } void Register() @@ -283,13 +278,14 @@ class spell_gen_pet_summoned : public SpellScriptLoader { PrepareSpellScript(spell_gen_pet_summoned_SpellScript); - void HandleScript(SpellEffIndex /*effIndex*/) + bool Load() { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - Player* player = caster->ToPlayer(); + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* player = GetCaster()->ToPlayer(); if (player->GetLastPetNumber()) { PetType newPetType = (player->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET; @@ -340,10 +336,14 @@ class spell_gen_remove_flight_auras : public SpellScriptLoader class spell_gen_remove_flight_auras_SpellScript : public SpellScript { PrepareSpellScript(spell_gen_remove_flight_auras_SpellScript); + void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAurasByType(SPELL_AURA_FLY); - GetHitUnit()->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); + if (Unit* target = GetHitUnit()) + { + target->RemoveAurasByType(SPELL_AURA_FLY); + target->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); + } } void Register() @@ -376,22 +376,21 @@ class spell_gen_leeching_swarm : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_LEECHING_SWARM_DMG)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_LEECHING_SWARM_HEAL)) + if (!sSpellMgr->GetSpellInfo(SPELL_LEECHING_SWARM_DMG) || !sSpellMgr->GetSpellInfo(SPELL_LEECHING_SWARM_HEAL)) return false; return true; } void HandleEffectPeriodic(AuraEffect const* aurEff) { - if (Unit* caster = GetCaster()) + Unit* caster = GetCaster(); + if (Unit* target = GetTarget()) { - int32 lifeLeeched = GetTarget()->CountPctFromCurHealth(aurEff->GetAmount()); + int32 lifeLeeched = target->CountPctFromCurHealth(aurEff->GetAmount()); if (lifeLeeched < 250) lifeLeeched = 250; // Damage - caster->CastCustomSpell(GetTarget(), SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false); + caster->CastCustomSpell(target, SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false); // Heal caster->CastCustomSpell(caster, SPELL_LEECHING_SWARM_HEAL, &lifeLeeched, 0, 0, false); } @@ -500,31 +499,16 @@ class spell_gen_trick : public SpellScriptLoader PrepareSpellScript(spell_gen_trick_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_PIRATE_COSTUME_MALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_PIRATE_COSTUME_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NINJA_COSTUME_MALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NINJA_COSTUME_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_LEPER_GNOME_COSTUME_MALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_LEPER_GNOME_COSTUME_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SKELETON_COSTUME)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_MALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_TRICK_BUFF)) + if (!sSpellMgr->GetSpellInfo(SPELL_PIRATE_COSTUME_MALE) || !sSpellMgr->GetSpellInfo(SPELL_PIRATE_COSTUME_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_NINJA_COSTUME_MALE) + || !sSpellMgr->GetSpellInfo(SPELL_NINJA_COSTUME_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_LEPER_GNOME_COSTUME_MALE) || !sSpellMgr->GetSpellInfo(SPELL_LEPER_GNOME_COSTUME_FEMALE) + || !sSpellMgr->GetSpellInfo(SPELL_SKELETON_COSTUME) || !sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_MALE) || !sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_TRICK_BUFF)) return false; return true; } void HandleScript(SpellEffIndex /*effIndex*/) { + Unit* caster = GetCaster(); if (Player* target = GetHitPlayer()) { uint8 gender = target->getGender(); @@ -550,7 +534,7 @@ class spell_gen_trick : public SpellScriptLoader break; } - GetCaster()->CastSpell(target, spellId, true, NULL); + caster->CastSpell(target, spellId, true, NULL); } } @@ -585,21 +569,18 @@ class spell_gen_trick_or_treat : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_TRICK)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_TREAT)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_TRICKED_OR_TREATED)) + if (!sSpellMgr->GetSpellInfo(SPELL_TRICK) || !sSpellMgr->GetSpellInfo(SPELL_TREAT) || !sSpellMgr->GetSpellInfo(SPELL_TRICKED_OR_TREATED)) return false; return true; } void HandleScript(SpellEffIndex /*effIndex*/) { + Unit* caster = GetCaster(); if (Player* target = GetHitPlayer()) { - GetCaster()->CastSpell(target, roll_chance_i(50) ? SPELL_TRICK : SPELL_TREAT, true, NULL); - GetCaster()->CastSpell(target, SPELL_TRICKED_OR_TREATED, true, NULL); + caster->CastSpell(target, roll_chance_i(50) ? SPELL_TRICK : SPELL_TREAT, true, NULL); + caster->CastSpell(target, SPELL_TRICKED_OR_TREATED, true, NULL); } } @@ -661,11 +642,14 @@ class spell_pvp_trinket_wotf_shared_cd : public SpellScriptLoader { PrepareSpellScript(spell_pvp_trinket_wotf_shared_cd_SpellScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF)) + if (!sSpellMgr->GetSpellInfo(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER) || !sSpellMgr->GetSpellInfo(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF)) return false; return true; } @@ -673,10 +657,7 @@ class spell_pvp_trinket_wotf_shared_cd : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { Player* caster = GetCaster()->ToPlayer(); - if (!caster) - return; SpellInfo const* spellInfo = GetSpellInfo(); - caster->AddSpellCooldown(spellInfo->Id, 0, time(NULL) + sSpellMgr->GetSpellInfo(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER)->GetRecoveryTime() / IN_MILLISECONDS); WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4); data << uint64(caster->GetGUID()); @@ -729,8 +710,9 @@ class spell_gen_animal_blood : public SpellScriptLoader void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (GetUnitOwner()->IsInWater()) - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SPAWN_BLOOD_POOL, true); + if (Unit* owner = GetUnitOwner()) + if (owner->IsInWater()) + owner->CastSpell(owner, SPELL_SPAWN_BLOOD_POOL, true); } void Register() @@ -761,6 +743,11 @@ class spell_gen_divine_storm_cd_reset : public SpellScriptLoader { PrepareSpellScript(spell_gen_divine_storm_cd_reset_SpellScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_DIVINE_STORM)) @@ -770,9 +757,9 @@ class spell_gen_divine_storm_cd_reset : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - if (Player* caster = GetCaster()->ToPlayer()) - if (caster->HasSpellCooldown(SPELL_DIVINE_STORM)) - caster->RemoveSpellCooldown(SPELL_DIVINE_STORM, true); + Player* caster = GetCaster()->ToPlayer(); + if (caster->HasSpellCooldown(SPELL_DIVINE_STORM)) + caster->RemoveSpellCooldown(SPELL_DIVINE_STORM, true); } void Register() @@ -796,13 +783,15 @@ class spell_gen_gunship_portal : public SpellScriptLoader { PrepareSpellScript(spell_gen_gunship_portal_SpellScript); - void HandleScript(SpellEffIndex /*effIndex*/) + bool Load() { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - if (Battleground* bg = caster->ToPlayer()->GetBattleground()) + void HandleScript(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + if (Battleground* bg = caster->GetBattleground()) if (bg->GetTypeID(true) == BATTLEGROUND_IC) bg->DoAction(1, caster->GetGUID()); } @@ -821,7 +810,7 @@ class spell_gen_gunship_portal : public SpellScriptLoader enum parachuteIC { - SPELL_PARACHUTE_IC = 66657 + SPELL_PARACHUTE_IC = 66657, }; class spell_gen_parachute_ic : public SpellScriptLoader @@ -835,13 +824,9 @@ class spell_gen_parachute_ic : public SpellScriptLoader void HandleTriggerSpell(AuraEffect const* /*aurEff*/) { - Unit* target = GetTarget(); - - if (!target->ToPlayer()) - return; - - if (target->ToPlayer()->m_movementInfo.fallTime > 2000) - target->CastSpell(target, SPELL_PARACHUTE_IC, true); + if (Player* target = GetTarget()->ToPlayer()) + if (target->m_movementInfo.fallTime > 2000) + target->CastSpell(target, SPELL_PARACHUTE_IC, true); } void Register() @@ -868,7 +853,7 @@ class spell_gen_dungeon_credit : public SpellScriptLoader bool Load() { _handled = false; - return true; + return GetCaster()->GetTypeId() == TYPEID_UNIT; } void CreditEncounter() @@ -878,9 +863,9 @@ class spell_gen_dungeon_credit : public SpellScriptLoader return; _handled = true; - if (GetCaster()->GetTypeId() == TYPEID_UNIT) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - instance->UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, GetSpellInfo()->Id, GetCaster()); + Unit* caster = GetCaster(); + if (InstanceScript* instance = caster->GetInstanceScript()) + instance->UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, GetSpellInfo()->Id, caster); } void Register() @@ -906,9 +891,14 @@ class spell_gen_profession_research : public SpellScriptLoader { PrepareSpellScript(spell_gen_profession_research_SpellScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + SpellCastResult CheckRequirement() { - if (GetCaster()->GetTypeId() == TYPEID_PLAYER && HasDiscoveredAllSpells(GetSpellInfo()->Id, GetCaster()->ToPlayer())) + if (HasDiscoveredAllSpells(GetSpellInfo()->Id, GetCaster()->ToPlayer())) { SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_NOTHING_TO_DISCOVER); return SPELL_FAILED_CUSTOM_ERROR; @@ -978,19 +968,11 @@ class spell_generic_clone_weapon : public SpellScriptLoader class spell_generic_clone_weapon_SpellScript : public SpellScript { PrepareSpellScript(spell_generic_clone_weapon_SpellScript); + bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED)) + if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND) + || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED)) return false; return true; } @@ -999,57 +981,56 @@ class spell_generic_clone_weapon : public SpellScriptLoader { PreventHitDefaultEffect(effIndex); Unit* caster = GetCaster(); - Unit* target = GetHitUnit(); - - if (!target) - return; + if (Unit* target = GetHitUnit()) + { - uint32 spellId = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); - target->CastSpell(caster, spellId, true); + uint32 spellId = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); + target->CastSpell(caster, spellId, true); - if (target->GetTypeId() == TYPEID_PLAYER) - return; + if (target->GetTypeId() == TYPEID_PLAYER) + return; - switch (GetSpellInfo()->Id) - { - case SPELL_COPY_WEAPON: - case SPELL_COPY_WEAPON_2: - case SPELL_COPY_WEAPON_3: + switch (GetSpellInfo()->Id) { - if (Player* player = caster->ToPlayer()) + case SPELL_COPY_WEAPON: + case SPELL_COPY_WEAPON_2: + case SPELL_COPY_WEAPON_3: { - if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); + if (Player* player = caster->ToPlayer()) + { + if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); + } + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); + break; } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); - break; - } - case SPELL_COPY_OFFHAND: - case SPELL_COPY_OFFHAND_2: - { - if (Player* player = caster->ToPlayer()) + case SPELL_COPY_OFFHAND: + case SPELL_COPY_OFFHAND_2: { - if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); + if (Player* player = caster->ToPlayer()) + { + if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); + } + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); + break; } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); - break; - } - case SPELL_COPY_RANGED: - { - if (Player* player = caster->ToPlayer()) + case SPELL_COPY_RANGED: { - if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); + if (Player* player = caster->ToPlayer()) + { + if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); + } + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); + break; } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); - break; + default: + break; } - default: - break; } } @@ -1095,10 +1076,10 @@ class spell_gen_seaforium_blast : public SpellScriptLoader void AchievementCredit(SpellEffIndex /*effIndex*/) { // but in effect handling OriginalCaster can become NULL - if (!GetOriginalCaster() || !GetHitGObj() || GetHitGObj()->GetGOInfo()->type != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) - return; - - GetOriginalCaster()->CastSpell(GetOriginalCaster(), SPELL_PLANT_CHARGES_CREDIT_ACHIEVEMENT, true); + if (Unit* originalCaster = GetOriginalCaster()) + if (GameObject* go = GetHitGObj()) + if (GetHitGObj()->GetGOInfo()->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) + originalCaster->CastSpell(originalCaster, SPELL_PLANT_CHARGES_CREDIT_ACHIEVEMENT, true); } void Register() @@ -1131,10 +1112,11 @@ class spell_gen_turkey_marker : public SpellScriptLoader { // store stack apply times, so we can pop them while they expire _applyTimes.push_back(getMSTime()); + Unit* target = GetTarget(); // on stack 15 cast the achievement crediting spell if (GetStackAmount() >= 15) - GetTarget()->CastSpell(GetTarget(), SPELL_TURKEY_VENGEANCE, true, NULL, aurEff, GetCasterGUID()); + target->CastSpell(target, SPELL_TURKEY_VENGEANCE, true, NULL, aurEff, GetCasterGUID()); } void OnPeriodic(AuraEffect const* /*aurEff*/) @@ -1208,29 +1190,28 @@ class spell_gen_magic_rooster : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - Player* target = GetHitPlayer(); - if (!target) - return; + if (Player* target = GetHitPlayer()) + { + // prevent client crashes from stacking mounts + target->RemoveAurasByType(SPELL_AURA_MOUNTED); - // prevent client crashes from stacking mounts - target->RemoveAurasByType(SPELL_AURA_MOUNTED); + uint32 spellId = SPELL_MAGIC_ROOSTER_NORMAL; + switch (target->getRace()) + { + case RACE_DRAENEI: + if (target->getGender() == GENDER_MALE) + spellId = SPELL_MAGIC_ROOSTER_DRAENEI_MALE; + break; + case RACE_TAUREN: + if (target->getGender() == GENDER_MALE) + spellId = SPELL_MAGIC_ROOSTER_TAUREN_MALE; + break; + default: + break; + } - uint32 spellId = SPELL_MAGIC_ROOSTER_NORMAL; - switch (target->getRace()) - { - case RACE_DRAENEI: - if (target->getGender() == GENDER_MALE) - spellId = SPELL_MAGIC_ROOSTER_DRAENEI_MALE; - break; - case RACE_TAUREN: - if (target->getGender() == GENDER_MALE) - spellId = SPELL_MAGIC_ROOSTER_TAUREN_MALE; - break; - default: - break; + target->CastSpell(target, spellId, true); } - - target->CastSpell(target, spellId, true); } void Register() @@ -1258,7 +1239,6 @@ public: { if (!GetCastItem()) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; - return SPELL_CAST_OK; } @@ -1335,12 +1315,14 @@ class spell_gen_vehicle_scaling : public SpellScriptLoader { PrepareAuraScript(spell_gen_vehicle_scaling_AuraScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { Unit* caster = GetCaster(); - if (!caster || !caster->ToPlayer()) - return; - float factor; uint16 baseItemLevel; @@ -1379,21 +1361,23 @@ class spell_gen_vehicle_scaling : public SpellScriptLoader }; -class spell_gen_oracle_wolvar_reputation: public SpellScriptLoader +class spell_gen_oracle_wolvar_reputation : public SpellScriptLoader { -public: - spell_gen_oracle_wolvar_reputation() : SpellScriptLoader("spell_gen_oracle_wolvar_reputation") { } - - class spell_gen_oracle_wolvar_reputation_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_oracle_wolvar_reputation_SpellScript) + public: + spell_gen_oracle_wolvar_reputation() : SpellScriptLoader("spell_gen_oracle_wolvar_reputation") { } - void HandleDummy(SpellEffIndex effIndex) + class spell_gen_oracle_wolvar_reputation_SpellScript : public SpellScript { + PrepareSpellScript(spell_gen_oracle_wolvar_reputation_SpellScript); - if (Player* player = GetCaster()->ToPlayer()) + bool Load() { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + void HandleDummy(SpellEffIndex effIndex) + { + Player* player = GetCaster()->ToPlayer(); uint32 factionId = GetSpellInfo()->Effects[effIndex].CalcValue(); int32 repChange = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); @@ -1410,18 +1394,16 @@ public: // EFFECT_INDEX_2 most likely update at war state, we already handle this in SetReputation } - } + void Register() + { + OnEffectHit += SpellEffectFn(spell_gen_oracle_wolvar_reputation_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_gen_oracle_wolvar_reputation_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_gen_oracle_wolvar_reputation_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_gen_oracle_wolvar_reputation_SpellScript(); - } }; enum DamageReductionAura @@ -1435,53 +1417,48 @@ enum DamageReductionAura class spell_gen_damage_reduction_aura : public SpellScriptLoader { -public: - spell_gen_damage_reduction_aura() : SpellScriptLoader("spell_gen_damage_reduction_aura") { } - - class spell_gen_damage_reduction_AuraScript : public AuraScript - { - PrepareAuraScript(spell_gen_damage_reduction_AuraScript); + public: + spell_gen_damage_reduction_aura() : SpellScriptLoader("spell_gen_damage_reduction_aura") { } - bool Validate(SpellInfo const* /*SpellEntry*/) + class spell_gen_damage_reduction_AuraScript : public AuraScript { - if (!sSpellMgr->GetSpellInfo(SPELL_DAMAGE_REDUCTION_AURA)) - return false; - return true; - } + PrepareAuraScript(spell_gen_damage_reduction_AuraScript); - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); - } + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DAMAGE_REDUCTION_AURA)) + return false; + return true; + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (!target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) - return; + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); + } - if (target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || - target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || - target->HasAura(SPELL_RENEWED_HOPE) || - target->HasAura(SPELL_VIGILANCE)) - return; + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (target->HasAura(SPELL_DAMAGE_REDUCTION_AURA) && !(target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_RENEWED_HOPE) || + target->HasAura(SPELL_VIGILANCE))) + target->RemoveAurasDueToSpell(SPELL_DAMAGE_REDUCTION_AURA); + } - target->RemoveAurasDueToSpell(SPELL_DAMAGE_REDUCTION_AURA); - } + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_gen_damage_reduction_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_damage_reduction_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } - void Register() + }; + + AuraScript* GetAuraScript() const { - OnEffectApply += AuraEffectApplyFn(spell_gen_damage_reduction_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - OnEffectRemove += AuraEffectRemoveFn(spell_gen_damage_reduction_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + return new spell_gen_damage_reduction_AuraScript(); } - - }; - - AuraScript* GetAuraScript() const - { - return new spell_gen_damage_reduction_AuraScript(); - } }; class spell_gen_luck_of_the_draw : public SpellScriptLoader @@ -1493,6 +1470,11 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader { PrepareAuraScript(spell_gen_luck_of_the_draw_AuraScript); + bool Load() + { + return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER; + } + // cheap hax to make it have update calls void CalcPeriodic(AuraEffect const* /*effect*/, bool& isPeriodic, int32& amplitude) { @@ -1502,30 +1484,30 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader void Update(AuraEffect* /*effect*/) { - if (GetUnitOwner()->GetTypeId() != TYPEID_PLAYER) - return; - - const LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(GetUnitOwner()->GetGUID()); - LfgDungeonSet::const_iterator itr = dungeons.begin(); - - if (itr == dungeons.end()) + if (Player* owner = GetUnitOwner()->ToPlayer()) { - Remove(AURA_REMOVE_BY_DEFAULT); - return; - } + const LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(owner->GetGUID()); + LfgDungeonSet::const_iterator itr = dungeons.begin(); + if (itr == dungeons.end()) + { + Remove(AURA_REMOVE_BY_DEFAULT); + return; + } - LFGDungeonEntry const* randomDungeon = sLFGDungeonStore.LookupEntry(*itr); - Group* group = GetUnitOwner()->ToPlayer()->GetGroup(); - Map const* map = GetUnitOwner()->GetMap(); - if (group && group->isLFGGroup()) - if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true)) - if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId)) - if (uint32(dungeon->map) == map->GetId() && dungeon->difficulty == map->GetDifficulty()) - if (randomDungeon && randomDungeon->type == LFG_TYPE_RANDOM) - return; // in correct dungeon - Remove(AURA_REMOVE_BY_DEFAULT); + LFGDungeonEntry const* randomDungeon = sLFGDungeonStore.LookupEntry(*itr); + if (Group* group = owner->GetGroup()) + if (Map const* map = owner->GetMap()) + if (group->isLFGGroup()) + if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true)) + if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId)) + if (uint32(dungeon->map) == map->GetId() && dungeon->difficulty == map->GetDifficulty()) + if (randomDungeon && randomDungeon->type == LFG_TYPE_RANDOM) + return; // in correct dungeon + + Remove(AURA_REMOVE_BY_DEFAULT); + } } void Register() @@ -1541,6 +1523,178 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader } }; +enum DummyTrigger +{ + SPELL_PERSISTANT_SHIELD_TRIGGERED = 26470, + SPELL_PERSISTANT_SHIELD = 26467, +}; + +class spell_gen_dummy_trigger : public SpellScriptLoader +{ + public: + spell_gen_dummy_trigger() : SpellScriptLoader("spell_gen_dummy_trigger") { } + + class spell_gen_dummy_trigger_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_dummy_trigger_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_PERSISTANT_SHIELD_TRIGGERED) || !sSpellMgr->GetSpellInfo(SPELL_PERSISTANT_SHIELD)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + if (SpellInfo const* triggeredByAuraSpell = GetTriggeringSpell()) + if (triggeredByAuraSpell->Id == SPELL_PERSISTANT_SHIELD_TRIGGERED) + caster->CastCustomSpell(target, SPELL_PERSISTANT_SHIELD_TRIGGERED, &damage, NULL, NULL, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_dummy_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_dummy_trigger_SpellScript(); + } + +}; + +class spell_gen_spirit_healer_res : public SpellScriptLoader +{ + public: + spell_gen_spirit_healer_res(): SpellScriptLoader("spell_gen_spirit_healer_res") { } + + class spell_gen_spirit_healer_res_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_spirit_healer_res_SpellScript); + + bool Load() + { + return GetOriginalCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (Player* originalCaster = GetOriginalCaster()->ToPlayer()) + { + if (Unit* target = GetHitUnit()) + { + WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); + data << uint64(target->GetGUID()); + originalCaster->GetSession()->SendPacket(&data); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_spirit_healer_res_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_spirit_healer_res_SpellScript(); + } +}; + +enum TransporterBackfires +{ + SPELL_TRANSPORTER_MALFUNCTION_POLYMORPH = 23444, + SPELL_TRANSPORTER_EVIL_TWIN = 23445, + SPELL_TRANSPORTER_MALFUNCTION_MISS = 36902, +}; + +class spell_gen_gadgetzan_transporter_backfire : public SpellScriptLoader +{ + public: + spell_gen_gadgetzan_transporter_backfire() : SpellScriptLoader("spell_gen_gadgetzan_transporter_backfire") { } + + class spell_gen_gadgetzan_transporter_backfire_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_gadgetzan_transporter_backfire_SpellScript) + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_TRANSPORTER_MALFUNCTION_POLYMORPH) || !sSpellMgr->GetSpellInfo(SPELL_TRANSPORTER_EVIL_TWIN) + || !sSpellMgr->GetSpellInfo(SPELL_TRANSPORTER_MALFUNCTION_MISS)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + int32 r = irand(0, 119); + if (r < 20) // Transporter Malfunction - 1/6 polymorph + caster->CastSpell(caster, SPELL_TRANSPORTER_MALFUNCTION_POLYMORPH, true); + else if (r < 100) // Evil Twin - 4/6 evil twin + caster->CastSpell(caster, SPELL_TRANSPORTER_EVIL_TWIN, true); + else // Transporter Malfunction - 1/6 miss the target + caster->CastSpell(caster, SPELL_TRANSPORTER_MALFUNCTION_MISS, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_gadgetzan_transporter_backfire_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_gadgetzan_transporter_backfire_SpellScript(); + } +}; + +enum GnomishTransporter +{ + SPELL_TRANSPORTER_SUCCESS = 23441, + SPELL_TRANSPORTER_FAILURE = 23446, +}; + +class spell_gen_gnomish_transporter : public SpellScriptLoader +{ + public: + spell_gen_gnomish_transporter() : SpellScriptLoader("spell_gen_gnomish_transporter") { } + + class spell_gen_gnomish_transporter_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_gnomish_transporter_SpellScript) + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_TRANSPORTER_SUCCESS) || !sSpellMgr->GetSpellInfo(SPELL_TRANSPORTER_FAILURE)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, roll_chance_i(50) ? SPELL_TRANSPORTER_SUCCESS : SPELL_TRANSPORTER_FAILURE , true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_gnomish_transporter_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_gnomish_transporter_SpellScript(); + } +}; + enum DalaranDisguiseSpells { SPELL_SUNREAVER_DISGUISE_TRIGGER = 69672, @@ -1565,15 +1719,11 @@ class spell_gen_dalaran_disguise : public SpellScriptLoader switch (spellEntry->Id) { case SPELL_SUNREAVER_DISGUISE_TRIGGER: - if (!sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_MALE)) + if (!sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_SUNREAVER_DISGUISE_MALE)) return false; break; case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: - if (!sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_MALE)) + if (!sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_SILVER_COVENANT_DISGUISE_MALE)) return false; break; } @@ -1599,7 +1749,6 @@ class spell_gen_dalaran_disguise : public SpellScriptLoader default: break; } - GetCaster()->CastSpell(player, spellId, true); } } @@ -2354,6 +2503,47 @@ class spell_gen_tournament_pennant : public SpellScriptLoader } }; +enum ChaosBlast +{ + SPELL_CHAOS_BLAST = 37675, +}; + +class spell_gen_chaos_blast : public SpellScriptLoader +{ + public: + spell_gen_chaos_blast() : SpellScriptLoader("spell_gen_chaos_blast") { } + + class spell_gen_chaos_blast_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_chaos_blast_SpellScript) + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CHAOS_BLAST)) + return false; + return true; + } + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 basepoints0 = 100; + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + caster->CastCustomSpell(target, SPELL_CHAOS_BLAST, &basepoints0, NULL, NULL, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_chaos_blast_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_chaos_blast_SpellScript(); + } + +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -2387,6 +2577,10 @@ void AddSC_generic_spell_scripts() new spell_gen_oracle_wolvar_reputation(); new spell_gen_damage_reduction_aura(); new spell_gen_luck_of_the_draw(); + new spell_gen_dummy_trigger(); + new spell_gen_spirit_healer_res(); + new spell_gen_gadgetzan_transporter_backfire(); + new spell_gen_gnomish_transporter(); new spell_gen_dalaran_disguise("spell_gen_sunreaver_disguise"); new spell_gen_dalaran_disguise("spell_gen_silver_covenant_disguise"); new spell_gen_elune_candle(); @@ -2398,4 +2592,5 @@ void AddSC_generic_spell_scripts() new spell_gen_summon_tournament_mount(); new spell_gen_on_tournament_mount(); new spell_gen_tournament_pennant(); + new spell_gen_chaos_blast(); } diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 8a3424ab1e7..13ad05b1930 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_hun_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" #include "GridNotifiers.h" @@ -45,219 +44,215 @@ enum HunterSpells // 13161 Aspect of the Beast class spell_hun_aspect_of_the_beast : public SpellScriptLoader { -public: - spell_hun_aspect_of_the_beast() : SpellScriptLoader("spell_hun_aspect_of_the_beast") { } - - class spell_hun_aspect_of_the_beast_AuraScript : public AuraScript - { - PrepareAuraScript(spell_hun_aspect_of_the_beast_AuraScript) - bool Validate(SpellInfo const* /*entry*/) - { - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET)) - return false; - return true; - } + public: + spell_hun_aspect_of_the_beast() : SpellScriptLoader("spell_hun_aspect_of_the_beast") { } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + class spell_hun_aspect_of_the_beast_AuraScript : public AuraScript { - if (!GetCaster()) - return; + PrepareAuraScript(spell_hun_aspect_of_the_beast_AuraScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*entry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET)) + return false; + return true; + } - Unit* caster = GetCaster(); - if (caster->ToPlayer()) - if (Pet* pet = caster->ToPlayer()->GetPet()) - pet->RemoveAurasDueToSpell(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET); - } + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Player* caster = GetCaster()->ToPlayer()) + if (Pet* pet = caster->GetPet()) + pet->RemoveAurasDueToSpell(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET); + } - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (!GetCaster()) - return; + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Player* caster = GetCaster()->ToPlayer()) + if (caster->GetPet()) + caster->CastSpell(caster, HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET, true); + } - Unit* caster = GetCaster(); - if (caster->ToPlayer()) - if (caster->ToPlayer()->GetPet()) - caster->CastSpell(caster, HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET, true); - } + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_hun_aspect_of_the_beast_AuraScript::OnApply, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_hun_aspect_of_the_beast_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); + } + }; - void Register() + AuraScript* GetAuraScript() const { - AfterEffectApply += AuraEffectApplyFn(spell_hun_aspect_of_the_beast_AuraScript::OnApply, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_hun_aspect_of_the_beast_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); + return new spell_hun_aspect_of_the_beast_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_hun_aspect_of_the_beast_AuraScript(); - } }; // 53209 Chimera Shot class spell_hun_chimera_shot : public SpellScriptLoader { -public: - spell_hun_chimera_shot() : SpellScriptLoader("spell_hun_chimera_shot") { } + public: + spell_hun_chimera_shot() : SpellScriptLoader("spell_hun_chimera_shot") { } - class spell_hun_chimera_shot_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_chimera_shot_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_hun_chimera_shot_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_SERPENT)) - return false; - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_VIPER)) - return false; - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_SCORPID)) - return false; - return true; - } + PrepareSpellScript(spell_hun_chimera_shot_SpellScript); - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - Unit* unitTarget = GetHitUnit(); - if (!unitTarget) - return; - - uint32 spellId = 0; - int32 basePoint = 0; - Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras(); - for (Unit::AuraApplicationMap::iterator i = Auras.begin(); i != Auras.end(); ++i) - { - Aura* aura = i->second->GetBase(); - if (aura->GetCasterGUID() != caster->GetGUID()) - continue; - - // Search only Serpent Sting, Viper Sting, Scorpid Sting auras - flag96 familyFlag = aura->GetSpellInfo()->SpellFamilyFlags; - if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000)) - continue; - if (AuraEffect const* aurEff = aura->GetEffect(0)) + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_SERPENT) || !sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_VIPER) || !sSpellMgr->GetSpellInfo(HUNTER_SPELL_CHIMERA_SHOT_SCORPID)) + return false; + return true; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* unitTarget = GetHitUnit()) { - // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting. - if (familyFlag[0] & 0x4000) - { - int32 TickCount = aurEff->GetTotalTicks(); - spellId = HUNTER_SPELL_CHIMERA_SHOT_SERPENT; - basePoint = caster->SpellDamageBonus(unitTarget, aura->GetSpellInfo(), aurEff->GetAmount(), DOT, aura->GetStackAmount()); - ApplyPctN(basePoint, TickCount * 40); - } - // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting. - else if (familyFlag[1] & 0x00000080) + uint32 spellId = 0; + int32 basePoint = 0; + Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras(); + for (Unit::AuraApplicationMap::iterator i = Auras.begin(); i != Auras.end(); ++i) { - int32 TickCount = aura->GetEffect(0)->GetTotalTicks(); - spellId = HUNTER_SPELL_CHIMERA_SHOT_VIPER; - - // Amount of one aura tick - basePoint = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), aurEff->GetAmount())); - int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50; // TODO: WTF? caster uses unitTarget? - if (basePoint > casterBasePoint) - basePoint = casterBasePoint; - ApplyPctN(basePoint, TickCount * 60); + Aura* aura = i->second->GetBase(); + if (aura->GetCasterGUID() != caster->GetGUID()) + continue; + + // Search only Serpent Sting, Viper Sting, Scorpid Sting auras + flag96 familyFlag = aura->GetSpellInfo()->SpellFamilyFlags; + if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000)) + continue; + if (AuraEffect const* aurEff = aura->GetEffect(0)) + { + // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting. + if (familyFlag[0] & 0x4000) + { + int32 TickCount = aurEff->GetTotalTicks(); + spellId = HUNTER_SPELL_CHIMERA_SHOT_SERPENT; + basePoint = caster->SpellDamageBonus(unitTarget, aura->GetSpellInfo(), aurEff->GetAmount(), DOT, aura->GetStackAmount()); + ApplyPctN(basePoint, TickCount * 40); + } + // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting. + else if (familyFlag[1] & 0x00000080) + { + int32 TickCount = aura->GetEffect(0)->GetTotalTicks(); + spellId = HUNTER_SPELL_CHIMERA_SHOT_VIPER; + + // Amount of one aura tick + basePoint = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), aurEff->GetAmount())); + int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50; // TODO: WTF? caster uses unitTarget? + if (basePoint > casterBasePoint) + basePoint = casterBasePoint; + ApplyPctN(basePoint, TickCount * 60); + } + // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute. + else if (familyFlag[0] & 0x00008000) + spellId = HUNTER_SPELL_CHIMERA_SHOT_SCORPID; + // ?? nothing say in spell desc (possibly need addition check) + //if (familyFlag & 0x0000010000000000LL || // dot + // familyFlag & 0x0000100000000000LL) // stun + //{ + // spellId = 53366; // 53366 Chimera Shot - Wyvern + //} + + // Refresh aura duration + aura->RefreshDuration(); + } + break; } - // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute. - else if (familyFlag[0] & 0x00008000) - spellId = HUNTER_SPELL_CHIMERA_SHOT_SCORPID; - // ?? nothing say in spell desc (possibly need addition check) - //if (familyFlag & 0x0000010000000000LL || // dot - // familyFlag & 0x0000100000000000LL) // stun - //{ - // spellId = 53366; // 53366 Chimera Shot - Wyvern - //} - - // Refresh aura duration - aura->RefreshDuration(); + if (spellId) + caster->CastCustomSpell(unitTarget, spellId, &basePoint, 0, 0, true); + if (spellId == HUNTER_SPELL_CHIMERA_SHOT_SCORPID && caster->ToPlayer()) // Scorpid Sting - Add 1 minute cooldown + caster->ToPlayer()->AddSpellCooldown(spellId, 0, uint32(time(NULL) + 60)); } - break; } - if (spellId) - caster->CastCustomSpell(unitTarget, spellId, &basePoint, 0, 0, true); - if (spellId == HUNTER_SPELL_CHIMERA_SHOT_SCORPID && caster->ToPlayer()) // Scorpid Sting - Add 1 minute cooldown - caster->ToPlayer()->AddSpellCooldown(spellId, 0, uint32(time(NULL) + 60)); - } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_hun_chimera_shot_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_hun_chimera_shot_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + return new spell_hun_chimera_shot_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_chimera_shot_SpellScript(); - } }; // 53412 Invigoration class spell_hun_invigoration : public SpellScriptLoader { -public: - spell_hun_invigoration() : SpellScriptLoader("spell_hun_invigoration") { } + public: + spell_hun_invigoration() : SpellScriptLoader("spell_hun_invigoration") { } - class spell_hun_invigoration_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_invigoration_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_hun_invigoration_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_INVIGORATION_TRIGGERED)) - return false; - return true; - } + PrepareSpellScript(spell_hun_invigoration_SpellScript); - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - if (Unit* unitTarget = GetHitUnit()) - if (AuraEffect* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 3487, 0)) - if (roll_chance_i(aurEff->GetAmount())) - unitTarget->CastSpell(unitTarget, HUNTER_SPELL_INVIGORATION_TRIGGERED, true); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_INVIGORATION_TRIGGERED)) + return false; + return true; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + if (Unit* unitTarget = GetHitUnit()) + if (AuraEffect* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 3487, 0)) + if (roll_chance_i(aurEff->GetAmount())) + unitTarget->CastSpell(unitTarget, HUNTER_SPELL_INVIGORATION_TRIGGERED, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_hun_invigoration_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_hun_invigoration_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + return new spell_hun_invigoration_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_invigoration_SpellScript(); - } }; class spell_hun_last_stand_pet : public SpellScriptLoader { -public: - spell_hun_last_stand_pet() : SpellScriptLoader("spell_hun_last_stand_pet") { } + public: + spell_hun_last_stand_pet() : SpellScriptLoader("spell_hun_last_stand_pet") { } - class spell_hun_last_stand_pet_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_last_stand_pet_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_hun_last_stand_pet_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(HUNTER_PET_SPELL_LAST_STAND_TRIGGERED)) - return false; - return true; - } + PrepareSpellScript(spell_hun_last_stand_pet_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); - caster->CastCustomSpell(caster, HUNTER_PET_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_PET_SPELL_LAST_STAND_TRIGGERED)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); + caster->CastCustomSpell(caster, HUNTER_PET_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); + } + + void Register() + { + // add dummy effect spell handler to pet's Last Stand + OnEffectHitTarget += SpellEffectFn(spell_hun_last_stand_pet_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - void Register() + SpellScript* GetSpellScript() const { - // add dummy effect spell handler to pet's Last Stand - OnEffectHitTarget += SpellEffectFn(spell_hun_last_stand_pet_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_hun_last_stand_pet_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_last_stand_pet_SpellScript(); - } }; class spell_hun_masters_call : public SpellScriptLoader @@ -267,14 +262,11 @@ class spell_hun_masters_call : public SpellScriptLoader class spell_hun_masters_call_SpellScript : public SpellScript { - PrepareSpellScript(spell_hun_masters_call_SpellScript) + PrepareSpellScript(spell_hun_masters_call_SpellScript); + bool Validate(SpellInfo const* spellEntry) { - if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_MASTERS_CALL_TRIGGERED)) - return false; - if (!sSpellMgr->GetSpellInfo(spellEntry->Effects[EFFECT_0].CalcValue())) - return false; - if (!sSpellMgr->GetSpellInfo(spellEntry->Effects[EFFECT_1].CalcValue())) + if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_MASTERS_CALL_TRIGGERED) || !sSpellMgr->GetSpellInfo(spellEntry->Effects[EFFECT_0].CalcValue()) || !sSpellMgr->GetSpellInfo(spellEntry->Effects[EFFECT_1].CalcValue())) return false; return true; } @@ -312,80 +304,86 @@ class spell_hun_masters_call : public SpellScriptLoader class spell_hun_readiness : public SpellScriptLoader { -public: - spell_hun_readiness() : SpellScriptLoader("spell_hun_readiness") { } + public: + spell_hun_readiness() : SpellScriptLoader("spell_hun_readiness") { } - class spell_hun_readiness_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_readiness_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_hun_readiness_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; - - // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath - const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) - { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); - - ///! If spellId in cooldown map isn't valid, the above will return a null pointer. - if (spellInfo && - spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && - spellInfo->Id != HUNTER_SPELL_READINESS && - spellInfo->Id != HUNTER_SPELL_BESTIAL_WRATH && - spellInfo->GetRecoveryTime() > 0) - caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true); - else - ++itr; + PrepareSpellScript(spell_hun_readiness_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath + const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap(); + for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + + ///! If spellId in cooldown map isn't valid, the above will return a null pointer. + if (spellInfo && + spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && + spellInfo->Id != HUNTER_SPELL_READINESS && + spellInfo->Id != HUNTER_SPELL_BESTIAL_WRATH && + spellInfo->GetRecoveryTime() > 0) + caster->RemoveSpellCooldown((itr++)->first, true); + else + ++itr; + } + } + + void Register() + { + // add dummy effect spell handler to Readiness + OnEffectHitTarget += SpellEffectFn(spell_hun_readiness_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - // add dummy effect spell handler to Readiness - OnEffectHitTarget += SpellEffectFn(spell_hun_readiness_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_hun_readiness_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_readiness_SpellScript(); - } }; // 37506 Scatter Shot class spell_hun_scatter_shot : public SpellScriptLoader { -public: - spell_hun_scatter_shot() : SpellScriptLoader("spell_hun_scatter_shot") { } + public: + spell_hun_scatter_shot() : SpellScriptLoader("spell_hun_scatter_shot") { } - class spell_hun_scatter_shot_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_scatter_shot_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_hun_scatter_shot_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; - - // break Auto Shot and autohit - caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - caster->AttackStop(); - caster->ToPlayer()->SendAttackSwingCancelAttack(); - } + PrepareSpellScript(spell_hun_scatter_shot_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + // break Auto Shot and autohit + caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + caster->AttackStop(); + caster->SendAttackSwingCancelAttack(); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_hun_scatter_shot_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_hun_scatter_shot_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_hun_scatter_shot_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_scatter_shot_SpellScript(); - } }; // 53302, 53303, 53304 Sniper Training @@ -397,169 +395,164 @@ enum eSniperTrainingSpells class spell_hun_sniper_training : public SpellScriptLoader { -public: - spell_hun_sniper_training() : SpellScriptLoader("spell_hun_sniper_training") { } - - class spell_hun_sniper_training_AuraScript : public AuraScript - { - PrepareAuraScript(spell_hun_sniper_training_AuraScript) - bool Validate(SpellInfo const* /*entry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_SNIPER_TRAINING_R1)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SNIPER_TRAINING_BUFF_R1)) - return false; - return true; - } + public: + spell_hun_sniper_training() : SpellScriptLoader("spell_hun_sniper_training") { } - void HandlePeriodic(AuraEffect const* aurEff) + class spell_hun_sniper_training_AuraScript : public AuraScript { - PreventDefaultAction(); - if (aurEff->GetAmount() > 0) - return; + PrepareAuraScript(spell_hun_sniper_training_AuraScript); - Unit* caster = GetCaster(); + bool Validate(SpellInfo const* /*entry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SNIPER_TRAINING_R1) || !sSpellMgr->GetSpellInfo(SPELL_SNIPER_TRAINING_BUFF_R1)) + return false; + return true; + } - if (!caster) - return; + void HandlePeriodic(AuraEffect const* aurEff) + { + PreventDefaultAction(); + if (aurEff->GetAmount() <= 0) + { + Unit* caster = GetCaster(); + uint32 spellId = SPELL_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_SNIPER_TRAINING_R1; + if (Unit* target = GetTarget()) + if (!target->HasAura(spellId)) + { + SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(spellId); + Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster() ? caster : target; + triggerCaster->CastSpell(target, triggeredSpellInfo, true, 0, aurEff); + } + } + } - uint32 spellId = SPELL_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_SNIPER_TRAINING_R1; - Unit* target = GetTarget(); - if (!target->HasAura(spellId)) + void HandleUpdatePeriodic(AuraEffect* aurEff) { - SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(spellId); - Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster() ? caster : target; - triggerCaster->CastSpell(target, triggeredSpellInfo, true, 0, aurEff); + if (Player* playerTarget = GetUnitOwner()->ToPlayer()) + { + int32 baseAmount = aurEff->GetBaseAmount(); + int32 amount = playerTarget->isMoving() ? + playerTarget->CalculateSpellDamage(playerTarget, GetSpellInfo(), aurEff->GetEffIndex(), &baseAmount) : + aurEff->GetAmount() - 1; + aurEff->SetAmount(amount); + } } - } - void HandleUpdatePeriodic(AuraEffect* aurEff) - { - Unit* target = GetUnitOwner(); - if (Player* playerTarget = target->ToPlayer()) + void Register() { - int32 baseAmount = aurEff->GetBaseAmount(); - int32 amount = playerTarget->isMoving() ? - target->CalculateSpellDamage(target, GetSpellInfo(), aurEff->GetEffIndex(), &baseAmount) : - aurEff->GetAmount() - 1; - aurEff->SetAmount(amount); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_hun_sniper_training_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_hun_sniper_training_AuraScript::HandleUpdatePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } - } + }; - void Register() + AuraScript* GetAuraScript() const { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_hun_sniper_training_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_hun_sniper_training_AuraScript::HandleUpdatePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + return new spell_hun_sniper_training_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_hun_sniper_training_AuraScript(); - } }; class spell_hun_pet_heart_of_the_phoenix : public SpellScriptLoader { -public: - spell_hun_pet_heart_of_the_phoenix() : SpellScriptLoader("spell_hun_pet_heart_of_the_phoenix") { } + public: + spell_hun_pet_heart_of_the_phoenix() : SpellScriptLoader("spell_hun_pet_heart_of_the_phoenix") { } - class spell_hun_pet_heart_of_the_phoenix_SpellScript : public SpellScript - { - PrepareSpellScript(spell_hun_pet_heart_of_the_phoenix_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_hun_pet_heart_of_the_phoenix_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED)) - return false; - if (!sSpellMgr->GetSpellInfo(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF)) - return false; - return true; - } + PrepareSpellScript(spell_hun_pet_heart_of_the_phoenix_SpellScript); - void HandleScript(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - Unit* owner = caster->GetOwner(); - if (!owner || caster->HasAura(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF)) - return; - owner->CastCustomSpell(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED, SPELLVALUE_BASE_POINT0, 100, caster, true); - caster->CastSpell(caster, HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF, true); - } + bool Load() + { + if (!GetCaster()->isPet()) + return false; + return true; + } - void Register() - { - // add dummy effect spell handler to pet's Last Stand - OnEffectHitTarget += SpellEffectFn(spell_hun_pet_heart_of_the_phoenix_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED) || !sSpellMgr->GetSpellInfo(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF)) + return false; + return true; + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* owner = caster->GetOwner()) + if (!caster->HasAura(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF)) + { + owner->CastCustomSpell(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED, SPELLVALUE_BASE_POINT0, 100, caster, true); + caster->CastSpell(caster, HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF, true); + } + } - bool Load() + void Register() + { + // add dummy effect spell handler to pet's Last Stand + OnEffectHitTarget += SpellEffectFn(spell_hun_pet_heart_of_the_phoenix_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const { - if (!GetCaster()->isPet()) - return false; - return true; + return new spell_hun_pet_heart_of_the_phoenix_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_pet_heart_of_the_phoenix_SpellScript(); - } }; class spell_hun_pet_carrion_feeder : public SpellScriptLoader { -public: - spell_hun_pet_carrion_feeder() : SpellScriptLoader("spell_hun_pet_carrion_feeder") { } + 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 Validate(SpellInfo const* /*spellEntry*/) + class spell_hun_pet_carrion_feeder_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED)) - return false; - return true; - } + PrepareSpellScript(spell_hun_pet_carrion_feeder_SpellScript); + + bool Load() + { + if (!GetCaster()->isPet()) + return false; + return true; + } - SpellCastResult CheckIfCorpseNear() - { - Unit* caster = GetCaster(); - float max_range = GetSpellInfo()->GetMaxRange(false); - WorldObject* result = NULL; - // search for nearby enemy corpse in range - Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_SELECT_CHECK_ENEMY); - Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); - caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher); - if (!result) - return SPELL_FAILED_NO_EDIBLE_CORPSES; - return SPELL_CAST_OK; - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED)) + return false; + return true; + } - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - caster->CastSpell(caster, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED, false); - } + SpellCastResult CheckIfCorpseNear() + { + Unit* caster = GetCaster(); + float max_range = GetSpellInfo()->GetMaxRange(false); + WorldObject* result = NULL; + // search for nearby enemy corpse in range + Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_SELECT_CHECK_ENEMY); + Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); + caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher); + if (!result) + return SPELL_FAILED_NO_EDIBLE_CORPSES; + return SPELL_CAST_OK; + } - void Register() - { - // add dummy effect spell handler to pet's Last Stand - OnEffectHit += SpellEffectFn(spell_hun_pet_carrion_feeder_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - OnCheckCast += SpellCheckCastFn(spell_hun_pet_carrion_feeder_SpellScript::CheckIfCorpseNear); - } + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED, false); + } - bool Load() + void Register() + { + // add dummy effect spell handler to pet's Last Stand + 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 { - if (!GetCaster()->isPet()) - return false; - return true; + return new spell_hun_pet_carrion_feeder_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_hun_pet_carrion_feeder_SpellScript(); - } }; void AddSC_hunter_spell_scripts() diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index b40879d500e..844162a88ec 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -21,55 +21,55 @@ * Scriptnames of files in this file should be prefixed with "spell_item_". */ -#include "ScriptPCH.h" #include "SkillDiscovery.h" // Generic script for handling item dummy effects which trigger another spell. class spell_item_trigger_spell : public SpellScriptLoader { -private: - uint32 _triggeredSpellId; - -public: - spell_item_trigger_spell(const char* name, uint32 triggeredSpellId) : SpellScriptLoader(name), _triggeredSpellId(triggeredSpellId) { } - - class spell_item_trigger_spell_SpellScript : public SpellScript - { - PrepareSpellScript(spell_item_trigger_spell_SpellScript) private: uint32 _triggeredSpellId; public: - spell_item_trigger_spell_SpellScript(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { } + spell_item_trigger_spell(const char* name, uint32 triggeredSpellId) : SpellScriptLoader(name), _triggeredSpellId(triggeredSpellId) { } - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_item_trigger_spell_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(_triggeredSpellId)) - return false; - return true; - } + PrepareSpellScript(spell_item_trigger_spell_SpellScript); + private: + uint32 _triggeredSpellId; - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Item* pItem = GetCastItem()) - GetCaster()->CastSpell(GetCaster(), _triggeredSpellId, true, pItem); - } + public: + spell_item_trigger_spell_SpellScript(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { } - void Register() + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(_triggeredSpellId)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Item* pItem = GetCastItem()) + caster->CastSpell(caster, _triggeredSpellId, true, pItem); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_trigger_spell_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_trigger_spell_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_trigger_spell_SpellScript(_triggeredSpellId); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_trigger_spell_SpellScript(_triggeredSpellId); - } }; // http://www.wowhead.com/item=6522 Deviate Fish // 8063 Deviate Fish -enum eDeviateFishSpells +enum DeviateFishSpells { SPELL_SLEEPY = 8064, SPELL_INVIGORATE = 8065, @@ -80,46 +80,48 @@ enum eDeviateFishSpells class spell_item_deviate_fish : public SpellScriptLoader { -public: - spell_item_deviate_fish() : SpellScriptLoader("spell_item_deviate_fish") { } - - class spell_item_deviate_fish_SpellScript : public SpellScript - { - PrepareSpellScript(spell_item_deviate_fish_SpellScript) public: - bool Validate(SpellInfo const* /*spellEntry*/) - { - for (uint32 spellId = SPELL_SLEEPY; spellId <= SPELL_HEALTHY_SPIRIT; ++spellId) - if (!sSpellMgr->GetSpellInfo(spellId)) - return false; - return true; - } + spell_item_deviate_fish() : SpellScriptLoader("spell_item_deviate_fish") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_deviate_fish_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_deviate_fish_SpellScript); - uint32 spellId = urand(SPELL_SLEEPY, SPELL_HEALTHY_SPIRIT); - pCaster->CastSpell(pCaster, spellId, true, NULL); - } + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - void Register() + bool Validate(SpellInfo const* /*spellEntry*/) + { + for (uint32 spellId = SPELL_SLEEPY; spellId <= SPELL_HEALTHY_SPIRIT; ++spellId) + if (!sSpellMgr->GetSpellInfo(spellId)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + uint32 spellId = urand(SPELL_SLEEPY, SPELL_HEALTHY_SPIRIT); + caster->CastSpell(caster, spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_deviate_fish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_deviate_fish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_deviate_fish_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_deviate_fish_SpellScript(); - } }; // http://www.wowhead.com/item=47499 Flask of the North // 67019 Flask of the North -enum eFlaskOfTheNorthSpells +enum FlaskOfTheNorthSpells { SPELL_FLASK_OF_THE_NORTH_SP = 67016, SPELL_FLASK_OF_THE_NORTH_AP = 67017, @@ -128,75 +130,68 @@ enum eFlaskOfTheNorthSpells class spell_item_flask_of_the_north : public SpellScriptLoader { -public: - spell_item_flask_of_the_north() : SpellScriptLoader("spell_item_flask_of_the_north") { } - - class spell_item_flask_of_the_north_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_flask_of_the_north_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_SP)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_AP)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_STR)) - return false; - return true; - } + spell_item_flask_of_the_north() : SpellScriptLoader("spell_item_flask_of_the_north") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_flask_of_the_north_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_flask_of_the_north_SpellScript); - std::vector<uint32> possibleSpells; - switch (pCaster->getClass()) + bool Validate(SpellInfo const* /*spellEntry*/) { - case CLASS_WARLOCK: - case CLASS_MAGE: - case CLASS_PRIEST: - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); - break; - case CLASS_DEATH_KNIGHT: - case CLASS_WARRIOR: - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR); - break; - case CLASS_ROGUE: - case CLASS_HUNTER: - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP); - break; - case CLASS_DRUID: - case CLASS_PALADIN: - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR); - break; - case CLASS_SHAMAN: - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); - possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP); - break; + if (!sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_SP) || !sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_AP) || !sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_STR)) + return false; + return true; } - pCaster->CastSpell(pCaster, possibleSpells[irand(0, (possibleSpells.size() - 1))], true, NULL); - } + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + std::vector<uint32> possibleSpells; + switch (caster->getClass()) + { + case CLASS_WARLOCK: + case CLASS_MAGE: + case CLASS_PRIEST: + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); + break; + case CLASS_DEATH_KNIGHT: + case CLASS_WARRIOR: + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR); + break; + case CLASS_ROGUE: + case CLASS_HUNTER: + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP); + break; + case CLASS_DRUID: + case CLASS_PALADIN: + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR); + break; + case CLASS_SHAMAN: + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP); + possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP); + break; + } - void Register() + caster->CastSpell(caster, possibleSpells[irand(0, (possibleSpells.size() - 1))], true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_flask_of_the_north_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_flask_of_the_north_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_flask_of_the_north_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_flask_of_the_north_SpellScript(); - } }; // http://www.wowhead.com/item=10645 Gnomish Death Ray // 13280 Gnomish Death Ray -enum eGnomishDeathRay +enum GnomishDeathRay { SPELL_GNOMISH_DEATH_RAY_SELF = 13493, SPELL_GNOMISH_DEATH_RAY_TARGET = 13279, @@ -204,49 +199,45 @@ enum eGnomishDeathRay class spell_item_gnomish_death_ray : public SpellScriptLoader { -public: - spell_item_gnomish_death_ray() : SpellScriptLoader("spell_item_gnomish_death_ray") { } - - class spell_item_gnomish_death_ray_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_gnomish_death_ray_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_SELF)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_TARGET)) - return false; - return true; - } + spell_item_gnomish_death_ray() : SpellScriptLoader("spell_item_gnomish_death_ray") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_gnomish_death_ray_SpellScript : public SpellScript { - if (Unit* target = GetHitUnit()) + PrepareSpellScript(spell_item_gnomish_death_ray_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) { - Unit* pCaster = GetCaster(); - if (urand(0, 99) < 15) - pCaster->CastSpell(pCaster, SPELL_GNOMISH_DEATH_RAY_SELF, true, NULL); // failure - else - pCaster->CastSpell(target, SPELL_GNOMISH_DEATH_RAY_TARGET, true, NULL); + if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_SELF) || !sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_TARGET)) + return false; + return true; } - } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + if (urand(0, 99) < 15) + caster->CastSpell(caster, SPELL_GNOMISH_DEATH_RAY_SELF, true, NULL); // failure + else + caster->CastSpell(target, SPELL_GNOMISH_DEATH_RAY_TARGET, true, NULL); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_gnomish_death_ray_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_item_gnomish_death_ray_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_gnomish_death_ray_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_gnomish_death_ray_SpellScript(); - } }; // http://www.wowhead.com/item=27388 Mr. Pinchy // 33060 Make a Wish -enum eMakeAWish +enum MakeAWish { SPELL_MR_PINCHYS_BLESSING = 33053, SPELL_SUMMON_MIGHTY_MR_PINCHY = 33057, @@ -257,115 +248,110 @@ enum eMakeAWish class spell_item_make_a_wish : public SpellScriptLoader { -public: - spell_item_make_a_wish() : SpellScriptLoader("spell_item_make_a_wish") { } - - class spell_item_make_a_wish_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_make_a_wish_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_BLESSING)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_MIGHTY_MR_PINCHY)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FURIOUS_MR_PINCHY)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_TINY_MAGICAL_CRAWDAD)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_GIFT)) - return false; - return true; - } + spell_item_make_a_wish() : SpellScriptLoader("spell_item_make_a_wish") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_make_a_wish_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_make_a_wish_SpellScript); - uint32 spellId = SPELL_MR_PINCHYS_GIFT; - switch (urand(1, 5)) + bool Load() { - case 1: spellId = SPELL_MR_PINCHYS_BLESSING; break; - case 2: spellId = SPELL_SUMMON_MIGHTY_MR_PINCHY; break; - case 3: spellId = SPELL_SUMMON_FURIOUS_MR_PINCHY; break; - case 4: spellId = SPELL_TINY_MAGICAL_CRAWDAD; break; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - pCaster->CastSpell(pCaster, spellId, true, NULL); - } - void Register() + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_BLESSING) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_MIGHTY_MR_PINCHY) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_FURIOUS_MR_PINCHY) || !sSpellMgr->GetSpellInfo(SPELL_TINY_MAGICAL_CRAWDAD) || !sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_GIFT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + uint32 spellId = SPELL_MR_PINCHYS_GIFT; + switch (urand(1, 5)) + { + case 1: spellId = SPELL_MR_PINCHYS_BLESSING; break; + case 2: spellId = SPELL_SUMMON_MIGHTY_MR_PINCHY; break; + case 3: spellId = SPELL_SUMMON_FURIOUS_MR_PINCHY; break; + case 4: spellId = SPELL_TINY_MAGICAL_CRAWDAD; break; + } + caster->CastSpell(caster, spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_make_a_wish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_make_a_wish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_make_a_wish_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_make_a_wish_SpellScript(); - } }; // http://www.wowhead.com/item=32686 Mingo's Fortune Giblets // 40802 Mingo's Fortune Generator class spell_item_mingos_fortune_generator : public SpellScriptLoader { -public: - spell_item_mingos_fortune_generator() : SpellScriptLoader("spell_item_mingos_fortune_generator") { } + public: + spell_item_mingos_fortune_generator() : SpellScriptLoader("spell_item_mingos_fortune_generator") { } - class spell_item_mingos_fortune_generator_SpellScript : public SpellScript - { - PrepareSpellScript(spell_item_mingos_fortune_generator_SpellScript) - void HandleDummy(SpellEffIndex effIndex) - { - // Selecting one from Bloodstained Fortune item - uint32 newitemid; - switch (urand(1, 20)) - { - case 1: newitemid = 32688; break; - case 2: newitemid = 32689; break; - case 3: newitemid = 32690; break; - case 4: newitemid = 32691; break; - case 5: newitemid = 32692; break; - case 6: newitemid = 32693; break; - case 7: newitemid = 32700; break; - case 8: newitemid = 32701; break; - case 9: newitemid = 32702; break; - case 10: newitemid = 32703; break; - case 11: newitemid = 32704; break; - case 12: newitemid = 32705; break; - case 13: newitemid = 32706; break; - case 14: newitemid = 32707; break; - case 15: newitemid = 32708; break; - case 16: newitemid = 32709; break; - case 17: newitemid = 32710; break; - case 18: newitemid = 32711; break; - case 19: newitemid = 32712; break; - case 20: newitemid = 32713; break; - default: - return; + class spell_item_mingos_fortune_generator_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_mingos_fortune_generator_SpellScript); + + void HandleDummy(SpellEffIndex effIndex) + { + // Selecting one from Bloodstained Fortune item + uint32 newitemid; + switch (urand(1, 20)) + { + case 1: newitemid = 32688; break; + case 2: newitemid = 32689; break; + case 3: newitemid = 32690; break; + case 4: newitemid = 32691; break; + case 5: newitemid = 32692; break; + case 6: newitemid = 32693; break; + case 7: newitemid = 32700; break; + case 8: newitemid = 32701; break; + case 9: newitemid = 32702; break; + case 10: newitemid = 32703; break; + case 11: newitemid = 32704; break; + case 12: newitemid = 32705; break; + case 13: newitemid = 32706; break; + case 14: newitemid = 32707; break; + case 15: newitemid = 32708; break; + case 16: newitemid = 32709; break; + case 17: newitemid = 32710; break; + case 18: newitemid = 32711; break; + case 19: newitemid = 32712; break; + case 20: newitemid = 32713; break; + default: + return; + } + + CreateItem(effIndex, newitemid); } - CreateItem(effIndex, newitemid); - } + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_mingos_fortune_generator_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_mingos_fortune_generator_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_mingos_fortune_generator_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_mingos_fortune_generator_SpellScript(); - } }; // http://www.wowhead.com/item=10720 Gnomish Net-o-Matic Projector // 13120 Net-o-Matic -enum eNetOMaticSpells +enum NetOMaticSpells { SPELL_NET_O_MATIC_TRIGGERED1 = 16566, SPELL_NET_O_MATIC_TRIGGERED2 = 13119, @@ -374,54 +360,50 @@ enum eNetOMaticSpells class spell_item_net_o_matic : public SpellScriptLoader { -public: - spell_item_net_o_matic() : SpellScriptLoader("spell_item_net_o_matic") { } - - class spell_item_net_o_matic_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_net_o_matic_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED1)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED2)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED3)) - return false; - return true; - } + spell_item_net_o_matic() : SpellScriptLoader("spell_item_net_o_matic") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_net_o_matic_SpellScript : public SpellScript { - if (Unit* target = GetHitUnit()) + PrepareSpellScript(spell_item_net_o_matic_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) { - uint32 spellId = SPELL_NET_O_MATIC_TRIGGERED3; - uint32 roll = urand(0, 99); - if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) - spellId = SPELL_NET_O_MATIC_TRIGGERED1; - else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) - spellId = SPELL_NET_O_MATIC_TRIGGERED2; + if (!sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED1) || !sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED2) || !sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED3)) + return false; + return true; + } - GetCaster()->CastSpell(target, spellId, true, NULL); + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + { + uint32 spellId = SPELL_NET_O_MATIC_TRIGGERED3; + uint32 roll = urand(0, 99); + if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) + spellId = SPELL_NET_O_MATIC_TRIGGERED1; + else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) + spellId = SPELL_NET_O_MATIC_TRIGGERED2; + + GetCaster()->CastSpell(target, spellId, true, NULL); + } } - } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_net_o_matic_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_item_net_o_matic_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_net_o_matic_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_net_o_matic_SpellScript(); - } }; // http://www.wowhead.com/item=8529 Noggenfogger Elixir // 16589 Noggenfogger Elixir -enum eNoggenfoggerElixirSpells +enum NoggenfoggerElixirSpells { SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1 = 16595, SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2 = 16593, @@ -430,55 +412,53 @@ enum eNoggenfoggerElixirSpells class spell_item_noggenfogger_elixir : public SpellScriptLoader { -public: - spell_item_noggenfogger_elixir() : SpellScriptLoader("spell_item_noggenfogger_elixir") { } - - class spell_item_noggenfogger_elixir_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_noggenfogger_elixir_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3)) - return false; - return true; - } + spell_item_noggenfogger_elixir() : SpellScriptLoader("spell_item_noggenfogger_elixir") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_noggenfogger_elixir_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_noggenfogger_elixir_SpellScript); - uint32 spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3; - switch (urand(1, 3)) + bool Load() { - case 1: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1; break; - case 2: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2; break; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - pCaster->CastSpell(pCaster, spellId, true, NULL); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1) || !sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2) || !sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3)) + return false; + return true; + } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + uint32 spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3; + switch (urand(1, 3)) + { + case 1: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1; break; + case 2: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2; break; + } + + caster->CastSpell(caster, spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_noggenfogger_elixir_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_noggenfogger_elixir_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_noggenfogger_elixir_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_noggenfogger_elixir_SpellScript(); - } }; // http://www.wowhead.com/item=6657 Savory Deviate Delight // 8213 Savory Deviate Delight -enum eSavoryDeviateDelight +enum SavoryDeviateDelight { SPELL_FLIP_OUT_MALE = 8219, SPELL_FLIP_OUT_FEMALE = 8220, @@ -488,53 +468,55 @@ enum eSavoryDeviateDelight class spell_item_savory_deviate_delight : public SpellScriptLoader { -public: - spell_item_savory_deviate_delight() : SpellScriptLoader("spell_item_savory_deviate_delight") { } - - class spell_item_savory_deviate_delight_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_savory_deviate_delight_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - for (uint32 spellId = SPELL_FLIP_OUT_MALE; spellId <= SPELL_YAAARRRR_FEMALE; ++spellId) - if (!sSpellMgr->GetSpellInfo(spellId)) - return false; - return true; - } + spell_item_savory_deviate_delight() : SpellScriptLoader("spell_item_savory_deviate_delight") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_savory_deviate_delight_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_savory_deviate_delight_SpellScript); - uint32 spellId = 0; - switch (urand(1, 2)) + bool Load() { - // Flip Out - ninja - case 1: spellId = (pCaster->getGender() == GENDER_MALE ? SPELL_FLIP_OUT_MALE : SPELL_FLIP_OUT_FEMALE); break; - // Yaaarrrr - pirate - case 2: spellId = (pCaster->getGender() == GENDER_MALE ? SPELL_YAAARRRR_MALE : SPELL_YAAARRRR_FEMALE); break; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - pCaster->CastSpell(pCaster, spellId, true, NULL); - } - void Register() + bool Validate(SpellInfo const* /*spellEntry*/) + { + for (uint32 spellId = SPELL_FLIP_OUT_MALE; spellId <= SPELL_YAAARRRR_FEMALE; ++spellId) + if (!sSpellMgr->GetSpellInfo(spellId)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + uint32 spellId = 0; + switch (urand(1, 2)) + { + // Flip Out - ninja + case 1: spellId = (caster->getGender() == GENDER_MALE ? SPELL_FLIP_OUT_MALE : SPELL_FLIP_OUT_FEMALE); break; + // Yaaarrrr - pirate + case 2: spellId = (caster->getGender() == GENDER_MALE ? SPELL_YAAARRRR_MALE : SPELL_YAAARRRR_FEMALE); break; + } + caster->CastSpell(caster, spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_savory_deviate_delight_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_savory_deviate_delight_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_savory_deviate_delight_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_savory_deviate_delight_SpellScript(); - } }; // http://www.wowhead.com/item=7734 Six Demon Bag // 14537 Six Demon Bag -enum eSixDemonBagSpells +enum SixDemonBagSpells { SPELL_FROSTBOLT = 11538, SPELL_POLYMORPH = 14621, @@ -546,77 +528,66 @@ enum eSixDemonBagSpells class spell_item_six_demon_bag : public SpellScriptLoader { -public: - spell_item_six_demon_bag() : SpellScriptLoader("spell_item_six_demon_bag") { } - - class spell_item_six_demon_bag_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_six_demon_bag_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_FROSTBOLT)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_POLYMORPH)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FELHOUND_MINION)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_FIREBALL)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_CHAIN_LIGHTNING)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_ENVELOPING_WINDS)) - return false; - return true; - } + spell_item_six_demon_bag() : SpellScriptLoader("spell_item_six_demon_bag") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_six_demon_bag_SpellScript : public SpellScript { - if (Unit* target = GetHitUnit()) + PrepareSpellScript(spell_item_six_demon_bag_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) { - Unit* pCaster = GetCaster(); + if (!sSpellMgr->GetSpellInfo(SPELL_FROSTBOLT) || !sSpellMgr->GetSpellInfo(SPELL_POLYMORPH) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_FELHOUND_MINION) || !sSpellMgr->GetSpellInfo(SPELL_FIREBALL) || !sSpellMgr->GetSpellInfo(SPELL_CHAIN_LIGHTNING) || !sSpellMgr->GetSpellInfo(SPELL_ENVELOPING_WINDS)) + return false; + return true; + } - uint32 spellId = 0; - uint32 rand = urand(0, 99); - if (rand < 25) // Fireball (25% chance) - spellId = SPELL_FIREBALL; - else if (rand < 50) // Frostball (25% chance) - spellId = SPELL_FROSTBOLT; - else if (rand < 70) // Chain Lighting (20% chance) - spellId = SPELL_CHAIN_LIGHTNING; - else if (rand < 80) // Polymorph (10% chance) - { - spellId = SPELL_POLYMORPH; - if (urand(0, 100) <= 30) // 30% chance to self-cast - target = pCaster; - } - else if (rand < 95) // Enveloping Winds (15% chance) - spellId = SPELL_ENVELOPING_WINDS; - else // Summon Felhund minion (5% chance) + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) { - spellId = SPELL_SUMMON_FELHOUND_MINION; - target = pCaster; + uint32 spellId = 0; + uint32 rand = urand(0, 99); + if (rand < 25) // Fireball (25% chance) + spellId = SPELL_FIREBALL; + else if (rand < 50) // Frostball (25% chance) + spellId = SPELL_FROSTBOLT; + else if (rand < 70) // Chain Lighting (20% chance) + spellId = SPELL_CHAIN_LIGHTNING; + else if (rand < 80) // Polymorph (10% chance) + { + spellId = SPELL_POLYMORPH; + if (urand(0, 100) <= 30) // 30% chance to self-cast + target = caster; + } + else if (rand < 95) // Enveloping Winds (15% chance) + spellId = SPELL_ENVELOPING_WINDS; + else // Summon Felhund minion (5% chance) + { + spellId = SPELL_SUMMON_FELHOUND_MINION; + target = caster; + } + + caster->CastSpell(target, spellId, true, GetCastItem()); } + } - pCaster->CastSpell(target, spellId, true, GetCastItem()); + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_six_demon_bag_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_item_six_demon_bag_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_six_demon_bag_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_six_demon_bag_SpellScript(); - } }; // http://www.wowhead.com/item=44012 Underbelly Elixir // 59640 Underbelly Elixir -enum eUnderbellyElixirSpells +enum UnderbellyElixirSpells { SPELL_UNDERBELLY_ELIXIR_TRIGGERED1 = 59645, SPELL_UNDERBELLY_ELIXIR_TRIGGERED2 = 59831, @@ -625,49 +596,46 @@ enum eUnderbellyElixirSpells class spell_item_underbelly_elixir : public SpellScriptLoader { -public: - spell_item_underbelly_elixir() : SpellScriptLoader("spell_item_underbelly_elixir") { } - - class spell_item_underbelly_elixir_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_item_underbelly_elixir_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED1)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED2)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED3)) - return false; - return true; - } + spell_item_underbelly_elixir() : SpellScriptLoader("spell_item_underbelly_elixir") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_item_underbelly_elixir_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + PrepareSpellScript(spell_item_underbelly_elixir_SpellScript); - uint32 spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED3; - switch (urand(1, 3)) + bool Load() { - case 1: spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED1; break; - case 2: spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED2; break; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED1) || !sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED2) || !sSpellMgr->GetSpellInfo(SPELL_UNDERBELLY_ELIXIR_TRIGGERED3)) + return false; + return true; } - pCaster->CastSpell(pCaster, spellId, true, NULL); - } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + uint32 spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED3; + switch (urand(1, 3)) + { + case 1: spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED1; break; + case 2: spellId = SPELL_UNDERBELLY_ELIXIR_TRIGGERED2; break; + } + caster->CastSpell(caster, spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_item_underbelly_elixir_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_item_underbelly_elixir_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_item_underbelly_elixir_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_item_underbelly_elixir_SpellScript(); - } }; enum eShadowmourneVisuals @@ -684,17 +652,11 @@ public: class spell_item_shadowmourne_AuraScript : public AuraScript { - public: - PrepareAuraScript(spell_item_shadowmourne_AuraScript) - spell_item_shadowmourne_AuraScript() : AuraScript() { } + PrepareAuraScript(spell_item_shadowmourne_AuraScript); bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_VISUAL_LOW)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_VISUAL_HIGH)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_CHAOS_BANE_BUFF)) + if (!sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_VISUAL_LOW) || !sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_VISUAL_HIGH) || !sSpellMgr->GetSpellInfo(SPELL_SHADOWMOURNE_CHAOS_BANE_BUFF)) return false; return true; } @@ -702,7 +664,6 @@ public: void OnStackChange(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - switch (GetStackAmount()) { case 1: @@ -716,6 +677,8 @@ public: target->RemoveAurasDueToSpell(SPELL_SHADOWMOURNE_VISUAL_HIGH); target->CastSpell(target, SPELL_SHADOWMOURNE_CHAOS_BANE_BUFF, true); break; + default: + break; } } @@ -757,11 +720,7 @@ class spell_item_red_rider_air_rifle : public SpellScriptLoader bool Validate(SpellInfo const* /*spell*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_HOLD_VISUAL)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_SHOOT)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_SHOOT_SELF)) + if (!sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_HOLD_VISUAL) || !sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_SHOOT) || !sSpellMgr->GetSpellInfo(SPELL_AIR_RIFLE_SHOOT_SELF)) return false; return true; } @@ -769,17 +728,18 @@ class spell_item_red_rider_air_rifle : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; - - GetCaster()->CastSpell(GetCaster(), SPELL_AIR_RIFLE_HOLD_VISUAL, true); - // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) - if (Player* player = GetCaster()->ToPlayer()) - player->GetGlobalCooldownMgr().CancelGlobalCooldown(GetSpellInfo()); - if (urand(0, 4)) - GetCaster()->CastSpell(GetHitUnit(), SPELL_AIR_RIFLE_SHOOT, false); - else - GetCaster()->CastSpell(GetCaster(), SPELL_AIR_RIFLE_SHOOT_SELF, false); + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + caster->CastSpell(caster, SPELL_AIR_RIFLE_HOLD_VISUAL, true); + // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) + if (Player* player = caster->ToPlayer()) + player->GetGlobalCooldownMgr().CancelGlobalCooldown(GetSpellInfo()); + if (urand(0, 4)) + caster->CastSpell(target, SPELL_AIR_RIFLE_SHOOT, false); + else + caster->CastSpell(caster, SPELL_AIR_RIFLE_SHOOT_SELF, false); + } } void Register() @@ -794,7 +754,7 @@ class spell_item_red_rider_air_rifle : public SpellScriptLoader } }; -enum eGenericData +enum GenericData { SPELL_ARCANITE_DRAGONLING = 19804, SPELL_BATTLE_CHICKEN = 13166, @@ -826,14 +786,11 @@ class spell_item_create_heart_candy : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - if (!GetHitUnit() || !GetHitUnit()->ToPlayer()) - return; - - Player* target = GetHitUnit()->ToPlayer(); - - static const uint32 items[] = {ITEM_HEART_CANDY_1, ITEM_HEART_CANDY_2, ITEM_HEART_CANDY_3, ITEM_HEART_CANDY_4, ITEM_HEART_CANDY_5, ITEM_HEART_CANDY_6, ITEM_HEART_CANDY_7, ITEM_HEART_CANDY_8}; - - target->AddItem(items[urand(0, 7)], 1); + if (Player* target = GetHitPlayer()) + { + static const uint32 items[] = {ITEM_HEART_CANDY_1, ITEM_HEART_CANDY_2, ITEM_HEART_CANDY_3, ITEM_HEART_CANDY_4, ITEM_HEART_CANDY_5, ITEM_HEART_CANDY_6, ITEM_HEART_CANDY_7, ITEM_HEART_CANDY_8}; + target->AddItem(items[urand(0, 7)], 1); + } } void Register() @@ -856,10 +813,15 @@ class spell_item_book_of_glyph_mastery : public SpellScriptLoader class spell_item_book_of_glyph_mastery_SpellScript : public SpellScript { PrepareSpellScript(spell_item_book_of_glyph_mastery_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } SpellCastResult CheckRequirement() { - if (GetCaster()->GetTypeId() == TYPEID_PLAYER && HasDiscoveredAllSpells(GetSpellInfo()->Id, GetCaster()->ToPlayer())) + if (HasDiscoveredAllSpells(GetSpellInfo()->Id, GetCaster()->ToPlayer())) { SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_LEARNED_EVERYTHING); return SPELL_FAILED_CUSTOM_ERROR; @@ -939,7 +901,7 @@ class spell_item_map_of_the_geyser_fields : public SpellScriptLoader SpellCastResult CheckSinkholes() { Unit* caster = GetCaster(); - if (caster->FindNearestCreature(NPC_SOUTH_SINKHOLE, 30.0f, true) || + if (caster->FindNearestCreature(NPC_SOUTH_SINKHOLE, 30.0f, true) || caster->FindNearestCreature(NPC_NORTHEAST_SINKHOLE, 30.0f, true) || caster->FindNearestCreature(NPC_NORTHWEST_SINKHOLE, 30.0f, true)) return SPELL_CAST_OK; @@ -978,11 +940,7 @@ class spell_item_vanquished_clutches : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_CRUSHER)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_CONSTRICTOR)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_CORRUPTOR)) + if (!sSpellMgr->GetSpellInfo(SPELL_CRUSHER) || !sSpellMgr->GetSpellInfo(SPELL_CONSTRICTOR) || !sSpellMgr->GetSpellInfo(SPELL_CORRUPTOR)) return false; return true; } @@ -990,7 +948,8 @@ class spell_item_vanquished_clutches : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { uint32 spellId = RAND(SPELL_CRUSHER, SPELL_CONSTRICTOR, SPELL_CORRUPTOR); - GetCaster()->CastSpell(GetCaster(), spellId, true); + Unit* caster = GetCaster(); + caster->CastSpell(caster, spellId, true); } void Register() @@ -1019,9 +978,6 @@ enum AshbringerSounds SOUND_ASHBRINGER_10 = 8926, // "Scarlet Crusade is pure no longer" SOUND_ASHBRINGER_11 = 8927, // "Balnazzar's crusade corrupted my son" SOUND_ASHBRINGER_12 = 8928, // "Kill them all!" - - SPELL_ASHBRINGER = 28282, // Ashbringer - Inflicts the will of the Ashbringer upon the wielder - SPELL_ASHBRINGER_TR = 28441 // AB Effect 000 }; class spell_item_ashbringer : public SpellScriptLoader @@ -1031,28 +987,24 @@ class spell_item_ashbringer : public SpellScriptLoader class spell_item_ashbringer_SpellScript : public SpellScript { - PrepareSpellScript(spell_item_ashbringer_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + PrepareSpellScript(spell_item_ashbringer_SpellScript); + + bool Load() { - if (!sSpellMgr->GetSpellInfo(SPELL_ASHBRINGER)) - return false; - return true; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } void OnDummyEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - Unit* caster = GetCaster(); - if (Player* player = caster->ToPlayer()) - { - uint32 sound_id = RAND( SOUND_ASHBRINGER_1, SOUND_ASHBRINGER_2, SOUND_ASHBRINGER_3, SOUND_ASHBRINGER_4, SOUND_ASHBRINGER_5, SOUND_ASHBRINGER_6, - SOUND_ASHBRINGER_7, SOUND_ASHBRINGER_8, SOUND_ASHBRINGER_9, SOUND_ASHBRINGER_10, SOUND_ASHBRINGER_11, SOUND_ASHBRINGER_12 ); + Player* player = GetCaster()->ToPlayer(); + uint32 sound_id = RAND( SOUND_ASHBRINGER_1, SOUND_ASHBRINGER_2, SOUND_ASHBRINGER_3, SOUND_ASHBRINGER_4, SOUND_ASHBRINGER_5, SOUND_ASHBRINGER_6, + SOUND_ASHBRINGER_7, SOUND_ASHBRINGER_8, SOUND_ASHBRINGER_9, SOUND_ASHBRINGER_10, SOUND_ASHBRINGER_11, SOUND_ASHBRINGER_12 ); - // Ashbringers effect (spellID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds - if (urand(0, 60) < 1) - player->PlayDirectSound(sound_id, player); - } + // Ashbringers effect (spellID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds + if (urand(0, 60) < 1) + player->PlayDirectSound(sound_id, player); } void Register() @@ -1080,9 +1032,7 @@ enum MagicEater class spell_magic_eater_food : public SpellScriptLoader { public: - spell_magic_eater_food() : SpellScriptLoader("spell_magic_eater_food") - { - } + spell_magic_eater_food() : SpellScriptLoader("spell_magic_eater_food") {} class spell_magic_eater_food_AuraScript : public AuraScript { @@ -1092,7 +1042,6 @@ class spell_magic_eater_food : public SpellScriptLoader { PreventDefaultAction(); Unit* target = GetTarget(); - switch (urand(0, 5)) { case 0: @@ -1113,7 +1062,7 @@ class spell_magic_eater_food : public SpellScriptLoader case 5: target->CastSpell(target, SPELL_WELL_FED_5, true); break; - } + } } void Register() @@ -1128,6 +1077,873 @@ class spell_magic_eater_food : public SpellScriptLoader } }; +class spell_item_shimmering_vessel : public SpellScriptLoader +{ + public: + spell_item_shimmering_vessel() : SpellScriptLoader("spell_item_shimmering_vessel") { } + + class spell_item_shimmering_vessel_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_shimmering_vessel_SpellScript); + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (Creature* target = GetHitCreature()) + target->setDeathState(JUST_ALIVED); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_shimmering_vessel_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_shimmering_vessel_SpellScript(); + } +}; + +enum PurifyHelboarMeat +{ + SPELL_SUMMON_PURIFIED_HELBOAR_MEAT = 29277, + SPELL_SUMMON_TOXIC_HELBOAR_MEAT = 29278, +}; + +class spell_item_purify_helboar_meat : public SpellScriptLoader +{ + public: + spell_item_purify_helboar_meat() : SpellScriptLoader("spell_item_purify_helboar_meat") { } + + class spell_item_purify_helboar_meat_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_purify_helboar_meat_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_PURIFIED_HELBOAR_MEAT) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_TOXIC_HELBOAR_MEAT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, roll_chance_i(50) ? SPELL_SUMMON_PURIFIED_HELBOAR_MEAT : SPELL_SUMMON_TOXIC_HELBOAR_MEAT, true, NULL); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_purify_helboar_meat_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_purify_helboar_meat_SpellScript(); + } +}; + +enum CrystalPrison +{ + OBJECT_IMPRISONED_DOOMGUARD = 179644, +}; + +class spell_item_crystal_prison_dummy_dnd : public SpellScriptLoader +{ + public: + spell_item_crystal_prison_dummy_dnd() : SpellScriptLoader("spell_item_crystal_prison_dummy_dnd") { } + + class spell_item_crystal_prison_dummy_dnd_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_crystal_prison_dummy_dnd_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sObjectMgr->GetGameObjectTemplate(OBJECT_IMPRISONED_DOOMGUARD)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (Creature* target = GetHitCreature()) + if (target->isDead() && !target->isPet()) + { + GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 0, 0, 0, 0, uint32(target->GetRespawnTime()-time(NULL))); + target->DespawnOrUnsummon(); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_crystal_prison_dummy_dnd_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_crystal_prison_dummy_dnd_SpellScript(); + } +}; + +enum ReindeerTransformation +{ + SPELL_FLYING_REINDEER_310 = 44827, + SPELL_FLYING_REINDEER_280 = 44825, + SPELL_FLYING_REINDEER_60 = 44824, + SPELL_REINDEER_100 = 25859, + SPELL_REINDEER_60 = 25858, +}; + +class spell_item_reindeer_transformation : public SpellScriptLoader +{ + public: + spell_item_reindeer_transformation() : SpellScriptLoader("spell_item_reindeer_transformation") { } + + class spell_item_reindeer_transformation_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_reindeer_transformation_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_FLYING_REINDEER_310) || !sSpellMgr->GetSpellInfo(SPELL_FLYING_REINDEER_280) + || !sSpellMgr->GetSpellInfo(SPELL_FLYING_REINDEER_60) || !sSpellMgr->GetSpellInfo(SPELL_REINDEER_100) + || !sSpellMgr->GetSpellInfo(SPELL_REINDEER_60)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (caster->HasAuraType(SPELL_AURA_MOUNTED)) + { + float flyspeed = caster->GetSpeedRate(MOVE_FLIGHT); + float speed = caster->GetSpeedRate(MOVE_RUN); + + caster->RemoveAurasByType(SPELL_AURA_MOUNTED); + //5 different spells used depending on mounted speed and if mount can fly or not + + if (flyspeed >= 4.1f) + // Flying Reindeer + caster->CastSpell(caster, SPELL_FLYING_REINDEER_310, true); //310% flying Reindeer + else if (flyspeed >= 3.8f) + // Flying Reindeer + caster->CastSpell(caster, SPELL_FLYING_REINDEER_280, true); //280% flying Reindeer + else if (flyspeed >= 1.6f) + // Flying Reindeer + caster->CastSpell(caster, SPELL_FLYING_REINDEER_60, true); //60% flying Reindeer + else if (speed >= 2.0f) + // Reindeer + caster->CastSpell(caster, SPELL_REINDEER_100, true); //100% ground Reindeer + else + // Reindeer + caster->CastSpell(caster, SPELL_REINDEER_60, true); //60% ground Reindeer + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_reindeer_transformation_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_reindeer_transformation_SpellScript(); + } +}; + +enum NighInvulnerability +{ + SPELL_NIGH_INVULNERABILITY = 30456, + SPELL_COMPLETE_VULNERABILITY = 30457, +}; + +class spell_item_nigh_invulnerability : public SpellScriptLoader +{ + public: + spell_item_nigh_invulnerability() : SpellScriptLoader("spell_item_nigh_invulnerability") { } + + class spell_item_nigh_invulnerability_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_nigh_invulnerability_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_NIGH_INVULNERABILITY) || !sSpellMgr->GetSpellInfo(SPELL_COMPLETE_VULNERABILITY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Item* castItem = GetCastItem()) + if (roll_chance_i(86)) // Nigh-Invulnerability - success + caster->CastSpell(caster, SPELL_NIGH_INVULNERABILITY, true, castItem); + else // Complete Vulnerability - backfire in 14% casts + caster->CastSpell(caster, SPELL_COMPLETE_VULNERABILITY, true, castItem); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_nigh_invulnerability_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_nigh_invulnerability_SpellScript(); + } +}; + +enum Poultryzer +{ + SPELL_POULTRYIZER_SUCCESS = 30501, + SPELL_POULTRYIZER_BACKFIRE = 30504, +}; + +class spell_item_poultryizer : public SpellScriptLoader +{ + public: + spell_item_poultryizer() : SpellScriptLoader("spell_item_poultryizer") { } + + class spell_item_poultryizer_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_poultryizer_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_POULTRYIZER_SUCCESS) || !sSpellMgr->GetSpellInfo(SPELL_POULTRYIZER_BACKFIRE)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (GetCastItem() && GetHitUnit()) + GetCaster()->CastSpell(GetHitUnit(), roll_chance_i(80) ? SPELL_POULTRYIZER_SUCCESS : SPELL_POULTRYIZER_BACKFIRE , true, GetCastItem()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_poultryizer_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_poultryizer_SpellScript(); + } +}; + +enum SocretharsStone +{ + SPELL_SOCRETHAR_TO_SEAT = 35743, + SPELL_SOCRETHAR_FROM_SEAT = 35744, +}; + +class spell_item_socrethars_stone : public SpellScriptLoader +{ + public: + spell_item_socrethars_stone() : SpellScriptLoader("spell_item_socrethars_stone") { } + + class spell_item_socrethars_stone_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_socrethars_stone_SpellScript); + + bool Load() + { + return (GetCaster()->GetAreaId() == 3900 || GetCaster()->GetAreaId() == 3742); + } + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SOCRETHAR_TO_SEAT) || !sSpellMgr->GetSpellInfo(SPELL_SOCRETHAR_FROM_SEAT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + switch (caster->GetAreaId()) + { + case 3900: + caster->CastSpell(caster, SPELL_SOCRETHAR_TO_SEAT, true); + break; + case 3742: + caster->CastSpell(caster, SPELL_SOCRETHAR_FROM_SEAT, true); + break; + default: + return; + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_socrethars_stone_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_socrethars_stone_SpellScript(); + } +}; + +enum DemonBroiledSurprise +{ + QUEST_SUPER_HOT_STEW = 11379, + SPELL_CREATE_DEMON_BROILED_SURPRISE = 43753, + NPC_ABYSSAL_FLAMEBRINGER = 19973, +}; + +class spell_item_demon_broiled_surprise : public SpellScriptLoader +{ + public: + spell_item_demon_broiled_surprise() : SpellScriptLoader("spell_item_demon_broiled_surprise") { } + + class spell_item_demon_broiled_surprise_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_demon_broiled_surprise_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CREATE_DEMON_BROILED_SURPRISE) || !sObjectMgr->GetCreatureTemplate(NPC_ABYSSAL_FLAMEBRINGER) || !sObjectMgr->GetQuestTemplate(QUEST_SUPER_HOT_STEW)) + return false; + return true; + } + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* player = GetCaster(); + player->CastSpell(player, SPELL_CREATE_DEMON_BROILED_SURPRISE, false); + } + + SpellCastResult CheckRequirement() + { + Player* player = GetCaster()->ToPlayer(); + if (player->GetQuestStatus(QUEST_SUPER_HOT_STEW) != QUEST_STATUS_INCOMPLETE) + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + + if (Creature* creature = player->FindNearestCreature(NPC_ABYSSAL_FLAMEBRINGER, 10, false)) + if (creature->isDead()) + return SPELL_CAST_OK; + return SPELL_FAILED_NOT_HERE; + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_demon_broiled_surprise_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); + OnCheckCast += SpellCheckCastFn(spell_item_demon_broiled_surprise_SpellScript::CheckRequirement); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_demon_broiled_surprise_SpellScript(); + } +}; + +enum CompleteRaptorCapture +{ + SPELL_RAPTOR_CAPTURE_CREDIT = 42337, +}; + +class spell_item_complete_raptor_capture : public SpellScriptLoader +{ + public: + spell_item_complete_raptor_capture() : SpellScriptLoader("spell_item_complete_raptor_capture") { } + + class spell_item_complete_raptor_capture_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_complete_raptor_capture_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_RAPTOR_CAPTURE_CREDIT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (GetHitCreature()) + { + GetHitCreature()->DespawnOrUnsummon(); + + //cast spell Raptor Capture Credit + caster->CastSpell(caster, SPELL_RAPTOR_CAPTURE_CREDIT, true, NULL); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_complete_raptor_capture_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_complete_raptor_capture_SpellScript(); + } +}; + +enum ImpaleLeviroth +{ + NPC_LEVIROTH = 26452, +}; + +class spell_item_impale_leviroth : public SpellScriptLoader +{ + public: + spell_item_impale_leviroth() : SpellScriptLoader("spell_item_impale_leviroth") { } + + class spell_item_impale_leviroth_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_impale_leviroth_SpellScript); + + bool Load() + { + return GetHitCreature()->GetEntry() == NPC_LEVIROTH; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sObjectMgr->GetCreatureTemplate(NPC_LEVIROTH)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitCreature()) + if (target->HealthBelowPct(95)) + caster->DealDamage(target, target->CountPctFromMaxHealth(93)); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_impale_leviroth_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_impale_leviroth_SpellScript(); + } +}; + +enum BrewfestMountTransformation +{ + SPELL_MOUNT_RAM_100 = 43900, + SPELL_MOUNT_RAM_60 = 43899, + SPELL_MOUNT_KODO_100 = 49379, + SPELL_MOUNT_KODO_60 = 49378, + SPELL_BREWFEST_MOUNT_TRANSFORM = 49357, + SPELL_BREWFEST_MOUNT_TRANSFORM_REVERSE = 52845, +}; + +class spell_item_brewfest_mount_transformation : public SpellScriptLoader +{ + public: + spell_item_brewfest_mount_transformation() : SpellScriptLoader("spell_item_brewfest_mount_transformation") { } + + class spell_item_brewfest_mount_transformation_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_brewfest_mount_transformation_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_MOUNT_RAM_100) || !sSpellMgr->GetSpellInfo(SPELL_MOUNT_RAM_60) || !sSpellMgr->GetSpellInfo(SPELL_MOUNT_KODO_100) || !sSpellMgr->GetSpellInfo(SPELL_MOUNT_KODO_60)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Player* caster = GetCaster()->ToPlayer(); + if (caster->HasAuraType(SPELL_AURA_MOUNTED)) + { + caster->RemoveAurasByType(SPELL_AURA_MOUNTED); + uint32 spell_id; + + switch (GetSpellInfo()->Id) + { + case SPELL_BREWFEST_MOUNT_TRANSFORM: + if (caster->GetSpeedRate(MOVE_RUN) >= 2.0f) + spell_id = caster->GetTeam() == ALLIANCE ? SPELL_MOUNT_RAM_100 : SPELL_MOUNT_KODO_100 ; + else + spell_id = caster->GetTeam() == ALLIANCE ? SPELL_MOUNT_RAM_60 : SPELL_MOUNT_KODO_60 ; + break; + case SPELL_BREWFEST_MOUNT_TRANSFORM_REVERSE: + if (caster->GetSpeedRate(MOVE_RUN) >= 2.0f) + spell_id = caster->GetTeam() == HORDE ? SPELL_MOUNT_RAM_100 : SPELL_MOUNT_KODO_100 ; + else + spell_id = caster->GetTeam() == HORDE ? SPELL_MOUNT_RAM_60 : SPELL_MOUNT_KODO_60 ; + break; + default: + return; + } + caster->CastSpell(caster, spell_id, true); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_brewfest_mount_transformation_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_brewfest_mount_transformation_SpellScript(); + } +}; + +enum NitroBoots +{ + SPELL_NITRO_BOOTS_SUCCESS = 54861, + SPELL_NITRO_BOOTS_BACKFIRE = 46014, +}; + +class spell_item_nitro_boots : public SpellScriptLoader +{ + public: + spell_item_nitro_boots() : SpellScriptLoader("spell_item_nitro_boots") { } + + class spell_item_nitro_boots_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_nitro_boots_SpellScript); + + bool Load() + { + if (!GetCastItem()) + return false; + return true; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_NITRO_BOOTS_SUCCESS) || !sSpellMgr->GetSpellInfo(SPELL_NITRO_BOOTS_BACKFIRE)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, roll_chance_i(95) ? SPELL_NITRO_BOOTS_SUCCESS : SPELL_NITRO_BOOTS_BACKFIRE, true, GetCastItem()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_nitro_boots_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_nitro_boots_SpellScript(); + } +}; + +enum TeachLanguage +{ + SPELL_LEARN_GNOMISH_BINARY = 50242, + SPELL_LEARN_GOBLIN_BINARY = 50246, +}; + +class spell_item_teach_language : public SpellScriptLoader +{ + public: + spell_item_teach_language() : SpellScriptLoader("spell_item_teach_language") { } + + class spell_item_teach_language_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_teach_language_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_LEARN_GNOMISH_BINARY) || !sSpellMgr->GetSpellInfo(SPELL_LEARN_GOBLIN_BINARY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Player* caster = GetCaster()->ToPlayer(); + + if (roll_chance_i(34)) + caster->CastSpell(caster,caster->GetTeam() == ALLIANCE ? SPELL_LEARN_GNOMISH_BINARY : SPELL_LEARN_GOBLIN_BINARY, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_teach_language_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_teach_language_SpellScript(); + } +}; + +enum RocketBoots +{ + SPELL_ROCKET_BOOTS_PROC = 30452, +}; + +class spell_item_rocket_boots : public SpellScriptLoader +{ + public: + spell_item_rocket_boots() : SpellScriptLoader("spell_item_rocket_boots") { } + + class spell_item_rocket_boots_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_rocket_boots_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_ROCKET_BOOTS_PROC)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Player* caster = GetCaster()->ToPlayer(); + if (Battleground* bg = caster->GetBattleground()) + bg->EventPlayerDroppedFlag(caster); + + caster->CastSpell(caster, SPELL_ROCKET_BOOTS_PROC, true, NULL); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_rocket_boots_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_rocket_boots_SpellScript(); + } +}; + +enum PygmyOil +{ + SPELL_PYGMY_OIL_PYGMY_AURA = 53806, + SPELL_PYGMY_OIL_SMALLER_AURA = 53805, +}; + +class spell_item_pygmy_oil : public SpellScriptLoader +{ + public: + spell_item_pygmy_oil() : SpellScriptLoader("spell_item_pygmy_oil") { } + + class spell_item_pygmy_oil_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_pygmy_oil_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_PYGMY_OIL_PYGMY_AURA) || !sSpellMgr->GetSpellInfo(SPELL_PYGMY_OIL_SMALLER_AURA)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Aura* aura = caster->GetAura(SPELL_PYGMY_OIL_PYGMY_AURA)) + aura->RefreshDuration(); + else + { + aura = caster->GetAura(SPELL_PYGMY_OIL_SMALLER_AURA); + if (!aura || aura->GetStackAmount() < 5 || !roll_chance_i(50)) + caster->CastSpell(caster, SPELL_PYGMY_OIL_SMALLER_AURA, true); + else + { + aura->Remove(); + caster->CastSpell(caster, SPELL_PYGMY_OIL_PYGMY_AURA, true); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_pygmy_oil_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_pygmy_oil_SpellScript(); + } +}; + +class spell_item_unusual_compass : public SpellScriptLoader +{ + public: + spell_item_unusual_compass() : SpellScriptLoader("spell_item_unusual_compass") { } + + class spell_item_unusual_compass_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_unusual_compass_SpellScript); + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + caster->SetOrientation(frand(0.0f, 62832.0f) / 10000.0f); + caster->SendMovementFlagUpdate(); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_unusual_compass_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_unusual_compass_SpellScript(); + } +}; + +enum UDED +{ + NPC_IRONWOOL_MAMMOTH = 53806, + SPELL_MAMMOTH_CARCASS = 57444, + SPELL_MAMMOTH_MEAT = 54625, +}; + +class spell_item_uded : public SpellScriptLoader +{ + public: + spell_item_uded() : SpellScriptLoader("spell_item_uded") { } + + class spell_item_uded_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_uded_SpellScript); + + bool Load() + { + if (GetHitCreature() && GetHitCreature()->GetEntry() == NPC_IRONWOOL_MAMMOTH) + return true; + return false; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_MAMMOTH_CARCASS) || !sSpellMgr->GetSpellInfo(SPELL_MAMMOTH_MEAT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + Creature* creature = GetHitCreature(); + caster->CastSpell(caster,SPELL_MAMMOTH_CARCASS,true); + + for (uint8 i = 0; i < 4; ++i) + caster->CastSpell(caster,SPELL_MAMMOTH_MEAT,true); + + creature->Kill(creature); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_uded_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_uded_SpellScript(); + } +}; + +enum ChickenCover +{ + SPELL_CHICKEN_NET = 51959, + SPELL_CAPTURE_CHICKEN_ESCAPE = 51037, + QUEST_CHICKEN_PARTY = 12702, + QUEST_FLOWN_THE_COOP = 12532, +}; + +class spell_item_chicken_cover : public SpellScriptLoader +{ + public: + spell_item_chicken_cover() : SpellScriptLoader("spell_item_chicken_cover") { } + + class spell_item_chicken_cover_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_chicken_cover_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CHICKEN_NET) || !sSpellMgr->GetSpellInfo(SPELL_CAPTURE_CHICKEN_ESCAPE) || !sObjectMgr->GetQuestTemplate(QUEST_CHICKEN_PARTY) || !sObjectMgr->GetQuestTemplate(QUEST_FLOWN_THE_COOP)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Player* caster = GetCaster()->ToPlayer(); + if (Unit* target = GetHitUnit()) + { + if (!target->HasAura(SPELL_CHICKEN_NET) && (caster->GetQuestStatus(QUEST_CHICKEN_PARTY) == QUEST_STATUS_INCOMPLETE || caster->GetQuestStatus(QUEST_FLOWN_THE_COOP) == QUEST_STATUS_INCOMPLETE)) + { + caster->CastSpell(caster, SPELL_CAPTURE_CHICKEN_ESCAPE, true); + target->Kill(target); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_item_chicken_cover_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_chicken_cover_SpellScript(); + } +}; + enum Refocus { SPELL_AIMED_SHOT = 19434, @@ -1206,4 +2022,22 @@ void AddSC_item_spell_scripts() new spell_item_ashbringer(); new spell_magic_eater_food(); new spell_item_refocus(); + new spell_item_shimmering_vessel(); + new spell_item_purify_helboar_meat(); + new spell_item_crystal_prison_dummy_dnd(); + new spell_item_reindeer_transformation(); + new spell_item_nigh_invulnerability(); + new spell_item_poultryizer(); + new spell_item_socrethars_stone(); + new spell_item_demon_broiled_surprise(); + new spell_item_complete_raptor_capture(); + new spell_item_impale_leviroth(); + new spell_item_brewfest_mount_transformation(); + new spell_item_nitro_boots(); + new spell_item_teach_language(); + new spell_item_rocket_boots(); + new spell_item_pygmy_oil(); + new spell_item_unusual_compass(); + new spell_item_uded(); + new spell_item_chicken_cover(); } diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index b0b619c8b08..181b89ed5f8 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_mage_". */ -#include "ScriptPCH.h" enum MageSpells { @@ -45,7 +44,8 @@ class spell_mage_blast_wave : public SpellScriptLoader class spell_mage_blast_wave_SpellScript : public SpellScript { - PrepareSpellScript(spell_mage_blast_wave_SpellScript) + PrepareSpellScript(spell_mage_blast_wave_SpellScript); + bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_GLYPH_OF_BLAST_WAVE)) @@ -78,16 +78,19 @@ class spell_mage_cold_snap : public SpellScriptLoader class spell_mage_cold_snap_SpellScript : public SpellScript { - PrepareSpellScript(spell_mage_cold_snap_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); + PrepareSpellScript(spell_mage_cold_snap_SpellScript); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + void HandleDummy(SpellEffIndex /*effIndex*/) + { + + Player* caster = GetCaster()->ToPlayer(); // immediately finishes the cooldown on Frost spells - const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap(); + const SpellCooldowns& cm = caster->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); @@ -96,7 +99,7 @@ class spell_mage_cold_snap : public SpellScriptLoader (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && spellInfo->Id != SPELL_MAGE_COLD_SNAP && spellInfo->GetRecoveryTime() > 0) { - caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true); + caster->RemoveSpellCooldown((itr++)->first, true); } else ++itr; @@ -123,7 +126,8 @@ class spell_mage_polymorph_cast_visual : public SpellScriptLoader class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript { - PrepareSpellScript(spell_mage_polymorph_cast_visual_SpellScript) + PrepareSpellScript(spell_mage_polymorph_cast_visual_SpellScript); + static const uint32 spell_list[6]; bool Validate(SpellInfo const* /*spellEntry*/) @@ -172,14 +176,11 @@ class spell_mage_summon_water_elemental : public SpellScriptLoader class spell_mage_summon_water_elemental_SpellScript : public SpellScript { - PrepareSpellScript(spell_mage_summon_water_elemental_SpellScript) + PrepareSpellScript(spell_mage_summon_water_elemental_SpellScript); + bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT)) + if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT)) return false; return true; } @@ -210,78 +211,79 @@ class spell_mage_summon_water_elemental : public SpellScriptLoader // Frost Warding class spell_mage_frost_warding_trigger : public SpellScriptLoader { -public: - spell_mage_frost_warding_trigger() : SpellScriptLoader("spell_mage_frost_warding_trigger") { } - - class spell_mage_frost_warding_trigger_AuraScript : public AuraScript - { - PrepareAuraScript(spell_mage_frost_warding_trigger_AuraScript); + public: + spell_mage_frost_warding_trigger() : SpellScriptLoader("spell_mage_frost_warding_trigger") { } - enum Spells + class spell_mage_frost_warding_trigger_AuraScript : public AuraScript { - SPELL_MAGE_FROST_WARDING_TRIGGERED = 57776, - SPELL_MAGE_FROST_WARDING_R1 = 28332, - }; + PrepareAuraScript(spell_mage_frost_warding_trigger_AuraScript); - bool Validate(SpellInfo const* /*spellEntry*/) - { - return sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_TRIGGERED) - && sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_R1); - } + enum Spells + { + SPELL_MAGE_FROST_WARDING_TRIGGERED = 57776, + SPELL_MAGE_FROST_WARDING_R1 = 28332, + }; - void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - Unit* target = GetTarget(); - if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_FROST_WARDING_R1, EFFECT_0)) + bool Validate(SpellInfo const* /*spellEntry*/) { - int32 chance = talentAurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_TRIGGERED) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_R1)) + return false; + return true; + } - if (roll_chance_i(chance)) + void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) + { + Unit* target = GetTarget(); + if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_FROST_WARDING_R1, EFFECT_0)) { - absorbAmount = dmgInfo.GetDamage(); - int32 bp = absorbAmount; - target->CastCustomSpell(target, SPELL_MAGE_FROST_WARDING_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + int32 chance = talentAurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + + if (roll_chance_i(chance)) + { + absorbAmount = dmgInfo.GetDamage(); + int32 bp = absorbAmount; + target->CastCustomSpell(target, SPELL_MAGE_FROST_WARDING_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + } } } - } - void Register() + void Register() + { + OnEffectAbsorb += AuraEffectAbsorbFn(spell_mage_frost_warding_trigger_AuraScript::Absorb, EFFECT_0); + } + }; + + AuraScript* GetAuraScript() const { - OnEffectAbsorb += AuraEffectAbsorbFn(spell_mage_frost_warding_trigger_AuraScript::Absorb, EFFECT_0); + return new spell_mage_frost_warding_trigger_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_mage_frost_warding_trigger_AuraScript(); - } }; class spell_mage_incanters_absorbtion_base_AuraScript : public AuraScript { -public: - enum Spells - { - SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED = 44413, - SPELL_MAGE_INCANTERS_ABSORBTION_R1 = 44394, - }; - - bool Validate(SpellInfo const* /*spellEntry*/) - { - return sSpellMgr->GetSpellInfo(SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED) - && sSpellMgr->GetSpellInfo(SPELL_MAGE_INCANTERS_ABSORBTION_R1); - } + public: + enum Spells + { + SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED = 44413, + SPELL_MAGE_INCANTERS_ABSORBTION_R1 = 44394, + }; - void Trigger(AuraEffect* aurEff, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) - { - Unit* target = GetTarget(); + bool Validate(SpellInfo const* /*spellEntry*/) + { + return sSpellMgr->GetSpellInfo(SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED) + && sSpellMgr->GetSpellInfo(SPELL_MAGE_INCANTERS_ABSORBTION_R1); + } - if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_INCANTERS_ABSORBTION_R1, EFFECT_0)) + void Trigger(AuraEffect* aurEff, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) { - int32 bp = CalculatePctN(absorbAmount, talentAurEff->GetAmount()); - target->CastCustomSpell(target, SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + Unit* target = GetTarget(); + + if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_INCANTERS_ABSORBTION_R1, EFFECT_0)) + { + int32 bp = CalculatePctN(absorbAmount, talentAurEff->GetAmount()); + target->CastCustomSpell(target, SPELL_MAGE_INCANTERS_ABSORBTION_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + } } - } }; // Incanter's Absorption diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 39360e04aa1..0ef158fe4bf 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -21,8 +21,9 @@ * Scriptnames of files in this file should be prefixed with "spell_pal_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" +#include "Unit.h" + enum PaladinSpells { @@ -46,323 +47,369 @@ enum PaladinSpells // 31850 - Ardent Defender class spell_pal_ardent_defender : public SpellScriptLoader { -public: - spell_pal_ardent_defender() : SpellScriptLoader("spell_pal_ardent_defender") { } + public: + spell_pal_ardent_defender() : SpellScriptLoader("spell_pal_ardent_defender") { } - class spell_pal_ardent_defender_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_ardent_defender_AuraScript); + class spell_pal_ardent_defender_AuraScript : public AuraScript + { + PrepareAuraScript(spell_pal_ardent_defender_AuraScript); - uint32 absorbPct, healPct; + uint32 absorbPct, healPct; - enum Spell - { - PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235, - }; + enum Spell + { + PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235, + }; - bool Load() - { - healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); - absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - return GetUnitOwner()->ToPlayer(); - } + bool Load() + { + healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); + return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER; + } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) - { - // Set absorbtion amount to unlimited - amount = -1; - } + void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + { + // Set absorbtion amount to unlimited + amount = -1; + } - void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - Unit* victim = GetTarget(); - int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); - uint32 allowedHealth = victim->CountPctFromMaxHealth(35); - // If damage kills us - if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) + void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { - // Cast healing spell, completely avoid damage - absorbAmount = dmgInfo.GetDamage(); - - uint32 defenseSkillValue = victim->GetDefenseSkillValue(); - // Max heal when defense skill denies critical hits from raid bosses - // Formula: max defense at level + 140 (raiting from gear) - uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; - float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) - ? 1.0f - : float(defenseSkillValue) / float(reqDefForMaxHeal); - - int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); - victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); - victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, time(NULL) + 120); + Unit* victim = GetTarget(); + int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); + uint32 allowedHealth = victim->CountPctFromMaxHealth(35); + // If damage kills us + if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) + { + // Cast healing spell, completely avoid damage + absorbAmount = dmgInfo.GetDamage(); + + uint32 defenseSkillValue = victim->GetDefenseSkillValue(); + // Max heal when defense skill denies critical hits from raid bosses + // Formula: max defense at level + 140 (raiting from gear) + uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; + float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) + ? 1.0f + : float(defenseSkillValue) / float(reqDefForMaxHeal); + + int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); + victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); + victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, time(NULL) + 120); + } + else if (remainingHealth < int32(allowedHealth)) + { + // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% + uint32 damageToReduce = (victim->GetHealth() < allowedHealth) + ? dmgInfo.GetDamage() + : allowedHealth - remainingHealth; + absorbAmount = CalculatePctN(damageToReduce, absorbPct); + } } - else if (remainingHealth < int32(allowedHealth)) + + void Register() { - // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% - uint32 damageToReduce = (victim->GetHealth() < allowedHealth) - ? dmgInfo.GetDamage() - : allowedHealth - remainingHealth; - absorbAmount = CalculatePctN(damageToReduce, absorbPct); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_ardent_defender_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); + OnEffectAbsorb += AuraEffectAbsorbFn(spell_pal_ardent_defender_AuraScript::Absorb, EFFECT_0); } - } + }; - void Register() + AuraScript* GetAuraScript() const { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_ardent_defender_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); - OnEffectAbsorb += AuraEffectAbsorbFn(spell_pal_ardent_defender_AuraScript::Absorb, EFFECT_0); + return new spell_pal_ardent_defender_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_pal_ardent_defender_AuraScript(); - } }; class spell_pal_blessing_of_faith : public SpellScriptLoader { -public: - spell_pal_blessing_of_faith() : SpellScriptLoader("spell_pal_blessing_of_faith") { } + public: + spell_pal_blessing_of_faith() : SpellScriptLoader("spell_pal_blessing_of_faith") { } - class spell_pal_blessing_of_faith_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_blessing_of_faith_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_pal_blessing_of_faith_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_DRUID)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_PALADIN)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_PRIEST)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_SHAMAN)) - return false; - return true; - } + PrepareSpellScript(spell_pal_blessing_of_faith_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* unitTarget = GetHitUnit()) + bool Validate(SpellInfo const* /*spellEntry*/) { - uint32 spell_id = 0; - switch (unitTarget->getClass()) + if (!sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_DRUID) || !sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_PALADIN) || !sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_PRIEST) || !sSpellMgr->GetSpellInfo(SPELL_BLESSING_OF_LOWER_CITY_SHAMAN)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* unitTarget = GetHitUnit()) { - case CLASS_DRUID: spell_id = SPELL_BLESSING_OF_LOWER_CITY_DRUID; break; - case CLASS_PALADIN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PALADIN; break; - case CLASS_PRIEST: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PRIEST; break; - case CLASS_SHAMAN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_SHAMAN; break; - default: return; // ignore for non-healing classes + uint32 spell_id = 0; + switch (unitTarget->getClass()) + { + case CLASS_DRUID: spell_id = SPELL_BLESSING_OF_LOWER_CITY_DRUID; break; + case CLASS_PALADIN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PALADIN; break; + case CLASS_PRIEST: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PRIEST; break; + case CLASS_SHAMAN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_SHAMAN; break; + default: return; // ignore for non-healing classes + } + Unit* caster = GetCaster(); + caster->CastSpell(caster, spell_id, true); } + } - GetCaster()->CastSpell(GetCaster(), spell_id, true); + void Register() + { + // add dummy effect spell handler to Blessing of Faith + OnEffectHitTarget += SpellEffectFn(spell_pal_blessing_of_faith_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - } + }; - void Register() + SpellScript* GetSpellScript() const { - // add dummy effect spell handler to Blessing of Faith - OnEffectHitTarget += SpellEffectFn(spell_pal_blessing_of_faith_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_pal_blessing_of_faith_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_pal_blessing_of_faith_SpellScript(); - } }; // 20911 Blessing of Sanctuary // 25899 Greater Blessing of Sanctuary class spell_pal_blessing_of_sanctuary : public SpellScriptLoader { -public: - spell_pal_blessing_of_sanctuary() : SpellScriptLoader("spell_pal_blessing_of_sanctuary") { } + public: + spell_pal_blessing_of_sanctuary() : SpellScriptLoader("spell_pal_blessing_of_sanctuary") { } - class spell_pal_blessing_of_sanctuary_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_blessing_of_sanctuary_AuraScript) - bool Validate(SpellInfo const* /*entry*/) + class spell_pal_blessing_of_sanctuary_AuraScript : public AuraScript { - if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF)) - return false; - return true; - } + PrepareAuraScript(spell_pal_blessing_of_sanctuary_AuraScript); - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (Unit* pCaster = GetCaster()) - pCaster->CastSpell(target, PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, true); - } + bool Validate(SpellInfo const* /*entry*/) + { + if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF)) + return false; + return true; + } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - target->RemoveAura(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); - } + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (Unit* caster = GetCaster()) + caster->CastSpell(target, PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, true); + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->RemoveAura(PALADIN_SPELL_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); + } - void Register() + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } + }; + + AuraScript* GetAuraScript() const { - AfterEffectApply += AuraEffectApplyFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + return new spell_pal_blessing_of_sanctuary_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_pal_blessing_of_sanctuary_AuraScript(); - } }; // 63521 Guarded by The Light class spell_pal_guarded_by_the_light : public SpellScriptLoader { -public: - spell_pal_guarded_by_the_light() : SpellScriptLoader("spell_pal_guarded_by_the_light") { } + public: + spell_pal_guarded_by_the_light() : SpellScriptLoader("spell_pal_guarded_by_the_light") { } - class spell_pal_guarded_by_the_light_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_guarded_by_the_light_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_pal_guarded_by_the_light_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_DIVINE_PLEA)) - return false; - return true; - } + PrepareSpellScript(spell_pal_guarded_by_the_light_SpellScript); - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - // Divine Plea - if (Aura* aura = GetCaster()->GetAura(PALADIN_SPELL_DIVINE_PLEA)) - aura->RefreshDuration(); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_DIVINE_PLEA)) + return false; + return true; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + // Divine Plea + if (Aura* aura = GetCaster()->GetAura(PALADIN_SPELL_DIVINE_PLEA)) + aura->RefreshDuration(); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_pal_guarded_by_the_light_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_pal_guarded_by_the_light_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + return new spell_pal_guarded_by_the_light_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_pal_guarded_by_the_light_SpellScript(); - } }; class spell_pal_holy_shock : public SpellScriptLoader { -public: - spell_pal_holy_shock() : SpellScriptLoader("spell_pal_holy_shock") { } + public: + spell_pal_holy_shock() : SpellScriptLoader("spell_pal_holy_shock") { } - class spell_pal_holy_shock_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_holy_shock_SpellScript) - bool Validate(SpellInfo const* spellEntry) + class spell_pal_holy_shock_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_HOLY_SHOCK_R1)) - return false; + PrepareSpellScript(spell_pal_holy_shock_SpellScript) + bool Validate(SpellInfo const* spellEntry) + { + if (!sSpellMgr->GetSpellInfo(PALADIN_SPELL_HOLY_SHOCK_R1)) + return false; - // can't use other spell than holy shock due to spell_ranks dependency - if (sSpellMgr->GetFirstSpellInChain(PALADIN_SPELL_HOLY_SHOCK_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id)) - return false; + // can't use other spell than holy shock due to spell_ranks dependency + if (sSpellMgr->GetFirstSpellInChain(PALADIN_SPELL_HOLY_SHOCK_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id)) + return false; - uint8 rank = sSpellMgr->GetSpellRank(spellEntry->Id); - if (!sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank, true)) - return false; - if (!sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank, true)) - return false; + uint8 rank = sSpellMgr->GetSpellRank(spellEntry->Id); + if (!sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank, true) || !sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank, true)) + return false; - return true; - } + return true; + } - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* unitTarget = GetHitUnit()) + void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); + if (Unit* unitTarget = GetHitUnit()) + { + uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + if (caster->IsFriendlyTo(unitTarget)) + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0); + else + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank), true, 0); + } + } - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); - - if (caster->IsFriendlyTo(unitTarget)) - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0); - else - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank), true, 0); + void Register() + { + // add dummy effect spell handler to Holy Shock + OnEffectHitTarget += SpellEffectFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - } + }; - void Register() + SpellScript* GetSpellScript() const { - // add dummy effect spell handler to Holy Shock - OnEffectHitTarget += SpellEffectFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_pal_holy_shock_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_pal_holy_shock_SpellScript(); - } }; class spell_pal_judgement_of_command : public SpellScriptLoader { -public: - spell_pal_judgement_of_command() : SpellScriptLoader("spell_pal_judgement_of_command") { } + public: + spell_pal_judgement_of_command() : SpellScriptLoader("spell_pal_judgement_of_command") { } - class spell_pal_judgement_of_command_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_judgement_of_command_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_pal_judgement_of_command_SpellScript : public SpellScript { - if (Unit* unitTarget = GetHitUnit()) - if (SpellInfo const* spell_proto = sSpellMgr->GetSpellInfo(GetEffectValue())) - GetCaster()->CastSpell(unitTarget, spell_proto, true, NULL); - } + PrepareSpellScript(spell_pal_judgement_of_command_SpellScript) + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* unitTarget = GetHitUnit()) + if (SpellInfo const* spell_proto = sSpellMgr->GetSpellInfo(GetEffectValue())) + GetCaster()->CastSpell(unitTarget, spell_proto, true, NULL); + } + + void Register() + { + // add dummy effect spell handler to Judgement of Command + OnEffectHitTarget += SpellEffectFn(spell_pal_judgement_of_command_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - void Register() + SpellScript* GetSpellScript() const { - // add dummy effect spell handler to Judgement of Command - OnEffectHitTarget += SpellEffectFn(spell_pal_judgement_of_command_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_pal_judgement_of_command_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_pal_judgement_of_command_SpellScript(); - } }; class spell_pal_divine_storm : public SpellScriptLoader { -public: - spell_pal_divine_storm() : SpellScriptLoader("spell_pal_divine_storm") { } + public: + spell_pal_divine_storm() : SpellScriptLoader("spell_pal_divine_storm") { } + + class spell_pal_divine_storm_SpellScript : public SpellScript + { + PrepareSpellScript(spell_pal_divine_storm_SpellScript); + + uint32 healPct; + + bool Validate(SpellInfo const* /* spell */) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DIVINE_STORM_DUMMY)) + return false; + return true; + } - class spell_pal_divine_storm_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_divine_storm_SpellScript); + bool Load() + { + healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(GetCaster()); + return true; + } - uint32 healPct; + void TriggerHeal() + { + Unit* caster = GetCaster(); + caster->CastCustomSpell(SPELL_DIVINE_STORM_DUMMY, SPELLVALUE_BASE_POINT0, (GetHitDamage() * healPct) / 100, caster, true); + } - bool Load() + void Register() + { + AfterHit += SpellHitFn(spell_pal_divine_storm_SpellScript::TriggerHeal); + } + }; + + SpellScript* GetSpellScript() const { - healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(GetCaster()); - return true; + return new spell_pal_divine_storm_SpellScript(); } +}; - void TriggerHeal() +class spell_pal_divine_storm_dummy : public SpellScriptLoader +{ + public: + spell_pal_divine_storm_dummy() : SpellScriptLoader("spell_pal_divine_storm_dummy") { } + + class spell_pal_divine_storm_dummy_SpellScript : public SpellScript { - GetCaster()->CastCustomSpell(SPELL_DIVINE_STORM_DUMMY, SPELLVALUE_BASE_POINT0, (GetHitDamage() * healPct) / 100, GetCaster(), true); - } + PrepareSpellScript(spell_pal_divine_storm_dummy_SpellScript); - void Register() + bool Validate(SpellInfo const* /* spell */) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DIVINE_STORM_HEAL)) + return false; + return true; + } + + void CountTargets(std::list<Unit*>& targetList) + { + _targetCount = targetList.size(); + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (!_targetCount || ! GetHitUnit()) + return; + + int32 heal = GetEffectValue() / _targetCount; + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_DIVINE_STORM_HEAL, &heal, NULL, NULL, true); + } + private: + uint32 _targetCount; + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_pal_divine_storm_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_pal_divine_storm_dummy_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_CASTER_AREA_RAID); + } + }; + + SpellScript* GetSpellScript() const { - AfterHit += SpellHitFn(spell_pal_divine_storm_SpellScript::TriggerHeal); + return new spell_pal_divine_storm_dummy_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_pal_divine_storm_SpellScript(); - } }; void AddSC_paladin_spell_scripts() @@ -374,4 +421,5 @@ void AddSC_paladin_spell_scripts() new spell_pal_holy_shock(); new spell_pal_judgement_of_command(); new spell_pal_divine_storm(); + new spell_pal_divine_storm_dummy(); } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index ee5f6a6d772..b7793c919b6 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_pri_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" #include "GridNotifiers.h" @@ -49,7 +48,9 @@ class spell_pri_guardian_spirit : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - return sSpellMgr->GetSpellInfo(PRIEST_SPELL_GUARDIAN_SPIRIT_HEAL) != NULL; + if (!sSpellMgr->GetSpellInfo(PRIEST_SPELL_GUARDIAN_SPIRIT_HEAL)) + return false; + return true; } bool Load() @@ -101,11 +102,8 @@ class spell_pri_mana_burn : public SpellScriptLoader void HandleAfterHit() { - Unit* unitTarget = GetHitUnit(); - if (!unitTarget) - return; - - unitTarget->RemoveAurasWithMechanic((1 << MECHANIC_FEAR) | (1 << MECHANIC_POLYMORPH)); + if (Unit* unitTarget = GetHitUnit()) + unitTarget->RemoveAurasWithMechanic((1 << MECHANIC_FEAR) | (1 << MECHANIC_POLYMORPH)); } void Register() @@ -204,18 +202,19 @@ class spell_pri_penance : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Unit* unitTarget = GetHitUnit(); - if (!unitTarget || !unitTarget->isAlive()) - return; - Unit* caster = GetCaster(); + if (Unit* unitTarget = GetHitUnit()) + { + if(!unitTarget->isAlive()) + return; - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); - if (caster->IsFriendlyTo(unitTarget)) - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_HEAL, rank), false, 0); - else - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_DAMAGE, rank), false, 0); + if (caster->IsFriendlyTo(unitTarget)) + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_HEAL, rank), false, 0); + else + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(PRIEST_SPELL_PENANCE_R1_DAMAGE, rank), false, 0); + } } void Register() @@ -243,7 +242,9 @@ class spell_pri_reflective_shield_trigger : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - return sSpellMgr->GetSpellInfo(PRIEST_SPELL_REFLECTIVE_SHIELD_TRIGGERED) && sSpellMgr->GetSpellInfo(PRIEST_SPELL_REFLECTIVE_SHIELD_R1); + if (!sSpellMgr->GetSpellInfo(PRIEST_SPELL_REFLECTIVE_SHIELD_TRIGGERED) || !sSpellMgr->GetSpellInfo(PRIEST_SPELL_REFLECTIVE_SHIELD_R1)) + return false; + return true; } void Trigger(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) @@ -251,14 +252,13 @@ class spell_pri_reflective_shield_trigger : public SpellScriptLoader Unit* target = GetTarget(); if (dmgInfo.GetAttacker() == target) return; - Unit* caster = GetCaster(); - if (!caster) - return; - if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(PRIEST_SPELL_REFLECTIVE_SHIELD_R1, EFFECT_0)) - { - int32 bp = CalculatePctN(absorbAmount, talentAurEff->GetAmount()); - target->CastCustomSpell(dmgInfo.GetAttacker(), PRIEST_SPELL_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); - } + + if (Unit* caster = GetCaster()) + if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(PRIEST_SPELL_REFLECTIVE_SHIELD_R1, EFFECT_0)) + { + int32 bp = CalculatePctN(absorbAmount, talentAurEff->GetAmount()); + target->CastCustomSpell(dmgInfo.GetAttacker(), PRIEST_SPELL_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + } } void Register() diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 940e494f18f..9b5e2b2ea09 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -21,48 +21,47 @@ * Scriptnames of files in this file should be prefixed with "spell_q#questID_". */ -#include "ScriptPCH.h" #include "Vehicle.h" class spell_generic_quest_update_entry_SpellScript : public SpellScript { - PrepareSpellScript(spell_generic_quest_update_entry_SpellScript) -private: - uint16 _spellEffect; - uint8 _effIndex; - uint32 _originalEntry; - uint32 _newEntry; - bool _shouldAttack; - uint32 _despawnTime; - -public: - spell_generic_quest_update_entry_SpellScript(uint16 spellEffect, uint8 effIndex, uint32 originalEntry, uint32 newEntry, bool shouldAttack, uint32 despawnTime = 0) : - SpellScript(), _spellEffect(spellEffect), _effIndex(effIndex), _originalEntry(originalEntry), - _newEntry(newEntry), _shouldAttack(shouldAttack), _despawnTime(despawnTime) { } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Creature* creatureTarget = GetHitCreature()) - if (!creatureTarget->isPet() && creatureTarget->GetEntry() == _originalEntry) - { - creatureTarget->UpdateEntry(_newEntry); - if (_shouldAttack && creatureTarget->IsAIEnabled) - creatureTarget->AI()->AttackStart(GetCaster()); + PrepareSpellScript(spell_generic_quest_update_entry_SpellScript); + private: + uint16 _spellEffect; + uint8 _effIndex; + uint32 _originalEntry; + uint32 _newEntry; + bool _shouldAttack; + uint32 _despawnTime; - if (_despawnTime) - creatureTarget->DespawnOrUnsummon(_despawnTime); - } - } + public: + spell_generic_quest_update_entry_SpellScript(uint16 spellEffect, uint8 effIndex, uint32 originalEntry, uint32 newEntry, bool shouldAttack, uint32 despawnTime = 0) : + SpellScript(), _spellEffect(spellEffect), _effIndex(effIndex), _originalEntry(originalEntry), + _newEntry(newEntry), _shouldAttack(shouldAttack), _despawnTime(despawnTime) { } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Creature* creatureTarget = GetHitCreature()) + if (!creatureTarget->isPet() && creatureTarget->GetEntry() == _originalEntry) + { + creatureTarget->UpdateEntry(_newEntry); + if (_shouldAttack && creatureTarget->IsAIEnabled) + creatureTarget->AI()->AttackStart(GetCaster()); + + if (_despawnTime) + creatureTarget->DespawnOrUnsummon(_despawnTime); + } + } - void Register() - { - OnEffectHitTarget += SpellEffectFn(spell_generic_quest_update_entry_SpellScript::HandleDummy, _effIndex, _spellEffect); - } + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_generic_quest_update_entry_SpellScript::HandleDummy, _effIndex, _spellEffect); + } }; // http://www.wowhead.com/quest=55 Morbent Fel // 8913 Sacred Cleansing -enum eQuest55Data +enum Quest55Data { NPC_MORBENT = 1200, NPC_WEAKENED_MORBENT = 24782, @@ -70,18 +69,18 @@ enum eQuest55Data class spell_q55_sacred_cleansing : public SpellScriptLoader { -public: - spell_q55_sacred_cleansing() : SpellScriptLoader("spell_q55_sacred_cleansing") { } + public: + spell_q55_sacred_cleansing() : SpellScriptLoader("spell_q55_sacred_cleansing") { } - SpellScript* GetSpellScript() const - { - return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_1, NPC_MORBENT, NPC_WEAKENED_MORBENT, true); - } + SpellScript* GetSpellScript() const + { + return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_1, NPC_MORBENT, NPC_WEAKENED_MORBENT, true); + } }; // http://www.wowhead.com/quest=5206 Marauders of Darrowshire // 17271 Test Fetid Skull -enum eQuest5206Data +enum Quest5206Data { SPELL_CREATE_RESONATING_SKULL = 17269, SPELL_CREATE_BONE_DUST = 17270 @@ -89,47 +88,48 @@ enum eQuest5206Data class spell_q5206_test_fetid_skull : public SpellScriptLoader { -public: - spell_q5206_test_fetid_skull() : SpellScriptLoader("spell_q5206_test_fetid_skull") { } + public: + spell_q5206_test_fetid_skull() : SpellScriptLoader("spell_q5206_test_fetid_skull") { } - class spell_q5206_test_fetid_skull_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q5206_test_fetid_skull_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_q5206_test_fetid_skull_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_CREATE_RESONATING_SKULL)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_CREATE_BONE_DUST)) - return false; - return true; - } + PrepareSpellScript(spell_q5206_test_fetid_skull_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() == TYPEID_PLAYER) + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CREATE_RESONATING_SKULL) || !sSpellMgr->GetSpellInfo(SPELL_CREATE_BONE_DUST)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) { + Unit* caster = GetCaster(); uint32 spellId = roll_chance_i(50) ? SPELL_CREATE_RESONATING_SKULL : SPELL_CREATE_BONE_DUST; - pCaster->CastSpell(pCaster, spellId, true, NULL); + caster->CastSpell(caster, spellId, true, NULL); } - } - void Register() + void Register() + { + OnEffectHit += SpellEffectFn(spell_q5206_test_fetid_skull_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_q5206_test_fetid_skull_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q5206_test_fetid_skull_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q5206_test_fetid_skull_SpellScript(); - } }; // http://www.wowhead.com/quest=6124 Curing the Sick (A) // http://www.wowhead.com/quest=6129 Curing the Sick (H) // 19512 Apply Salve -enum eQuests6124_6129Data +enum Quests6124_6129Data { NPC_SICKLY_GAZELLE = 12296, NPC_CURED_GAZELLE = 12297, @@ -140,20 +140,26 @@ enum eQuests6124_6129Data class spell_q6124_6129_apply_salve : public SpellScriptLoader { -public: - spell_q6124_6129_apply_salve() : SpellScriptLoader("spell_q6124_6129_apply_salve") { } + public: + spell_q6124_6129_apply_salve() : SpellScriptLoader("spell_q6124_6129_apply_salve") { } - class spell_q6124_6129_apply_salve_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q6124_6129_apply_salve_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_q6124_6129_apply_salve_SpellScript : public SpellScript { - if (GetCastItem()) - if (Player* pCaster = GetCaster()->ToPlayer()) + PrepareSpellScript(spell_q6124_6129_apply_salve_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + if (GetCastItem()) if (Creature* creatureTarget = GetHitCreature()) { uint32 uiNewEntry = 0; - switch (pCaster->GetTeam()) + switch (caster->GetTeam()) { case HORDE: if (creatureTarget->GetEntry() == NPC_SICKLY_GAZELLE) @@ -170,23 +176,23 @@ public: creatureTarget->DespawnOrUnsummon(DESPAWN_TIME); } } - } + } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q6124_6129_apply_salve_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q6124_6129_apply_salve_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q6124_6129_apply_salve_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q6124_6129_apply_salve_SpellScript(); - } }; // http://www.wowhead.com/quest=10255 Testing the Antidote // 34665 Administer Antidote -enum eQuest10255Data +enum Quest10255Data { NPC_HELBOAR = 16880, NPC_DREADTUSK = 16992, @@ -194,18 +200,18 @@ enum eQuest10255Data class spell_q10255_administer_antidote : public SpellScriptLoader { -public: - spell_q10255_administer_antidote() : SpellScriptLoader("spell_q10255_administer_antidote") { } + public: + spell_q10255_administer_antidote() : SpellScriptLoader("spell_q10255_administer_antidote") { } - SpellScript* GetSpellScript() const - { - return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_0, NPC_HELBOAR, NPC_DREADTUSK, true); - } + SpellScript* GetSpellScript() const + { + return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_0, NPC_HELBOAR, NPC_DREADTUSK, true); + } }; // http://www.wowhead.com/quest=11396 Bring Down Those Shields (A) // http://www.wowhead.com/quest=11399 Bring Down Those Shields (H) -enum eQuest11396_11399Data +enum Quest11396_11399Data { SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3 = 43874, SPELL_SCOURGING_CRYSTAL_CONTROLLER = 43878 @@ -214,115 +220,116 @@ enum eQuest11396_11399Data // 43874 Scourge Mur'gul Camp: Force Shield Arcane Purple x3 class spell_q11396_11399_force_shield_arcane_purple_x3 : public SpellScriptLoader { -public: - spell_q11396_11399_force_shield_arcane_purple_x3() : SpellScriptLoader("spell_q11396_11399_force_shield_arcane_purple_x3") { } + public: + spell_q11396_11399_force_shield_arcane_purple_x3() : SpellScriptLoader("spell_q11396_11399_force_shield_arcane_purple_x3") { } - class spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript : public AuraScript - { - PrepareAuraScript(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript) - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + class spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript : public AuraScript { - Unit* target = GetTarget(); + PrepareAuraScript(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript); + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); target->AddUnitState(UNIT_STATE_ROOT); - } + } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - } + } - void Register() - { - OnEffectApply += AuraEffectApplyFn(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } - }; + }; - AuraScript* GetAuraScript() const - { - return new spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript(); - } + AuraScript* GetAuraScript() const + { + return new spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript(); + } }; // 50133 Scourging Crystal Controller class spell_q11396_11399_scourging_crystal_controller : public SpellScriptLoader { -public: - spell_q11396_11399_scourging_crystal_controller() : SpellScriptLoader("spell_q11396_11399_scourging_crystal_controller") { } + public: + spell_q11396_11399_scourging_crystal_controller() : SpellScriptLoader("spell_q11396_11399_scourging_crystal_controller") { } - class spell_q11396_11399_scourging_crystal_controller_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q11396_11399_scourging_crystal_controller_SpellScript); - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_q11396_11399_scourging_crystal_controller_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SCOURGING_CRYSTAL_CONTROLLER)) - return false; - return true; - } + PrepareSpellScript(spell_q11396_11399_scourging_crystal_controller_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetTargetUnit()) - if (target->GetTypeId() == TYPEID_UNIT && target->HasAura(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3)) - // Make sure nobody else is channeling the same target - if (!target->HasAura(SPELL_SCOURGING_CRYSTAL_CONTROLLER)) - GetCaster()->CastSpell(target, SPELL_SCOURGING_CRYSTAL_CONTROLLER, true, GetCastItem()); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3) || !sSpellMgr->GetSpellInfo(SPELL_SCOURGING_CRYSTAL_CONTROLLER)) + return false; + return true; + } - void Register() - { - OnEffectHitTarget += SpellEffectFn(spell_q11396_11399_scourging_crystal_controller_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetTargetUnit()) + if (target->GetTypeId() == TYPEID_UNIT && target->HasAura(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3)) + // Make sure nobody else is channeling the same target + if (!target->HasAura(SPELL_SCOURGING_CRYSTAL_CONTROLLER)) + GetCaster()->CastSpell(target, SPELL_SCOURGING_CRYSTAL_CONTROLLER, true, GetCastItem()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q11396_11399_scourging_crystal_controller_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - SpellScript* GetSpellScript() const - { - return new spell_q11396_11399_scourging_crystal_controller_SpellScript(); - }; + SpellScript* GetSpellScript() const + { + return new spell_q11396_11399_scourging_crystal_controller_SpellScript(); + }; }; // 43882 Scourging Crystal Controller Dummy class spell_q11396_11399_scourging_crystal_controller_dummy : public SpellScriptLoader { -public: - spell_q11396_11399_scourging_crystal_controller_dummy() : SpellScriptLoader("spell_q11396_11399_scourging_crystal_controller_dummy") { } + public: + spell_q11396_11399_scourging_crystal_controller_dummy() : SpellScriptLoader("spell_q11396_11399_scourging_crystal_controller_dummy") { } - class spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript); - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3)) - return false; - return true; - } + PrepareSpellScript(spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetTargetUnit()) - if (target->GetTypeId() == TYPEID_UNIT) - target->RemoveAurasDueToSpell(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3); - } + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3)) + return false; + return true; + } - void Register() - { - OnEffectHitTarget += SpellEffectFn(spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + if (target->GetTypeId() == TYPEID_UNIT) + target->RemoveAurasDueToSpell(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - SpellScript* GetSpellScript() const - { - return new spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript(); - }; + SpellScript* GetSpellScript() const + { + return new spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript(); + }; }; // http://www.wowhead.com/quest=11515 Blood for Blood // 44936 Quest - Fel Siphon Dummy -enum eQuest11515Data +enum Quest11515Data { NPC_FELBLOOD_INITIATE = 24918, NPC_EMACIATED_FELBLOOD = 24955 @@ -330,18 +337,18 @@ enum eQuest11515Data class spell_q11515_fel_siphon_dummy : public SpellScriptLoader { -public: - spell_q11515_fel_siphon_dummy() : SpellScriptLoader("spell_q11515_fel_siphon_dummy") { } + public: + spell_q11515_fel_siphon_dummy() : SpellScriptLoader("spell_q11515_fel_siphon_dummy") { } - SpellScript* GetSpellScript() const - { - return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_0, NPC_FELBLOOD_INITIATE, NPC_EMACIATED_FELBLOOD, true); - } + SpellScript* GetSpellScript() const + { + return new spell_generic_quest_update_entry_SpellScript(SPELL_EFFECT_DUMMY, EFFECT_0, NPC_FELBLOOD_INITIATE, NPC_EMACIATED_FELBLOOD, true); + } }; // http://www.wowhead.com/quest=11587 Prison Break // 45449 Arcane Prisoner Rescue -enum eQuest11587Data +enum Quest11587Data { SPELL_SUMMON_ARCANE_PRISONER_MALE = 45446, // Summon Arcane Prisoner - Male SPELL_SUMMON_ARCANE_PRISONER_FEMALE = 45448, // Summon Arcane Prisoner - Female @@ -350,51 +357,48 @@ enum eQuest11587Data class spell_q11587_arcane_prisoner_rescue : public SpellScriptLoader { -public: - spell_q11587_arcane_prisoner_rescue() : SpellScriptLoader("spell_q11587_arcane_prisoner_rescue") { } + public: + spell_q11587_arcane_prisoner_rescue() : SpellScriptLoader("spell_q11587_arcane_prisoner_rescue") { } - class spell_q11587_arcane_prisoner_rescue_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q11587_arcane_prisoner_rescue_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_q11587_arcane_prisoner_rescue_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ARCANE_PRISONER_MALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ARCANE_PRISONER_FEMALE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_ARCANE_PRISONER_KILL_CREDIT)) - return false; - return true; - } + PrepareSpellScript(spell_q11587_arcane_prisoner_rescue_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (Unit* unitTarget = GetHitUnit()) + bool Validate(SpellInfo const* /*spellEntry*/) { - uint32 spellId = SPELL_SUMMON_ARCANE_PRISONER_MALE; - if (rand() % 2) - spellId = SPELL_SUMMON_ARCANE_PRISONER_FEMALE; - caster->CastSpell(caster, spellId, true); - unitTarget->CastSpell(caster, SPELL_ARCANE_PRISONER_KILL_CREDIT, true); + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ARCANE_PRISONER_MALE) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_ARCANE_PRISONER_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_ARCANE_PRISONER_KILL_CREDIT)) + return false; + return true; } - } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* unitTarget = GetHitUnit()) + { + uint32 spellId = SPELL_SUMMON_ARCANE_PRISONER_MALE; + if (rand() % 2) + spellId = SPELL_SUMMON_ARCANE_PRISONER_FEMALE; + caster->CastSpell(caster, spellId, true); + unitTarget->CastSpell(caster, SPELL_ARCANE_PRISONER_KILL_CREDIT, true); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q11587_arcane_prisoner_rescue_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q11587_arcane_prisoner_rescue_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q11587_arcane_prisoner_rescue_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q11587_arcane_prisoner_rescue_SpellScript(); - } }; // http://www.wowhead.com/quest=11730 Master and Servant // 46023 The Ultrasonic Screwdriver -enum eQuest11730Data +enum Quest11730Data { SPELL_SUMMON_SCAVENGEBOT_004A8 = 46063, SPELL_SUMMON_SENTRYBOT_57K = 46068, @@ -411,74 +415,63 @@ enum eQuest11730Data class spell_q11730_ultrasonic_screwdriver : public SpellScriptLoader { -public: - spell_q11730_ultrasonic_screwdriver() : SpellScriptLoader("spell_q11730_ultrasonic_screwdriver") { } + public: + spell_q11730_ultrasonic_screwdriver() : SpellScriptLoader("spell_q11730_ultrasonic_screwdriver") { } - class spell_q11730_ultrasonic_screwdriver_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q11730_ultrasonic_screwdriver_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) + class spell_q11730_ultrasonic_screwdriver_SpellScript : public SpellScript { - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_SCAVENGEBOT_004A8)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_SENTRYBOT_57K)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_DEFENDOTANK_66D)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_SCAVENGEBOT_005B6)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_55D_COLLECTATRON)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_ROBOT_KILL_CREDIT)) - return false; - return true; - } + PrepareSpellScript(spell_q11730_ultrasonic_screwdriver_SpellScript); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Item* castItem = GetCastItem(); - if (!castItem) - return; + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCastItem(); + } - Unit* pCaster = GetCaster(); - if (pCaster->GetTypeId() != TYPEID_PLAYER) - return; + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_SCAVENGEBOT_004A8) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_SENTRYBOT_57K) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_DEFENDOTANK_66D) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_SCAVENGEBOT_005B6) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_55D_COLLECTATRON) || !sSpellMgr->GetSpellInfo(SPELL_ROBOT_KILL_CREDIT)) + return false; + return true; + } - Creature* target = GetHitCreature(); - if (!target) - return; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Item* castItem = GetCastItem(); + Unit* caster = GetCaster(); + if (Creature* target = GetHitCreature()) + { + uint32 spellId = 0; + switch (target->GetEntry()) + { + case NPC_SCAVENGEBOT_004A8: spellId = SPELL_SUMMON_SCAVENGEBOT_004A8; break; + case NPC_SENTRYBOT_57K: spellId = SPELL_SUMMON_SENTRYBOT_57K; break; + case NPC_DEFENDOTANK_66D: spellId = SPELL_SUMMON_DEFENDOTANK_66D; break; + case NPC_SCAVENGEBOT_005B6: spellId = SPELL_SUMMON_SCAVENGEBOT_005B6; break; + case NPC_55D_COLLECTATRON: spellId = SPELL_SUMMON_55D_COLLECTATRON; break; + default: + return; + } + caster->CastSpell(caster, spellId, true, castItem); + caster->CastSpell(caster, SPELL_ROBOT_KILL_CREDIT, true); + target->DespawnOrUnsummon(); + } + } - uint32 spellId = 0; - switch (target->GetEntry()) + void Register() { - case NPC_SCAVENGEBOT_004A8: spellId = SPELL_SUMMON_SCAVENGEBOT_004A8; break; - case NPC_SENTRYBOT_57K: spellId = SPELL_SUMMON_SENTRYBOT_57K; break; - case NPC_DEFENDOTANK_66D: spellId = SPELL_SUMMON_DEFENDOTANK_66D; break; - case NPC_SCAVENGEBOT_005B6: spellId = SPELL_SUMMON_SCAVENGEBOT_005B6; break; - case NPC_55D_COLLECTATRON: spellId = SPELL_SUMMON_55D_COLLECTATRON; break; - default: - return; + OnEffectHitTarget += SpellEffectFn(spell_q11730_ultrasonic_screwdriver_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - pCaster->CastSpell(pCaster, spellId, true, castItem); - pCaster->CastSpell(pCaster, SPELL_ROBOT_KILL_CREDIT, true); - target->DespawnOrUnsummon(); - } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q11730_ultrasonic_screwdriver_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q11730_ultrasonic_screwdriver_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q11730_ultrasonic_screwdriver_SpellScript(); - } }; // http://www.wowhead.com/quest=12459 That Which Creates Can Also Destroy // 49587 Seeds of Nature's Wrath -enum eQuest12459Data +enum Quest12459Data { NPC_REANIMATED_FROSTWYRM = 26841, NPC_WEAK_REANIMATED_FROSTWYRM = 27821, @@ -492,44 +485,44 @@ enum eQuest12459Data class spell_q12459_seeds_of_natures_wrath : public SpellScriptLoader { -public: - spell_q12459_seeds_of_natures_wrath() : SpellScriptLoader("spell_q12459_seeds_of_natures_wrath") { } - - class spell_q12459_seeds_of_natures_wrath_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_q12459_seeds_of_natures_wrath_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + spell_q12459_seeds_of_natures_wrath() : SpellScriptLoader("spell_q12459_seeds_of_natures_wrath") { } + + class spell_q12459_seeds_of_natures_wrath_SpellScript : public SpellScript { - if (Creature* creatureTarget = GetHitCreature()) + PrepareSpellScript(spell_q12459_seeds_of_natures_wrath_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) { - uint32 uiNewEntry = 0; - switch (creatureTarget->GetEntry()) + if (Creature* creatureTarget = GetHitCreature()) { - case NPC_REANIMATED_FROSTWYRM: uiNewEntry = NPC_WEAK_REANIMATED_FROSTWYRM; break; - case NPC_TURGID: uiNewEntry = NPC_WEAK_TURGID; break; - case NPC_DEATHGAZE: uiNewEntry = NPC_WEAK_DEATHGAZE; break; + uint32 uiNewEntry = 0; + switch (creatureTarget->GetEntry()) + { + case NPC_REANIMATED_FROSTWYRM: uiNewEntry = NPC_WEAK_REANIMATED_FROSTWYRM; break; + case NPC_TURGID: uiNewEntry = NPC_WEAK_TURGID; break; + case NPC_DEATHGAZE: uiNewEntry = NPC_WEAK_DEATHGAZE; break; + } + if (uiNewEntry) + creatureTarget->UpdateEntry(uiNewEntry); } - if (uiNewEntry) - creatureTarget->UpdateEntry(uiNewEntry); } - } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q12459_seeds_of_natures_wrath_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q12459_seeds_of_natures_wrath_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q12459_seeds_of_natures_wrath_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q12459_seeds_of_natures_wrath_SpellScript(); - } }; // http://www.wowhead.com/quest=12634 Some Make Lemonade, Some Make Liquor // 51840 Despawn Fruit Tosser -enum eQuest12634Data +enum Quest12634Data { SPELL_BANANAS_FALL_TO_GROUND = 51836, SPELL_ORANGE_FALLS_TO_GROUND = 51837, @@ -539,90 +532,84 @@ enum eQuest12634Data class spell_q12634_despawn_fruit_tosser : public SpellScriptLoader { -public: - spell_q12634_despawn_fruit_tosser() : SpellScriptLoader("spell_q12634_despawn_fruit_tosser") { } - - class spell_q12634_despawn_fruit_tosser_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_q12634_despawn_fruit_tosser_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_BANANAS_FALL_TO_GROUND)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_ORANGE_FALLS_TO_GROUND)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_PAPAYA_FALLS_TO_GROUND)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ADVENTUROUS_DWARF)) - return false; - return true; - } + spell_q12634_despawn_fruit_tosser() : SpellScriptLoader("spell_q12634_despawn_fruit_tosser") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_q12634_despawn_fruit_tosser_SpellScript : public SpellScript { - uint32 spellId = SPELL_BANANAS_FALL_TO_GROUND; - switch (urand(0, 3)) + PrepareSpellScript(spell_q12634_despawn_fruit_tosser_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) { - case 1: spellId = SPELL_ORANGE_FALLS_TO_GROUND; break; - case 2: spellId = SPELL_PAPAYA_FALLS_TO_GROUND; break; + if (!sSpellMgr->GetSpellInfo(SPELL_BANANAS_FALL_TO_GROUND) || !sSpellMgr->GetSpellInfo(SPELL_ORANGE_FALLS_TO_GROUND) || !sSpellMgr->GetSpellInfo(SPELL_PAPAYA_FALLS_TO_GROUND) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_ADVENTUROUS_DWARF)) + return false; + return true; } - // sometimes, if you're lucky, you get a dwarf - if (roll_chance_i(5)) - spellId = SPELL_SUMMON_ADVENTUROUS_DWARF; - GetCaster()->CastSpell(GetCaster(), spellId, true, NULL); - } - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + uint32 spellId = SPELL_BANANAS_FALL_TO_GROUND; + switch (urand(0, 3)) + { + case 1: spellId = SPELL_ORANGE_FALLS_TO_GROUND; break; + case 2: spellId = SPELL_PAPAYA_FALLS_TO_GROUND; break; + } + // sometimes, if you're lucky, you get a dwarf + if (roll_chance_i(5)) + spellId = SPELL_SUMMON_ADVENTUROUS_DWARF; + GetCaster()->CastSpell(GetCaster(), spellId, true, NULL); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_q12634_despawn_fruit_tosser_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_q12634_despawn_fruit_tosser_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q12634_despawn_fruit_tosser_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q12634_despawn_fruit_tosser_SpellScript(); - } }; // http://www.wowhead.com/quest=12683 Burning to Help // 52308 Take Sputum Sample class spell_q12683_take_sputum_sample : public SpellScriptLoader { -public: - spell_q12683_take_sputum_sample() : SpellScriptLoader("spell_q12683_take_sputum_sample") { } - - class spell_q12683_take_sputum_sample_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_q12683_take_sputum_sample_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + spell_q12683_take_sputum_sample() : SpellScriptLoader("spell_q12683_take_sputum_sample") { } + + class spell_q12683_take_sputum_sample_SpellScript : public SpellScript { - uint32 reqAuraId = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + PrepareSpellScript(spell_q12683_take_sputum_sample_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + uint32 reqAuraId = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + + Unit* caster = GetCaster(); + if (caster->HasAuraEffect(reqAuraId, 0)) + { + uint32 spellId = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); + caster->CastSpell(caster, spellId, true, NULL); + } + } - Unit* pCaster = GetCaster(); - if (pCaster->HasAuraEffect(reqAuraId, 0)) + void Register() { - uint32 spellId = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - pCaster->CastSpell(pCaster, spellId, true, NULL); + OnEffectHit += SpellEffectFn(spell_q12683_take_sputum_sample_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - } + }; - void Register() + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_q12683_take_sputum_sample_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q12683_take_sputum_sample_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q12683_take_sputum_sample_SpellScript(); - } }; // http://www.wowhead.com/quest=12851 Going Bearback // 54798 FLAMING Arrow Triggered Effect -enum eQuest12851Data +enum Quest12851Data { NPC_FROSTGIANT = 29351, NPC_FROSTWORG = 29358, @@ -634,53 +621,53 @@ enum eQuest12851Data class spell_q12851_going_bearback : public SpellScriptLoader { -public: - spell_q12851_going_bearback() : SpellScriptLoader("spell_q12851_going_bearback") { } - - class spell_q12851_going_bearback_AuraScript : public AuraScript - { public: - PrepareAuraScript(spell_q12851_going_bearback_AuraScript) - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + spell_q12851_going_bearback() : SpellScriptLoader("spell_q12851_going_bearback") { } + + class spell_q12851_going_bearback_AuraScript : public AuraScript { - if (Unit* caster = GetCaster()) + PrepareAuraScript(spell_q12851_going_bearback_AuraScript); + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* target = GetTarget(); - if (Player* player = caster->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Unit* caster = GetCaster()) { - switch (target->GetEntry()) + Unit* target = GetTarget(); + if (Player* player = caster->GetCharmerOrOwnerPlayerOrPlayerItself()) { - case NPC_FROSTWORG: - target->CastSpell(player, SPELL_FROSTWORG_CREDIT, true); - target->CastSpell(target, SPELL_IMMOLATION, true); - target->CastSpell(target, SPELL_ABLAZE, true); - break; - case NPC_FROSTGIANT: - target->CastSpell(player, SPELL_FROSTGIANT_CREDIT, true); - target->CastSpell(target, SPELL_IMMOLATION, true); - target->CastSpell(target, SPELL_ABLAZE, true); - break; + switch (target->GetEntry()) + { + case NPC_FROSTWORG: + target->CastSpell(player, SPELL_FROSTWORG_CREDIT, true); + target->CastSpell(target, SPELL_IMMOLATION, true); + target->CastSpell(target, SPELL_ABLAZE, true); + break; + case NPC_FROSTGIANT: + target->CastSpell(player, SPELL_FROSTGIANT_CREDIT, true); + target->CastSpell(target, SPELL_IMMOLATION, true); + target->CastSpell(target, SPELL_ABLAZE, true); + break; + } } } } - } - void Register() - { - AfterEffectApply += AuraEffectApplyFn(spell_q12851_going_bearback_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - } + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_q12851_going_bearback_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } - }; + }; - AuraScript* GetAuraScript() const - { - return new spell_q12851_going_bearback_AuraScript(); - } + AuraScript* GetAuraScript() const + { + return new spell_q12851_going_bearback_AuraScript(); + } }; // http://www.wowhead.com/quest=12937 Relief for the Fallen // 55804 Healing Finished -enum eQuest12937Data +enum Quest12937Data { SPELL_TRIGGER_AID_OF_THE_EARTHEN = 55809, NPC_FALLEN_EARTHEN_DEFENDER = 30035, @@ -688,50 +675,50 @@ enum eQuest12937Data class spell_q12937_relief_for_the_fallen : public SpellScriptLoader { -public: - spell_q12937_relief_for_the_fallen() : SpellScriptLoader("spell_q12937_relief_for_the_fallen") { } - - class spell_q12937_relief_for_the_fallen_SpellScript : public SpellScript - { public: - PrepareSpellScript(spell_q12937_relief_for_the_fallen_SpellScript) - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGER_AID_OF_THE_EARTHEN)) - return false; - return true; - } + spell_q12937_relief_for_the_fallen() : SpellScriptLoader("spell_q12937_relief_for_the_fallen") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_q12937_relief_for_the_fallen_SpellScript : public SpellScript { - Unit* pCaster = GetCaster(); - if (Player* player = pCaster->ToPlayer()) + PrepareSpellScript(spell_q12937_relief_for_the_fallen_SpellScript); + + bool Load() { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_TRIGGER_AID_OF_THE_EARTHEN)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); if (Creature* target = GetHitCreature()) { - player->CastSpell(player, SPELL_TRIGGER_AID_OF_THE_EARTHEN, true, NULL); - player->KilledMonsterCredit(NPC_FALLEN_EARTHEN_DEFENDER, 0); + caster->CastSpell(caster, SPELL_TRIGGER_AID_OF_THE_EARTHEN, true, NULL); + caster->KilledMonsterCredit(NPC_FALLEN_EARTHEN_DEFENDER, 0); target->DespawnOrUnsummon(); } } - } - void Register() + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q12937_relief_for_the_fallen_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q12937_relief_for_the_fallen_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q12937_relief_for_the_fallen_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q12937_relief_for_the_fallen_SpellScript(); - } }; -enum eWhoarethey +enum Whoarethey { - SPELL_QUESTGIVER = 48917, - SPELL_MALE_DISGUISE = 38080, SPELL_FEMALE_DISGUISE = 38081, SPELL_GENERIC_DISGUISE = 32756 @@ -748,7 +735,7 @@ class spell_q10041_q10040_who_are_they : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_QUESTGIVER)) + if (!sSpellMgr->GetSpellInfo(SPELL_MALE_DISGUISE) || !sSpellMgr->GetSpellInfo(SPELL_FEMALE_DISGUISE) || !sSpellMgr->GetSpellInfo(SPELL_GENERIC_DISGUISE)) return false; return true; } @@ -756,11 +743,11 @@ class spell_q10041_q10040_who_are_they : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - if (!GetHitUnit() || !GetHitUnit()->ToPlayer()) - return; - - GetHitUnit()->CastSpell(GetHitUnit(), GetHitUnit()->getGender() == GENDER_MALE ? SPELL_MALE_DISGUISE : SPELL_FEMALE_DISGUISE, true); - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_GENERIC_DISGUISE, true); + if (Player* target = GetHitPlayer()) + { + target->CastSpell(target, target->getGender() == GENDER_MALE ? SPELL_MALE_DISGUISE : SPELL_FEMALE_DISGUISE, true); + target->CastSpell(target, SPELL_GENERIC_DISGUISE, true); + } } void Register() @@ -783,79 +770,81 @@ enum symboloflife // 8593 Symbol of life dummy class spell_symbol_of_life_dummy : public SpellScriptLoader { -public: - spell_symbol_of_life_dummy() : SpellScriptLoader("spell_symbol_of_life_dummy") { } - - class spell_symbol_of_life_dummy_SpellScript : public SpellScript - { - PrepareSpellScript(spell_symbol_of_life_dummy_SpellScript); + public: + spell_symbol_of_life_dummy() : SpellScriptLoader("spell_symbol_of_life_dummy") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_symbol_of_life_dummy_SpellScript : public SpellScript { - if (Creature* target = GetHitCreature()) + PrepareSpellScript(spell_symbol_of_life_dummy_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) { - if (target->HasAura(SPELL_PERMANENT_FEIGN_DEATH)) + if (Creature* target = GetHitCreature()) { - target->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH); - target->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - target->SetUInt32Value(UNIT_FIELD_FLAGS_2, 0); - target->SetHealth(target->GetMaxHealth() / 2); - target->SetPower(POWER_MANA, uint32(target->GetMaxPower(POWER_MANA) * 0.75f)); + if (target->HasAura(SPELL_PERMANENT_FEIGN_DEATH)) + { + target->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH); + target->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + target->SetUInt32Value(UNIT_FIELD_FLAGS_2, 0); + target->SetHealth(target->GetMaxHealth() / 2); + target->SetPower(POWER_MANA, uint32(target->GetMaxPower(POWER_MANA) * 0.75f)); + } } } - } - void Register() - { - OnEffectHitTarget += SpellEffectFn(spell_symbol_of_life_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_symbol_of_life_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - SpellScript* GetSpellScript() const - { - return new spell_symbol_of_life_dummy_SpellScript(); - }; + SpellScript* GetSpellScript() const + { + return new spell_symbol_of_life_dummy_SpellScript(); + }; }; // http://www.wowhead.com/quest=12659 Scalps! // 52090 Ahunae's Knife -enum eQuest12659Data +enum Quest12659Data { NPC_SCALPS_KC_BUNNY = 28622, }; class spell_q12659_ahunaes_knife : public SpellScriptLoader { -public: - spell_q12659_ahunaes_knife() : SpellScriptLoader("spell_q12659_ahunaes_knife") { } - - class spell_q12659_ahunaes_knife_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q12659_ahunaes_knife_SpellScript); + public: + spell_q12659_ahunaes_knife() : SpellScriptLoader("spell_q12659_ahunaes_knife") { } - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_q12659_ahunaes_knife_SpellScript : public SpellScript { - Player* caster = GetCaster()->ToPlayer(); - if (!caster) - return; + PrepareSpellScript(spell_q12659_ahunaes_knife_SpellScript); - if (Creature* target = GetTargetUnit()->ToCreature()) + bool Load() { - target->ForcedDespawn(); - caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0); + return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - } - void Register() - { - OnEffectHitTarget += SpellEffectFn(spell_q12659_ahunaes_knife_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + if (Creature* target = GetHitCreature()) + { + target->ForcedDespawn(); + caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q12659_ahunaes_knife_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; - SpellScript* GetSpellScript() const - { - return new spell_q12659_ahunaes_knife_SpellScript(); - }; + SpellScript* GetSpellScript() const + { + return new spell_q12659_ahunaes_knife_SpellScript(); + }; }; enum StoppingTheSpread @@ -875,16 +864,21 @@ class spell_q9874_liquid_fire : public SpellScriptLoader { PrepareSpellScript(spell_q9874_liquid_fire_SpellScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + void HandleDummy(SpellEffIndex /*effIndex*/) { Player* caster = GetCaster()->ToPlayer(); - Creature* target = GetHitUnit()->ToCreature(); - if (!caster || !target || (target && target->HasAura(SPELL_FLAMES))) - return; - - caster->KilledMonsterCredit(NPC_VILLAGER_KILL_CREDIT, 0); - target->CastSpell(target, SPELL_FLAMES, true); - target->DespawnOrUnsummon(60000); + if (Creature* target = GetHitCreature()) + if (target && target->HasAura(SPELL_FLAMES)) + { + caster->KilledMonsterCredit(NPC_VILLAGER_KILL_CREDIT, 0); + target->CastSpell(target, SPELL_FLAMES, true); + target->DespawnOrUnsummon(60000); + } } void Register() @@ -915,16 +909,20 @@ class spell_q12805_lifeblood_dummy : public SpellScriptLoader { PrepareSpellScript(spell_q12805_lifeblood_dummy_SpellScript); + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + void HandleScript(SpellEffIndex /*effIndex*/) { Player* caster = GetCaster()->ToPlayer(); - Creature* target = GetHitUnit()->ToCreature(); - if (!caster || !target) - return; - - caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT, 0); - target->CastSpell(target, uint32(GetEffectValue()), true); - target->DespawnOrUnsummon(2000); + if (Creature* target = GetHitCreature()) + { + caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT, 0); + target->CastSpell(target, uint32(GetEffectValue()), true); + target->DespawnOrUnsummon(2000); + } } void Register() @@ -945,37 +943,38 @@ class spell_q12805_lifeblood_dummy : public SpellScriptLoader 59643 Plant Horde Battle Standard 4338 Plant Alliance Battle Standard */ -enum eBattleStandard +enum BattleStandard { NPC_KING_OF_THE_MOUNTAINT_KC = 31766, }; class spell_q13280_13283_plant_battle_standard: public SpellScriptLoader { -public: - spell_q13280_13283_plant_battle_standard() : SpellScriptLoader("spell_q13280_13283_plant_battle_standard") { } + public: + spell_q13280_13283_plant_battle_standard() : SpellScriptLoader("spell_q13280_13283_plant_battle_standard") { } - class spell_q13280_13283_plant_battle_standard_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q13280_13283_plant_battle_standard_SpellScript) - void HandleDummy(SpellEffIndex /*effIndex*/) + class spell_q13280_13283_plant_battle_standard_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - if (caster->IsVehicle()) - if (Unit* player = caster->GetVehicleKit()->GetPassenger(0)) - player->ToPlayer()->KilledMonsterCredit(NPC_KING_OF_THE_MOUNTAINT_KC, 0); - } + PrepareSpellScript(spell_q13280_13283_plant_battle_standard_SpellScript); - void Register() + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (caster->IsVehicle()) + if (Unit* player = caster->GetVehicleKit()->GetPassenger(0)) + player->ToPlayer()->KilledMonsterCredit(NPC_KING_OF_THE_MOUNTAINT_KC, 0); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_q13280_13283_plant_battle_standard_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHit += SpellEffectFn(spell_q13280_13283_plant_battle_standard_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + return new spell_q13280_13283_plant_battle_standard_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q13280_13283_plant_battle_standard_SpellScript(); - } }; enum ChumTheWaterSummons @@ -988,42 +987,36 @@ enum ChumTheWaterSummons class spell_q14112_14145_chum_the_water: public SpellScriptLoader { -public: - spell_q14112_14145_chum_the_water() : SpellScriptLoader("spell_q14112_14145_chum_the_water") { } - - class spell_q14112_14145_chum_the_water_SpellScript : public SpellScript - { - PrepareSpellScript(spell_q14112_14145_chum_the_water_SpellScript); - - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SUMMON_ANGRY_KVALDIR)) - return false; - if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_MAKO)) - return false; - if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_THRESHER)) - return false; - if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_BLUE_SHARK)) - return false; - return true; - } + public: + spell_q14112_14145_chum_the_water() : SpellScriptLoader("spell_q14112_14145_chum_the_water") { } - void HandleScriptEffect(SpellEffIndex /*effIndex*/) + class spell_q14112_14145_chum_the_water_SpellScript : public SpellScript { - Unit* caster = GetCaster(); - caster->CastSpell(caster, RAND(SUMMON_ANGRY_KVALDIR, SUMMON_NORTH_SEA_MAKO, SUMMON_NORTH_SEA_THRESHER, SUMMON_NORTH_SEA_BLUE_SHARK)); - } + PrepareSpellScript(spell_q14112_14145_chum_the_water_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SUMMON_ANGRY_KVALDIR) || !sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_MAKO) || !sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_THRESHER) || !sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_BLUE_SHARK)) + return false; + return true; + } - void Register() + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, RAND(SUMMON_ANGRY_KVALDIR, SUMMON_NORTH_SEA_MAKO, SUMMON_NORTH_SEA_THRESHER, SUMMON_NORTH_SEA_BLUE_SHARK)); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q14112_14145_chum_the_water_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const { - OnEffectHitTarget += SpellEffectFn(spell_q14112_14145_chum_the_water_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + return new spell_q14112_14145_chum_the_water_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_q14112_14145_chum_the_water_SpellScript(); - } }; // http://old01.wowhead.com/quest=9452 - Red Snapper - Very Tasty! @@ -1041,15 +1034,16 @@ class spell_q9452_cast_net: public SpellScriptLoader class spell_q9452_cast_net_SpellScript : public SpellScript { - PrepareSpellScript(spell_q9452_cast_net_SpellScript) + PrepareSpellScript(spell_q9452_cast_net_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } void HandleDummy(SpellEffIndex /*effIndex*/) { Player* caster = GetCaster()->ToPlayer(); - - if (!caster) - return; - switch (urand(0, 2)) { case 0: case 1: diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index c88d7b891d6..0be2bf6b40c 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_rog_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" enum RogueSpells @@ -29,120 +28,114 @@ enum RogueSpells ROGUE_SPELL_SHIV_TRIGGERED = 5940, ROGUE_SPELL_GLYPH_OF_PREPARATION = 56819, ROGUE_SPELL_PREY_ON_THE_WEAK = 58670, + ROGUE_SPELL_CHEAT_DEATH_COOLDOWN = 31231, }; // Cheat Death class spell_rog_cheat_death : public SpellScriptLoader { -public: - spell_rog_cheat_death() : SpellScriptLoader("spell_rog_cheat_death") { } + public: + spell_rog_cheat_death() : SpellScriptLoader("spell_rog_cheat_death") { } - class spell_rog_cheat_death_AuraScript : public AuraScript - { - PrepareAuraScript(spell_rog_cheat_death_AuraScript); + class spell_rog_cheat_death_AuraScript : public AuraScript + { + PrepareAuraScript(spell_rog_cheat_death_AuraScript); - uint32 absorbChance; + uint32 absorbChance; - enum Spell - { - ROG_SPELL_CHEAT_DEATH_COOLDOWN = 31231, - }; + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(ROGUE_SPELL_CHEAT_DEATH_COOLDOWN)) + return false; + return true; + } - bool Validate(SpellInfo const* /*spellEntry*/) - { - return sSpellMgr->GetSpellInfo(ROG_SPELL_CHEAT_DEATH_COOLDOWN); - } + bool Load() + { + absorbChance = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); + return GetUnitOwner()->ToPlayer(); + } - bool Load() - { - absorbChance = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - return GetUnitOwner()->ToPlayer(); - } + void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + { + // Set absorbtion amount to unlimited + amount = -1; + } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) - { - // Set absorbtion amount to unlimited - amount = -1; - } + void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) + { + Player* target = GetTarget()->ToPlayer(); + if (dmgInfo.GetDamage() < target->GetHealth() || target->HasSpellCooldown(ROGUE_SPELL_CHEAT_DEATH_COOLDOWN) || !roll_chance_i(absorbChance)) + return; - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - Unit* target = GetTarget(); - if (dmgInfo.GetDamage() < target->GetHealth()) - return; - if (target->ToPlayer()->HasSpellCooldown(ROG_SPELL_CHEAT_DEATH_COOLDOWN)) - return; - if (!roll_chance_i(absorbChance)) - return; - - target->CastSpell(target, ROG_SPELL_CHEAT_DEATH_COOLDOWN, true); - target->ToPlayer()->AddSpellCooldown(ROG_SPELL_CHEAT_DEATH_COOLDOWN, 0, time(NULL) + 60); - - uint32 health10 = target->CountPctFromMaxHealth(10); - - // hp > 10% - absorb hp till 10% - if (target->GetHealth() > health10) - absorbAmount = dmgInfo.GetDamage() - target->GetHealth() + health10; - // hp lower than 10% - absorb everything - else - absorbAmount = dmgInfo.GetDamage(); - } + target->CastSpell(target, ROGUE_SPELL_CHEAT_DEATH_COOLDOWN, true); + target->AddSpellCooldown(ROGUE_SPELL_CHEAT_DEATH_COOLDOWN, 0, time(NULL) + 60); - void Register() + uint32 health10 = target->CountPctFromMaxHealth(10); + + // hp > 10% - absorb hp till 10% + if (target->GetHealth() > health10) + absorbAmount = dmgInfo.GetDamage() - target->GetHealth() + health10; + // hp lower than 10% - absorb everything + else + absorbAmount = dmgInfo.GetDamage(); + } + + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_rog_cheat_death_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); + OnEffectAbsorb += AuraEffectAbsorbFn(spell_rog_cheat_death_AuraScript::Absorb, EFFECT_0); + } + }; + + AuraScript* GetAuraScript() const { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_rog_cheat_death_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); - OnEffectAbsorb += AuraEffectAbsorbFn(spell_rog_cheat_death_AuraScript::Absorb, EFFECT_0); + return new spell_rog_cheat_death_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_rog_cheat_death_AuraScript(); - } }; // 31130 - Nerves of Steel class spell_rog_nerves_of_steel : public SpellScriptLoader { -public: - spell_rog_nerves_of_steel() : SpellScriptLoader("spell_rog_nerves_of_steel") { } + public: + spell_rog_nerves_of_steel() : SpellScriptLoader("spell_rog_nerves_of_steel") { } - class spell_rog_nerves_of_steel_AuraScript : public AuraScript - { - PrepareAuraScript(spell_rog_nerves_of_steel_AuraScript); + class spell_rog_nerves_of_steel_AuraScript : public AuraScript + { + PrepareAuraScript(spell_rog_nerves_of_steel_AuraScript); - uint32 absorbPct; + uint32 absorbPct; - bool Load() - { - absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster()); - return true; - } + bool Load() + { + absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster()); + return true; + } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) - { - // Set absorbtion amount to unlimited - amount = -1; - } + void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + { + // Set absorbtion amount to unlimited + amount = -1; + } - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) - { - // reduces all damage taken while stun or fear - if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_FLEEING) || (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1<<MECHANIC_STUN))) - absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct); - } + void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) + { + // reduces all damage taken while stun or fear + if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_FLEEING) || (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1<<MECHANIC_STUN))) + absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct); + } - void Register() + void Register() + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_rog_nerves_of_steel_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); + OnEffectAbsorb += AuraEffectAbsorbFn(spell_rog_nerves_of_steel_AuraScript::Absorb, EFFECT_0); + } + }; + + AuraScript* GetAuraScript() const { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_rog_nerves_of_steel_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); - OnEffectAbsorb += AuraEffectAbsorbFn(spell_rog_nerves_of_steel_AuraScript::Absorb, EFFECT_0); + return new spell_rog_nerves_of_steel_AuraScript(); } - }; - - AuraScript* GetAuraScript() const - { - return new spell_rog_nerves_of_steel_AuraScript(); - } }; class spell_rog_preparation : public SpellScriptLoader @@ -152,7 +145,13 @@ class spell_rog_preparation : public SpellScriptLoader class spell_rog_preparation_SpellScript : public SpellScript { - PrepareSpellScript(spell_rog_preparation_SpellScript) + PrepareSpellScript(spell_rog_preparation_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(ROGUE_SPELL_GLYPH_OF_PREPARATION)) @@ -162,12 +161,10 @@ class spell_rog_preparation : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; + Player* caster = GetCaster()->ToPlayer(); //immediately finishes the cooldown on certain Rogue abilities - const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap(); + const SpellCooldowns& cm = caster->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); @@ -176,14 +173,14 @@ class spell_rog_preparation : public SpellScriptLoader { if (spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_COLDB_SHADOWSTEP || // Cold Blood, Shadowstep spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_ROGUE_VAN_EVAS_SPRINT) // Vanish, Evasion, Sprint - caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true); + caster->RemoveSpellCooldown((itr++)->first, true); else if (caster->HasAura(ROGUE_SPELL_GLYPH_OF_PREPARATION)) { if (spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_DISMANTLE || // Dismantle spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_ROGUE_KICK || // Kick (spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_ROGUE_BLADE_FLURRY && // Blade Flurry spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_BLADE_FLURRY)) - caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true); + caster->RemoveSpellCooldown((itr++)->first, true); else ++itr; } @@ -216,7 +213,8 @@ public: class spell_rog_prey_on_the_weak_AuraScript : public AuraScript { - PrepareAuraScript(spell_rog_prey_on_the_weak_AuraScript) + PrepareAuraScript(spell_rog_prey_on_the_weak_AuraScript); + bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(ROGUE_SPELL_PREY_ON_THE_WEAK)) @@ -259,7 +257,13 @@ class spell_rog_shiv : public SpellScriptLoader class spell_rog_shiv_SpellScript : public SpellScript { - PrepareSpellScript(spell_rog_shiv_SpellScript) + PrepareSpellScript(spell_rog_shiv_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(ROGUE_SPELL_SHIV_TRIGGERED)) @@ -270,9 +274,6 @@ class spell_rog_shiv : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return; - if (Unit* unitTarget = GetHitUnit()) caster->CastSpell(unitTarget, ROGUE_SPELL_SHIV_TRIGGERED, true); } @@ -297,8 +298,7 @@ class spell_rog_deadly_poison : public SpellScriptLoader class spell_rog_deadly_poison_SpellScript : public SpellScript { - PrepareSpellScript(spell_rog_deadly_poison_SpellScript) - + PrepareSpellScript(spell_rog_deadly_poison_SpellScript); bool Load() { @@ -309,13 +309,10 @@ class spell_rog_deadly_poison : public SpellScriptLoader void HandleBeforeHit() { - Unit* target = GetHitUnit(); - if (!target) - return; - - // Deadly Poison - if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID())) - _stackAmount = aurEff->GetBase()->GetStackAmount(); + if (Unit* target = GetHitUnit()) + // Deadly Poison + if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID())) + _stackAmount = aurEff->GetBase()->GetStackAmount(); } void HandleAfterHit() @@ -324,49 +321,50 @@ class spell_rog_deadly_poison : public SpellScriptLoader return; Player* player = GetCaster()->ToPlayer(); - Unit* target = GetHitUnit(); - if (!target) - return; - - Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + + if (Unit* target = GetHitUnit()) + { - if (item == GetCastItem()) - item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - if (!item) - return; + if (item == GetCastItem()) + item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - // item combat enchantments - for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) - { - SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(EnchantmentSlot(slot))); - if (!enchant) - continue; + if (!item) + return; - for (uint8 s = 0; s < 3; ++s) + // item combat enchantments + for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) { - if (enchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(EnchantmentSlot(slot))); + if (!enchant) continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); - if (!spellInfo) + for (uint8 s = 0; s < 3; ++s) { - sLog->outError("Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName(), player->GetGUIDLow(), enchant->spellid[s]); - continue; + if (enchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + continue; + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); + if (!spellInfo) + { + sLog->outError("Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName(), player->GetGUIDLow(), enchant->spellid[s]); + continue; + } + + // Proc only rogue poisons + if (spellInfo->SpellFamilyName != SPELLFAMILY_ROGUE || spellInfo->Dispel != DISPEL_POISON) + continue; + + // Do not reproc deadly + if (spellInfo->SpellFamilyFlags.IsEqual(0x10000, 0x80000, 0)) + continue; + + if (spellInfo->IsPositive()) + player->CastSpell(player, enchant->spellid[s], true, item); + else + player->CastSpell(target, enchant->spellid[s], true, item); } - - // Proc only rogue poisons - if (spellInfo->SpellFamilyName != SPELLFAMILY_ROGUE || spellInfo->Dispel != DISPEL_POISON) - continue; - - // Do not reproc deadly - if (spellInfo->SpellFamilyFlags.IsEqual(0x10000, 0x80000, 0)) - continue; - - if (spellInfo->IsPositive()) - player->CastSpell(player, enchant->spellid[s], true, item); - else - player->CastSpell(target, enchant->spellid[s], true, item); } } } diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index b0116d6d33d..be5d04c1597 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_sha_". */ -#include "ScriptPCH.h" #include "SpellAuraEffects.h" enum ShamanSpells @@ -94,9 +93,7 @@ class spell_sha_fire_nova : public SpellScriptLoader bool Validate(SpellInfo const* spellEntry) { - if (!sSpellMgr->GetSpellInfo(SHAMAN_SPELL_FIRE_NOVA_R1)) - return false; - if (sSpellMgr->GetFirstSpellInChain(SHAMAN_SPELL_FIRE_NOVA_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id)) + if (!sSpellMgr->GetSpellInfo(SHAMAN_SPELL_FIRE_NOVA_R1) || sSpellMgr->GetFirstSpellInChain(SHAMAN_SPELL_FIRE_NOVA_R1) != sSpellMgr->GetFirstSpellInChain(spellEntry->Id)) return false; uint8 rank = sSpellMgr->GetSpellRank(spellEntry->Id); @@ -119,13 +116,15 @@ class spell_sha_fire_nova : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Unit* caster = GetCaster(); - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); - if (uint32 spellId = sSpellMgr->GetSpellWithRank(SHAMAN_SPELL_FIRE_NOVA_TRIGGERED_R1, rank)) + if (Unit* caster = GetCaster()) { - Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[1]); - if (totem && totem->isTotem()) - caster->CastSpell(totem, spellId, true); + uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + if (uint32 spellId = sSpellMgr->GetSpellWithRank(SHAMAN_SPELL_FIRE_NOVA_TRIGGERED_R1, rank)) + { + Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[1]); + if (totem && totem->isTotem()) + caster->CastSpell(totem, spellId, true); + } } } @@ -154,30 +153,28 @@ class spell_sha_mana_tide_totem : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SHAMAN_SPELL_GLYPH_OF_MANA_TIDE)) - return false; - if (!sSpellMgr->GetSpellInfo(SHAMAN_SPELL_MANA_TIDE_TOTEM)) + if (!sSpellMgr->GetSpellInfo(SHAMAN_SPELL_GLYPH_OF_MANA_TIDE) || !sSpellMgr->GetSpellInfo(SHAMAN_SPELL_MANA_TIDE_TOTEM)) return false; return true; } void HandleDummy(SpellEffIndex /*effIndex*/) { - Unit* caster = GetCaster(); - if (Unit* unitTarget = GetHitUnit()) - { - if (unitTarget->getPowerType() == POWER_MANA) + if (Unit* caster = GetCaster()) + if (Unit* unitTarget = GetHitUnit()) { - int32 effValue = GetEffectValue(); - // Glyph of Mana Tide - if (Unit* owner = caster->GetOwner()) - if (AuraEffect* dummy = owner->GetAuraEffect(SHAMAN_SPELL_GLYPH_OF_MANA_TIDE, 0)) - effValue += dummy->GetAmount(); - // Regenerate 6% of Total Mana Every 3 secs - int32 effBasePoints0 = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), effValue)); - caster->CastCustomSpell(unitTarget, SHAMAN_SPELL_MANA_TIDE_TOTEM, &effBasePoints0, NULL, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID()); + if (unitTarget->getPowerType() == POWER_MANA) + { + int32 effValue = GetEffectValue(); + // Glyph of Mana Tide + if (Unit* owner = caster->GetOwner()) + if (AuraEffect* dummy = owner->GetAuraEffect(SHAMAN_SPELL_GLYPH_OF_MANA_TIDE, 0)) + effValue += dummy->GetAmount(); + // Regenerate 6% of Total Mana Every 3 secs + int32 effBasePoints0 = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), effValue)); + caster->CastCustomSpell(unitTarget, SHAMAN_SPELL_MANA_TIDE_TOTEM, &effBasePoints0, NULL, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID()); + } } - } } void Register() @@ -204,22 +201,20 @@ class spell_sha_earthbind_totem : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SHAMAN_TOTEM_SPELL_EARTHBIND_TOTEM)) - return false; - if (!sSpellMgr->GetSpellInfo(SHAMAN_TOTEM_SPELL_EARTHEN_POWER)) + if (!sSpellMgr->GetSpellInfo(SHAMAN_TOTEM_SPELL_EARTHBIND_TOTEM) || !sSpellMgr->GetSpellInfo(SHAMAN_TOTEM_SPELL_EARTHEN_POWER)) return false; return true; } void HandleEffectPeriodic(AuraEffect const* aurEff) { - Unit* target = GetTarget(); - if (Unit* caster = aurEff->GetBase()->GetCaster()) - if (TempSummon* summon = caster->ToTempSummon()) - if (Unit* owner = summon->GetOwner()) - if (AuraEffect* aur = owner->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0)) - if (roll_chance_i(aur->GetBaseAmount()) && target->HasAuraWithMechanic(1 << MECHANIC_SNARE)) - caster->CastSpell(caster, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true, NULL, aurEff); + if (Unit* target = GetTarget()) + if (Unit* caster = aurEff->GetBase()->GetCaster()) + if (TempSummon* summon = caster->ToTempSummon()) + if (Unit* owner = summon->GetOwner()) + if (AuraEffect* aur = owner->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, 2289, 0)) + if (roll_chance_i(aur->GetBaseAmount()) && target->HasAuraWithMechanic(1 << MECHANIC_SNARE)) + caster->CastSpell(caster, SHAMAN_TOTEM_SPELL_EARTHEN_POWER, true, NULL, aurEff); } void Register() @@ -257,7 +252,8 @@ class spell_sha_bloodlust : public SpellScriptLoader void ApplyDebuff() { - GetHitUnit()->CastSpell(GetHitUnit(), SHAMAN_SPELL_SATED, true); + if (Unit* target = GetHitUnit()) + target->CastSpell(target, SHAMAN_SPELL_SATED, true); } void Register() @@ -298,7 +294,8 @@ class spell_sha_heroism : public SpellScriptLoader void ApplyDebuff() { - GetHitUnit()->CastSpell(GetHitUnit(), SHAMAN_SPELL_EXHAUSTION, true); + if (Unit* target = GetHitUnit()) + target->CastSpell(target, SHAMAN_SPELL_EXHAUSTION, true); } void Register() @@ -316,6 +313,232 @@ class spell_sha_heroism : public SpellScriptLoader } }; +enum AncestralAwakeningProc +{ + SPELL_ANCESTRAL_AWAKENING_PROC = 52752, +}; + +class spell_sha_ancestral_awakening_proc : public SpellScriptLoader +{ + public: + spell_sha_ancestral_awakening_proc() : SpellScriptLoader("spell_sha_ancestral_awakening_proc") { } + + class spell_sha_ancestral_awakening_proc_SpellScript : public SpellScript + { + PrepareSpellScript(spell_sha_ancestral_awakening_proc_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_ANCESTRAL_AWAKENING_PROC)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + if (GetCaster() && GetHitUnit()) + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_ANCESTRAL_AWAKENING_PROC, &damage, NULL, NULL, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_sha_ancestral_awakening_proc_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_sha_ancestral_awakening_proc_SpellScript(); + } +}; + +enum CleansingTotemPulse +{ + SPELL_CLEANSING_TOTEM_EFFECT = 52025, +}; + +class spell_sha_cleansing_totem_pulse : public SpellScriptLoader +{ + public: + spell_sha_cleansing_totem_pulse() : SpellScriptLoader("spell_sha_cleansing_totem_pulse") { } + + class spell_sha_cleansing_totem_pulse_SpellScript : public SpellScript + { + PrepareSpellScript(spell_sha_cleansing_totem_pulse_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CLEANSING_TOTEM_EFFECT)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 bp = 1; + if (GetCaster() && GetHitUnit() && GetOriginalCaster()) + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_CLEANSING_TOTEM_EFFECT, NULL, &bp, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_sha_cleansing_totem_pulse_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_sha_cleansing_totem_pulse_SpellScript(); + } +}; + +enum HealingStreamTotem +{ + SPELL_GLYPH_OF_HEALING_STREAM_TOTEM = 55456, + ICON_ID_RESTORATIVE_TOTEMS = 338, + SPELL_HEALING_STREAM_TOTEM_HEAL = 52042, +}; + +class spell_sha_healing_stream_totem : public SpellScriptLoader +{ + public: + spell_sha_healing_stream_totem() : SpellScriptLoader("spell_sha_healing_stream_totem") { } + + class spell_sha_healing_stream_totem_SpellScript : public SpellScript + { + PrepareSpellScript(spell_sha_healing_stream_totem_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_GLYPH_OF_HEALING_STREAM_TOTEM) || !sSpellMgr->GetSpellInfo(SPELL_HEALING_STREAM_TOTEM_HEAL)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + SpellInfo const* triggeringSpell = GetTriggeringSpell(); + if (Unit* target = GetHitUnit()) + if (Unit* caster = GetCaster()) + { + if (Unit* owner = caster->GetOwner()) + { + if (triggeringSpell) + damage = int32(owner->SpellHealingBonus(target, triggeringSpell, damage, HEAL)); + + // Restorative Totems + if (AuraEffect* dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, ICON_ID_RESTORATIVE_TOTEMS, 1)) + AddPctN(damage, dummy->GetAmount()); + + // Glyph of Healing Stream Totem + if (AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_GLYPH_OF_HEALING_STREAM_TOTEM, EFFECT_0)) + AddPctN(damage, aurEff->GetAmount()); + } + caster->CastCustomSpell(target, SPELL_HEALING_STREAM_TOTEM_HEAL, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID()); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_sha_healing_stream_totem_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_sha_healing_stream_totem_SpellScript(); + } +}; + +enum ManaSpringTotem +{ + SPELL_MANA_SPRING_TOTEM_ENERGIZE = 52032, +}; + +class spell_sha_mana_spring_totem : public SpellScriptLoader +{ + public: + spell_sha_mana_spring_totem() : SpellScriptLoader("spell_sha_mana_spring_totem") { } + + class spell_sha_mana_spring_totem_SpellScript : public SpellScript + { + PrepareSpellScript(spell_sha_mana_spring_totem_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_MANA_SPRING_TOTEM_ENERGIZE)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + if (Unit* target = GetHitUnit()) + if (Unit* caster = GetCaster()) + if (target->getPowerType() == POWER_MANA) + caster->CastCustomSpell(target, SPELL_MANA_SPRING_TOTEM_ENERGIZE, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID()); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_sha_mana_spring_totem_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + + }; + + SpellScript* GetSpellScript() const + { + return new spell_sha_mana_spring_totem_SpellScript(); + } +}; + +class spell_sha_lava_lash : public SpellScriptLoader +{ + public: + spell_sha_lava_lash() : SpellScriptLoader("spell_sha_lava_lash") { } + + class spell_sha_lava_lash_SpellScript : public SpellScript + { + PrepareSpellScript(spell_sha_lava_lash_SpellScript) + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + if (Player* caster = GetCaster()->ToPlayer()) + { + int32 damage = GetEffectValue(); + int32 hitDamage = GetHitDamage(); + if (caster->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + { + // Damage is increased by 25% if your off-hand weapon is enchanted with Flametongue. + if (caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0x200000, 0, 0)) + AddPctN(hitDamage, damage); + SetHitDamage(hitDamage); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_sha_lava_lash_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); + } + + }; + + SpellScript* GetSpellScript() const + { + return new spell_sha_lava_lash_SpellScript(); + } +}; + + void AddSC_shaman_spell_scripts() { new spell_sha_astral_shift(); @@ -324,4 +547,9 @@ void AddSC_shaman_spell_scripts() new spell_sha_earthbind_totem(); new spell_sha_bloodlust(); new spell_sha_heroism(); + new spell_sha_ancestral_awakening_proc(); + new spell_sha_cleansing_totem_pulse(); + new spell_sha_healing_stream_totem(); + new spell_sha_mana_spring_totem(); + new spell_sha_lava_lash(); } diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 51b2de5d0f3..bf1c205f1af 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_warl_". */ -#include "ScriptPCH.h" #include "Spell.h" #include "SpellAuraEffects.h" @@ -99,15 +98,7 @@ class spell_warl_demonic_empowerment : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_SUCCUBUS)) - return false; - if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER)) - return false; - if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_FELGUARD)) - return false; - if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_FELHUNTER)) - return false; - if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_IMP)) + if (!sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_SUCCUBUS) || !sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER) || !sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_FELGUARD) || !sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_FELHUNTER) || !sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_EMPOWERMENT_IMP)) return false; return true; } @@ -172,9 +163,7 @@ class spell_warl_create_healthstone : public SpellScriptLoader bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(WARLOCK_IMPROVED_HEALTHSTONE_R1)) - return false; - if (!sSpellMgr->GetSpellInfo(WARLOCK_IMPROVED_HEALTHSTONE_R2)) + if (!sSpellMgr->GetSpellInfo(WARLOCK_IMPROVED_HEALTHSTONE_R1) || !sSpellMgr->GetSpellInfo(WARLOCK_IMPROVED_HEALTHSTONE_R2)) return false; return true; } @@ -267,7 +256,8 @@ public: void HandleDummy(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetCaster(), GetEffectValue(), true); + Unit* caster = GetCaster(); + caster->CastSpell(caster, GetEffectValue(), true); } void Register() @@ -293,7 +283,8 @@ class spell_warl_seed_of_corruption : public SpellScriptLoader void FilterTargets(std::list<Unit*>& unitList) { - unitList.remove(GetTargetUnit()); + if (GetTargetUnit()) + unitList.remove(GetTargetUnit()); } void Register() @@ -308,6 +299,147 @@ class spell_warl_seed_of_corruption : public SpellScriptLoader } }; +enum Soulshatter +{ + SPELL_SOULSHATTER = 32835, +}; + +class spell_warl_soulshatter : public SpellScriptLoader +{ + public: + spell_warl_soulshatter() : SpellScriptLoader("spell_warl_soulshatter") { } + + class spell_warl_soulshatter_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warl_soulshatter_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SOULSHATTER)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + if (target->CanHaveThreatList() && target->getThreatManager().getThreat(caster) > 0.0f) + { + sLog->outString("THREATREDUCTION"); + caster->CastSpell(target, SPELL_SOULSHATTER, true); + } else + sLog->outString("can have threat? %b . threat number? %f ",target->CanHaveThreatList(),target->getThreatManager().getThreat(caster)); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warl_soulshatter_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warl_soulshatter_SpellScript(); + } +}; + +enum LifeTap +{ + SPELL_LIFE_TAP_RANK_6 = 11689, + SPELL_LIFE_TAP_RANK_7 = 27222, + SPELL_LIFE_TAP_RANK_8 = 57946, + SPELL_LIFE_TAP_ENERGIZE = 31818, + SPELL_LIFE_TAP_ENERGIZE_2 = 32553, + ICON_ID_IMPROVED_LIFE_TAP = 208, + ICON_ID_MANA_FEED = 1982, +}; + +class spell_warl_life_tap : public SpellScriptLoader +{ + public: + spell_warl_life_tap() : SpellScriptLoader("spell_warl_life_tap") { } + + class spell_warl_life_tap_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warl_life_tap_SpellScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + bool Validate(SpellInfo const* /*spell*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_LIFE_TAP_RANK_6) || !sSpellMgr->GetSpellInfo(SPELL_LIFE_TAP_RANK_7) + || !sSpellMgr->GetSpellInfo(SPELL_LIFE_TAP_RANK_8) || !sSpellMgr->GetSpellInfo(SPELL_LIFE_TAP_ENERGIZE) + || !sSpellMgr->GetSpellInfo(SPELL_LIFE_TAP_ENERGIZE_2)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Player* caster = GetCaster()->ToPlayer(); + if (Unit* target = GetHitUnit()) + { + SpellInfo const* spellInfo = GetSpellInfo(); + float spFactor = 0.0f; + int32 damage = int32(GetEffectValue() + (6.3875 * spellInfo->BaseLevel)); + switch (spellInfo->Id) + { + case SPELL_LIFE_TAP_RANK_6: spFactor = 0.2f; break; + case SPELL_LIFE_TAP_RANK_7: + case SPELL_LIFE_TAP_RANK_8: spFactor = 0.5f; break; + default: break; + } + + int32 mana = int32(damage + (caster->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+SPELL_SCHOOL_SHADOW) * spFactor)); + + // Shouldn't Appear in Combat Log + target->ModifyHealth(-damage); + + // Improved Life Tap mod + if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, ICON_ID_IMPROVED_LIFE_TAP, 0)) + AddPctN(mana, aurEff->GetAmount()); + + caster->CastCustomSpell(target, SPELL_LIFE_TAP_ENERGIZE, &mana, NULL, NULL, false); + + // Mana Feed + int32 manaFeedVal = 0; + if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_WARLOCK, ICON_ID_MANA_FEED, 0)) + manaFeedVal = aurEff->GetAmount(); + + if (manaFeedVal > 0) + { + ApplyPctN(manaFeedVal, mana); + caster->CastCustomSpell(caster, SPELL_LIFE_TAP_ENERGIZE_2, &manaFeedVal, NULL, NULL, true, NULL); + } + } + } + + SpellCastResult CheckCast() + { + if ((int32(GetCaster()->GetHealth()) > int32(GetSpellInfo()->Effects[EFFECT_0].CalcValue() + (6.3875 * GetSpellInfo()->BaseLevel)))) + { + return SPELL_CAST_OK; + } + return SPELL_FAILED_FIZZLE; + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warl_life_tap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnCheckCast += SpellCheckCastFn(spell_warl_life_tap_SpellScript::CheckCast); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warl_life_tap_SpellScript(); + } +}; + void AddSC_warlock_spell_scripts() { new spell_warl_banish(); @@ -316,4 +448,6 @@ void AddSC_warlock_spell_scripts() new spell_warl_everlasting_affliction(); new spell_warl_ritual_of_doom_effect(); new spell_warl_seed_of_corruption(); + new spell_warl_soulshatter(); + new spell_warl_life_tap(); } diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index f39ad3d1426..cf4c7bfdec8 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -21,7 +21,6 @@ * Scriptnames of files in this file should be prefixed with "spell_warr_". */ -#include "ScriptPCH.h" enum WarriorSpells { @@ -46,8 +45,11 @@ class spell_warr_last_stand : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - int32 healthModSpellBasePoints0 = int32(GetCaster()->CountPctFromMaxHealth(30)); - GetCaster()->CastCustomSpell(GetCaster(), WARRIOR_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); + if (Unit* caster = GetCaster()) + { + int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); + caster->CastCustomSpell(caster, WARRIOR_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); + } } void Register() @@ -74,7 +76,8 @@ class spell_warr_improved_spell_reflection : public SpellScriptLoader void FilterTargets(std::list<Unit*>& unitList) { - unitList.remove(GetCaster()); + if (GetCaster()) + unitList.remove(GetCaster()); } void Register() @@ -115,23 +118,19 @@ public: void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* target = GetTarget(); - target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); + if (Unit* target = GetTarget()) + target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* target = GetTarget(); - - if (!target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) - return; - - if (target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || - target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || - target->HasAura(SPELL_RENEWED_HOPE)) - return; - - target->RemoveAurasDueToSpell(SPELL_DAMAGE_REDUCTION_AURA); + if (Unit* target = GetTarget()) + { + if (target->HasAura(SPELL_DAMAGE_REDUCTION_AURA) && !(target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_RENEWED_HOPE))) + target->RemoveAurasDueToSpell(SPELL_DAMAGE_REDUCTION_AURA); + } } void Register() @@ -148,9 +147,278 @@ public: } }; +enum DeepWounds +{ + SPELL_DEEP_WOUNDS_RANK_1 = 12162, + SPELL_DEEP_WOUNDS_RANK_2 = 12850, + SPELL_DEEP_WOUNDS_RANK_3 = 12868, + SPELL_DEEP_WOUNDS_RANK_PERIODIC = 12721, +}; + +class spell_warr_deep_wounds : public SpellScriptLoader +{ + public: + spell_warr_deep_wounds() : SpellScriptLoader("spell_warr_deep_wounds") { } + + class spell_warr_deep_wounds_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_deep_wounds_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DEEP_WOUNDS_RANK_1) || !sSpellMgr->GetSpellInfo(SPELL_DEEP_WOUNDS_RANK_2) || !sSpellMgr->GetSpellInfo(SPELL_DEEP_WOUNDS_RANK_3)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + if (Unit* target = GetHitUnit()) + if (Unit* caster = GetCaster()) + { + // apply percent damage mods + damage = caster->SpellDamageBonus(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); + + ApplyPctN(damage, 16 * sSpellMgr->GetSpellRank(GetSpellInfo()->Id)); + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_DEEP_WOUNDS_RANK_PERIODIC); + uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude; + + // Add remaining ticks to damage done + if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_DEEP_WOUNDS_RANK_PERIODIC, EFFECT_0, caster->GetGUID())) + damage += aurEff->GetAmount() * (ticks - aurEff->GetTickNumber()); + + damage = damage / ticks; + caster->CastCustomSpell(target, SPELL_DEEP_WOUNDS_RANK_PERIODIC, &damage, NULL, NULL, true); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_deep_wounds_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_deep_wounds_SpellScript(); + } +}; + +enum Charge +{ + SPELL_JUGGERNAUT_CRIT_BONUS_TALENT = 64976, + SPELL_JUGGERNAUT_CRIT_BONUS_BUFF = 65156, + SPELL_CHARGE = 34846, +}; + +class spell_warr_charge : public SpellScriptLoader +{ + public: + spell_warr_charge() : SpellScriptLoader("spell_warr_charge") { } + + class spell_warr_charge_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_charge_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_JUGGERNAUT_CRIT_BONUS_TALENT) || !sSpellMgr->GetSpellInfo(SPELL_JUGGERNAUT_CRIT_BONUS_BUFF) || !sSpellMgr->GetSpellInfo(SPELL_CHARGE)) + return false; + return true; + } + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 chargeBasePoints0 = GetEffectValue(); + Unit* caster = GetCaster(); + caster->CastCustomSpell(caster, SPELL_CHARGE, &chargeBasePoints0, NULL, NULL, true); + + //Juggernaut crit bonus + if (caster->HasAura(SPELL_JUGGERNAUT_CRIT_BONUS_TALENT)) + caster->CastSpell(caster, SPELL_JUGGERNAUT_CRIT_BONUS_BUFF, true); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_charge_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_charge_SpellScript(); + } +}; + +enum Slam +{ + SPELL_SLAM = 50783, +}; + +class spell_warr_slam : public SpellScriptLoader +{ + public: + spell_warr_slam() : SpellScriptLoader("spell_warr_slam") { } + + class spell_warr_slam_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_slam_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_SLAM)) + return false; + return true; + } + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 bp0 = GetEffectValue(); + if (GetHitUnit()) + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_SLAM, &bp0, NULL, NULL, true, 0); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_slam_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_slam_SpellScript(); + } +}; + +enum Execute +{ + SPELL_EXECUTE = 20647, + SPELL_GLYPH_OF_EXECUTION = 58367, + ICON_ID_SUDDEN_DEATH = 1989, +}; + +class spell_warr_execute : public SpellScriptLoader +{ + public: + spell_warr_execute() : SpellScriptLoader("spell_warr_execute") { } + + class spell_warr_execute_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_execute_SpellScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_EXECUTE) || !sSpellMgr->GetSpellInfo(SPELL_GLYPH_OF_EXECUTION)) + return false; + return true; + } + void HandleDummy(SpellEffIndex effIndex) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + SpellInfo const* spellInfo = GetSpellInfo(); + int32 rageUsed = std::min<int32>(300 - spellInfo->CalcPowerCost(caster, SpellSchoolMask(spellInfo->SchoolMask)), caster->GetPower(POWER_RAGE)); + int32 newRage = std::max<int32>(0, caster->GetPower(POWER_RAGE) - rageUsed); + + // Sudden Death rage save + if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_GENERIC, ICON_ID_SUDDEN_DEATH, EFFECT_0)) + { + int32 ragesave = aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue() * 10; + newRage = std::max(newRage, ragesave); + } + + caster->SetPower(POWER_RAGE, uint32(newRage)); + // Glyph of Execution bonus + if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_GLYPH_OF_EXECUTION, EFFECT_0)) + rageUsed += aurEff->GetAmount() * 10; + + + int32 bp = GetEffectValue() + int32(rageUsed * spellInfo->Effects[effIndex].DamageMultiplier + caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.2f); + caster->CastCustomSpell(target,SPELL_EXECUTE,&bp,0,0,true,0,0,GetOriginalCaster()->GetGUID()); + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_execute_SpellScript(); + } +}; + +class spell_warr_concussion_blow : public SpellScriptLoader +{ + public: + spell_warr_concussion_blow() : SpellScriptLoader("spell_warr_concussion_blow") { } + + class spell_warr_concussion_blow_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_concussion_blow_SpellScript); + + void HandleDummy(SpellEffIndex /* effIndex */) + { + SetHitDamage(GetHitDamage() + CalculatePctF(GetHitDamage(),GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK))); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_concussion_blow_SpellScript::HandleDummy, EFFECT_2, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_concussion_blow_SpellScript(); + } +}; + +enum Bloodthirst +{ + SPELL_BLOODTHIRST = 23885, +}; + +class spell_warr_bloodthirst : public SpellScriptLoader +{ + public: + spell_warr_bloodthirst() : SpellScriptLoader("spell_warr_bloodthirst") { } + + class spell_warr_bloodthirst_SpellScript : public SpellScript + { + PrepareSpellScript(spell_warr_bloodthirst_SpellScript); + + void HandleDummy(SpellEffIndex /* effIndex */) + { + int32 damage = GetEffectValue(); + if (GetHitUnit()) + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_BLOODTHIRST, &damage, NULL, NULL, true, NULL); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_warr_bloodthirst_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_warr_bloodthirst_SpellScript(); + } +}; + void AddSC_warrior_spell_scripts() { new spell_warr_last_stand(); new spell_warr_improved_spell_reflection(); new spell_warr_vigilance(); + new spell_warr_deep_wounds(); + new spell_warr_charge(); + new spell_warr_slam(); + new spell_warr_execute(); + new spell_warr_concussion_blow(); + new spell_warr_bloodthirst(); } |