Esempio n. 1
0
        private void AddNewObjects()
        {
            try
            {
                lock (_objectsToAdd)
                {
                    foreach (ObjectAdd obj in _objectsToAdd)
                    {
                        var plr = obj.Obj as Player;

                        if (obj.Obj.Region != this)
                        {
                            if (obj.Obj.Region != null)
                            {
                                obj.Obj.Region.RemoveObject(obj.Obj);
                            }

                            GenerateOid(obj.Obj);

                            if (plr != null)
                            {
                                plr.InRegionChange = true;
                                if (!Players.Contains(plr))
                                {
                                    Players.Add(plr);
                                }
                            }
                        }

                        else
                        {
                            obj.Obj.Zone.RemoveObject(obj.Obj);
                        }

                        ZoneMgr mgr = GetZoneMgr(obj.ZoneId);
                        mgr.AddObject(obj.Obj);

                        if (obj.MustUpdateRange)
                        {
                            UpdateRange(obj.Obj);
                        }

                        if (plr != null)
                        {
                            //Bttlfront?.SendObjectives(plr);

                            ndbf?.SendObjectives(plr);
                            WorldMgr.SendCampaignStatus(plr);
                        }
                    }
                    _objectsToAdd.Clear();
                }
            }
            catch (Exception e)
            {
                Log.Error("AddNewObjects", e.ToString());
            }
        }
Esempio n. 2
0
        public override void ResetPairing()
        {
            Log.Info("Battlefront.ResetT4Campaign", " Region: " + Region.RegionId + " | RESETTING CAMPAIGN");
            //Log.Info("LockTimer: ", "Timer was " + PairingDrawTime.ToString() + " and its now " + TCPManager.GetTimeStamp().ToString() + " ProximityProgressingBattlefront");
            PairingLocked = false;
            GraceDisabled = false;

            RealmRank[0]              = 0;
            RealmRank[1]              = 0;
            RealmCurrentResources[0]  = 0;
            RealmCurrentResources[1]  = 0;
            RealmMaxResource[0]       = 0;
            RealmMaxResource[1]       = 0;
            RealmLastReturnSeconds[0] = 0;
            RealmLastReturnSeconds[1] = 0;
            RealmLostKeep[0]          = false;
            RealmLostKeep[1]          = false;
            RealmDeployedRam[0]       = 0;
            RealmDeployedRam[1]       = 0;
            RealmCannon[0]            = 0;
            RealmCannon[1]            = 0;

            PairingDrawTime     = 0;
            DefenderPopTooSmall = false;
            _totalMaxOrder      = 0;
            _totalMaxDestro     = 0;

            foreach (ProximityFlag flag in _Objectives.ToList())
            {
                if (flag != null && flag.Ruin)
                {
                    _Objectives.Remove(flag);
                    flag.RemoveFromWorld();
                }
            }

            LockZone(Realms.REALMS_REALM_DESTRUCTION, Zones[0].ZoneId, false, true);
            LiftZoneLock(Zones[1].ZoneId, true);
            LockZone(Realms.REALMS_REALM_ORDER, Zones[2].ZoneId, false, true);
            LockingRealm   = Realms.REALMS_REALM_NEUTRAL;
            DefendingRealm = Realms.REALMS_REALM_NEUTRAL;
            WorldMgr.SendCampaignStatus(null);

            if (_battlefrontStatus != null)
            {
                _battlefrontStatus.OpenZoneIndex = 1;
                WorldMgr.Database.SaveObject(_battlefrontStatus);
            }
        }
        public override void ResetPairing()
        {
            Log.Info("Battlefront.ResetT4Campaign", " Region: " + Region.RegionId + " | RESETTING CAMPAIGN");
            PairingLocked = false;
            GraceDisabled = false;
            LockZone(Realms.REALMS_REALM_DESTRUCTION, Zones[0].ZoneId, false, true);
            LiftZoneLock(Zones[1].ZoneId, true);
            LockZone(Realms.REALMS_REALM_ORDER, Zones[2].ZoneId, false, true);
            LockingRealm   = Realms.REALMS_REALM_NEUTRAL;
            DefendingRealm = Realms.REALMS_REALM_NEUTRAL;
            WorldMgr.SendCampaignStatus(null);

            if (_battlefrontStatus != null)
            {
                _battlefrontStatus.OpenZoneIndex = 1;
                WorldMgr.Database.SaveObject(_battlefrontStatus);
            }
        }
Esempio n. 4
0
        private void LoadPairing()
        {
            Log.Info("Battlefront.LoadPairing", " Region: " + Region.RegionId + " | LOADING CAMPAIGN");

            if (_battlefrontStatus == null)
            {
                Log.Error("Battlefront.LoadPairing", "No Battlefront Status - campaign resetting.");
                ResetPairing();
                return;
            }

            if (Constants.DoomsdaySwitch > 0)
            {
                PairingLocked = true;
                GraceDisabled = true;
            }
            else
            {
                PairingLocked = false;
                GraceDisabled = false;
            }

            for (int i = 0; i < _battlefrontStatus.OpenZoneIndex; ++i)
            {
                Log.Info("LoadPairing", "Setting ownership of " + Zones[i].Name + " to Destruction");
                LockZone(Realms.REALMS_REALM_DESTRUCTION, Zones[i].ZoneId, false, true);
                foreach (Keep keep in _Keeps)
                {
                    if (keep.Info.ZoneId == Zones[i].ZoneId)
                    {
                        keep.Realm = Realms.REALMS_REALM_DESTRUCTION;
                    }
                }
            }


            if (Constants.DoomsdaySwitch > 0)
            {
                LockZone(Realms.REALMS_REALM_NEUTRAL, Zones[_battlefrontStatus.OpenZoneIndex].ZoneId, false, true);
            }
            else
            {
                LiftZoneLock(Zones[_battlefrontStatus.OpenZoneIndex].ZoneId, true);
                Log.Info("LoadPairing", "Setting ownership of " + Zones[_battlefrontStatus.OpenZoneIndex].Name + " to Contested");
            }



            for (int i = _battlefrontStatus.OpenZoneIndex + 1; i < 3; ++i)
            {
                LockZone(Realms.REALMS_REALM_ORDER, Zones[i].ZoneId, false, true);
                Log.Info("LoadPairing", "Setting ownership of " + Zones[i].Name + " to Order");
                foreach (Keep keep in _Keeps)
                {
                    if (keep.Info.ZoneId == Zones[i].ZoneId)
                    {
                        keep.Realm = Realms.REALMS_REALM_ORDER;
                    }
                }
            }

            LockingRealm   = Realms.REALMS_REALM_NEUTRAL;
            DefendingRealm = Realms.REALMS_REALM_NEUTRAL;
            WorldMgr.SendCampaignStatus(null);
        }
Esempio n. 5
0
        public void LiftZoneLock(int zoneId, bool reset)
        {
            long _BOLockTime = (int)(10 * 60 * 1000 * TIMER_MODIFIER);

#if (DEBUG)
            _BOLockTime = (1 * 60 * 1000);
#endif

            PairingLocked = false;
            GraceDisabled = false;

            RealmRank[0]              = 0;
            RealmRank[1]              = 0;
            RealmCurrentResources[0]  = 0;
            RealmCurrentResources[1]  = 0;
            RealmMaxResource[0]       = 0;
            RealmMaxResource[1]       = 0;
            RealmLastReturnSeconds[0] = 0;
            RealmLastReturnSeconds[1] = 0;
            RealmLostKeep[0]          = false;
            RealmLostKeep[1]          = false;
            RealmDeployedRam[0]       = 0;
            RealmDeployedRam[1]       = 0;
            RealmCannon[0]            = 0;
            RealmCannon[1]            = 0;

            PairingDrawTime     = 0;
            DefenderPopTooSmall = false;
            _totalMaxOrder      = 0;
            _totalMaxDestro     = 0;

            _Objectives.Clear();
            LoadObjectives();

            DefendingRealm = Realms.REALMS_REALM_NEUTRAL;

            if (Constants.DoomsdaySwitch > 0)
            {
                _battlefrontStatus.OpenZoneIndex      = Zones.FindIndex(z => z.ZoneId == zoneId);
                _battlefrontStatus.ActiveRegionOrZone = zoneId;
                WorldMgr.Database.SaveObject(_battlefrontStatus);
            }
            else
            {
                if (!reset)
                {
                    _battlefrontStatus.OpenZoneIndex      = Zones.FindIndex(z => z.ZoneId == zoneId);
                    _battlefrontStatus.ActiveRegionOrZone = zoneId;
                    WorldMgr.Database.SaveObject(_battlefrontStatus);
                }
            }

            _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 4;
            _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 0;
            _held[Zones.FindIndex(z => z.ZoneId == zoneId), 2] = 0;

            HeldObjectives[0] = 4;
            HeldObjectives[1] = 0;
            HeldObjectives[2] = 0;

            foreach (ProximityFlag flag in _Objectives.ToList())
            {
                if (flag.Ruin)
                {
                    _Objectives.Remove(flag);
                    flag.RemoveFromWorld();
                    continue;
                }

                if (flag.ZoneId == zoneId)
                {
                    flag.UnlockObjective();
                }
            }

            Random coinFlip = new Random();
            int    flip     = coinFlip.Next(1, 3);

            foreach (Keep keep in _Keeps)
            {
                if (keep.Info.ZoneId == zoneId)
                {
                    keep.NotifyPairingUnlocked();

                    if (flip == 2)
                    {
                        if (keep.Realm == Realms.REALMS_REALM_ORDER)
                        {
                            keep.Realm = Realms.REALMS_REALM_DESTRUCTION;
                        }
                        else
                        {
                            keep.Realm = Realms.REALMS_REALM_ORDER;
                        }
                    }

                    foreach (KeepDoor door in keep.Doors)
                    {
                        door.GameObject?.SetAttackable(keep.KeepStatus != KeepStatus.KEEPSTATUS_LOCKED && CanAttackDoor(keep.Realm, keep.Info.ZoneId));
                    }

                    keep.LockKeep(keep.Realm, false, false);
                    keep.SendKeepStatus(null);
                }
            }

            // Where 0 = Destromost zone, and 2 = Ordermost zone
            int campaignProgress = Zones.FindIndex(z => z.ZoneId == zoneId);

            lock (Player._Players)
            {
                foreach (Player plr in Player._Players)
                {
                    if (!plr.ValidInTier(Tier, true))
                    {
                        continue;
                    }

                    plr.SendLocalizeString(Zones[campaignProgress].Name + " battlefield objectives will soon be open for capture!", ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT);
                    plr.SendLocalizeString(Zones[campaignProgress].Name + " battlefield objectives will soon be open for capture!", plr.Realm == Realms.REALMS_REALM_ORDER ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE, Localized_text.CHAT_TAG_DEFAULT);
                }
            }

            WorldMgr.SendCampaignStatus(null);
        }
Esempio n. 6
0
        public void LockZone(Realms realm, int zoneId, bool announce, bool reset, bool noRewards = false, bool draw = false)
        {
            Log.Debug("Battlefront.LockT4Zone", "Locking zone " + zoneId + " for " + realm);

            foreach (ProximityFlag flag in _Objectives.ToList())
            {
                if (flag.Ruin)
                {
                    _Objectives.Remove(flag);
                    flag.RemoveFromWorld();
                    continue;
                }

                if (flag.ZoneId == zoneId)
                {
                    flag.LockObjective(realm, announce);
                    flag._owningRealm = realm;
                    flag.BroadcastFlagInfo(false);
                }
            }

            if (realm == Realms.REALMS_REALM_ORDER)
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 4;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 2] = 0;
                HeldObjectives[0] = 0;
                HeldObjectives[1] = 4;
                HeldObjectives[2] = 0;
            }
            else
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 2] = 4;
                HeldObjectives[0] = 0;
                HeldObjectives[1] = 0;
                HeldObjectives[2] = 4;
            }

            foreach (Keep keep in _Keeps)
            {
                if (keep.Info.ZoneId == zoneId)
                {
                    Realms targetRealm = keep.GetContestedRealm();
                    Dictionary <uint, ContributionInfo> contributors = GetContributorsFromRealm(targetRealm);

                    if (contributors.Count > 0 && !noRewards)
                    {
                        if (DefenderPopTooSmall)
                        {
                            WinnerShare = 0.0f;
                        }

                        if (draw)
                        {
                            WinnerShare = 0.1f;
                            LoserShare  = 0.1f;
                        }

                        Log.Success("Logging keep rewards...", "");
                        Log.Success("Zone", ActiveZoneName);
                        Log.Success("Is defender pop too small to award rewards", DefenderPopTooSmall.ToString());
                        Log.Success("ProgressingBattlefront", $"Creating gold chest for {keep.Info.Name} for {contributors.Count} {(targetRealm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction")} contributors");
                        GoldChest.Create(Region, keep.Info.PQuest, ref contributors, targetRealm == realm ? WinnerShare : LoserShare);
                    }

                    keep.Realm = realm;
                    keep.LockKeep(realm, announce, reset);
                }
            }

            if (DefenderPopTooSmall)
            {
                Broadcast($"The forces of {(realm == Realms.REALMS_REALM_ORDER ? "Order " : "Destruction ")} conquered abandoned keep, no spoils of war were found!");
            }

            if (draw)
            {
                Broadcast("As forces of Order and Destruction were reluctant to trade final blows the war moved elsewhere!");
            }

            if (!announce)
            {
                return;
            }

            DisableSupplies();

            // Where 0 = Destromost zone, and 2 = Ordermost zone
            int campaignProgress = Zones.FindIndex(z => z.ZoneId == zoneId);

            string message;
            float  winnerRewardScale;

            if (realm == Realms.REALMS_REALM_DESTRUCTION)
            {
                campaignProgress = 2 - campaignProgress;
            }

            switch (campaignProgress)
            {
            case 0:
                // The realm has captured the zone closest to the enemy fort, leave the last zone locked and give them a reward
                UpdateStateOfTheRealm();
                PairingLocked = true;

#if DEBUG
                EvtInterface.AddEvent(EndGrace, 90 * 1000, 1);
#else
                EvtInterface.AddEvent(EndGrace, 10 * 60 * 1000, 1);
#endif


                Log.Info("Battlefront.LockT4Zone", "Locked all of region " + Region.RegionId);

                winnerRewardScale = 1.25f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[0].Name + " has been liberated by the forces of Order! The forces of Destruction have been cleansed from this region, but the fighting continues on elsewhere!";
                }
                else
                {
                    message = Zones[2].Name + " has been conquered by the forces of Destruction! The forces of Order flee like cowards, but the fighting continues on elsewhere!";
                }

                LockingRealm = realm;

                WorldMgr.EvaluateT4CampaignStatus(Region.RegionId);
                break;

            case 1:
                // The realm has captured the middle zone, unlock zone closest to enemy fort.
                if (Constants.DoomsdaySwitch > 0)
                {
                    //LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, true);
                    CheckUnlockZone(true, Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, true);
                }
                else
                {
                    //LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, false);
                    CheckUnlockZone(true, Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, false);
                }

                winnerRewardScale = 1f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message        = Zones[1].Name + " has been reclaimed by the forces of Order! The forces of Destruction have retreated to " + Zones[0].Name + ", to build up for a renewed assault.";
                    DefendingRealm = Realms.REALMS_REALM_DESTRUCTION;
                }
                else
                {
                    message        = Zones[1].Name + " has been seized by the forces of Destruction! The forces of Order have fallen back to " + Zones[2].Name + " to make a last stand.";
                    DefendingRealm = Realms.REALMS_REALM_ORDER;
                }

                UpdateStateOfTheRealm();
                break;

            case 2:
                // The realm has recaptured the zone closest to their fort, unlock the middle zone
                if (Constants.DoomsdaySwitch > 0)
                {
                    CheckUnlockZone(true, Zones[1].ZoneId, true);
                }
                //LiftZoneLock(Zones[1].ZoneId, true);
                else
                {
                    CheckUnlockZone(true, Zones[1].ZoneId, false);
                }
                //LiftZoneLock(Zones[1].ZoneId, false);

                winnerRewardScale = 0.75f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[2].Name + " has been saved by the forces of Order! The forces of Destruction fall back to " + Zones[1].Name + "!";
                }
                else
                {
                    message = "The forces of Destruction tighten their grip on " + Zones[0].Name + ", and the forces of Order fall back to " + Zones[1].Name + "!";
                }

                DefendingRealm = Realms.REALMS_REALM_NEUTRAL;

                UpdateStateOfTheRealm();
                break;

            default:
                Log.Error("Battlefront.LockT4Zone", "The campaign progress was somehow at stage " + campaignProgress + ". This is not supposed to happen.");
                return;
            }

            VictoryPoints = 50;
            LastAnnouncedVictoryPoints = 50;

            WorldMgr.SendCampaignStatus(null);

            winnerRewardScale *= RelativeActivityFactor;

            try
            {
                Log.Info("Zone Lock", ZoneService.GetZone_Info((ushort)zoneId).Name);
                HandleLockReward(realm, winnerRewardScale, message, zoneId);
            }
            catch (Exception e)
            {
                Log.Error("HandleLockReward", "Exception thrown: " + e);
            }

            TotalContribFromRenown = (ulong)(Tier * 50);
            PlayerContributions.Clear();

            PlayerContributions = new Dictionary <uint, ContributionInfo>();

            int arr;
            if (Constants.DoomsdaySwitch == 2)
            {
                arr = (int)pairing;
            }
            else
            {
                arr = Tier;
            }

            if (BattlefrontList.ActiveFronts[arr - 1] == this)
            {
                BattlefrontList.ActiveFronts[arr - 1] = null;
            }

            // This should be 2 to make it work correct with 3 open zones, codeword c4rr0t
            if (Constants.DoomsdaySwitch != 2)
            {
                int i = 0;
                foreach (IBattlefront b in BattlefrontList.Battlefronts[Tier - 1])
                {
                    if (i > 0)
                    {
                        ProximityBattlefront front = b as ProximityBattlefront;
                        if (front != this && !front.PairingLocked)
                        {
                            front.EvtInterface.AddEvent(front.SupplyLineReset, 1, 1);
                        }
                    }
                    i++;
                }
            }

            /*else
             * {
             *  foreach (ProximityBattlefront b in BattlefrontList.RegionManagers[arr - 1])
             *      if (b != this && !b.PairingLocked && b.pairing == pairing)
             *          //b.EvtInterface.AddEvent(b.SupplyLineReset, 1, 1);
             * }*/
            DefenderPopTooSmall = false;
            _totalMaxOrder      = 0;
            _totalMaxDestro     = 0;

            PairingDrawTime = 0;
        }
        public void LiftZoneLock(int zoneId, bool reset)
        {
            long _BOLockTime = (int)(10 * 60 * 1000 * TIMER_MODIFIER);

            #if (DEBUG)
            _BOLockTime = (1 * 60 * 1000);
            #endif

            PairingLocked = false;
            GraceDisabled = false;

            DefendingRealm = Realms.REALMS_REALM_NEUTRAL;

            if (Constants.DoomsdaySwitch > 0)
            {
                _battlefrontStatus.OpenZoneIndex      = Zones.FindIndex(z => z.ZoneId == zoneId);
                _battlefrontStatus.ActiveRegionOrZone = zoneId;
                WorldMgr.Database.SaveObject(_battlefrontStatus);
            }
            else
            {
                if (!reset)
                {
                    _battlefrontStatus.OpenZoneIndex      = Zones.FindIndex(z => z.ZoneId == zoneId);
                    _battlefrontStatus.ActiveRegionOrZone = zoneId;
                    WorldMgr.Database.SaveObject(_battlefrontStatus);
                }
            }

            _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
            _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 0;

            HeldObjectives[0] = 0;
            HeldObjectives[1] = 0;

            foreach (BattlefrontFlag flag in _Objectives)
            {
                if (flag.ZoneId == zoneId)
                {
                    flag.OpenObjective(Realms.REALMS_REALM_NEUTRAL, _BOLockTime);
                }
            }

            foreach (Keep keep in _Keeps)
            {
                if (keep.Info.ZoneId == zoneId)
                {
                    keep.NotifyPairingUnlocked();

                    foreach (KeepDoor door in keep.Doors)
                    {
                        door.GameObject?.SetAttackable(keep.KeepStatus != KeepStatus.KEEPSTATUS_LOCKED && CanAttackDoor(keep.Realm, keep.Info.ZoneId));
                    }
                }
            }

            // Where 0 = Destromost zone, and 2 = Ordermost zone
            int campaignProgress = Zones.FindIndex(z => z.ZoneId == zoneId);

            lock (Player._Players)
            {
                foreach (Player plr in Player._Players)
                {
                    if (!plr.ValidInTier(Tier, true))
                    {
                        continue;
                    }

                    plr.SendLocalizeString(Zones[campaignProgress].Name + " battlefield objectives will soon be open for capture!", ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT);
                    plr.SendLocalizeString(Zones[campaignProgress].Name + " battlefield objectives will soon be open for capture!", plr.Realm == Realms.REALMS_REALM_ORDER ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE, Localized_text.CHAT_TAG_DEFAULT);
                }
            }

            WorldMgr.SendCampaignStatus(null);
        }
        public void LockZone(Realms realm, int zoneId, bool announce, bool reset, bool noRewards = false)
        {
            Log.Debug("Battlefront.LockT4Zone", "Locking zone " + zoneId + " for " + realm);

            foreach (BattlefrontFlag flag in _Objectives)
            {
                if (flag.ZoneId == zoneId)
                {
                    flag.LockObjective(realm, announce);
                }
            }

            if (realm == Realms.REALMS_REALM_ORDER)
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 4;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 0;
            }
            else
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 4;
            }

            HeldObjectives[0] = 0;
            HeldObjectives[1] = 0;

            foreach (Keep keep in _Keeps)
            {
                if (keep.Info.ZoneId == zoneId)
                {
                    Realms targetRealm = keep.GetContestedRealm();
                    Dictionary <uint, ContributionInfo> contributors = GetContributorsFromRealm(targetRealm);

                    if (contributors.Count > 0 && !noRewards)
                    {
                        Log.Info("ProgressingBattlefront", $"Creating gold chest for {keep.Info.Name} for {contributors.Count} {(targetRealm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction")} contributors");
                        GoldChest.Create(Region, keep.Info.PQuest, ref contributors, targetRealm == realm ? WinnerShare : LoserShare);
                    }

                    keep.LockKeep(realm, announce, reset);
                }
            }

            if (!announce)
            {
                return;
            }

            DisableSupplies();

            // Where 0 = Destromost zone, and 2 = Ordermost zone
            int campaignProgress = Zones.FindIndex(z => z.ZoneId == zoneId);

            string message;
            float  winnerRewardScale;

            if (realm == Realms.REALMS_REALM_DESTRUCTION)
            {
                campaignProgress = 2 - campaignProgress;
            }

            switch (campaignProgress)
            {
            case 0:
                // The realm has captured the zone closest to the enemy fort, leave the last zone locked and give them a reward
                UpdateStateOfTheRealm();
                PairingLocked = true;

                    #if DEBUG
                EvtInterface.AddEvent(EndGrace, 90 * 1000, 1);
                    #else
                EvtInterface.AddEvent(EndGrace, 10 * 60 * 1000, 1);
                    #endif


                Log.Info("Battlefront.LockT4Zone", "Locked all of region " + Region.RegionId);

                winnerRewardScale = 1.25f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[0].Name + " has been liberated by the forces of Order! The forces of Destruction have been cleansed from this region, but the fighting continues on elsewhere!";
                }
                else
                {
                    message = Zones[2].Name + " has been conquered by the forces of Destruction! The forces of Order flee like cowards, but the fighting continues on elsewhere!";
                }

                LockingRealm = realm;

                WorldMgr.EvaluateT4CampaignStatus(Region.RegionId);
                break;

            case 1:
                // The realm has captured the middle zone, unlock zone closest to enemy fort.
                if (Constants.DoomsdaySwitch > 0)
                {
                    LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, true);
                }
                else
                {
                    LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, false);
                }

                winnerRewardScale = 1f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message        = Zones[1].Name + " has been reclaimed by the forces of Order! The forces of Destruction have retreated to " + Zones[0].Name + ", to build up for a renewed assault.";
                    DefendingRealm = Realms.REALMS_REALM_DESTRUCTION;
                }
                else
                {
                    message        = Zones[1].Name + " has been seized by the forces of Destruction! The forces of Order have fallen back to " + Zones[2].Name + " to make a last stand.";
                    DefendingRealm = Realms.REALMS_REALM_ORDER;
                }

                UpdateStateOfTheRealm();
                break;

            case 2:
                // The realm has recaptured the zone closest to their fort, unlock the middle zone
                if (Constants.DoomsdaySwitch > 0)
                {
                    LiftZoneLock(Zones[1].ZoneId, true);
                }
                else
                {
                    LiftZoneLock(Zones[1].ZoneId, false);
                }

                winnerRewardScale = 0.75f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[2].Name + " has been saved by the forces of Order! The forces of Destruction fall back to " + Zones[1].Name + "!";
                }
                else
                {
                    message = "The forces of Destruction tighten their grip on " + Zones[0].Name + ", and the forces of Order fall back to " + Zones[1].Name + "!";
                }

                DefendingRealm = Realms.REALMS_REALM_NEUTRAL;

                UpdateStateOfTheRealm();
                break;

            default:
                Log.Error("Battlefront.LockT4Zone", "The campaign progress was somehow at stage " + campaignProgress + ". This is not supposed to happen.");
                return;
            }

            VictoryPoints = 50;
            LastAnnouncedVictoryPoints = 50;

            WorldMgr.SendCampaignStatus(null);

            winnerRewardScale *= RelativeActivityFactor;

            try
            {
                Log.Info("Zone Lock", ZoneService.GetZone_Info((ushort)zoneId).Name);
                HandleLockReward(realm, winnerRewardScale, message, zoneId);
            }
            catch (Exception e)
            {
                Log.Error("HandleLockReward", "Exception thrown: " + e);
            }

            TotalContribFromRenown = (ulong)(Tier * 50);

            PlayerContributions.Clear();

            int arr;
            if (Constants.DoomsdaySwitch == 2)
            {
                arr = (int)pairing;
            }
            else
            {
                arr = Tier;
            }

            if (BattlefrontList.ActiveFronts[arr - 1] == this)
            {
                BattlefrontList.ActiveFronts[arr - 1] = null;
            }

            if (Constants.DoomsdaySwitch == 2)
            {
                foreach (Battlefront b in BattlefrontList.Battlefronts[Tier - 1])
                {
                    if (b != this && !b.PairingLocked && b.pairing == pairing)
                    {
                        b.EvtInterface.AddEvent(b.SupplyLineReset, 1, 1);
                    }
                }
            }
            else
            {
                foreach (Battlefront b in BattlefrontList.Battlefronts[Tier - 1])
                {
                    if (b != this && !b.PairingLocked)
                    {
                        b.EvtInterface.AddEvent(b.SupplyLineReset, 1, 1);
                    }
                }
            }
        }