Core/Creatures: Implemented serverside checks for UNIT_FLAG2_INTERACT_WHILE_HOSTILE and UNIT_FLAG3_ALLOW_INTERACTION_WHILE_IN_COMBAT

* Also stop sending npc flags for hostile creatures
Port From (https://github.com/TrinityCore/TrinityCore/commit/c2e36dea6c6af6139bf60454e9299447ec7d9897)
This commit is contained in:
hondacrx
2024-03-05 18:16:38 -05:00
parent 0325d8b523
commit e646b8008d
8 changed files with 125 additions and 39 deletions
@@ -2332,16 +2332,25 @@ namespace Game.Entities
uint GetViewerDependentNpcFlags(UnitData unitData, int i, Unit unit, Player receiver)
{
uint npcFlag = unitData.NpcFlags[i];
if (i == 0)
if (npcFlag != 0)
{
Creature creature = unit.ToCreature();
if (creature != null)
if ((!unit.IsInteractionAllowedInCombat() && unit.IsInCombat())
|| (!unit.IsInteractionAllowedWhileHostile() && unit.IsHostileTo(receiver)))
npcFlag = 0;
else
{
if (!receiver.CanSeeGossipOn(creature))
npcFlag &= ~(uint)(NPCFlags.Gossip | NPCFlags.QuestGiver);
Creature creature = unit.ToCreature();
if (creature != null)
{
if (i == 0)
{
if (!receiver.CanSeeGossipOn(creature))
npcFlag &= ~(uint)(NPCFlags.Gossip | NPCFlags.QuestGiver);
if (!receiver.CanSeeSpellClickOn(creature))
npcFlag &= ~(uint)NPCFlags.SpellClick;
if (!receiver.CanSeeSpellClickOn(creature))
npcFlag &= ~(uint)NPCFlags.SpellClick;
}
}
}
}