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

@@ -492,9 +492,9 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
SetUInt32Value(UNIT_NPC_FLAGS, npcflag | sGameEventMgr->GetNPCFlag(this));
ReplaceAllNpcFlags(NPCFlags(npcflag | sGameEventMgr->GetNPCFlag(this)));
else
SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
ReplaceAllNpcFlags(NPCFlags(npcflag));
// Xinef: NPC is in combat, keep this flag!
unit_flags &= ~UNIT_FLAG_IN_COMBAT;
@@ -1301,7 +1301,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_spawnId);
uint32 displayId = GetNativeDisplayId();
uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
uint32 npcflag = GetNpcFlags();
uint32 unit_flags = GetUnitFlags();
uint32 dynamicflags = GetDynamicFlags();
@@ -1846,7 +1846,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
SaveRespawnTime();
SetTarget(); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
Dismount(); // if creature is mounted on a virtual mount, remove it at death
@@ -1888,7 +1888,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
UpdateMovementFlags();
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
ReplaceAllNpcFlags(NPCFlags(cinfo->npcflag));
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_NO_ENVIRONMENT_UPD)));
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));