fix(Core/Creatures): Fixed displaying trainer npcflags that are not valid to player. (#4848)

This commit is contained in:
UltraNix
2021-03-21 15:18:41 +01:00
committed by GitHub
parent 485f7e7639
commit 6c7cc1690f
4 changed files with 52 additions and 0 deletions

View File

@@ -1033,6 +1033,47 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const
&& player->getClass() == GetCreatureTemplate()->trainer_class;
}
bool Creature::IsValidTrainerForPlayer(Player* player, uint32* npcFlags /*= nullptr*/) const
{
if (!IsTrainer())
{
return false;
}
switch (m_creatureInfo->trainer_type)
{
case TRAINER_TYPE_CLASS:
case TRAINER_TYPE_PETS:
if (m_creatureInfo->trainer_class && m_creatureInfo->trainer_class != player->getClass())
{
if (npcFlags)
*npcFlags &= ~UNIT_NPC_FLAG_TRAINER_CLASS;
return false;
}
break;
case TRAINER_TYPE_MOUNTS:
if (m_creatureInfo->trainer_race && m_creatureInfo->trainer_race != player->getRace())
{
return false;
}
break;
case TRAINER_TYPE_TRADESKILLS:
if (m_creatureInfo->trainer_spell && !player->HasSpell(m_creatureInfo->trainer_spell))
{
if (npcFlags)
*npcFlags &= ~UNIT_NPC_FLAG_TRAINER_PROFESSION;
return false;
}
break;
default:
break;
}
return true;
}
Player* Creature::GetLootRecipient() const
{
if (!m_lootRecipient)