bool IsAreaThatActivatesPvpTalents(uint areaID) { if (InBattleground()) { return(true); } AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(areaID); if (area != null) { do { if (area.IsSanctuary()) { return(false); } if (area.Flags[0].HasAnyFlag(AreaFlags.Arena)) { return(true); } if (Global.BattleFieldMgr.GetBattlefieldToZoneId(area.Id) != null) { return(true); } area = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID); } while (area != null); } return(false); }
void UpdateArea(uint newArea) { // FFA_PVP flags are area and not zone id dependent // so apply them accordingly m_areaUpdateId = newArea; AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(newArea); bool oldFFAPvPArea = pvpInfo.IsInFFAPvPArea; pvpInfo.IsInFFAPvPArea = area != null && area.Flags[0].HasAnyFlag(AreaFlags.Arena); UpdatePvPState(true); // check if we were in ffa arena and we left if (oldFFAPvPArea && !pvpInfo.IsInFFAPvPArea) { ValidateAttackersAndOwnTarget(); } PhasingHandler.OnAreaChange(this); UpdateAreaDependentAuras(newArea); if (IsAreaThatActivatesPvpTalents(newArea)) { EnablePvpRules(); } else { DisablePvpRules(); } // previously this was in UpdateZone (but after UpdateArea) so nothing will break pvpInfo.IsInNoPvPArea = false; if (area != null && area.IsSanctuary()) // in sanctuary { AddPvpFlag(UnitPVPStateFlags.Sanctuary); pvpInfo.IsInNoPvPArea = true; if (duel == null) { CombatStopWithPets(); } } else { RemovePvpFlag(UnitPVPStateFlags.Sanctuary); } AreaFlags areaRestFlag = (GetTeam() == Team.Alliance) ? AreaFlags.RestZoneAlliance : AreaFlags.RestZoneHorde; if (area != null && area.Flags[0].HasAnyFlag(areaRestFlag)) { _restMgr.SetRestFlag(RestFlag.FactionArea); } else { _restMgr.RemoveRestFlag(RestFlag.FactionArea); } UpdateCriteria(CriteriaTypes.TravelledToArea, newArea); }
void UpdateArea(uint newArea) { // FFA_PVP flags are area and not zone id dependent // so apply them accordingly m_areaUpdateId = newArea; AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(newArea); pvpInfo.IsInFFAPvPArea = area != null && area.Flags[0].HasAnyFlag(AreaFlags.Arena); UpdatePvPState(true); UpdateAreaDependentAuras(newArea); PhasingHandler.OnAreaChange(this); if (IsAreaThatActivatesPvpTalents(newArea)) { EnablePvpRules(); } else { DisablePvpRules(); } // previously this was in UpdateZone (but after UpdateArea) so nothing will break pvpInfo.IsInNoPvPArea = false; if (area != null && area.IsSanctuary()) // in sanctuary { SetByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.Sanctuary); pvpInfo.IsInNoPvPArea = true; if (duel == null) { CombatStopWithPets(); } } else { RemoveByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PvpFlag, UnitBytes2Flags.Sanctuary); } AreaFlags areaRestFlag = (GetTeam() == Team.Alliance) ? AreaFlags.RestZoneAlliance : AreaFlags.RestZoneHorde; if (area != null && area.Flags[0].HasAnyFlag(areaRestFlag)) { _restMgr.SetRestFlag(RestFlag.FactionArea); } else { _restMgr.RemoveRestFlag(RestFlag.FactionArea); } }
public void UpdateZone(uint newZone, uint newArea) { if (m_zoneUpdateId != newZone) { Global.OutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId); Global.OutdoorPvPMgr.HandlePlayerEnterZone(this, newZone); Global.BattleFieldMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId); Global.BattleFieldMgr.HandlePlayerEnterZone(this, newZone); SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange... Guild guild = GetGuild(); if (guild) { guild.UpdateMemberData(this, GuildMemberData.ZoneId, newZone); } } // group update if (GetGroup()) { SetGroupUpdateFlag(GroupUpdateFlags.Full); Pet pet = GetPet(); if (pet) { pet.SetGroupUpdateFlag(GroupUpdatePetFlags.Full); } } m_zoneUpdateId = newZone; m_zoneUpdateTimer = 1 * Time.InMilliseconds; // zone changed, so area changed as well, update it UpdateArea(newArea); AreaTableRecord zone = CliDB.AreaTableStorage.LookupByKey(newZone); if (zone == null) { return; } if (WorldConfig.GetBoolValue(WorldCfg.Weather)) { GetMap().GetOrGenerateZoneDefaultWeather(newZone); } GetMap().SendZoneDynamicInfo(newZone, this); Global.ScriptMgr.OnPlayerUpdateZone(this, newZone, newArea); // in PvP, any not controlled zone (except zone.team == 6, default case) // in PvE, only opposition team capital switch ((AreaTeams)zone.FactionGroupMask) { case AreaTeams.Ally: pvpInfo.IsInHostileArea = GetTeam() != Team.Alliance && (Global.WorldMgr.IsPvPRealm() || zone.Flags[0].HasAnyFlag(AreaFlags.Capital)); break; case AreaTeams.Horde: pvpInfo.IsInHostileArea = GetTeam() != Team.Horde && (Global.WorldMgr.IsPvPRealm() || zone.Flags[0].HasAnyFlag(AreaFlags.Capital)); break; case AreaTeams.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(); if (zone.Flags[0].HasAnyFlag(AreaFlags.Capital)) // Is in a capital city { if (!pvpInfo.IsInHostileArea || zone.IsSanctuary()) { _restMgr.SetRestFlag(RestFlag.City); } pvpInfo.IsInNoPvPArea = true; } else { _restMgr.RemoveRestFlag(RestFlag.City); } UpdatePvPState(); // remove items with area/map limitations (delete only for alive player to allow back in ghost mode) // if player resurrected at teleport this will be applied in resurrect code if (IsAlive()) { DestroyZoneLimitedItem(true, newZone); } // check some item equip limitations (in result lost CanTitanGrip at talent reset, for example) AutoUnequipOffhandIfNeed(); // recent client version not send leave/join channel packets for built-in local channels UpdateLocalChannels(newZone); UpdateZoneDependentAuras(newZone); }
public void UpdateHostileAreaState(AreaTableRecord area) { ZonePVPTypeOverride overrideZonePvpType = GetOverrideZonePVPType(); pvpInfo.IsInHostileArea = false; if (area.IsSanctuary()) // sanctuary and arena cannot be overriden { pvpInfo.IsInHostileArea = false; } else if (area.HasFlag(AreaFlags.Arena)) { pvpInfo.IsInHostileArea = true; } else if (overrideZonePvpType == ZonePVPTypeOverride.None) { if (area != null) { if (InBattleground() || area.HasFlag(AreaFlags.Combat) || (area.PvpCombatWorldStateID != -1 && Global.WorldMgr.GetWorldState((WorldStates)area.PvpCombatWorldStateID) != 0)) { pvpInfo.IsInHostileArea = true; } else if (Global.WorldMgr.IsPvPRealm() || area.HasFlag(AreaFlags.Unk3)) { if (area.HasFlag(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(); } } } } } else { switch (overrideZonePvpType) { case ZonePVPTypeOverride.Friendly: pvpInfo.IsInHostileArea = false; break; case ZonePVPTypeOverride.Hostile: case ZonePVPTypeOverride.Contested: case ZonePVPTypeOverride.Combat: pvpInfo.IsInHostileArea = true; break; default: break; } } // Treat players having a quest flagging for PvP as always in hostile area pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest(); }
public void UpdateZone(uint newZone, uint newArea) { if (!IsInWorld) { return; } uint oldZone = m_zoneUpdateId; m_zoneUpdateId = newZone; m_zoneUpdateTimer = 1 * Time.InMilliseconds; GetMap().UpdatePlayerZoneStats(oldZone, newZone); // call leave script hooks immedately (before updating flags) if (oldZone != newZone) { Global.OutdoorPvPMgr.HandlePlayerLeaveZone(this, oldZone); Global.BattleFieldMgr.HandlePlayerLeaveZone(this, oldZone); } // group update if (GetGroup()) { SetGroupUpdateFlag(GroupUpdateFlags.Full); Pet pet = GetPet(); if (pet) { pet.SetGroupUpdateFlag(GroupUpdatePetFlags.Full); } } // zone changed, so area changed as well, update it UpdateArea(newArea); AreaTableRecord zone = CliDB.AreaTableStorage.LookupByKey(newZone); if (zone == null) { return; } if (WorldConfig.GetBoolValue(WorldCfg.Weather)) { GetMap().GetOrGenerateZoneDefaultWeather(newZone); } GetMap().SendZoneDynamicInfo(newZone, this); UpdateHostileAreaState(zone); if (zone.HasFlag(AreaFlags.Capital)) // Is in a capital city { if (!pvpInfo.IsInHostileArea || zone.IsSanctuary()) { _restMgr.SetRestFlag(RestFlag.City); } pvpInfo.IsInNoPvPArea = true; } else { _restMgr.RemoveRestFlag(RestFlag.City); } UpdatePvPState(); // remove items with area/map limitations (delete only for alive player to allow back in ghost mode) // if player resurrected at teleport this will be applied in resurrect code if (IsAlive()) { DestroyZoneLimitedItem(true, newZone); } // check some item equip limitations (in result lost CanTitanGrip at talent reset, for example) AutoUnequipOffhandIfNeed(); // recent client version not send leave/join channel packets for built-in local channels UpdateLocalChannels(newZone); UpdateZoneDependentAuras(newZone); // call enter script hooks after everyting else has processed Global.ScriptMgr.OnPlayerUpdateZone(this, newZone, newArea); if (oldZone != newZone) { Global.OutdoorPvPMgr.HandlePlayerEnterZone(this, newZone); Global.BattleFieldMgr.HandlePlayerEnterZone(this, newZone); SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange... Guild guild = GetGuild(); if (guild) { guild.UpdateMemberData(this, GuildMemberData.ZoneId, newZone); } } }