/// <summary>
        /// Grants rewards for taking this battlefield objective from the enemy.
        /// </summary>
        /// <param name="capturingRealm"></param>
        public void GrantCaptureRewards(Realms capturingRealm)
        {
            if (State == StateFlags.ZoneLocked)
            {
                return;
            }

            var closePlayers = GetClosePlayers(capturingRealm);

            var contributionDefinition  = new ContributionDefinition();
            var activeBattleFrontStatus = BattleFront.GetActiveBattleFrontStatus();

            VictoryPoint VP = new VictoryPoint(0, 0);

            // Check RC is within range of this BO to award RP for.
            var destructionRealmCaptain = activeBattleFrontStatus.DestructionRealmCaptain;

            if (destructionRealmCaptain?.GetDistanceToObject(this) < 200)
            {
                destructionRealmCaptain?.AddRenown(150, false, RewardType.ObjectiveCapture,
                                                   "for being Realm Captain");
            }
            var orderRealmCaptain = activeBattleFrontStatus.OrderRealmCaptain;

            if (orderRealmCaptain?.GetDistanceToObject(this) < 200)
            {
                orderRealmCaptain?.AddRenown(150, false, RewardType.ObjectiveCapture,
                                             "for being Realm Captain");
            }

            switch (State)
            {
            case StateFlags.Contested:     // small tick
                VP = RewardManager.RewardCaptureTick(closePlayers, capturingRealm, Tier, Name, 1f, BORewardType.CAPTURING);
                lock (closePlayers)
                {
                    foreach (var closePlayer in closePlayers)
                    {
                        closePlayer.UpdatePlayerBountyEvent((byte)ContributionDefinitions.BO_TAKE_SMALL_TICK);
                    }
                }
                break;

            case StateFlags.Secure:     // big tick
                VP = RewardManager.RewardCaptureTick(closePlayers, capturingRealm, Tier, Name, 1f, BORewardType.CAPTURED);

                WorldMgr.UpperTierCampaignManager.GetActiveCampaign().VictoryPointProgress.UpdateStatus(WorldMgr.UpperTierCampaignManager.GetActiveCampaign());

                lock (closePlayers)
                {
                    foreach (var closePlayer in closePlayers)
                    {
                        closePlayer.UpdatePlayerBountyEvent((byte)ContributionDefinitions.BO_TAKE_BIG_TICK);

                        // is this player the group leader?
                        if (closePlayer.PriorityGroup?.GetLeader() == closePlayer)
                        {
                            closePlayer.UpdatePlayerBountyEvent((byte)ContributionDefinitions.GROUP_LEADER_BO_BIG_TICK);
                        }
                    }
                }
                break;

            case StateFlags.Locked:     // unlock tick
                VP = RewardManager.RewardCaptureTick(closePlayers, capturingRealm, Tier, Name, 1f, BORewardType.GUARDED);
                lock (closePlayers)
                {
                    foreach (var closePlayer in closePlayers)
                    {
                        // ContributionManagerInstance holds the long term values of contribution for a player.
                        closePlayer.UpdatePlayerBountyEvent((byte)ContributionDefinitions.BO_TAKE_UNLOCK_TICK);
                    }
                }

                break;

            default:
                break;
            }

            // Make sure VP dont go less than 0
            if (BattleFront.VictoryPointProgress.OrderVictoryPoints <= 0)
            {
                BattleFront.VictoryPointProgress.OrderVictoryPoints = 0;
            }

            if (BattleFront.VictoryPointProgress.DestructionVictoryPoints <= 0)
            {
                BattleFront.VictoryPointProgress.DestructionVictoryPoints = 0;
            }

            BattlefrontLogger.Trace($"{Name} Order VP:{BattleFront.VictoryPointProgress.OrderVictoryPoints} Dest VP:{BattleFront.VictoryPointProgress.DestructionVictoryPoints}");
        }
示例#2
0
        /// <summary>
        ///     Grants a small reward to all players in close range for defending.
        /// </summary>
        /// <remarks>Invoked in short periods of time</remarks>
        public VictoryPoint RewardCaptureTick(ISet <Player> playersWithinRange, Realms owningRealm, int tier, string objectiveName, float rewardScaleMultiplier, BORewardType boRewardType)
        {
            ushort influenceId;

            _logger.Trace($"Objective {objectiveName} has {playersWithinRange} players (realm:{owningRealm}) nearby");

            // Because of the Field of Glory buff, the XP value here is doubled.
            // The base reward in T4 is therefore 3000 XP.
            // Population scale factors can up this to 9000 if the region is full of people and then raise or lower it depending on population balance.
            var baseXp  = 0;
            var baseRp  = 0;
            var baseInf = 0;

            if (boRewardType == BORewardType.CAPTURING)
            {
                baseXp  = Program.Config.BOCapturingRewardXp;
                baseRp  = Program.Config.BOCapturingRewardRp;
                baseInf = Program.Config.BOCapturingRewardInf;
            }
            if (boRewardType == BORewardType.CAPTURED)
            {
                baseXp  = Program.Config.BOCapturedRewardXp;
                baseRp  = Program.Config.BOCapturedRewardRp;
                baseInf = Program.Config.BOCapturedRewardInf;
            }
            if (boRewardType == BORewardType.GUARDED)
            {
                baseXp  = Program.Config.BOGuardedRewardXp;
                baseRp  = Program.Config.BOGuardedRewardRp;
                baseInf = Program.Config.BOGuardedRewardInf;
            }

            foreach (var player in playersWithinRange)
            {
                // if the BattlefieldObjective is Neutral, allow rewards.
                if (owningRealm != Realms.REALMS_REALM_NEUTRAL)
                {
                    if (player.Realm != owningRealm || player.IsAFK || player.IsAutoAFK)
                    {
                        continue;
                    }
                }


                if (player.CurrentArea != null)
                {
                    if (player.Realm == Realms.REALMS_REALM_ORDER)
                    {
                        influenceId = (ushort)player.CurrentArea.OrderInfluenceId;
                    }
                    else
                    {
                        influenceId = (ushort)player.CurrentArea.DestroInfluenceId;
                    }

                    player.AddInfluence(influenceId, Math.Max((ushort)baseInf, (ushort)1));
                }

                Random rnd    = new Random();
                int    random = rnd.Next(-25, 25);
                var    xp     = (uint)Math.Max((baseXp * (1 + (random / 100))), 1);
                var    rr     = (uint)Math.Max((baseRp * (1 + (random / 100))), 1);

                player.AddXp(xp, false, false);
                player.AddRenown(rr, false, RewardType.ObjectiveCapture, objectiveName);

                _logger.Trace($"Player:{player.Name} ScaleMult:{rewardScaleMultiplier} XP:{xp} RR:{rr}");
            }

            VictoryPoint VP = new VictoryPoint(0, 0);

            switch (boRewardType)
            {
            case BORewardType.CAPTURING:                     // small tick
                if (owningRealm == Realms.REALMS_REALM_ORDER)
                {
                    VP.OrderVictoryPoints += 0;
                }
                else if (owningRealm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    VP.DestructionVictoryPoints += 0;
                }
                break;

            case BORewardType.CAPTURED:                     // big tick
                if (owningRealm == Realms.REALMS_REALM_ORDER)
                {
                    VP.OrderVictoryPoints       += 50;
                    VP.DestructionVictoryPoints -= 50;
                }
                else if (owningRealm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    VP.DestructionVictoryPoints += 50;
                    VP.OrderVictoryPoints       -= 50;
                }

                break;

            case BORewardType.GUARDED:                     // small tick
                if (owningRealm == Realms.REALMS_REALM_ORDER)
                {
                    VP.OrderVictoryPoints += 0;
                }
                else if (owningRealm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    VP.DestructionVictoryPoints += 0;
                }
                break;

            default:
                break;
            }
            return(VP);
        }