コード例 #1
0
        protected BodyProperties GetBodyProperties(
            MissionPeer missionPeer,
            BasicCultureObject cultureLimit)
        {
            NetworkCommunicator networkPeer = missionPeer.GetNetworkPeer();

            if (networkPeer != null)
            {
                return(networkPeer.PlayerConnectionInfo.GetParameter <PlayerData>("PlayerData").BodyProperties);
            }
            Team team = missionPeer.Team;
            BasicCharacterObject troopCharacter = MultiplayerClassDivisions.GetMPHeroClasses(cultureLimit).ToList <MultiplayerClassDivisions.MPHeroClass>().GetRandomElement <MultiplayerClassDivisions.MPHeroClass>().TroopCharacter;
            MatrixFrame          spawnFrame     = this.SpawnComponent.GetSpawnFrame(team, troopCharacter.HasMount(), true);
            AgentBuildData       agentBuildData = new AgentBuildData(troopCharacter);

            agentBuildData.Team(team);
            agentBuildData.InitialFrame(spawnFrame);
            agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(troopCharacter));
            agentBuildData.EquipmentSeed(this.MissionLobbyComponent.GetRandomFaceSeedForCharacter(troopCharacter));
            agentBuildData.ClothingColor1(team.Side == BattleSideEnum.Attacker ? cultureLimit.Color : cultureLimit.ClothAlternativeColor);
            agentBuildData.ClothingColor2(team.Side == BattleSideEnum.Attacker ? cultureLimit.Color2 : cultureLimit.ClothAlternativeColor2);
            agentBuildData.IsFemale(troopCharacter.IsFemale);
            agentBuildData.Equipment(Equipment.GetRandomEquipmentElements(troopCharacter, !(Game.Current.GameType is MultiplayerGame), seed: agentBuildData.AgentEquipmentSeed));
            agentBuildData.BodyProperties(BodyProperties.GetRandomBodyProperties(agentBuildData.AgentIsFemale, troopCharacter.GetBodyPropertiesMin(), troopCharacter.GetBodyPropertiesMax(), (int)agentBuildData.AgentOverridenSpawnEquipment.HairCoverType, agentBuildData.AgentEquipmentSeed, troopCharacter.HairTags, troopCharacter.BeardTags, troopCharacter.TattooTags));
            return(agentBuildData.AgentBodyProperties);
        }
        private void OnAllAgentsFromPeerSpawnedFromVisuals(MissionPeer peer)
        {
            bool flag         = peer.Team == this.Mission.AttackerTeam;
            Team defenderTeam = this.Mission.DefenderTeam;

            MultiplayerClassDivisions.MPHeroClass mpHeroClass = MultiplayerClassDivisions.GetMPHeroClasses(MBObjectManager.Instance.GetObject <BasicCultureObject>(flag ? MultiplayerOptions.OptionType.CultureTeam1.GetStrValue() : MultiplayerOptions.OptionType.CultureTeam2.GetStrValue())).ElementAt <MultiplayerClassDivisions.MPHeroClass>(peer.SelectedTroopIndex);
            this.GameMode.ChangeCurrentGoldForPeer(peer, this.GameMode.GetCurrentGoldForPeer(peer) - mpHeroClass.TroopCost);
        }
コード例 #3
0
            public override void Deserialize(MBObjectManager objectManager, XmlNode node)
            {
                base.Deserialize(objectManager, node);
                this.HeroCharacter  = MultiplayerClassDivisions.GetMPCharacter(node.Attributes["hero"].Value);
                this.TroopCharacter = MultiplayerClassDivisions.GetMPCharacter(node.Attributes["troop"].Value);
                string stringId = node.Attributes["banner_bearer"]?.Value;

                if (stringId != null)
                {
                    this.BannerBearerCharacter = MultiplayerClassDivisions.GetMPCharacter(stringId);
                }
                this.HeroIdleAnim       = node.Attributes["hero_idle_anim"]?.Value;
                this.HeroMountIdleAnim  = node.Attributes["hero_mount_idle_anim"]?.Value;
                this.TroopIdleAnim      = node.Attributes["troop_idle_anim"]?.Value;
                this.TroopMountIdleAnim = node.Attributes["troop_mount_idle_anim"]?.Value;
                this.Culture            = this.HeroCharacter.Culture;
                this.ClassGroup         = new MultiplayerClassDivisions.MPHeroClassGroup(this.HeroCharacter.DefaultFormationClass.GetName());
                this.TroopMultiplier    = (float)Convert.ToDouble(node.Attributes["multiplier"].Value);
                this.TroopCost          = Convert.ToInt32(node.Attributes["cost"].Value);
                this.ArmorValue         = Convert.ToInt32(node.Attributes["armor"].Value);
                this.Health             = 100;
                this.MeleeAI            = 50;
                this.RangedAI           = 50;
                XmlNode attribute = (XmlNode)node.Attributes["hitpoints"];

                if (attribute != null)
                {
                    this.Health = Convert.ToInt32(attribute.Value);
                }
                this.MovementSpeedMultiplier       = (float)Convert.ToDouble(node.Attributes["movement_speed"].Value);
                this.CombatMovementSpeedMultiplier = (float)Convert.ToDouble(node.Attributes["combat_movement_speed"].Value);
                this.TopSpeedReachDuration         = (float)Convert.ToDouble(node.Attributes["acceleration"].Value);
                this.MeleeAI  = Convert.ToInt32(node.Attributes["melee_ai"].Value);
                this.RangedAI = Convert.ToInt32(node.Attributes["ranged_ai"].Value);
                TargetIconType result;

                if (Enum.TryParse <TargetIconType>(node.Attributes["icon"].Value, true, out result))
                {
                    this.IconType = result;
                }
                foreach (XmlNode childNode1 in node.ChildNodes)
                {
                    if (childNode1.NodeType != XmlNodeType.Comment && childNode1.Name == "Perks")
                    {
                        this._perks = new List <IReadOnlyPerkObject>();
                        foreach (XmlNode childNode2 in childNode1.ChildNodes)
                        {
                            if (childNode2.NodeType != XmlNodeType.Comment)
                            {
                                this._perks.Add(MPPerkObject.Deserialize(childNode2));
                            }
                        }
                    }
                }
            }
コード例 #4
0
        public static List <List <IReadOnlyPerkObject> > GetAvailablePerksForPeer(
            MissionPeer missionPeer)
        {
            List <List <IReadOnlyPerkObject> > readOnlyPerkObjectListList = new List <List <IReadOnlyPerkObject> >();

            if (missionPeer?.Team == null)
            {
                return(readOnlyPerkObjectListList);
            }
            MultiplayerClassDivisions.MPHeroClass heroClassForPeer = MultiplayerClassDivisions.GetMPHeroClassForPeer(missionPeer);
            for (int index = 0; index < 3; ++index)
            {
                readOnlyPerkObjectListList.Add(heroClassForPeer.GetAllAvailablePerksForListIndex(index).ToList <IReadOnlyPerkObject>());
            }
            return(readOnlyPerkObjectListList);
        }
コード例 #5
0
 private AgentDrivenProperties InitializeHumanAgentStats(
     Agent agent,
     AgentDrivenProperties agentDrivenProperties,
     AgentBuildData agentBuildData)
 {
     MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character);
     if (classForCharacter != null)
     {
         this.FillAgentStatsFromData(ref agentDrivenProperties, classForCharacter, agentBuildData?.AgentMissionPeer, agentBuildData?.OwningAgentMissionPeer);
         agentDrivenProperties.SetStat(DrivenProperty.UseRealisticBlocking, MultiplayerOptions.OptionType.UseRealisticBlocking.GetBoolValue() ? 1f : 0.0f);
     }
     agent.BaseHealthLimit = classForCharacter == null ? 100f : (float)classForCharacter.Health;
     agent.HealthLimit     = agent.BaseHealthLimit;
     agent.Health          = agent.HealthLimit;
     return(agentDrivenProperties);
 }
コード例 #6
0
        public static MultiplayerClassDivisions.MPHeroClass GetMPHeroClassForPeer(
            MissionPeer peer)
        {
            Team team  = peer.Team;
            bool flag1 = team == Mission.Current.AttackerTeam;
            bool flag2 = team == Mission.Current.DefenderTeam;

            if (team == null || !flag1 && !flag2 || peer.SelectedTroopIndex < 0 && peer.ControlledAgent == null)
            {
                return((MultiplayerClassDivisions.MPHeroClass)null);
            }
            if (peer.ControlledAgent != null)
            {
                return(MultiplayerClassDivisions.GetMPHeroClassForCharacter(peer.ControlledAgent.Character));
            }
            return(peer.SelectedTroopIndex >= 0 ? MultiplayerClassDivisions.GetMPHeroClasses(MBObjectManager.Instance.GetObject <BasicCultureObject>(flag1 ? MultiplayerOptions.OptionType.CultureTeam1.GetStrValue() : MultiplayerOptions.OptionType.CultureTeam2.GetStrValue())).ToList <MultiplayerClassDivisions.MPHeroClass>()[peer.SelectedTroopIndex] : (MultiplayerClassDivisions.MPHeroClass)null);
        }
コード例 #7
0
        protected void SpawnBot(Team agentTeam, BasicCultureObject cultureLimit)
        {
            BasicCharacterObject troopCharacter = MultiplayerClassDivisions.GetMPHeroClasses(cultureLimit).ToList <MultiplayerClassDivisions.MPHeroClass>().GetRandomElement <MultiplayerClassDivisions.MPHeroClass>().TroopCharacter;
            MatrixFrame          spawnFrame     = this.SpawnComponent.GetSpawnFrame(agentTeam, troopCharacter.HasMount(), true);
            AgentBuildData       agentBuildData = new AgentBuildData(troopCharacter);

            agentBuildData.Team(agentTeam);
            agentBuildData.InitialFrame(spawnFrame);
            agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(troopCharacter));
            agentBuildData.EquipmentSeed(this.MissionLobbyComponent.GetRandomFaceSeedForCharacter(troopCharacter));
            agentBuildData.ClothingColor1(agentTeam.Side == BattleSideEnum.Attacker ? cultureLimit.Color : cultureLimit.ClothAlternativeColor);
            agentBuildData.ClothingColor2(agentTeam.Side == BattleSideEnum.Attacker ? cultureLimit.Color2 : cultureLimit.ClothAlternativeColor2);
            agentBuildData.IsFemale(troopCharacter.IsFemale);
            agentBuildData.Equipment(Equipment.GetRandomEquipmentElements(troopCharacter, !(Game.Current.GameType is MultiplayerGame), seed: agentBuildData.AgentEquipmentSeed));
            agentBuildData.BodyProperties(BodyProperties.GetRandomBodyProperties(agentBuildData.AgentIsFemale, troopCharacter.GetBodyPropertiesMin(), troopCharacter.GetBodyPropertiesMax(), (int)agentBuildData.AgentOverridenSpawnEquipment.HairCoverType, agentBuildData.AgentEquipmentSeed, troopCharacter.HairTags, troopCharacter.BeardTags, troopCharacter.TattooTags));
            Agent agent = this.Mission.SpawnAgent(agentBuildData);

            agent.AddComponent((AgentComponent) new AgentAIStateFlagComponent(agent));
            agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed);
        }
コード例 #8
0
        private void UpdateTeamPowerBasedOnGold(Team team)
        {
            int num1 = 0;
            int num2 = 0;

            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                if (peer.Team != null && peer.Team.Side == team.Side)
                {
                    int gold = peer.GetComponent <FlagDominationMissionRepresentative>().Gold;
                    if (gold >= 100)
                    {
                        num2 += gold;
                    }
                    if (peer.ControlledAgent != null && peer.ControlledAgent.IsActive())
                    {
                        MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(peer.ControlledAgent.Character);
                        num2 += classForCharacter.TroopCost;
                    }
                    ++num1;
                }
            }
            int num3 = num1 + (team.Side == BattleSideEnum.Attacker ? MultiplayerOptions.OptionType.NumberOfBotsTeam1.GetIntValue() : MultiplayerOptions.OptionType.NumberOfBotsTeam2.GetIntValue());

            foreach (Agent activeAgent in team.ActiveAgents)
            {
                if (activeAgent.MissionPeer == null)
                {
                    num2 += 300;
                }
            }
            int   num4 = num3 * 300;
            float num5 = Math.Min(1f, num4 == 0 ? 0.0f : (float)num2 / (float)num4);
            Action <BattleSideEnum, float> powerChangedEvent = this.OnTeamPowerChangedEvent;

            if (powerChangedEvent == null)
            {
                return;
            }
            powerChangedEvent(team.Side, num5);
        }
コード例 #9
0
        public override bool CheckForRoundEnd()
        {
            if ((double)Math.Abs(this._morale) >= 1.0)
            {
                return(true);
            }
            bool flag1 = this.Mission.AttackerTeam.ActiveAgents.Count > 0;
            bool flag2 = this.Mission.DefenderTeam.ActiveAgents.Count > 0;

            if (flag1 & flag2)
            {
                return(false);
            }
            if (!this.SpawnComponent.AreAgentsSpawning())
            {
                return(true);
            }
            bool[] flagArray = new bool[2];
            if (this.UseGold())
            {
                foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers)
                {
                    MissionPeer component = networkPeer.GetComponent <MissionPeer>();
                    if (component?.Team != null && component.Team.Side != BattleSideEnum.None && !flagArray[(int)component.Team.Side])
                    {
                        string strValue = MultiplayerOptions.OptionType.CultureTeam1.GetStrValue();
                        if (component.Team.Side != BattleSideEnum.Attacker)
                        {
                            strValue = MultiplayerOptions.OptionType.CultureTeam2.GetStrValue();
                        }
                        if (this.GetCurrentGoldForPeer(component) >= MultiplayerClassDivisions.GetMinimumTroopCost(MBObjectManager.Instance.GetObject <BasicCultureObject>(strValue)))
                        {
                            flagArray[(int)component.Team.Side] = true;
                        }
                    }
                }
            }
            return(!flag1 && !flagArray[1] || !flag2 && !flagArray[0]);
        }
コード例 #10
0
        protected override void OnInitialize()
        {
            Game currentGame = this.CurrentGame;

            currentGame.FirstInitialize(false);
            if (!GameNetwork.IsDedicatedServer)
            {
                this.AddGameTexts();
            }
            IGameStarter gameStarter = (IGameStarter) new BasicGameStarter();

            this.AddGameModels(gameStarter);
            this.GameManager.OnGameStart(this.CurrentGame, gameStarter);
            currentGame.SecondInitialize(gameStarter.Models);
            currentGame.CreateGameManager();
            currentGame.ThirdInitialize();
            this.GameManager.BeginGameStart(this.CurrentGame);
            currentGame.CreateObjects();
            currentGame.InitializeDefaultGameObjects();
            currentGame.LoadBasicFiles(false);
            this.ObjectManager.LoadXML("Items");
            this.ObjectManager.LoadXML("MPCharacters");
            this.ObjectManager.LoadXML("BasicCultures");
            currentGame.CreateLists();
            this.ObjectManager.LoadXML("MPClassDivisions");
            this.ObjectManager.ClearEmptyObjects();
            MultiplayerClassDivisions.Initialize();
            BadgeManager.LoadFromXml(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/mpbadges.xml");
            this.GameManager.OnCampaignStart(this.CurrentGame, (object)null);
            this.GameManager.OnAfterCampaignStart(this.CurrentGame);
            this.GameManager.OnGameInitializationFinished(this.CurrentGame);
            this.CurrentGame.AddGameHandler <ChatBox>();
            if (!GameNetwork.IsDedicatedServer)
            {
                return;
            }
            this.CurrentGame.AddGameHandler <MultiplayerGameLogger>();
        }
        protected override void SpawnAgents()
        {
            BasicCultureObject cultureLimit1 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam1.GetStrValue());
            BasicCultureObject cultureLimit2 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam2.GetStrValue());

            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                NetworkCommunicator networkPeer = peer.GetNetworkPeer();
                if (networkPeer.IsSynchronized && peer.ControlledAgent == null && (!peer.HasSpawnedAgentVisuals && peer.Team != null) && (peer.Team != this.Mission.SpectatorTeam && peer.SpawnTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission))))
                {
                    BasicCultureObject basicCultureObject = peer.Team.Side == BattleSideEnum.Attacker ? cultureLimit1 : cultureLimit2;
                    MultiplayerClassDivisions.MPHeroClass heroClassForPeer = MultiplayerClassDivisions.GetMPHeroClassForPeer(peer);
                    if (heroClassForPeer == null || heroClassForPeer.TroopCost > this.GameMode.GetCurrentGoldForPeer(peer))
                    {
                        if (peer.SelectedTroopIndex != 0)
                        {
                            peer.SelectedTroopIndex = 0;
                            GameNetwork.BeginBroadcastModuleEvent();
                            GameNetwork.WriteMessage((GameNetworkMessage) new UpdateSelectedTroopIndex(networkPeer, 0));
                            GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, networkPeer);
                        }
                    }
                    else
                    {
                        BasicCharacterObject heroCharacter = heroClassForPeer.HeroCharacter;
                        Equipment            equipment     = heroCharacter.Equipment.Clone();
                        IEnumerable <(EquipmentIndex, EquipmentElement)> alternativeEquipments = MPPerkObject.GetOnSpawnPerkHandler(peer)?.GetAlternativeEquipments(true);
                        if (alternativeEquipments != null)
                        {
                            foreach ((EquipmentIndex, EquipmentElement)tuple in alternativeEquipments)
                            {
                                equipment[tuple.Item1] = tuple.Item2;
                            }
                        }
                        AgentBuildData agentBuildData = new AgentBuildData(heroCharacter);
                        agentBuildData.MissionPeer(peer);
                        agentBuildData.Equipment(equipment);
                        agentBuildData.Team(peer.Team);
                        agentBuildData.IsFemale(peer.Peer.IsFemale);
                        agentBuildData.BodyProperties(this.GetBodyProperties(peer, peer.Team == this.Mission.AttackerTeam ? cultureLimit1 : cultureLimit2));
                        agentBuildData.VisualsIndex(0);
                        agentBuildData.ClothingColor1(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color : basicCultureObject.ClothAlternativeColor);
                        agentBuildData.ClothingColor2(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color2 : basicCultureObject.ClothAlternativeColor2);
                        agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(heroCharacter));
                        if (this.GameMode.ShouldSpawnVisualsForServer(networkPeer))
                        {
                            this.AgentVisualSpawnComponent.SpawnAgentVisualsForPeer(peer, agentBuildData, peer.SelectedTroopIndex);
                        }
                        this.GameMode.HandleAgentVisualSpawning(networkPeer, agentBuildData);
                    }
                }
            }
            if (this.Mission.AttackerTeam != null)
            {
                int num = 0;
                foreach (Agent activeAgent in this.Mission.AttackerTeam.ActiveAgents)
                {
                    if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                    {
                        ++num;
                    }
                }
                if (num < MultiplayerOptions.OptionType.NumberOfBotsTeam1.GetIntValue())
                {
                    this.SpawnBot(this.Mission.AttackerTeam, cultureLimit1);
                }
            }
            if (this.Mission.DefenderTeam == null)
            {
                return;
            }
            int num1 = 0;

            foreach (Agent activeAgent in this.Mission.DefenderTeam.ActiveAgents)
            {
                if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                {
                    ++num1;
                }
            }
            if (num1 >= MultiplayerOptions.OptionType.NumberOfBotsTeam2.GetIntValue())
            {
                return;
            }
            this.SpawnBot(this.Mission.DefenderTeam, cultureLimit2);
        }
コード例 #12
0
        private void OnRoundEnd()
        {
            foreach (FlagCapturePoint allCapturePoint in this.AllCapturePoints)
            {
                if (!allCapturePoint.IsDeactivated)
                {
                    allCapturePoint.SetMoveNone();
                }
            }
            RoundEndReason roundEndReason = RoundEndReason.Invalid;
            bool           flag1          = (double)this.RoundController.RemainingRoundTime <= 0.0 && !this.CheckIfOvertime();
            int            num1           = -1;

            for (int index = 0; index < 2; ++index)
            {
                int num2 = index * 2 - 1;
                if (flag1 && (double)num2 * (double)this._morale > 0.0 || !flag1 && (double)num2 * (double)this._morale >= 1.0)
                {
                    num1 = index;
                    break;
                }
            }
            CaptureTheFlagCaptureResultEnum roundResult = CaptureTheFlagCaptureResultEnum.NotCaptured;

            if (num1 >= 0)
            {
                roundResult = num1 == 0 ? CaptureTheFlagCaptureResultEnum.DefendersWin : CaptureTheFlagCaptureResultEnum.AttackersWin;
                this.RoundController.RoundWinner = num1 == 0 ? BattleSideEnum.Defender : BattleSideEnum.Attacker;
                roundEndReason = flag1 ? RoundEndReason.RoundTimeEnded : RoundEndReason.GameModeSpecificEnded;
            }
            else
            {
                bool flag2 = this.Mission.AttackerTeam.ActiveAgents.Count > 0;
                bool flag3 = this.Mission.DefenderTeam.ActiveAgents.Count > 0;
                if (flag2 & flag3)
                {
                    if ((double)this._morale > 0.0)
                    {
                        roundResult = CaptureTheFlagCaptureResultEnum.AttackersWin;
                        this.RoundController.RoundWinner = BattleSideEnum.Attacker;
                    }
                    else if ((double)this._morale < 0.0)
                    {
                        roundResult = CaptureTheFlagCaptureResultEnum.DefendersWin;
                        this.RoundController.RoundWinner = BattleSideEnum.Defender;
                    }
                    else
                    {
                        roundResult = CaptureTheFlagCaptureResultEnum.Draw;
                        this.RoundController.RoundWinner = BattleSideEnum.None;
                    }
                    roundEndReason = RoundEndReason.RoundTimeEnded;
                }
                else if (flag2)
                {
                    roundResult = CaptureTheFlagCaptureResultEnum.AttackersWin;
                    this.RoundController.RoundWinner = BattleSideEnum.Attacker;
                    roundEndReason = RoundEndReason.SideDepleted;
                }
                else if (flag3)
                {
                    roundResult = CaptureTheFlagCaptureResultEnum.DefendersWin;
                    this.RoundController.RoundWinner = BattleSideEnum.Defender;
                    roundEndReason = RoundEndReason.SideDepleted;
                }
                else
                {
                    foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers)
                    {
                        MissionPeer component = networkPeer.GetComponent <MissionPeer>();
                        if (component?.Team != null && component.Team.Side != BattleSideEnum.None)
                        {
                            string strValue = MultiplayerOptions.OptionType.CultureTeam1.GetStrValue();
                            if (component.Team.Side != BattleSideEnum.Attacker)
                            {
                                strValue = MultiplayerOptions.OptionType.CultureTeam2.GetStrValue();
                            }
                            if (this.GetCurrentGoldForPeer(component) >= MultiplayerClassDivisions.GetMinimumTroopCost(MBObjectManager.Instance.GetObject <BasicCultureObject>(strValue)))
                            {
                                this.RoundController.RoundWinner = component.Team.Side;
                                roundEndReason = RoundEndReason.SideDepleted;
                                roundResult    = component.Team.Side == BattleSideEnum.Attacker ? CaptureTheFlagCaptureResultEnum.AttackersWin : CaptureTheFlagCaptureResultEnum.DefendersWin;
                                break;
                            }
                        }
                    }
                }
            }
            if (roundResult == CaptureTheFlagCaptureResultEnum.NotCaptured)
            {
                return;
            }
            this.RoundController.RoundEndReason = roundEndReason;
            this.HandleRoundEnd(roundResult);
        }
コード例 #13
0
        public virtual void OnTick(float dt)
        {
            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                if (peer.GetNetworkPeer().IsSynchronized&& peer.ControlledAgent == null && (peer.HasSpawnedAgentVisuals && !this.CanUpdateSpawnEquipment(peer)))
                {
                    BasicCultureObject basicCultureObject1 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam1.GetStrValue());
                    BasicCultureObject basicCultureObject2 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam2.GetStrValue());
                    MultiplayerClassDivisions.MPHeroClass heroClassForPeer = MultiplayerClassDivisions.GetMPHeroClassForPeer(peer);
                    MPPerkObject.MPOnSpawnPerkHandler     spawnPerkHandler = MPPerkObject.GetOnSpawnPerkHandler(peer);
                    int  num1  = 0;
                    bool flag1 = false;
                    if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() > 0 && (this.GameMode.WarmupComponent == null || !this.GameMode.WarmupComponent.IsInWarmup))
                    {
                        num1 = MPPerkObject.GetTroopCount(heroClassForPeer, spawnPerkHandler);
                        foreach (MPPerkObject selectedPerk in (IEnumerable <MPPerkObject>)peer.SelectedPerks)
                        {
                            if (selectedPerk.HasBannerBearer)
                            {
                                flag1 = true;
                                break;
                            }
                        }
                    }
                    if (num1 > 0)
                    {
                        num1 = (int)((double)num1 * (double)this.GameMode.GetTroopNumberMultiplierForMissingPlayer(peer));
                    }
                    int num2 = num1 + (flag1 ? 2 : 1);
                    IEnumerable <(EquipmentIndex, EquipmentElement)> alternativeEquipments = spawnPerkHandler?.GetAlternativeEquipments(false);
                    for (int index = 0; index < num2; ++index)
                    {
                        bool isPlayer = index == 0;
                        BasicCharacterObject basicCharacterObject = isPlayer ? heroClassForPeer.HeroCharacter : (!flag1 || index != 1 ? heroClassForPeer.TroopCharacter : heroClassForPeer.BannerBearerCharacter);
                        AgentBuildData       agentBuildData       = new AgentBuildData(basicCharacterObject);
                        if (isPlayer)
                        {
                            agentBuildData.MissionPeer(peer);
                        }
                        else
                        {
                            agentBuildData.OwningMissionPeer(peer);
                        }
                        agentBuildData.VisualsIndex(index);
                        Equipment equipment = isPlayer ? basicCharacterObject.Equipment.Clone() : Equipment.GetRandomEquipmentElements(basicCharacterObject, false, seed: MBRandom.RandomInt());
                        IEnumerable <(EquipmentIndex, EquipmentElement)> valueTuples = isPlayer ? spawnPerkHandler?.GetAlternativeEquipments(true) : alternativeEquipments;
                        if (valueTuples != null)
                        {
                            foreach ((EquipmentIndex, EquipmentElement)valueTuple in valueTuples)
                            {
                                equipment[valueTuple.Item1] = valueTuple.Item2;
                            }
                        }
                        agentBuildData.Equipment(equipment);
                        agentBuildData.Team(peer.Team);
                        agentBuildData.Formation(peer.ControlledFormation);
                        agentBuildData.IsFemale(isPlayer ? peer.Peer.IsFemale : basicCharacterObject.IsFemale);
                        agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(basicCharacterObject));
                        BasicCultureObject basicCultureObject3 = peer.Team == this.Mission.AttackerTeam ? basicCultureObject1 : basicCultureObject2;
                        if (isPlayer)
                        {
                            agentBuildData.BodyProperties(this.GetBodyProperties(peer, peer.Team == this.Mission.AttackerTeam ? basicCultureObject1 : basicCultureObject2));
                        }
                        else
                        {
                            agentBuildData.EquipmentSeed(this.MissionLobbyComponent.GetRandomFaceSeedForCharacter(basicCharacterObject, agentBuildData.AgentVisualsIndex));
                            agentBuildData.BodyProperties(BodyProperties.GetRandomBodyProperties(agentBuildData.AgentIsFemale, basicCharacterObject.GetBodyPropertiesMin(), basicCharacterObject.GetBodyPropertiesMax(), (int)agentBuildData.AgentOverridenSpawnEquipment.HairCoverType, agentBuildData.AgentEquipmentSeed, basicCharacterObject.HairTags, basicCharacterObject.BeardTags, basicCharacterObject.TattooTags));
                        }
                        agentBuildData.ClothingColor1(peer.Team == this.Mission.AttackerTeam ? basicCultureObject3.Color : basicCultureObject3.ClothAlternativeColor);
                        agentBuildData.ClothingColor2(peer.Team == this.Mission.AttackerTeam ? basicCultureObject3.Color2 : basicCultureObject3.ClothAlternativeColor2);
                        Banner banner = new Banner(peer.Peer.BannerCode, peer.Team.Color, peer.Team.Color2);
                        agentBuildData.Banner(banner);
                        if (peer.ControlledFormation != null && peer.ControlledFormation.Banner == null)
                        {
                            peer.ControlledFormation.Banner = banner;
                        }
                        SpawnComponent   spawnComponent   = this.SpawnComponent;
                        Team             team             = peer.Team;
                        EquipmentElement equipmentElement = equipment[EquipmentIndex.ArmorItemEndSlot];
                        int         num3       = equipmentElement.Item != null ? 1 : 0;
                        int         num4       = peer.SpawnCountThisRound == 0 ? 1 : 0;
                        MatrixFrame spawnFrame = spawnComponent.GetSpawnFrame(team, num3 != 0, num4 != 0);
                        if (!spawnFrame.IsIdentity)
                        {
                            MatrixFrame matrixFrame       = spawnFrame;
                            MatrixFrame?agentInitialFrame = agentBuildData.AgentInitialFrame;
                            if ((agentInitialFrame.HasValue ? (matrixFrame != agentInitialFrame.GetValueOrDefault() ? 1 : 0) : 1) != 0)
                            {
                                agentBuildData.InitialFrame(spawnFrame);
                            }
                        }
                        if (peer.ControlledAgent != null && !isPlayer)
                        {
                            MatrixFrame frame = peer.ControlledAgent.Frame;
                            frame.rotation.OrthonormalizeAccordingToForwardAndKeepUpAsZAxis();
                            MatrixFrame matrixFrame = frame;
                            matrixFrame.origin -= matrixFrame.rotation.f.NormalizedCopy() * 3.5f;
                            Mat3 rotation = matrixFrame.rotation;
                            rotation.MakeUnit();
                            equipmentElement = basicCharacterObject.Equipment[EquipmentIndex.ArmorItemEndSlot];
                            bool flag2 = !equipmentElement.IsEmpty;
                            int  num5  = Math.Min(num2, 10);
                            List <WorldFrame> formationCreation = Formation.GetFormationFramesForBeforeFormationCreation((float)((double)num5 * (double)Formation.GetDefaultUnitDiameter(flag2) + (double)(num5 - 1) * (double)Formation.GetDefaultMinimumInterval(flag2)), num2, flag2, new WorldPosition(Mission.Current.Scene, matrixFrame.origin), rotation);
                            agentBuildData.InitialFrame(formationCreation[index - 1].ToGroundMatrixFrame());
                        }
                        Agent agent = this.Mission.SpawnAgent(agentBuildData, true);
                        agent.AddComponent((AgentComponent) new MPPerksAgentComponent(agent));
                        agent.MountAgent?.UpdateAgentProperties();
                        float num6 = spawnPerkHandler != null?spawnPerkHandler.GetHitpoints(isPlayer) : 0.0f;

                        agent.HealthLimit += num6;
                        agent.Health       = agent.HealthLimit;
                        agent.AddComponent((AgentComponent) new AgentAIStateFlagComponent(agent));
                        if (!isPlayer)
                        {
                            agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed);
                        }
                        agent.WieldInitialWeapons();
                        if (isPlayer)
                        {
                            Action <MissionPeer> spawnedFromVisuals = this.OnPeerSpawnedFromVisuals;
                            if (spawnedFromVisuals != null)
                            {
                                spawnedFromVisuals(peer);
                            }
                        }
                    }
                    ++peer.SpawnCountThisRound;
                    Action <MissionPeer> spawnedFromVisuals1 = this.OnAllAgentsFromPeerSpawnedFromVisuals;
                    if (spawnedFromVisuals1 != null)
                    {
                        spawnedFromVisuals1(peer);
                    }
                    this.AgentVisualSpawnComponent.RemoveAgentVisuals(peer, true);
                    MPPerkObject.GetPerkHandler(peer)?.OnEvent(MPPerkCondition.PerkEventFlags.SpawnEnd);
                }
            }
            if (this.IsSpawningEnabled || !this.IsRoundInProgress())
            {
                return;
            }
            if ((double)this.SpawningDelayTimer >= (double)this.SpawningEndDelay && !this._hasCalledSpawningEnded)
            {
                Mission.Current.AllowAiTicking = true;
                if (this.OnSpawningEnded != null)
                {
                    this.OnSpawningEnded();
                }
                this._hasCalledSpawningEnded = true;
            }
            this.SpawningDelayTimer += dt;
        }
コード例 #14
0
        protected override void SpawnAgents()
        {
            BasicCultureObject cultureLimit1 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam1.GetStrValue());
            BasicCultureObject cultureLimit2 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam2.GetStrValue());

            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                if (peer.GetNetworkPeer().IsSynchronized&& peer.ControlledAgent == null && (!peer.HasSpawnedAgentVisuals && peer.Team != null) && (peer.Team != this.Mission.SpectatorTeam && peer.SpawnTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission))))
                {
                    IAgentVisual       agentVisualForPeer = peer.GetAgentVisualForPeer(0);
                    BasicCultureObject basicCultureObject = peer.Team.Side == BattleSideEnum.Attacker ? cultureLimit1 : cultureLimit2;
                    int num = peer.SelectedTroopIndex;
                    IEnumerable <MultiplayerClassDivisions.MPHeroClass> mpHeroClasses = MultiplayerClassDivisions.GetMPHeroClasses(basicCultureObject);
                    MultiplayerClassDivisions.MPHeroClass mpHeroClass = num < 0 ? (MultiplayerClassDivisions.MPHeroClass)null : mpHeroClasses.ElementAt <MultiplayerClassDivisions.MPHeroClass>(num);
                    if (mpHeroClass == null && num < 0)
                    {
                        mpHeroClass = mpHeroClasses.First <MultiplayerClassDivisions.MPHeroClass>();
                        num         = 0;
                    }
                    BasicCharacterObject heroCharacter = mpHeroClass.HeroCharacter;
                    Equipment            equipment     = heroCharacter.Equipment.Clone();
                    IEnumerable <(EquipmentIndex, EquipmentElement)> alternativeEquipments = MPPerkObject.GetOnSpawnPerkHandler(peer)?.GetAlternativeEquipments(true);
                    if (alternativeEquipments != null)
                    {
                        foreach ((EquipmentIndex, EquipmentElement)tuple in alternativeEquipments)
                        {
                            equipment[tuple.Item1] = tuple.Item2;
                        }
                    }
                    AgentBuildData agentBuildData = new AgentBuildData(heroCharacter);
                    agentBuildData.MissionPeer(peer);
                    agentBuildData.Equipment(equipment);
                    agentBuildData.Team(peer.Team);
                    MatrixFrame frame;
                    if (agentVisualForPeer == null)
                    {
                        frame = this.SpawnComponent.GetSpawnFrame(peer.Team, heroCharacter.Equipment.Horse.Item != null);
                    }
                    else
                    {
                        frame = agentVisualForPeer.GetFrame();
                        frame.rotation.MakeUnit();
                    }
                    agentBuildData.InitialFrame(frame);
                    agentBuildData.IsFemale(peer.Peer.IsFemale);
                    BodyProperties bodyProperties = this.GetBodyProperties(peer, basicCultureObject);
                    agentBuildData.BodyProperties(bodyProperties);
                    agentBuildData.VisualsIndex(0);
                    agentBuildData.ClothingColor1(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color : basicCultureObject.ClothAlternativeColor);
                    agentBuildData.ClothingColor2(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color2 : basicCultureObject.ClothAlternativeColor2);
                    agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(heroCharacter));
                    NetworkCommunicator networkPeer = peer.GetNetworkPeer();
                    if (this.GameMode.ShouldSpawnVisualsForServer(networkPeer))
                    {
                        this.AgentVisualSpawnComponent.SpawnAgentVisualsForPeer(peer, agentBuildData, num);
                    }
                    this.GameMode.HandleAgentVisualSpawning(networkPeer, agentBuildData);
                }
            }
            if (this.Mission.AttackerTeam != null)
            {
                int num = 0;
                foreach (Agent activeAgent in this.Mission.AttackerTeam.ActiveAgents)
                {
                    if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                    {
                        ++num;
                    }
                }
                if (num < MultiplayerOptions.OptionType.NumberOfBotsTeam1.GetIntValue())
                {
                    this.SpawnBot(this.Mission.AttackerTeam, cultureLimit1);
                }
            }
            if (this.Mission.DefenderTeam == null)
            {
                return;
            }
            int num1 = 0;

            foreach (Agent activeAgent in this.Mission.DefenderTeam.ActiveAgents)
            {
                if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                {
                    ++num1;
                }
            }
            if (num1 >= MultiplayerOptions.OptionType.NumberOfBotsTeam2.GetIntValue())
            {
                return;
            }
            this.SpawnBot(this.Mission.DefenderTeam, cultureLimit2);
        }
コード例 #15
0
        public static int GetMinimumTroopCost(BasicCultureObject culture = null)
        {
            MBReadOnlyList <MultiplayerClassDivisions.MPHeroClass> mpHeroClasses = MultiplayerClassDivisions.GetMPHeroClasses();

            return(culture != null?mpHeroClasses.Where <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, bool>)(c => c.Culture == culture)).Min <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, int>)(troop => troop.TroopCost)) : mpHeroClasses.Min <MultiplayerClassDivisions.MPHeroClass>((Func <MultiplayerClassDivisions.MPHeroClass, int>)(troop => troop.TroopCost)));
        }
コード例 #16
0
        public override void OnAgentRemoved(
            Agent affectedAgent,
            Agent affectorAgent,
            AgentState agentState,
            KillingBlow blow)
        {
            if (blow.DamageType == DamageTypes.Invalid || agentState != AgentState.Unconscious && agentState != AgentState.Killed || !affectedAgent.IsHuman)
            {
                return;
            }
            if (affectorAgent != null && affectorAgent.IsEnemyOf(affectedAgent))
            {
                this._missionScoreboardComponent.ChangeTeamScore(affectorAgent.Team, this.GetScoreForKill(affectedAgent));
            }
            else
            {
                this._missionScoreboardComponent.ChangeTeamScore(affectedAgent.Team, -this.GetScoreForKill(affectedAgent));
            }
            MissionPeer missionPeer = affectedAgent.MissionPeer;

            if (missionPeer != null)
            {
                int num1 = 100;
                if (affectorAgent != affectedAgent)
                {
                    List <MissionPeer>[] missionPeerListArray = new List <MissionPeer> [2];
                    for (int index = 0; index < missionPeerListArray.Length; ++index)
                    {
                        missionPeerListArray[index] = new List <MissionPeer>();
                    }
                    foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers)
                    {
                        MissionPeer component = networkPeer.GetComponent <MissionPeer>();
                        if (component != null && component.Team != null && component.Team.Side != BattleSideEnum.None)
                        {
                            missionPeerListArray[(int)component.Team.Side].Add(component);
                        }
                    }
                    int            num2           = missionPeerListArray[1].Count - missionPeerListArray[0].Count;
                    BattleSideEnum battleSideEnum = num2 == 0 ? BattleSideEnum.None : (num2 < 0 ? BattleSideEnum.Attacker : BattleSideEnum.Defender);
                    if (battleSideEnum != BattleSideEnum.None && battleSideEnum == missionPeer.Team.Side)
                    {
                        int num3  = Math.Abs(num2);
                        int count = missionPeerListArray[(int)battleSideEnum].Count;
                        if (count > 0)
                        {
                            int num4 = num1 * num3 / 10 / count * 10;
                            num1 += num4;
                        }
                    }
                }
                this.ChangeCurrentGoldForPeer(missionPeer, missionPeer.Representative.Gold + num1);
            }
            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(affectedAgent.Character);
            Agent.Hitter assistingHitter = affectedAgent.GetAssistingHitter(affectorAgent?.MissionPeer);
            if (affectorAgent?.MissionPeer != null && affectorAgent != affectedAgent && !affectorAgent.IsFriendOf(affectedAgent))
            {
                TeamDeathmatchMissionRepresentative representative = affectorAgent.MissionPeer.Representative as TeamDeathmatchMissionRepresentative;
                int dataAndUpdateFlags = representative.GetGoldGainsFromKillDataAndUpdateFlags(MPPerkObject.GetPerkHandler(affectorAgent.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter?.HitterPeer), classForCharacter, false, blow.IsMissile);
                this.ChangeCurrentGoldForPeer(affectorAgent.MissionPeer, representative.Gold + dataAndUpdateFlags);
            }
            if (assistingHitter?.HitterPeer != null && !assistingHitter.IsFriendlyHit)
            {
                TeamDeathmatchMissionRepresentative representative = assistingHitter.HitterPeer.Representative as TeamDeathmatchMissionRepresentative;
                int dataAndUpdateFlags = representative.GetGoldGainsFromKillDataAndUpdateFlags(MPPerkObject.GetPerkHandler(affectorAgent?.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter.HitterPeer), classForCharacter, true, blow.IsMissile);
                this.ChangeCurrentGoldForPeer(assistingHitter.HitterPeer, representative.Gold + dataAndUpdateFlags);
            }
            if (missionPeer?.Team == null)
            {
                return;
            }
            IEnumerable <(MissionPeer, int)> goldRewardsOnDeath = MPPerkObject.GetPerkHandler(missionPeer)?.GetTeamGoldRewardsOnDeath();

            if (goldRewardsOnDeath == null)
            {
                return;
            }
            foreach ((MissionPeer peer, int baseAmount) in goldRewardsOnDeath)
            {
                if (peer?.Representative is TeamDeathmatchMissionRepresentative representative1)
                {
                    int local_21 = representative1.GetGoldGainsFromAllyDeathReward(baseAmount);
                    if (local_21 > 0)
                    {
                        this.ChangeCurrentGoldForPeer(peer, representative1.Gold + local_21);
                    }
                }
            }
        }
コード例 #17
0
 public static float CalculateMaximumSpeedMultiplier(Agent agent) => MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character).MovementSpeedMultiplier;
コード例 #18
0
        private void UpdateHumanAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties)
        {
            MPPerkObject.MPPerkHandler perkHandler = MPPerkObject.GetPerkHandler(agent);
            BasicCharacterObject       character   = agent.Character;
            MissionEquipment           equipment   = agent.Equipment;
            float          num1 = equipment.GetTotalWeightOfWeapons() * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(true) : 0.0));
            EquipmentIndex wieldedItemIndex1 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            EquipmentIndex wieldedItemIndex2 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand);

            if (wieldedItemIndex1 != EquipmentIndex.None)
            {
                ItemObject      itemObject       = equipment[wieldedItemIndex1].Item;
                WeaponComponent weaponComponent  = itemObject.WeaponComponent;
                float           realWeaponLength = weaponComponent.PrimaryWeapon.GetRealWeaponLength();
                float           num2             = (weaponComponent.GetItemType() == ItemObject.ItemTypeEnum.Bow ? 4f : 1.5f) * itemObject.Weight * MathF.Sqrt(realWeaponLength) * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0));
                num1 += num2;
            }
            if (wieldedItemIndex2 != EquipmentIndex.None)
            {
                float num2 = 1.5f * equipment[wieldedItemIndex2].Item.Weight * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0));
                num1 += num2;
            }
            agentDrivenProperties.WeaponsEncumbrance = num1;
            EquipmentIndex      wieldedItemIndex3   = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            WeaponComponentData weaponComponentData = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].CurrentUsageItem : (WeaponComponentData)null;
            ItemObject          primaryItem         = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].Item : (ItemObject)null;
            EquipmentIndex      wieldedItemIndex4   = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand);
            WeaponComponentData secondaryItem       = wieldedItemIndex4 != EquipmentIndex.None ? equipment[wieldedItemIndex4].CurrentUsageItem : (WeaponComponentData)null;
            float inaccuracy;

            agentDrivenProperties.LongestRangedWeaponSlotIndex       = (float)equipment.GetLongestRangedWeaponWithAimingError(out inaccuracy, agent);
            agentDrivenProperties.LongestRangedWeaponInaccuracy      = inaccuracy;
            agentDrivenProperties.SwingSpeedMultiplier               = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem));
            agentDrivenProperties.ThrustOrRangedReadySpeedMultiplier = agentDrivenProperties.SwingSpeedMultiplier;
            agentDrivenProperties.HandlingMultiplier = 1f;
            agentDrivenProperties.ShieldBashStunDurationMultiplier = 1f;
            agentDrivenProperties.KickStunDurationMultiplier       = 1f;
            agentDrivenProperties.ReloadSpeed = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem));
            agentDrivenProperties.ReloadMovementPenaltyFactor = 1f;
            agentDrivenProperties.WeaponInaccuracy            = 0.0f;
            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character);
            agentDrivenProperties.MaxSpeedMultiplier = (float)(1.04999995231628 * ((double)classForCharacter.MovementSpeedMultiplier * (100.0 / (100.0 + (double)num1))));
            int  skillValue = character.GetSkillValue(DefaultSkills.Riding);
            bool flag1      = false;
            bool flag2      = false;

            if (weaponComponentData != null)
            {
                int weaponSkill = character.GetSkillValue(weaponComponentData.RelevantSkill);
                if (weaponSkill > 0 && weaponComponentData.IsRangedWeapon && perkHandler != null)
                {
                    weaponSkill = MathF.Ceiling((float)weaponSkill * (perkHandler.GetRangedAccuracy() + 1f));
                }
                int thrustSpeed = weaponComponentData.ThrustSpeed;
                agentDrivenProperties.WeaponInaccuracy = this.GetWeaponInaccuracy(agent, weaponComponentData, weaponSkill);
                if (weaponComponentData.IsRangedWeapon)
                {
                    agentDrivenProperties.WeaponMaxMovementAccuracyPenalty = (float)(500 - weaponSkill) * 0.00025f;
                    agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty = (float)(500 - weaponSkill) * 0.0002f;
                    if (agent.HasMount)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * (3f / 1000f));
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * 0.0033f);
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Bow)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 4.5f / MBMath.Lerp(0.75f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0));
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 6f;
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Crossbow)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 1.2f;
                        agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 2.5f;
                    }
                    else if (weaponComponentData.RelevantSkill == DefaultSkills.Throwing)
                    {
                        agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 3.5f * MBMath.Lerp(1.5f, 0.8f, (float)(((double)thrustSpeed - 89.0) / 13.0));
                    }
                    if (weaponComponentData.WeaponClass == WeaponClass.Bow)
                    {
                        flag1 = true;
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.300000011920929 + (95.75 - (double)thrustSpeed) * 0.00499999988824129);
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = (float)(0.100000001490116 + (double)weaponSkill * 0.00999999977648258 * (double)MBMath.Lerp(1f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0)));
                        if (agent.IsAIControlled)
                        {
                            agentDrivenProperties.WeaponUnsteadyBeginTime *= 4f;
                        }
                        agentDrivenProperties.WeaponUnsteadyEndTime = 2f + agentDrivenProperties.WeaponUnsteadyBeginTime;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f;
                    }
                    else if (weaponComponentData.WeaponClass == WeaponClass.Javelin || weaponComponentData.WeaponClass == WeaponClass.ThrowingAxe || weaponComponentData.WeaponClass == WeaponClass.ThrowingKnife)
                    {
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.400000005960464 + (89.0 - (double)thrustSpeed) * 0.0299999993294477);
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = (float)(2.5 + (double)weaponSkill * 0.00999999977648258);
                        agentDrivenProperties.WeaponUnsteadyEndTime      = 10f + agentDrivenProperties.WeaponUnsteadyBeginTime;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.025f;
                    }
                    else
                    {
                        agentDrivenProperties.WeaponBestAccuracyWaitTime = 0.1f;
                        agentDrivenProperties.WeaponUnsteadyBeginTime    = 0.0f;
                        agentDrivenProperties.WeaponUnsteadyEndTime      = 0.0f;
                        agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f;
                    }
                }
                else if (weaponComponentData.WeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.WideGrip))
                {
                    flag2 = true;
                    agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(1.0 + (double)weaponSkill * 0.00499999988824129);
                    agentDrivenProperties.WeaponUnsteadyEndTime   = (float)(3.0 + (double)weaponSkill * 0.00999999977648258);
                }
            }
            agentDrivenProperties.AttributeShieldMissileCollisionBodySizeAdder = 0.3f;
            Agent mountAgent = agent.MountAgent;
            float num3       = mountAgent != null?mountAgent.GetAgentDrivenPropertyValue(DrivenProperty.AttributeRiding) : 1f;

            agentDrivenProperties.AttributeRiding                    = (float)skillValue * num3;
            agentDrivenProperties.AttributeHorseArchery              = Game.Current.BasicModels.StrikeMagnitudeModel.CalculateHorseArcheryFactor(character);
            agentDrivenProperties.BipedalRangedReadySpeedMultiplier  = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReadySpeedMultiplier);
            agentDrivenProperties.BipedalRangedReloadSpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReloadSpeedMultiplier);
            foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>())
            {
                if (!MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56))
                {
                    float num2 = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus;
                    agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num2);
                }
            }
            if (perkHandler != null)
            {
                for (int index = 56; index < 85; ++index)
                {
                    DrivenProperty drivenProperty = (DrivenProperty)index;
                    if (((drivenProperty == DrivenProperty.WeaponUnsteadyBeginTime ? 0 : (drivenProperty != DrivenProperty.WeaponUnsteadyEndTime ? 1 : 0)) | (flag1 ? 1 : 0) | (flag2 ? 1 : 0)) != 0 && drivenProperty != DrivenProperty.WeaponRotationalAccuracyPenaltyInRadians | flag1)
                    {
                        float stat = agentDrivenProperties.GetStat(drivenProperty);
                        agentDrivenProperties.SetStat(drivenProperty, stat + perkHandler.GetDrivenPropertyBonus(drivenProperty, stat));
                    }
                }
            }
            this.SetAiRelatedProperties(agent, agentDrivenProperties, weaponComponentData, secondaryItem);
        }
コード例 #19
0
 public override int GetScoreForKill(Agent killedAgent) => MultiplayerClassDivisions.GetMPHeroClassForCharacter(killedAgent.Character).TroopCost;
コード例 #20
0
 public override int GetScoreForAssist(Agent killedAgent) => (int)((double)MultiplayerClassDivisions.GetMPHeroClassForCharacter(killedAgent.Character).TroopCost * 0.5);
コード例 #21
0
 public override void OnAgentRemoved(
     Agent affectedAgent,
     Agent affectorAgent,
     AgentState agentState,
     KillingBlow blow)
 {
     base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, blow);
     if (this.UseGold() && affectorAgent != null && (affectedAgent != null && affectedAgent.IsHuman) && (blow.DamageType != DamageTypes.Invalid && (agentState == AgentState.Unconscious || agentState == AgentState.Killed)))
     {
         Agent.Hitter assistingHitter = affectedAgent.GetAssistingHitter(affectorAgent.MissionPeer);
         MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(affectedAgent.Character);
         if (affectorAgent.MissionPeer != null && affectorAgent.MissionPeer.Representative is FlagDominationMissionRepresentative representative10)
         {
             int gainsFromKillData = representative10.GetGoldGainsFromKillData(MPPerkObject.GetPerkHandler(affectorAgent.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter?.HitterPeer), classForCharacter, false);
             if (gainsFromKillData > 0)
             {
                 this.ChangeCurrentGoldForPeer(affectorAgent.MissionPeer, representative10.Gold + gainsFromKillData);
             }
         }
         if (assistingHitter?.HitterPeer != null && !assistingHitter.IsFriendlyHit && assistingHitter.HitterPeer.Representative is FlagDominationMissionRepresentative representative11)
         {
             int gainsFromKillData = representative11.GetGoldGainsFromKillData(MPPerkObject.GetPerkHandler(affectorAgent.MissionPeer), MPPerkObject.GetPerkHandler(assistingHitter.HitterPeer), classForCharacter, false);
             if (gainsFromKillData > 0)
             {
                 this.ChangeCurrentGoldForPeer(assistingHitter.HitterPeer, representative11.Gold + gainsFromKillData);
             }
         }
         if (affectedAgent.MissionPeer?.Team != null)
         {
             IEnumerable <(MissionPeer, int)> goldRewardsOnDeath = MPPerkObject.GetPerkHandler(affectedAgent.MissionPeer)?.GetTeamGoldRewardsOnDeath();
             if (goldRewardsOnDeath != null)
             {
                 foreach ((MissionPeer peer6, int baseAmount6) in goldRewardsOnDeath)
                 {
                     if (baseAmount6 > 0 && peer6?.Representative is FlagDominationMissionRepresentative representative12)
                     {
                         int local_11 = representative12.GetGoldGainsFromAllyDeathReward(baseAmount6);
                         if (local_11 > 0)
                         {
                             this.ChangeCurrentGoldForPeer(peer6, representative12.Gold + local_11);
                         }
                     }
                 }
             }
         }
     }
     if (affectedAgent.IsPlayerControlled)
     {
         affectedAgent.MissionPeer.GetComponent <FlagDominationMissionRepresentative>().UpdateSelectedClassServer((Agent)null);
     }
     else
     {
         if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() <= 0 || this.WarmupComponent != null && this.WarmupComponent.IsInWarmup || (affectedAgent.IsMount || affectedAgent.OwningAgentMissionPeer == null || (affectedAgent.Formation == null || affectedAgent.Formation.CountOfUnits != 1)))
         {
             return;
         }
         if (!GameNetwork.IsDedicatedServer)
         {
             MatrixFrame cameraFrame = Mission.Current.GetCameraFrame();
             Vec3        position    = cameraFrame.origin + cameraFrame.rotation.u;
             MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/squad_wiped"), position);
         }
         GameNetwork.BeginBroadcastModuleEvent();
         GameNetwork.WriteMessage((GameNetworkMessage) new FormationWipedMessage());
         GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, affectedAgent.OwningAgentMissionPeer.GetNetworkPeer());
     }
 }
コード例 #22
0
        public override List <CompassItemUpdateParams> GetCompassTargets()
        {
            List <CompassItemUpdateParams> itemUpdateParamsList = new List <CompassItemUpdateParams>();

            if (!GameNetwork.IsMyPeerReady || !this.IsRoundInProgress)
            {
                return(itemUpdateParamsList);
            }
            MissionPeer component1 = GameNetwork.MyPeer.GetComponent <MissionPeer>();

            if (component1 == null || component1.Team == null || component1.Team.Side == BattleSideEnum.None)
            {
                return(itemUpdateParamsList);
            }
            foreach (FlagCapturePoint flagCapturePoint in this.AllCapturePoints.Where <FlagCapturePoint>((Func <FlagCapturePoint, bool>)(cp => !cp.IsDeactivated)))
            {
                int num = 17 + flagCapturePoint.FlagIndex;
                itemUpdateParamsList.Add(new CompassItemUpdateParams((object)flagCapturePoint, (TargetIconType)num, flagCapturePoint.Position, flagCapturePoint.GetFlagColor(), flagCapturePoint.GetFlagColor2()));
            }
            bool flag1 = true;

            foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers)
            {
                MissionPeer component2 = networkPeer.GetComponent <MissionPeer>();
                if (component2?.Team != null && component2.Team.Side != BattleSideEnum.None)
                {
                    bool flag2 = component2.ControlledFormation != null;
                    if (!flag2)
                    {
                        flag1 = false;
                    }
                    if (flag1 || component2.Team == component1.Team)
                    {
                        MultiplayerClassDivisions.MPHeroClass heroClassForPeer = MultiplayerClassDivisions.GetMPHeroClassForPeer(component2);
                        if (flag2)
                        {
                            Formation controlledFormation = component2.ControlledFormation;
                            if (controlledFormation.CountOfUnits != 0)
                            {
                                WorldPosition medianPosition = controlledFormation.QuerySystem.MedianPosition;
                                Vec2          vec2           = controlledFormation.SmoothedAverageUnitPosition;
                                if (!vec2.IsValid)
                                {
                                    vec2 = controlledFormation.QuerySystem.AveragePosition;
                                }
                                medianPosition.SetVec2(vec2);
                                BannerCode bannerCode = (BannerCode)null;
                                bool       isAttacker = false;
                                bool       isAlly     = false;
                                if (controlledFormation.Team != null)
                                {
                                    if (controlledFormation.Banner == null)
                                    {
                                        controlledFormation.Banner = new Banner(controlledFormation.BannerCode, controlledFormation.Team.Color, controlledFormation.Team.Color2);
                                    }
                                    isAttacker = controlledFormation.Team.IsAttacker;
                                    isAlly     = controlledFormation.Team.IsPlayerAlly;
                                    bannerCode = BannerCode.CreateFrom(controlledFormation.Banner);
                                }
                                TargetIconType targetType = heroClassForPeer != null ? heroClassForPeer.IconType : TargetIconType.None;
                                itemUpdateParamsList.Add(new CompassItemUpdateParams((object)controlledFormation, targetType, medianPosition.GetNavMeshVec3(), bannerCode, isAttacker, isAlly));
                            }
                        }
                        else
                        {
                            Agent controlledAgent = component2.ControlledAgent;
                            if (controlledAgent != null && controlledAgent.IsActive() && controlledAgent.Controller != Agent.ControllerType.Player)
                            {
                                BannerCode from = BannerCode.CreateFrom(new Banner(component2.Peer.BannerCode, component2.Team.Color, component2.Team.Color2));
                                itemUpdateParamsList.Add(new CompassItemUpdateParams((object)controlledAgent, heroClassForPeer.IconType, controlledAgent.Position, from, component2.Team.IsAttacker, component2.Team.IsPlayerAlly));
                            }
                        }
                    }
                }
            }
            return(itemUpdateParamsList);
        }
コード例 #23
0
        public void SpawnAgentVisualsForPeer(
            MissionPeer missionPeer,
            AgentBuildData buildData,
            int selectedEquipmentSetIndex = -1,
            bool isBot          = false,
            int totalTroopCount = 0)
        {
            NetworkCommunicator myPeer = GameNetwork.MyPeer;

            if (myPeer != null)
            {
                myPeer.GetComponent <MissionPeer>();
            }
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.ClearAllVisuals();
            }
            missionPeer.ClearVisuals(buildData.AgentVisualsIndex);
            Equipment        overridenSpawnEquipment = buildData.AgentOverridenSpawnEquipment;
            ItemObject       mountItem           = overridenSpawnEquipment[10].Item;
            MatrixFrame      pointFrameForPlayer = this._spawnFrameSelectionHelper.GetSpawnPointFrameForPlayer(missionPeer.Peer, missionPeer.Team.Side, buildData.AgentVisualsIndex, totalTroopCount, mountItem != null);
            ActionIndexCache actionIndexCache1   = mountItem == null ? SpawningBehaviourBase.PoseActionInfantry : SpawningBehaviourBase.PoseActionCavalry;

            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(buildData.AgentCharacter);
            IReadOnlyList <MPPerkObject>          selectedPerks     = missionPeer.SelectedPerks;
            float        parameter    = (float)(0.100000001490116 + (double)MBRandom.RandomFloat * 0.800000011920929);
            IAgentVisual mountVisuals = (IAgentVisual)null;

            if (mountItem != null)
            {
                Monster          monster = mountItem.HorseComponent.Monster;
                AgentVisualsData data    = new AgentVisualsData().Equipment(overridenSpawnEquipment).Scale(mountItem.ScaleFactor).Frame(MatrixFrame.Identity).ActionSet(MBGlobals.GetActionSet(monster.ActionSetCode)).Scene(Mission.Current.Scene).Monster(monster).PrepareImmediately(false).MountCreationKey(MountCreationKey.GetRandomMountKey(mountItem, MBRandom.RandomInt()));
                mountVisuals = Mission.Current.AgentVisualCreator.Create(data, "Agent " + buildData.AgentCharacter.StringId + " mount", true);
                MatrixFrame frame = pointFrameForPlayer;
                frame.rotation.ApplyScaleLocal(data.ScaleData);
                ActionIndexCache actionName = ActionIndexCache.act_none;
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.HeroMountIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.TroopMountIdleAnimOverride);
                        break;
                    }
                }
                if (actionName == ActionIndexCache.act_none)
                {
                    if (mountItem.StringId == "mp_aserai_camel")
                    {
                        Debug.Print("Client is spawning a camel for without mountCustomAction from the perk.", debugFilter: 17179869184UL);
                        actionName = isBot ? ActionIndexCache.Create("act_camel_idle_1") : ActionIndexCache.Create("act_hero_mount_idle_camel");
                    }
                    else
                    {
                        if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.HeroMountIdleAnim);
                        }
                        if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.TroopMountIdleAnim);
                        }
                    }
                }
                if (actionName != ActionIndexCache.act_none)
                {
                    mountVisuals.SetAction(actionName);
                    mountVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
                    mountVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, frame, true);
                }
                mountVisuals.GetVisuals().GetEntity().SetFrame(ref frame);
            }
            ActionIndexCache actionIndexCache2 = actionIndexCache1;

            if (mountVisuals != null)
            {
                actionIndexCache2 = mountVisuals.GetVisuals().GetSkeleton().GetActionAtChannel(0);
            }
            else
            {
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.HeroIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.TroopIdleAnimOverride);
                        break;
                    }
                }
                if (actionIndexCache2 == actionIndexCache1)
                {
                    if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.HeroIdleAnim);
                    }
                    if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.TroopIdleAnim);
                    }
                }
            }
            IAgentVisual agentVisuals = Mission.Current.AgentVisualCreator.Create(new AgentVisualsData().Equipment(overridenSpawnEquipment).BodyProperties(buildData.AgentBodyProperties).Frame(pointFrameForPlayer).ActionSet(MBGlobals.PlayerMaleActionSet).Scene(Mission.Current.Scene).Monster(Game.Current.HumanMonster).PrepareImmediately(false).UseMorphAnims(true).SkeletonType(buildData.AgentIsFemale ? SkeletonType.Female : SkeletonType.Male).ClothColor1(buildData.AgentClothingColor1).ClothColor2(buildData.AgentClothingColor2).AddColorRandomness((uint)buildData.AgentVisualsIndex > 0U).ActionCode(actionIndexCache2), "Mission::SpawnAgentVisuals", true);

            agentVisuals.SetAction(actionIndexCache2);
            agentVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
            agentVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, pointFrameForPlayer, true);
            agentVisuals.GetVisuals().SetFrame(ref pointFrameForPlayer);
            agentVisuals.SetCharacterObjectID(buildData.AgentCharacter.StringId);
            EquipmentIndex mainHandWeaponIndex;
            EquipmentIndex offHandWeaponIndex;
            bool           isMainHandNotUsableWithOneHand;

            overridenSpawnEquipment.GetInitialWeaponIndicesToEquip(out mainHandWeaponIndex, out offHandWeaponIndex, out isMainHandNotUsableWithOneHand);
            if (isMainHandNotUsableWithOneHand)
            {
                offHandWeaponIndex = EquipmentIndex.None;
            }
            agentVisuals.GetVisuals().SetWieldedWeaponIndices((int)mainHandWeaponIndex, (int)offHandWeaponIndex);
            PeerVisualsHolder visualsHolder = new PeerVisualsHolder(missionPeer, buildData.AgentVisualsIndex, agentVisuals, mountVisuals);

            missionPeer.OnVisualsSpawned(visualsHolder, visualsHolder.VisualsIndex);
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.HasSpawnedAgentVisuals   = true;
                missionPeer.EquipmentUpdatingExpired = false;
            }
            if (!missionPeer.IsMine || buildData.AgentVisualsIndex != 0)
            {
                return;
            }
            Action agentVisualSpawned = this.OnMyAgentVisualSpawned;

            if (agentVisualSpawned == null)
            {
                return;
            }
            agentVisualSpawned();
        }