From ef6c97e96eea94d510567368d855150ff550bc8e Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sun, 24 Apr 2022 19:58:39 +0200 Subject: [PATCH] fix(Scripts/BlackiwingLair): Rogues should be teleported in front of Nefarian during Class Call event. (#11513) --- .../BlackwingLair/boss_nefarian.cpp | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index 2aadc1458..2b1164d0d 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -1015,49 +1015,42 @@ class spell_class_call_handler : public SpellScript if (SpellInfo const* spellInfo = GetSpellInfo()) { targets.remove_if([spellInfo](WorldObject const* target) -> bool + { + Player const* player = target->ToPlayer(); + if (!player || player->getClass() == CLASS_DEATH_KNIGHT) // ignore all death knights from whatever spell, for some reason the condition below is not working x.x { - Player const* player = target->ToPlayer(); - if (!player || player->getClass() == CLASS_DEATH_KNIGHT) // ignore all death knights from whatever spell, for some reason the condition below is not working x.x - { - return true; - } + return true; + } - auto it = classCallSpells.find(spellInfo->Id); - if (it != classCallSpells.end()) // should never happen but only to be sure. - { - return target->ToPlayer()->getClass() != it->second; - } + auto it = classCallSpells.find(spellInfo->Id); + if (it != classCallSpells.end()) // should never happen but only to be sure. + { + return target->ToPlayer()->getClass() != it->second; + } - return false; - }); + return false; + }); } } - void HandleOnHitRogue() + void HandleOnHitRogue(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); Unit* target = GetHitUnit(); - if (!caster || !target) { return; } - float angle = rand_norm() * 2 * M_PI; - Position tp = caster->GetPosition(); - tp.m_positionX += std::cos(angle) * 5.f; - tp.m_positionY += std::sin(angle) * 5.f; - float z = tp.m_positionZ + 0.5f; - caster->UpdateAllowedPositionZ(tp.GetPositionX(), tp.GetPositionY(), z); - target->NearTeleportTo(tp.GetPositionX(), tp.GetPositionY(), z, angle - M_PI); - target->UpdatePositionData(); + Position tp = caster->GetFirstCollisionPosition(5.f, 0.f); + target->NearTeleportTo(tp.GetPositionX(), tp.GetPositionY(), tp.GetPositionZ(), tp.GetOrientation()); } void HandleOnHitWarlock() { - if (GetHitUnit()) + if (Unit* target = GetHitUnit()) { - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_INFERNALS, true); + target->CastSpell(target, SPELL_SUMMON_INFERNALS, true); } } @@ -1067,7 +1060,7 @@ class spell_class_call_handler : public SpellScript if (m_scriptSpellId == SPELL_ROGUE) { - OnHit += SpellHitFn(spell_class_call_handler::HandleOnHitRogue); + OnEffectLaunchTarget += SpellEffectFn(spell_class_call_handler::HandleOnHitRogue, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } else if (m_scriptSpellId == SPELL_WARLOCK) {