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

@@ -172,7 +172,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
_init = true;
uint32 duration = 0;
uint32 aura = 0;
me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
if (Unit* owner = me->GetCharmerOrOwner())
if (Player* player = owner->ToPlayer())
@@ -182,7 +182,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
aura = (player->GetTeamId(true) == TEAM_ALLIANCE ? SPELL_AURA_TIRED_S : SPELL_AURA_TIRED_G);
duration = player->GetSpellCooldownDelay(aura);
me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP);
for (uint8 i = 0; i < 3; ++i)
{
@@ -231,7 +231,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
{
_mountTimer = 0;
if (_state == ARGENT_PONY_STATE_NONE)
me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
else if (Unit* owner = me->GetCharmerOrOwner())
{
if (owner->IsMounted() && !me->IsMounted())
@@ -294,20 +294,20 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
switch (action)
{
case GOSSIP_ACTION_TRADE:
creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR);
creature->ReplaceAllNpcFlags(UNIT_NPC_FLAG_VENDOR);
player->GetSession()->SendListInventory(creature->GetGUID());
spellId = player->GetTeamId(true) ? SPELL_AURA_SHOP_G : SPELL_AURA_SHOP_S;
creature->AI()->DoAction(ARGENT_PONY_STATE_VENDOR);
break;
case GOSSIP_ACTION_BANK:
creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER);
creature->ReplaceAllNpcFlags(UNIT_NPC_FLAG_BANKER);
player->GetSession()->SendShowBank(player->GetGUID());
spellId = player->GetTeamId(true) ? SPELL_AURA_BANK_G : SPELL_AURA_BANK_S;
creature->AI()->DoAction(ARGENT_PONY_STATE_BANK);
break;
case GOSSIP_ACTION_MAILBOX:
{
creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_MAILBOX);
creature->ReplaceAllNpcFlags(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_MAILBOX);
player->GetSession()->SendShowMailBox(creature->GetGUID());
spellId = player->GetTeamId(true) ? SPELL_AURA_POSTMAN_G : SPELL_AURA_POSTMAN_S;
creature->AI()->DoAction(ARGENT_PONY_STATE_MAILBOX);