예제 #1
0
        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.HasFlag(AreaFlags.Arena))
                    {
                        return(true);
                    }

                    if (Global.BattleFieldMgr.GetBattlefieldToZoneId(area.Id) != null)
                    {
                        return(true);
                    }

                    area = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID);
                } while (area != null);
            }

            return(false);
        }
예제 #2
0
        void HandleHearthAndResurrect(HearthAndResurrect packet)
        {
            if (GetPlayer().IsInFlight())
            {
                return;
            }

            BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetZoneId());

            if (bf != null)
            {
                bf.PlayerAskToLeave(_player);
                return;
            }

            AreaTableRecord atEntry = CliDB.AreaTableStorage.LookupByKey(GetPlayer().GetAreaId());

            if (atEntry == null || !atEntry.HasFlag(AreaFlags.CanHearthAndResurrect))
            {
                return;
            }

            GetPlayer().BuildPlayerRepop();
            GetPlayer().ResurrectPlayer(1.0f);
            GetPlayer().TeleportTo(GetPlayer().GetHomebind());
        }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        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();
        }
예제 #5
0
        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.HasFlag(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.HasFlag(areaRestFlag))
            {
                _restMgr.SetRestFlag(RestFlag.FactionArea);
            }
            else
            {
                _restMgr.RemoveRestFlag(RestFlag.FactionArea);
            }

            PushQuests();

            UpdateCriteria(CriteriaType.EnterTopLevelArea, newArea);

            UpdateMountCapability();
        }