fix(Core/Scripts): Fix GetVictim() returning null during JustEngagedWith (#25131)

Co-authored-by: blinkysc <blinkysc@users.noreply.github.com>
Co-authored-by: Treeston <treeston.mmoc@gmail.com>
This commit is contained in:
blinkysc
2026-03-19 18:37:03 -05:00
committed by GitHub
parent 8f5900b36b
commit e5746fbc89
3 changed files with 19 additions and 16 deletions

View File

@@ -225,7 +225,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
// When nearby mobs aggro from another mob's initial call for assistance // When nearby mobs aggro from another mob's initial call for assistance
// their leash timers become linked and attacking one will keep the rest from evading. // their leash timers become linked and attacking one will keep the rest from evading.
if (assistant->GetVictim()) if (assistant->IsEngaged())
assistant->SetLastLeashExtensionTimePtr(m_owner->GetLastLeashExtensionTimePtr()); assistant->SetLastLeashExtensionTimePtr(m_owner->GetLastLeashExtensionTimePtr());
} }
} }
@@ -2394,20 +2394,18 @@ void Creature::CallAssistance(Unit* target /*= nullptr*/)
void Creature::CallForHelp(float radius, Unit* target /*= nullptr*/) void Creature::CallForHelp(float radius, Unit* target /*= nullptr*/)
{ {
if (radius <= 0.0f || IsPet() || IsCharmed()) if (radius <= 0.0f || !IsEngaged() || !IsAlive() || IsPet() || IsCharmed())
{
return; return;
}
if (!target) if (!target)
{ target = GetThreatMgr().GetCurrentVictim();
target = GetVictim(); if (!target)
} target = GetThreatMgr().GetAnyTarget();
if (!target)
target = GetCombatManager().GetAnyTarget();
if (!target) if (!target)
{
return; return;
}
if (m_alreadyCallForHelp) // avoid recursive call for help for any reason if (m_alreadyCallForHelp) // avoid recursive call for help for any reason
return; return;

View File

@@ -82,20 +82,22 @@ public:
dropSludgeTimer = 0; dropSludgeTimer = 0;
} }
void PullChamberAdds() void PullChamberAdds(Unit* target)
{ {
if (!target)
return;
std::list<Creature*> StichedGiants; std::list<Creature*> StichedGiants;
me->GetCreaturesWithEntryInRange(StichedGiants, 300.0f, NPC_STICHED_GIANT); me->GetCreaturesWithEntryInRange(StichedGiants, 300.0f, NPC_STICHED_GIANT);
for (std::list<Creature*>::const_iterator itr = StichedGiants.begin(); itr != StichedGiants.end(); ++itr) for (std::list<Creature*>::const_iterator itr = StichedGiants.begin(); itr != StichedGiants.end(); ++itr)
{ {
(*itr)->ToCreature()->AI()->AttackStart(me->GetVictim()); (*itr)->ToCreature()->AI()->AttackStart(target);
} }
} }
void JustEngagedWith(Unit* who) override void JustEngagedWith(Unit* who) override
{ {
BossAI::JustEngagedWith(who); BossAI::JustEngagedWith(who);
PullChamberAdds(); PullChamberAdds(who);
me->SetInCombatWithZone(); me->SetInCombatWithZone();
events.ScheduleEvent(EVENT_POISON_CLOUD, 15s); events.ScheduleEvent(EVENT_POISON_CLOUD, 15s);
events.ScheduleEvent(EVENT_MUTATING_INJECTION, 20s); events.ScheduleEvent(EVENT_MUTATING_INJECTION, 20s);

View File

@@ -516,11 +516,14 @@ public:
// pull all the trash if not killed // pull all the trash if not killed
if (Creature* patchwerk = GetCreature(DATA_PATCHWERK_BOSS)) if (Creature* patchwerk = GetCreature(DATA_PATCHWERK_BOSS))
{ {
for (auto& itr : _patchwerkRoomTrash) if (Unit* target = patchwerk->GetThreatMgr().GetCurrentVictim())
{ {
Creature* trash = ObjectAccessor::GetCreature(*patchwerk, itr); for (auto& itr : _patchwerkRoomTrash)
if (trash && trash->IsAlive() && !trash->IsInCombat()) {
trash->AI()->AttackStart(patchwerk->GetVictim()); Creature* trash = ObjectAccessor::GetCreature(*patchwerk, itr);
if (trash && trash->IsAlive() && !trash->IsInCombat())
trash->AI()->AttackStart(target);
}
} }
} }