Core/Entities: killed Creature::SetInCombatWithZone and replaced with AI version

Closes #12108 (again)

(cherry picked from commit 7c9722a4ae08b5f283f6a085a411e37604a7da9f)

# Conflicts:
#	src/server/game/AI/SmartScripts/SmartScript.cpp
#	src/server/game/Entities/Creature/Creature.cpp
#	src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp
#	src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
#	src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp
#	src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
#	src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
#	src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
#	src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
#	src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp
#	src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
This commit is contained in:
ariel- authored and Ovahlord committed 2022-09-12 09:15:09 +02:00
1 parent 4e3c6bcf6a
commit 276d6e49f1
21 files changed
+34 -68

No files matched your search

@@ -2650,38 +2650,6 @@ void Creature::SendZoneUnderAttackMessage(Player* attacker)
sWorld->SendGlobalMessage(packet.Write(), nullptr, (enemy_team == ALLIANCE ? HORDE : ALLIANCE));
}
void Creature::SetInCombatWithZone()
{
if (!CanHaveThreatList())
{
TC_LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
return;
}
Map* map = GetMap();
if (!map->IsDungeon())
{
TC_LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), map->GetId());
return;
}
Map::PlayerList const& PlList = map->GetPlayers();
if (PlList.isEmpty())
return;
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if (Player* player = i->GetSource())
{
if (player->IsGameMaster())
continue;
if (player->IsAlive())
EngageWithTarget(player);
}
}
}
bool Creature::HasSpell(uint32 spellID) const
{
@@ -274,8 +274,6 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
void SendZoneUnderAttackMessage(Player* attacker);
void SetInCombatWithZone();
bool hasQuest(uint32 quest_id) const override;
bool hasInvolvedQuest(uint32 quest_id) const override;
@@ -382,7 +382,7 @@ public:
for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
{
if (Creature* creature = *itr)
creature->SetInCombatWithZone(); // AI()->AttackStart(me->GetVictim());
DoZoneInCombat(creature); // AI()->AttackStart(me->GetVictim());
}
_events.ScheduleEvent(EVENT_STRIKE, urand(8000, 16000));
@@ -300,7 +300,7 @@ public:
break;
case EVENT_INTRO_LANDING:
me->SetImmuneToPC(false);
me->SetInCombatWithZone();
DoZoneInCombat();
break;
case EVENT_LAND:
Talk(YELL_LAND_PHASE);
@@ -216,7 +216,7 @@ class boss_apothecary_hummel : public CreatureScript
case EVENT_START_FIGHT:
{
me->SetImmuneToAll(false);
me->SetInCombatWithZone();
DoZoneInCombat();
events.ScheduleEvent(EVENT_CALL_BAXTER, Seconds(6));
events.ScheduleEvent(EVENT_CALL_FRYE, Seconds(14));
events.ScheduleEvent(EVENT_PERFUME_SPRAY, Milliseconds(3640));
@@ -296,7 +296,7 @@ struct npc_apothecary_genericAI : public ScriptedAI
else if (action == ACTION_START_FIGHT)
{
me->SetImmuneToAll(false);
me->SetInCombatWithZone();
DoZoneInCombat();
}
}
@@ -173,7 +173,7 @@ public:
void JustSummoned(Creature* summoned) override
{
summoned->SetInCombatWithZone();
DoZoneInCombat(summoned);
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
summoned->AI()->AttackStart(target);
@@ -88,7 +88,7 @@ public:
Position goPos = go->GetPosition();
if (Creature* temp = go->SummonCreature(NPC_WHELP, goPos, TEMPSUMMON_CORPSE_DESPAWN))
{
temp->SetInCombatWithZone();
temp->AI()->DoZoneInCombat();
++manyWhelpsCounter;
}
break;
@@ -218,7 +218,7 @@ struct dummy_dragonAI : public ScriptedAI
if (pointId == POINT_ID_LAND)
{
me->GetMotionMaster()->Clear();
me->SetInCombatWithZone();
DoZoneInCombat();
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true))
{
AddThreat(target, 1.0f);
@@ -820,7 +820,7 @@ public:
void JustSummoned(Creature* who) override
{
who->SetInCombatWithZone();
DoZoneInCombat(who);
}
void UpdateAI(uint32 diff) override
@@ -986,7 +986,7 @@ public:
void Reset() override
{
me->RemoveAllAuras();
me->SetInCombatWithZone();
DoZoneInCombat();
events.ScheduleEvent(EVENT_FADE_ARMOR, 1000);
}
@@ -214,7 +214,7 @@ class npc_onyx_flamecaller : public CreatureScript
if (type != SPLINE_CHAIN_MOTION_TYPE && pointId != POINT_GENERAL_ROOM)
return;
me->SetInCombatWithZone();
DoZoneInCombat();
}
void MoveToGeneral()
@@ -1273,7 +1273,7 @@ class npc_living_inferno : public CreatureScript
void IsSummonedBy(Unit* /*summoner*/) override
{
me->SetInCombatWithZone();
DoZoneInCombat();
me->CastSpell(me, SPELL_BLAZING_AURA, true);
// SMSG_SPELL_GO for the living ember stuff isn't even sent to the client - Blizzard on drugs.
@@ -458,7 +458,7 @@ class npc_swarm_scarab : public CreatureScript
me->SetCorpseDelay(0);
Initialize();
DoCast(me, SPELL_ACID_MANDIBLE);
me->SetInCombatWithZone();
DoZoneInCombat();
if (me->IsInCombat())
if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_ANUBARAK)))
Anubarak->AI()->JustSummoned(me);
@@ -539,7 +539,7 @@ class npc_nerubian_burrower : public CreatureScript
DoCast(me, SPELL_EXPOSE_WEAKNESS);
DoCast(me, SPELL_SPIDER_FRENZY);
DoCast(me, SPELL_AWAKENED);
me->SetInCombatWithZone();
DoZoneInCombat();
if (me->IsInCombat())
if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_ANUBARAK)))
Anubarak->AI()->JustSummoned(me);
@@ -702,7 +702,7 @@ class npc_anubarak_spike : public CreatureScript
{
Initialize();
// make sure the spike has everyone on threat list
me->SetInCombatWithZone();
DoZoneInCombat();
}
bool CanAIAttack(Unit const* victim) const override
@@ -815,7 +815,7 @@ class npc_anubarak_spike : public CreatureScript
me->SetSpeedRate(MOVE_RUN, 0.5f);
// make sure the Spine will really follow the one he should
me->GetThreatManager().ResetAllThreat();
me->SetInCombatWithZone();
DoZoneInCombat();
AddThreat(who, 1000000.0f);
me->GetMotionMaster()->Clear(true);
me->GetMotionMaster()->MoveChase(who);
@@ -264,11 +264,11 @@ struct boss_twin_baseAI : public BossAI
void JustEngagedWith(Unit* /*who*/) override
{
me->SetInCombatWithZone();
DoZoneInCombat();
if (Creature* pSister = GetSister())
{
me->AddAura(MyEmphatySpellId, pSister);
pSister->SetInCombatWithZone();
DoZoneInCombat(pSister);
}
instance->SetBossState(BOSS_VALKIRIES, IN_PROGRESS);
@@ -152,7 +152,7 @@ class boss_drakkari_colossus : public CreatureScript
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveAura(SPELL_FREEZE_ANIM);
me->SetInCombatWithZone();
DoZoneInCombat();
break;
}
@@ -222,10 +222,10 @@ class boss_drakkari_colossus : public CreatureScript
void JustSummoned(Creature* summon) override
{
summon->SetInCombatWithZone();
DoZoneInCombat(summon);
if (phase == COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON)
summon->SetHealth(summon->GetMaxHealth() / 2);
if (phase == COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON)
summon->SetHealth(summon->GetMaxHealth() / 2);
}
private:
@@ -419,7 +419,7 @@ public:
colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS);
if (!colossus->AI()->GetData(DATA_INTRO_DONE))
colossus->AI()->SetData(DATA_INTRO_DONE, true);
colossus->SetInCombatWithZone();
DoZoneInCombat(colossus);
me->DespawnOrUnsummon();
}
}
@@ -743,7 +743,7 @@ class npc_putricide_oozeAI : public ScriptedAI
if (_instance->GetBossState(DATA_PROFESSOR_PUTRICIDE) != IN_PROGRESS)
me->DespawnOrUnsummon();
me->SetInCombatWithZone();
DoZoneInCombat();
DoCastAOE(_auraSpellId, true);
}
@@ -132,7 +132,7 @@ class boss_kologarn : public CreatureScript
if (Vehicle* vehicle = me->GetVehicleKit())
for (uint8 i = 0; i < 2; ++i)
if (Unit* arm = vehicle->GetPassenger(i))
arm->ToCreature()->SetInCombatWithZone();
DoZoneInCombat(arm->ToCreature());
BossAI::JustEngagedWith(who);
}
@@ -205,7 +205,7 @@ class boss_kologarn : public CreatureScript
else
{
events.CancelEvent(EVENT_STONE_SHOUT);
who->ToCreature()->SetInCombatWithZone();
DoZoneInCombat(who->ToCreature());
}
}
@@ -117,7 +117,7 @@ public:
{
_owner->SetReactState(REACT_AGGRESSIVE);
_owner->SetTempSummonType(TEMPSUMMON_CORPSE_DESPAWN);
_owner->SetInCombatWithZone();
_owner->AI()->DoZoneInCombat();
return true;
}
@@ -389,7 +389,7 @@ public:
if (summon->GetEntry() == NPC_AHUNE)
return;
summon->SetInCombatWithZone();
DoZoneInCombat(summon);
_summons.Summon(summon);
}
@@ -468,7 +468,7 @@ public:
if (TempSummon* ahune = me->SummonCreature(NPC_AHUNE, SummonPositions[0], TEMPSUMMON_DEAD_DESPAWN))
{
ahune->SummonCreature(NPC_FROZEN_CORE, SummonPositions[1], TEMPSUMMON_CORPSE_DESPAWN);
ahune->SetInCombatWithZone();
DoZoneInCombat(ahune);
DoCast(ahune, SPELL_RESURFACE);
}
break;
@@ -669,7 +669,7 @@ public:
if (Creature* ahuneBunny = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AHUNE_BUNNY)))
{
ahuneBunny->AI()->DoAction(ACTION_START_EVENT);
ahuneBunny->SetInCombatWithZone();
ahuneBunny->AI()->DoZoneInCombat();
}
if (Creature* luma = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LUMA_SKYMOTHER)))
luma->CastSpell(player, SPELL_SUMMONING_RHYME_AURA, true);
@@ -103,7 +103,7 @@ class boss_broggok : public CreatureScript
switch (action)
{
case ACTION_PREPARE_BROGGOK:
me->SetInCombatWithZone();
DoZoneInCombat();
break;
case ACTION_ACTIVATE_BROGGOK:
me->SetReactState(REACT_AGGRESSIVE);
@@ -287,7 +287,7 @@ class instance_blood_furnace : public InstanceMapScript
{
prisoner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
prisoner->SetImmuneToAll(false);
prisoner->SetInCombatWithZone();
prisoner->AI()->DoZoneInCombat();
}
}
@@ -252,7 +252,7 @@ class boss_magtheridon : public CreatureScript
case EVENT_RELEASED:
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(false);
me->SetInCombatWithZone();
DoZoneInCombat();
instance->SetData(DATA_MANTICRON_CUBE, ACTION_ENABLE);
events.ScheduleEvent(EVENT_CLEAVE, Seconds(10));
events.ScheduleEvent(EVENT_BLAST_NOVA, Seconds(60));
@@ -357,7 +357,7 @@ class npc_hellfire_channeler : public CreatureScript
if (Creature* magtheridon = _instance->GetCreature(DATA_MAGTHERIDON))
magtheridon->AI()->JustSummoned(summon);
summon->SetInCombatWithZone();
DoZoneInCombat(summon);
}
void EnterEvadeMode(EvadeReason /*why*/) override
@@ -123,7 +123,7 @@ class instance_magtheridons_lair : public InstanceMapScript
for (ObjectGuid warderGuid : warderGUIDS)
if (Creature* warder = instance->GetCreature(warderGuid))
if (warder->IsAlive())
warder->SetInCombatWithZone();
warder->AI()->DoZoneInCombat();
break;
default:
break;