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
+9 -1
View File
@@ -2032,6 +2032,14 @@ namespace Game.Entities
}
case TypeId.Unit:
{
Creature questGiverCreature = questgiver.ToCreature();
if (!questGiverCreature.IsInteractionAllowedWhileHostile() && questGiverCreature.IsHostileTo(this))
return QuestGiverStatus.None;
if (!questGiverCreature.IsInteractionAllowedInCombat() && questGiverCreature.IsInCombat())
return QuestGiverStatus.None;
CreatureAI ai = questgiver.ToCreature().GetAI();
if (ai != null)
{
@@ -3220,7 +3228,7 @@ namespace Game.Entities
{
// need also pet quests case support
Creature questgiver = ObjectAccessor.GetCreatureOrPetOrVehicle(this, itr);
if (questgiver == null || questgiver.IsHostileTo(this))
if (questgiver == null)
continue;
if (!questgiver.HasNpcFlag(NPCFlags.QuestGiver))
+4 -1
View File
@@ -5472,7 +5472,10 @@ namespace Game.Entities
return null;
// not unfriendly/hostile
if (!creature.HasUnitFlag2(UnitFlags2.InteractWhileHostile) && creature.GetReactionTo(this) <= ReputationRank.Unfriendly)
if (!creature.IsInteractionAllowedWhileHostile() && creature.GetReactionTo(this) <= ReputationRank.Unfriendly)
return nullptr;
if (creature.IsInCombat() && !creature.IsInteractionAllowedInCombat())
return null;
// not too far, taken from CGGameUI::SetInteractTarget