feat(Core/Unit): NPCFlags helpers (#11286)

* cherry-pick commit (TrinityCore/TrinityCore@d611925)
Co-Authored-By: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
Kitzunu
2022-04-05 13:52:42 +02:00
committed by GitHub
parent e2370446a5
commit edb7cac19b
75 changed files with 293 additions and 285 deletions

View File

@@ -316,7 +316,7 @@ public:
me->SetFaction(FACTION_FRIENDLY);
me->SetReactState(REACT_PASSIVE);
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
if(pInstance)
{
@@ -347,13 +347,13 @@ public:
SetEscortPaused(false);
InitializeEvent();
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
break;
}
case ACTION_GO_TO_SJONNIR:
SetEscortPaused(false);
ResetEvent();
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
break;
case ACTION_START_SJONNIR_FIGHT:
me->SetFaction(FACTION_FRIENDLY);
@@ -377,7 +377,7 @@ public:
Start(false, true, ObjectGuid::Empty, 0, true, false);
SetNextWaypoint(20, false);
ResetEvent();
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
break;
case ACTION_OPEN_DOOR:
if (GameObject* door = ObjectAccessor::GetGameObject(*me, pInstance->GetGuidData(GO_SJONNIR_DOOR)))
@@ -504,7 +504,7 @@ public:
me->CastSpell(me, 59046, true); // credit
}
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
// Spawn Chest and quest credit
if (Player* plr = SelectTargetFromPlayerList(200.0f))
@@ -528,7 +528,7 @@ public:
door->SetGoState(GO_STATE_ACTIVE);
SetEscortPaused(false);
ResetEvent();
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
break;
}
case EVENT_END:
@@ -537,7 +537,7 @@ public:
if (pInstance)
pInstance->SetData(BRANN_BRONZEBEARD, 6);
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->Yell("I'll use the forge to make batches o' earthen to stand guard... But our greatest challenge still remains: find and stop Loken!", LANG_UNIVERSAL);
me->PlayDirectSound(14279);
break;
@@ -653,7 +653,7 @@ void brann_bronzebeard::brann_bronzebeardAI::WaypointReached(uint32 id)
// Stop before stairs and ask to start
case 9:
SetEscortPaused(true);
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
if (pInstance)
pInstance->SetData(BRANN_BRONZEBEARD, 2);
@@ -674,7 +674,7 @@ void brann_bronzebeard::brann_bronzebeardAI::WaypointReached(uint32 id)
if(pInstance)
{
pInstance->SetData(BRANN_BRONZEBEARD, 5);
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(NPC_SJONNIR)))
cr->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetOrientation(3.132660f);

View File

@@ -873,7 +873,7 @@ public:
if (me->GetVehicle())
{
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
if (Unit* player = me->GetVehicle()->GetPassenger(SEAT_PLAYER))

View File

@@ -39,7 +39,7 @@ public:
bool OnGossipSelect(Player* /*player*/, Creature* creature, uint32 /*uiSender*/, uint32 /*uiAction*/) override
{
creature->SetUInt32Value(UNIT_NPC_FLAGS, 0);
creature->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
uint8 _keeper = 0;
switch (creature->GetEntry())
{
@@ -285,7 +285,7 @@ public:
me->SetReactState(REACT_PASSIVE);
me->SetRegeneratingHealth(false);
me->SetFaction(FACTION_PREY);
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->SetNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
me->CastSpell(me, 64770, true);
}
}