Core/Players: Corrected logic determining contested/friendly/hostile area types
Port From (https://github.com/TrinityCore/TrinityCore/commit/0a0fc86b96937315a9fce4ed6f452a4b7298f1af)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user