mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 23:26:23 +00:00
refactor(Core/Unit): PC&NPC Immunity (#11986)
* initial * refactor(Core/Unit): PC & NPC Immunities Cherry-pick TC:74af880217Co-authored-by: Treeston <treeston.nmoc@gmail.com> * fix builds error Cherry-pick TC:74af880217Co-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:
@@ -112,7 +112,7 @@ public:
|
||||
damage = 0;
|
||||
finished = true;
|
||||
me->SetRegeneratingHealth(false);
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(true);
|
||||
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
if (InstanceScript* pInstance = me->GetInstanceScript())
|
||||
|
||||
@@ -472,7 +472,7 @@ public:
|
||||
{
|
||||
summons.Despawn(cr);
|
||||
summons.Summon(cr);
|
||||
cr->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(true);
|
||||
cr->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
}
|
||||
Talk(SAY_PHASE501);
|
||||
@@ -972,7 +972,7 @@ public:
|
||||
if (Creature* cr = GetEventNpc(NPC_CITY_MAN))
|
||||
{
|
||||
cr->UpdateEntry(NPC_INFINITE_HUNTER, nullptr, false);
|
||||
cr->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(true);
|
||||
cr->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
ScheduleNextEvent(currentEvent, 2000);
|
||||
@@ -981,7 +981,7 @@ public:
|
||||
if (Creature* cr = GetEventNpc(NPC_CITY_MAN4))
|
||||
{
|
||||
cr->UpdateEntry(NPC_INFINITE_AGENT, nullptr, false);
|
||||
cr->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(true);
|
||||
cr->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
ScheduleNextEvent(currentEvent, 2000);
|
||||
@@ -996,14 +996,14 @@ public:
|
||||
}
|
||||
if (Creature* cr = GetEventNpc(NPC_INFINITE_AGENT)) // it is infinite agent now :)
|
||||
{
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(false);
|
||||
cr->SetReactState(REACT_AGGRESSIVE);
|
||||
cr->SetInCombatWithZone();
|
||||
cr->AddThreat(me, 0.0f);
|
||||
}
|
||||
if (Creature* cr = GetEventNpc(NPC_INFINITE_HUNTER)) // it is infinite hunter now :)
|
||||
{
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(false);
|
||||
cr->SetReactState(REACT_AGGRESSIVE);
|
||||
cr->SetInCombatWithZone();
|
||||
cr->AddThreat(me, 0.0f);
|
||||
@@ -1076,7 +1076,7 @@ public:
|
||||
me->SummonCreature(NPC_TIME_RIFT, EventPos[EVENT_SRC_EPOCH], TEMPSUMMON_TIMED_DESPAWN, 20000);
|
||||
if (Creature* cr = me->SummonCreature(NPC_EPOCH, EventPos[EVENT_SRC_EPOCH]))
|
||||
{
|
||||
cr->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(true);
|
||||
cr->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
me->SetTarget(cr->GetGUID());
|
||||
cr->GetMotionMaster()->MovePoint(0, EventPos[EVENT_DST_EPOCH]);
|
||||
@@ -1097,7 +1097,7 @@ public:
|
||||
case EVENT_ACTION_PHASE3+18:
|
||||
if (Creature* cr = GetEventNpc(NPC_EPOCH))
|
||||
{
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(false);
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
cr->SetReactState(REACT_AGGRESSIVE);
|
||||
cr->AddThreat(me, 0.0f);
|
||||
@@ -1122,7 +1122,7 @@ public:
|
||||
case EVENT_ACTION_PHASE5:
|
||||
if (Creature* cr = GetEventNpc(NPC_MAL_GANIS))
|
||||
{
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
cr->SetImmuneToAll(false);
|
||||
cr->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
cr->SetInCombatWithZone();
|
||||
cr->AddThreat(me, 0.0f);
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
summons.Summon(summon);
|
||||
if (Creature* thrall = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(DATA_THRALL_GUID)))
|
||||
thrall->AI()->JustSummoned(summon);
|
||||
summon->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
summon->SetImmuneToAll(true);
|
||||
|
||||
if (summon->GetEntry() == NPC_SKARLOC_MOUNT)
|
||||
return;
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
path.push_back(G3D::Vector3(startPath[i].GetPositionX(), startPath[i].GetPositionY(), startPath[i].GetPositionZ()));
|
||||
|
||||
me->GetMotionMaster()->MoveSplinePath(&path);
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(true);
|
||||
me->Mount(SKARLOC_MOUNT_MODEL);
|
||||
}
|
||||
|
||||
@@ -168,13 +168,13 @@ public:
|
||||
Talk(SAY_ENTER);
|
||||
break;
|
||||
case EVENT_START_FIGHT:
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(false);
|
||||
me->SetInCombatWithZone();
|
||||
for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
|
||||
if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
|
||||
if (summon->GetEntry() != NPC_SKARLOC_MOUNT)
|
||||
{
|
||||
summon->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
summon->SetImmuneToAll(false);
|
||||
summon->SetInCombatWithZone();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -620,7 +620,7 @@ public:
|
||||
case EVENT_SUMMON_CHRONO:
|
||||
if (Creature* epoch = me->SummonCreature(NPC_EPOCH_HUNTER, 2640.49f, 696.15f, 64.31f, 4.51f, TEMPSUMMON_MANUAL_DESPAWN))
|
||||
{
|
||||
epoch->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
epoch->SetImmuneToAll(true);
|
||||
epoch->AI()->Talk(SAY_EPOCH_ENTER1);
|
||||
}
|
||||
break;
|
||||
@@ -703,7 +703,7 @@ public:
|
||||
case EVENT_CALL_EPOCH:
|
||||
if (Creature* epoch = summons.GetCreatureWithEntry(NPC_EPOCH_HUNTER))
|
||||
{
|
||||
epoch->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
epoch->SetImmuneToAll(false);
|
||||
epoch->GetMotionMaster()->MovePoint(0, *me, false, true);
|
||||
}
|
||||
break;
|
||||
@@ -759,7 +759,7 @@ public:
|
||||
Talk(SAY_EVENT_COMPLETE);
|
||||
break;
|
||||
case EVENT_THRALL_RUN_AWAY:
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(true);
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
SetEscortPaused(false);
|
||||
break;
|
||||
|
||||
@@ -258,14 +258,14 @@ public:
|
||||
{
|
||||
summon->SetFaction(faction);
|
||||
if (remove)
|
||||
summon->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
summon->SetImmuneToNPC(false);
|
||||
else
|
||||
summon->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
summon->SetImmuneToNPC(true);
|
||||
}
|
||||
if (remove)
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToNPC(false);
|
||||
else
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToNPC(true);
|
||||
me->SetFaction(faction);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
return;
|
||||
|
||||
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
|
||||
me->SetImmuneToPC(false);
|
||||
SetCombatMovement(true);
|
||||
|
||||
if (me->IsInCombat())
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
void InitializeAI() override
|
||||
{
|
||||
me->SetNpcFlag(UNIT_NPC_FLAG_QUESTGIVER);
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(true);
|
||||
me->RestoreFaction();
|
||||
|
||||
_events.Reset();
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
Talk(TALK_0, player);
|
||||
|
||||
me->RemoveNpcFlag(UNIT_NPC_FLAG_QUESTGIVER);
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
me->SetImmuneToAll(false);
|
||||
me->SetFaction(FACTION_ESCORT_N_NEUTRAL_ACTIVE);
|
||||
me->GetMotionMaster()->MoveFollow(player, 3.f, M_PI);
|
||||
|
||||
|
||||
@@ -584,7 +584,7 @@ public:
|
||||
{
|
||||
npc_omenAI(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
me->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
|
||||
me->SetImmuneToPC(true);
|
||||
me->GetMotionMaster()->MovePoint(1, 7549.977f, -2855.137f, 456.9678f);
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ public:
|
||||
if (pointId == 1)
|
||||
{
|
||||
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
|
||||
me->SetImmuneToPC(false);
|
||||
if (Player* player = me->SelectNearestPlayer(40.0f))
|
||||
AttackStart(player);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
|
||||
creature->AI()->Talk(SAY_START);
|
||||
creature->SetFaction(FACTION_ESCORTEE_N_NEUTRAL_PASSIVE);
|
||||
creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
|
||||
creature->SetImmuneToPC(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user