From 77b08c3fd90c9297c6ab46b8026f34022fbe62e1 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 9 Oct 2020 13:50:37 -0400 Subject: [PATCH] Core/Players: Corrected logic determining contested/friendly/hostile area types Port From (https://github.com/TrinityCore/TrinityCore/commit/0a0fc86b96937315a9fce4ed6f452a4b7298f1af) --- Source/Framework/Constants/CliDBConst.cs | 7 ++- Source/Game/Entities/Player/Player.Map.cs | 58 +++++++++++++++-------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Source/Framework/Constants/CliDBConst.cs b/Source/Framework/Constants/CliDBConst.cs index 0436ffc95..dff012dff 100644 --- a/Source/Framework/Constants/CliDBConst.cs +++ b/Source/Framework/Constants/CliDBConst.cs @@ -898,7 +898,7 @@ namespace Framework.Constants Town = 0x200000, // Small Towns With Inn RestZoneHorde = 0x400000, // Warsong Hold, Acherus: The Ebon Hold, New Agamand Inn, Vengeance Landing Inn, Sunreaver Pavilion (Something To Do With Team?) RestZoneAlliance = 0x800000, // Valgarde, Acherus: The Ebon Hold, Westguard Inn, Silver Covenant Pavilion (Something To Do With Team?) - Wintergrasp = 0x1000000, // Wintergrasp And It'S Subzones + Combat = 0x1000000, // "combat" area (Script_GetZonePVPInfo), used Inside = 0x2000000, // Used For Determinating Spell Related Inside/Outside Questions In Map.Isoutdoors Outside = 0x4000000, // Used For Determinating Spell Related Inside/Outside Questions In Map.Isoutdoors CanHearthAndResurrect = 0x8000000, // Can Hearth And Resurrect From Area @@ -906,6 +906,11 @@ namespace Framework.Constants Unk9 = 0x40000000, } + public enum AreaFlags2 + { + DontShowSanctuary = 0x00000200, // Hides sanctuary status from zone text color (Script_GetZonePVPInfo) + } + public enum ArtifactCategory { Primary = 1, diff --git a/Source/Game/Entities/Player/Player.Map.cs b/Source/Game/Entities/Player/Player.Map.cs index 175cd4e92..77a65dfe3 100644 --- a/Source/Game/Entities/Player/Player.Map.cs +++ b/Source/Game/Entities/Player/Player.Map.cs @@ -183,27 +183,7 @@ namespace Game.Entities GetMap().SendZoneDynamicInfo(newZone, this); - // in PvP, any not controlled zone (except zone.team == 6, default case) - // in PvE, only opposition team capital - switch ((ArenaTeams)zone.FactionGroupMask) - { - case ArenaTeams.Ally: - pvpInfo.IsInHostileArea = GetTeam() != Team.Alliance && (Global.WorldMgr.IsPvPRealm() || zone.Flags[0].HasAnyFlag(AreaFlags.Capital)); - break; - case ArenaTeams.Horde: - pvpInfo.IsInHostileArea = GetTeam() != Team.Horde && (Global.WorldMgr.IsPvPRealm() || zone.Flags[0].HasAnyFlag(AreaFlags.Capital)); - break; - case ArenaTeams.None: - // overwrite for Battlegrounds, maybe batter some zone flags but current known not 100% fit to this - pvpInfo.IsInHostileArea = Global.WorldMgr.IsPvPRealm() || InBattleground() || zone.Flags[0].HasAnyFlag(AreaFlags.Wintergrasp); - break; - default: // 6 in fact - pvpInfo.IsInHostileArea = false; - break; - } - - // Treat players having a quest flagging for PvP as always in hostile area - pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest(); + UpdateHostileAreaState(zone); if (zone.Flags[0].HasAnyFlag(AreaFlags.Capital)) // Is in a capital city { @@ -242,6 +222,42 @@ namespace Game.Entities } } + void UpdateHostileAreaState(AreaTableRecord area) + { + pvpInfo.IsInHostileArea = false; + + if (area.IsSanctuary()) // sanctuary and arena cannot be overriden + pvpInfo.IsInHostileArea = false; + else if (area.Flags[0].HasAnyFlag(AreaFlags.Arena)) + pvpInfo.IsInHostileArea = true; + else + { + if (area != null) + { + if (InBattleground() || area.Flags[0].HasAnyFlag(AreaFlags.Combat) || (area.PvpCombatWorldStateID != -1 && Global.WorldMgr.GetWorldState((WorldStates)area.PvpCombatWorldStateID) != 0)) + pvpInfo.IsInHostileArea = true; + else if (Global.WorldMgr.IsPvPRealm() || area.Flags[0].HasAnyFlag(AreaFlags.Unk3)) + { + if (area.Flags[0].HasAnyFlag(AreaFlags.ContestedArea)) + pvpInfo.IsInHostileArea = Global.WorldMgr.IsPvPRealm(); + else + { + FactionTemplateRecord factionTemplate = GetFactionTemplateEntry(); + if (factionTemplate == null || factionTemplate.FriendGroup.HasAnyFlag(area.FactionGroupMask)) + pvpInfo.IsInHostileArea = false; + else if (factionTemplate.EnemyGroup.HasAnyFlag(area.FactionGroupMask)) + pvpInfo.IsInHostileArea = true; + else + pvpInfo.IsInHostileArea = Global.WorldMgr.IsPvPRealm(); + } + } + } + } + + // Treat players having a quest flagging for PvP as always in hostile area + pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest(); + } + public InstanceBind GetBoundInstance(uint mapid, Difficulty difficulty, bool withExpired = false) { // some instances only have one difficulty