Skip to content

Commit

Permalink
refactor(Core/Misc): Use NpcFlag helpers (#19676)
Browse files Browse the repository at this point in the history
* chore(Core/Misc): Use HasNpcFlag instead of HasFlag

* extend to all npcflag helpers
  • Loading branch information
Kitzunu committed Aug 19, 2024
1 parent 1275b64 commit 337135b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/server/game/AI/CoreAI/PassiveAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NullCreatureAI::NullCreatureAI(Creature* c) : CreatureAI(c) { me->SetReactState(

int32 NullCreatureAI::Permissible(Creature const* creature)
{
if (creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
if (creature->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
return PERMIT_BASE_PROACTIVE + 50;

if (creature->IsTrigger())
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/AI/SmartScripts/SmartScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,21 +2061,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (WorldObject* target : targets)
if (IsCreature(target))
target->ToUnit()->SetUInt32Value(UNIT_NPC_FLAGS, e.action.unitFlag.flag);
target->ToUnit()->ReplaceAllNpcFlags(NPCFlags(e.action.unitFlag.flag));
break;
}
case SMART_ACTION_ADD_NPC_FLAG:
{
for (WorldObject* target : targets)
if (IsCreature(target))
target->ToUnit()->SetFlag(UNIT_NPC_FLAGS, e.action.unitFlag.flag);
target->ToUnit()->SetNpcFlag(NPCFlags(e.action.unitFlag.flag));
break;
}
case SMART_ACTION_REMOVE_NPC_FLAG:
{
for (WorldObject* target : targets)
if (IsCreature(target))
target->ToUnit()->RemoveFlag(UNIT_NPC_FLAGS, e.action.unitFlag.flag);
target->ToUnit()->RemoveNpcFlag(NPCFlags(e.action.unitFlag.flag));
break;
}
case SMART_ACTION_CROSS_CAST:
Expand Down
5 changes: 2 additions & 3 deletions src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,13 +1003,12 @@ class Unit : public WorldObject
[[nodiscard]] bool IsInnkeeper() const { return HasNpcFlag(UNIT_NPC_FLAG_INNKEEPER); }
[[nodiscard]] bool IsSpiritHealer() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITHEALER); }
[[nodiscard]] bool IsSpiritGuide() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITGUIDE); }
[[nodiscard]] bool IsTabardDesigner()const { return HasNpcFlag(UNIT_NPC_FLAG_TABARDDESIGNER); }
[[nodiscard]] bool IsTabardDesigner() const { return HasNpcFlag(UNIT_NPC_FLAG_TABARDDESIGNER); }
[[nodiscard]] bool IsAuctioner() const { return HasNpcFlag(UNIT_NPC_FLAG_AUCTIONEER); }
[[nodiscard]] bool IsArmorer() const { return HasNpcFlag(UNIT_NPC_FLAG_REPAIR); }
[[nodiscard]] bool IsServiceProvider() const
{
return HasFlag(UNIT_NPC_FLAGS,
UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
return HasNpcFlag(UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER |
UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class npc_hyjal_jaina : public CreatureScript
scheduler.CancelAll();
if (InstanceScript* hyjal = me->GetInstanceScript())
if (!hyjal->GetData(DATA_WAVE_STATUS))
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
me->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
}

void JustEngagedWith(Unit* /*who*/) override
Expand All @@ -138,7 +138,7 @@ class npc_hyjal_jaina : public CreatureScript

void IsSummonedBy(WorldObject* /*summoner*/) override
{
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
me->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP);
DoCastSelf(SPELL_SIMPLE_TELEPORT, true);

// Should wait 2400ms
Expand Down Expand Up @@ -176,7 +176,7 @@ class npc_hyjal_jaina : public CreatureScript

bool OnGossipSelect(Player* /*player*/ , Creature* creature, uint32 /*sender*/, uint32 /*action*/) override
{
creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
creature->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP);

if (InstanceScript* hyjal = creature->GetInstanceScript())
{
Expand Down Expand Up @@ -213,7 +213,7 @@ class npc_hyjal_thrall : public CreatureScript
scheduler.CancelAll();
if (InstanceScript* hyjal = me->GetInstanceScript())
if (!hyjal->GetData(DATA_WAVE_STATUS))
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
me->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
}

void JustEngagedWith(Unit* /*who*/) override
Expand Down Expand Up @@ -251,7 +251,7 @@ class npc_hyjal_thrall : public CreatureScript

bool OnGossipSelect(Player* /*player*/, Creature* creature, uint32 /*sender*/, uint32 /*action*/) override
{
creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
creature->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP);

if (InstanceScript* hyjal = creature->GetInstanceScript())
{
Expand Down
4 changes: 2 additions & 2 deletions src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ class boss_yoggsaron_descend_portal : public CreatureScript
if (!spellClickHandled)
return;

if (!me->GetUInt32Value(UNIT_NPC_FLAGS))
if (!me->GetNpcFlags())
return;

switch (me->GetArmor())
Expand All @@ -1806,7 +1806,7 @@ class boss_yoggsaron_descend_portal : public CreatureScript
break;
}

me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
me->DespawnOrUnsummon(1000);
}

Expand Down

0 comments on commit 337135b

Please sign in to comment.