refactor(Core/Unit): PC&NPC Immunity (#11986)

* initial

* refactor(Core/Unit): PC & NPC Immunities

Cherry-pick TC: 74af880217

Co-authored-by: Treeston <treeston.nmoc@gmail.com>

* fix builds error

Cherry-pick TC: 74af880217

Co-authored-by: Treeston <treeston.nmoc@gmail.com>

* Fix nef combat, and replace SetFlag by SetUnitFlag

* fix combat with jedoga

Co-authored-by: Treeston <treeston.nmoc@gmail.com>
This commit is contained in:
Maelthyr
2022-06-18 14:16:45 +02:00
committed by GitHub
parent 4bc99f8070
commit d928d8d96a
88 changed files with 450 additions and 328 deletions

View File

@@ -228,7 +228,7 @@ public:
me->SetDisableGravity(false);
me->CastSpell(me, SPELL_DUAL_WIELD, true);
me->LoadEquipment(0, true);
me->ReplaceAllUnitFlags(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(true);
beamPosId = urand(0, 3);
}
@@ -957,7 +957,7 @@ public:
case EVENT_AKAMA_SCENE_29:
if (Creature* illidan = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ILLIDAN_STORMRAGE)))
{
illidan->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
illidan->SetImmuneToAll(false);
illidan->SetInCombatWithZone();
AttackStart(illidan);
}

View File

@@ -131,7 +131,8 @@ public:
{
BossAI::Reset();
me->SetReactState(REACT_PASSIVE);
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NOT_SELECTABLE);
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToAll(true);
me->SetWalk(true);
}
@@ -249,7 +250,8 @@ public:
DoResetThreat();
me->GetVictim()->InterruptNonMeleeSpells(false);
me->AddThreat(me->GetVictim(), 1000000.0f);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NOT_SELECTABLE);
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToAll(false);
summonsGenerator.DoAction(ACTION_STOP_SPAWNING);
break;
}

View File

@@ -58,7 +58,8 @@ public:
events.Reset();
me->SetReactState(REACT_PASSIVE);
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetImmuneToAll(true);
canAttack = false;
if (instance)
@@ -130,7 +131,8 @@ public:
events.ScheduleEvent(EVENT_SPELL_BOLT, 7000);
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetImmuneToAll(false);
canAttack = true;
break;
}

View File

@@ -93,7 +93,8 @@ public:
ApplyImmunities(true);
SummonChannelers();
me->SetReactState(REACT_PASSIVE);
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetImmuneToAll(true);
if (instance)
instance->SetData(DATA_KELIDAN, NOT_STARTED);
}
@@ -143,7 +144,8 @@ public:
return;
}
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetImmuneToAll(false);
if (Unit* target = me->SelectNearestPlayer(100.0f))
AttackStart(target);
}

View File

@@ -240,7 +240,8 @@ public:
{
if (!prisoner->IsAlive())
prisoner->Respawn(true);
prisoner->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
prisoner->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
prisoner->SetImmuneToAll(true);
}
void StorePrisoner(Creature* creature)
@@ -316,7 +317,8 @@ public:
for (ObjectGuid const& guid : prisoners)
if (Creature* prisoner = instance->GetCreature(guid))
{
prisoner->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
prisoner->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
prisoner->SetImmuneToAll(false);
prisoner->SetInCombatWithZone();
}
}

View File

@@ -114,7 +114,8 @@ public:
_Reset();
me->CastSpell(me, SPELL_SHADOW_CAGE, true);
me->SetReactState(REACT_PASSIVE);
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_PC);
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(true);
}
void KilledUnit(Unit* /*victim*/) override
@@ -184,7 +185,8 @@ public:
Talk(SAY_FREE);
break;
case EVENT_ENTER_COMBAT:
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_PC);
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(false);
me->SetReactState(REACT_AGGRESSIVE);
events.ScheduleEvent(EVENT_CLEAVE, 9000);
events.ScheduleEvent(EVENT_BLAST_NOVA, 60000);

View File

@@ -92,7 +92,7 @@ public:
ScriptedAI::InitializeAI();
me->SetReactState(REACT_PASSIVE);
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(true);
events2.Reset();
events2.ScheduleEvent(EVENT_TELEPORT_VISUAL, 0);
events2.ScheduleEvent(EVENT_MILLHOUSE_INTRO1, 3000);
@@ -174,7 +174,7 @@ public:
case EVENT_MILLHOUSE_INTRO9:
me->SetFacingTo(M_PI * 1.5f);
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), M_PI * 1.5f);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
me->SetReactState(REACT_AGGRESSIVE);
events2.ScheduleEvent(EVENT_SEARCH_FIGHT, 1000);
break;
@@ -365,7 +365,7 @@ public:
{
_Reset();
me->setActive(false);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
me->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD);
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
me->CastSpell((Unit*)nullptr, SPELL_TARGET_OMEGA, false);
@@ -379,7 +379,7 @@ public:
{
me->setActive(true);
me->InterruptNonMeleeSpells(false);
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(true);
events.ScheduleEvent(EVENT_WARDEN_INTRO1, 1500);
events.ScheduleEvent(EVENT_WARDEN_CHECK_PLAYERS, 1000);
instance->SetBossState(DATA_WARDEN_MELLICHAR, IN_PROGRESS);
@@ -535,7 +535,7 @@ public:
case EVENT_WARDEN_INTRO25:
if (Creature* cr = me->SummonCreature(NPC_HARBINGER_SKYRISS, 445.763f, -191.639f, 44.64f, 1.60f, TEMPSUMMON_MANUAL_DESPAWN))
{
cr->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
cr->SetImmuneToAll(true);
cr->CastSpell(cr, SPELL_TELEPORT_VISUAL, true);
}
events.ScheduleEvent(EVENT_WARDEN_INTRO26, 1000);
@@ -562,7 +562,7 @@ public:
me->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
if (Creature* creature = summons.GetCreatureWithEntry(NPC_HARBINGER_SKYRISS))
{
creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
creature->SetImmuneToAll(false);
if (Player* player = SelectTargetFromPlayerList(50.0f))
AttackStart(player);
}

View File

@@ -66,14 +66,14 @@ public:
{
_Reset();
events2.Reset();
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
}
void InitializeAI() override
{
BossAI::InitializeAI();
if (instance->GetBossState(DATA_SOCCOTHRATES) != DONE)
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(true);
}
void JustDied(Unit* /*killer*/) override

View File

@@ -75,7 +75,7 @@ public:
{
events.Reset();
summons.DespawnAll();
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
}
void EnterCombat(Unit* /*who*/) override

View File

@@ -87,14 +87,14 @@ public:
_Reset();
events2.Reset();
me->CastSpell(me, SPELL_FEL_IMMOLATION, true);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
}
void InitializeAI() override
{
BossAI::InitializeAI();
if (!preFight)
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(true);
}
void JustDied(Unit* /*killer*/) override
@@ -185,9 +185,9 @@ public:
if (Creature* dalliah = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DALLIAH)))
{
dalliah->SetFacingToObject(me);
dalliah->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
dalliah->SetImmuneToAll(false);
me->SetFacingToObject(dalliah);
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
me->SetImmuneToAll(false);
dalliah->SetHomePosition(dalliah->GetPositionX(), dalliah->GetPositionY(), dalliah->GetPositionZ(), 1.51737f);
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 4.725722f);
}

View File

@@ -255,7 +255,8 @@ public:
{
if (spell->Id == SPELL_SUMMON_INFERNAL)
{
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_PACIFIED | UNIT_FLAG_NOT_SELECTABLE);
me->RemoveUnitFlag(UNIT_FLAG_PACIFIED | UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(false);
me->SetDisplayId(MODEL_INFERNAL);
}
}

View File

@@ -69,7 +69,7 @@ public:
}
else
{
creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
creature->SetImmuneToAll(false);
Creature* cr;
if ((cr = creature->SummonCreature(17957, -186, -790, 43.8f, 4.2f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)))
cr->AI()->AttackStart(creature);