mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Scripts/Karazhan): Fix Enfeeble hitting more than 5 targets (#17290)
* fix(Scripts/Karazhan): Fix Enfeeble hitting more than 5 targets * reorder so there are no cases where only 4 players are hit * missing override
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_malchezaar_enfeeble' AND `spell_id` = 30843;
|
||||||
|
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
|
||||||
|
(30843, 'spell_malchezaar_enfeeble');
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "ScriptedCreature.h"
|
#include "ScriptedCreature.h"
|
||||||
#include "SpellInfo.h"
|
#include "SpellInfo.h"
|
||||||
|
#include "SpellScript.h"
|
||||||
#include "karazhan.h"
|
#include "karazhan.h"
|
||||||
|
|
||||||
enum PrinceSay
|
enum PrinceSay
|
||||||
@@ -197,7 +198,7 @@ struct boss_malchezaar : public BossAI
|
|||||||
|
|
||||||
scheduler.Schedule(30s, [this](TaskContext context)
|
scheduler.Schedule(30s, [this](TaskContext context)
|
||||||
{
|
{
|
||||||
EnfeebleHealthEffect();
|
DoCastAOE(SPELL_ENFEEBLE);
|
||||||
|
|
||||||
scheduler.Schedule(9s, [this](TaskContext)
|
scheduler.Schedule(9s, [this](TaskContext)
|
||||||
{
|
{
|
||||||
@@ -246,23 +247,12 @@ struct boss_malchezaar : public BossAI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnfeebleHealthEffect()
|
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
|
||||||
{
|
{
|
||||||
std::list<Unit*> targetList;
|
if (spell->Id == SPELL_ENFEEBLE)
|
||||||
SelectTargetList(targetList, 5, SelectTargetMethod::Random, 1, [&](Unit* u) { return u->IsAlive() && u->IsPlayer(); });
|
|
||||||
|
|
||||||
if (targetList.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto const& target : targetList)
|
|
||||||
{
|
{
|
||||||
if (target)
|
_enfeebleTargets[target->GetGUID()] = target->GetHealth();
|
||||||
{
|
target->SetHealth(1);
|
||||||
_enfeebleTargets[target->GetGUID()] = target->GetHealth();
|
|
||||||
|
|
||||||
me->CastSpell(target, SPELL_ENFEEBLE, true);
|
|
||||||
target->SetHealth(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,9 +368,43 @@ struct npc_malchezaar_axe : public ScriptedAI
|
|||||||
TaskScheduler _scheduler;
|
TaskScheduler _scheduler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 30843 - Enfeeble
|
||||||
|
class spell_malchezaar_enfeeble : public SpellScript
|
||||||
|
{
|
||||||
|
PrepareSpellScript(spell_malchezaar_enfeeble);
|
||||||
|
|
||||||
|
bool Load() override
|
||||||
|
{
|
||||||
|
return GetCaster()->ToCreature();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilterTargets(std::list<WorldObject*>& targets)
|
||||||
|
{
|
||||||
|
uint8 maxSize = 5;
|
||||||
|
Unit* caster = GetCaster();
|
||||||
|
|
||||||
|
targets.remove_if([caster](WorldObject const* target) -> bool
|
||||||
|
{
|
||||||
|
// Should not target current victim.
|
||||||
|
return caster->GetVictim() == target;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (targets.size() > maxSize)
|
||||||
|
{
|
||||||
|
Acore::Containers::RandomResize(targets, maxSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Register() override
|
||||||
|
{
|
||||||
|
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_malchezaar_enfeeble::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ENEMY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void AddSC_boss_malchezaar()
|
void AddSC_boss_malchezaar()
|
||||||
{
|
{
|
||||||
RegisterKarazhanCreatureAI(boss_malchezaar);
|
RegisterKarazhanCreatureAI(boss_malchezaar);
|
||||||
RegisterKarazhanCreatureAI(npc_malchezaar_axe);
|
RegisterKarazhanCreatureAI(npc_malchezaar_axe);
|
||||||
RegisterKarazhanCreatureAI(npc_netherspite_infernal);
|
RegisterKarazhanCreatureAI(npc_netherspite_infernal);
|
||||||
|
RegisterSpellScript(spell_malchezaar_enfeeble);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user