public override void Apply(Game game)
        {
            var textObjStrings = TextObject.ConvertToStringList(
                new List <TextObject> {
                _perk.Name,
                _perk.Description
            }
                );

            _perk.Initialize(
                textObjStrings[0],
                textObjStrings[1],
                _perk.Skill,
                (int)_perk.RequiredSkillValue,
                _perk.AlternativePerk,
                _perk.PrimaryRole, 20f,
                _perk.SecondaryRole, _perk.SecondaryBonus,
                _perk.IncrementType
                );
            if (Applied)
            {
                return;
            }

            CommunityPatchSubModule.Harmony.Patch(AiTargetMethodInfo, postfix: new HarmonyMethod(AiPatchMethodInfoPostfix));
            CommunityPatchSubModule.Harmony.Patch(PlayerTargetMethodInfo, postfix: new HarmonyMethod(PlayerPatchMethodInfoPostfix));
            CommunityPatchSubModule.Harmony.Patch(PlayerTargetMethodInfo, new HarmonyMethod(PlayerPatchMethodInfoPrefix));
            CommunityPatchSubModule.Harmony.Patch(MaxHitPointsTargetMethodInfo, postfix: new HarmonyMethod(MaxHitPointsPatchMethodInfoPostfix));
            CommunityPatchSubModule.Harmony.Patch(TooltipTargetMethodInfo, postfix: new HarmonyMethod(TooltipPatchMethodInfoPostfix));

            Applied = true;
        }
Beispiel #2
0
        private void FixPerkHealthyScout()
        {
            PerkObject _perk
                = PerkObject.FindFirst(x => x.Name.GetID() == "dDKOoD3e");

            if (_perk.PrimaryRole == SkillEffect.PerkRole.PartyMember &&
                _perk.PrimaryBonus == 0.15f)
            {
                var textObjStrings = TextObject.ConvertToStringList(
                    new List <TextObject> {
                    _perk.Name,
                    _perk.Description
                }
                    );

                // most of the properties of skills have private setters, yet Initialize is public
                _perk.Initialize(
                    textObjStrings[0],
                    textObjStrings[1],
                    _perk.Skill,
                    (int)_perk.RequiredSkillValue,
                    _perk.AlternativePerk,
                    SkillEffect.PerkRole.Personal, 8f,
                    _perk.SecondaryRole, _perk.SecondaryBonus,
                    _perk.IncrementType
                    );
            }
        }
        public override void Apply(Game game)
        {
            var textObjStrings = TextObject.ConvertToStringList(
                new List <TextObject> {
                _perk.Name,
                _perk.Description
            }
                );

            // most of the properties of skills have private setters, yet Initialize is public
            _perk.Initialize(
                textObjStrings[0],
                textObjStrings[1],
                _perk.Skill,
                (int)_perk.RequiredSkillValue,
                _perk.AlternativePerk,
                _perk.PrimaryRole, 30f,
                _perk.SecondaryRole, _perk.SecondaryBonus,
                _perk.IncrementType
                );
            if (Applied)
            {
                return;
            }

            CommunityPatchSubModule.Harmony.Patch(TargetMethodInfo, postfix: new HarmonyMethod(PatchMethodInfoPostfix));
            Applied = true;
        }
Beispiel #4
0
        private void FixPerkPeakForm()
        {
            var _perk = PerkObject.FindFirst(x => x.Name.GetID() == "fBgGbxaw");

            if (_perk.PrimaryBonus == 0f)
            {
                var textObjStrings = TextObject.ConvertToStringList(
                    new List <TextObject> {
                    _perk.Name,
                    _perk.Description
                }
                    );

                // most of the properties of skills have private setters, yet Initialize is public
                _perk.Initialize(
                    textObjStrings[0],
                    textObjStrings[1],
                    _perk.Skill,
                    (int)_perk.RequiredSkillValue,
                    _perk.AlternativePerk,
                    _perk.PrimaryRole, 10f,
                    _perk.SecondaryRole, _perk.SecondaryBonus,
                    _perk.IncrementType
                    );
            }
        }
Beispiel #5
0
        private void FixPerkDisciplinarian()
        {
            PerkObject _perk
                = PerkObject.FindFirst(x => x.Name.GetID() == "ER3ieXOb");

            if (_perk.PrimaryRole == SkillEffect.PerkRole.Personal)
            {
                var textObjStrings = TextObject.ConvertToStringList(
                    new List <TextObject> {
                    _perk.Name,
                    _perk.Description
                }
                    );

                // most of the properties of skills have private setters, yet Initialize is public
                _perk.Initialize(
                    textObjStrings[0],
                    textObjStrings[1],
                    _perk.Skill,
                    (int)_perk.RequiredSkillValue,
                    _perk.AlternativePerk,
                    SkillEffect.PerkRole.PartyLeader, 0f,
                    _perk.PrimaryRole, _perk.PrimaryBonus,
                    _perk.IncrementType
                    );
            }
        }
        public override void Apply(Game game)
        {
            // Dear TaleWorlds; Value should probably be publicly exposed, maybe by a method
            // and maybe marked [Obsolete] if you want to avoid your developers doing dirty deeds
            var textObjStrings = TextObject.ConvertToStringList(
                new List <TextObject> {
                _perk.Name,
                _perk.Description
            }
                );

            // most of the properties of skills have private setters, yet Initialize is public
            _perk.Initialize(
                textObjStrings[0],
                textObjStrings[1],
                _perk.Skill,
                (int)_perk.RequiredSkillValue,
                _perk.AlternativePerk,
                SkillEffect.PerkRole.Personal, 8f,
                _perk.SecondaryRole, _perk.SecondaryBonus,
                _perk.IncrementType
                );

            if (Applied)
            {
                return;
            }

            CommunityPatchSubModule.Harmony.Patch(TargetMethodInfo,
                                                  postfix: new HarmonyMethod(PatchMethodInfo));

            Applied = true;
        }
Beispiel #7
0
        public void Apply(Game game)
        {
            // Dear TaleWorlds; Value should probably be publicly exposed, maybe by a method
            // and maybe marked [Obsolete] if you want to avoid your developers doing dirty deeds
            var textObjStrings = TextObject.ConvertToStringList(
                new List <TextObject> {
                _perk.Name,
                _perk.Description
            }
                );

            // most of the properties of skills have private setters, yet Initialize is public
            _perk.Initialize(
                textObjStrings[0],
                textObjStrings[1],
                _perk.Skill,
                (int)_perk.RequiredSkillValue,
                _perk.AlternativePerk,
                SkillEffect.PerkRole.PartyLeader, 0f,
                _perk.PrimaryRole, _perk.PrimaryBonus,
                _perk.IncrementType
                );

            Applied = true;
        }
Beispiel #8
0
        public void Apply(Game game)
        {
            var textObjStrings = TextObject.ConvertToStringList(
                new List <TextObject> {
                _perk.Name,
                _perk.Description
            }
                );

            _perk.Initialize(
                textObjStrings[0],
                textObjStrings[1],
                _perk.Skill,
                (int)_perk.RequiredSkillValue,
                _perk.AlternativePerk,
                _perk.PrimaryRole, 0.3f,
                _perk.SecondaryRole, _perk.SecondaryBonus,
                _perk.IncrementType
                );

            Applied = true;
        }
        public static Mission OpenEnhancedBattleTestField(
            string scene,
            BattleConfig config,
            IEnhancedBattleTestCombatant playerParty,
            IEnhancedBattleTestCombatant enemyParty,
            float timeOfDay = 12f)
        {
            var playerSide = config.BattleTypeConfig.PlayerSide;
            var enemySide  = config.BattleTypeConfig.PlayerSide.GetOppositeSide();
            var player     = config.PlayerTeamConfig.General;

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

            bool hasPlayer = config.PlayerTeamConfig.HasGeneral;

            bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker;

            IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2];
            bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer;

            troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true);
            troopSuppliers[(int)enemySide]  = CreateTroopSupplier(enemyParty, isMultiplayer, false);
            bool isPlayerGeneral  = config.BattleTypeConfig.PlayerType == PlayerType.Commander;
            bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant;

            List <CharacterObject> charactersInPlayerSideByPriority = null;
            List <CharacterObject> charactersInEnemySideByPriority  = null;
            string playerTeamGeneralName = null;
            string enemyTeamGeneralName  = null;

            if (!isMultiplayer)
            {
                var playerCharacter = player.CharacterObject as CharacterObject;
                if (playerCharacter == null)
                {
                    return(null);
                }
                charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig);
                var playerGeneral = hasPlayer && isPlayerGeneral
                    ? playerCharacter
                    : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter
                        ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault()
                        : charactersInPlayerSideByPriority.FirstOrDefault());
                if (playerGeneral != null)
                {
                    charactersInPlayerSideByPriority.Remove(playerGeneral);
                    playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        playerGeneral.Name
                    }).FirstOrDefault();
                }
                charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig);
                var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault();
                if (enemyGeneral != null)
                {
                    charactersInEnemySideByPriority.Remove(enemyGeneral);
                    enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        enemyGeneral.Name
                    }).FirstOrDefault();
                }
            }


            AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay);

            return(MissionState.OpenNew("EnhancedBattleTestFieldBattle", new MissionInitializerRecord(scene)
            {
                DoNotUseLoadingScreen = false,
                PlayingInCampaignMode = false,
                AtmosphereOnCampaign = atmosphereInfo,
                SceneLevels = "",
                TimeOfDay = timeOfDay
            }, mission =>
                                        new MissionBehaviour[]
            {
                new CommanderLogic(config),
                new MissionOptionsComponent(),
                new BattleEndLogic(),
                new MissionCombatantsLogic(null, playerParty,
                                           !isPlayerAttacker ? playerParty : enemyParty,
                                           isPlayerAttacker ? playerParty : enemyParty,
                                           Mission.MissionTeamAITypeEnum.FieldBattle, isPlayerSergeant),
                new BattleObserverMissionLogic(),
                new CustomBattleAgentLogic(),
                new MissionAgentSpawnLogic(troopSuppliers, playerSide),
                new EnhancedBattleTestMissionSpawnHandler(!isPlayerAttacker ? playerParty : enemyParty,
                                                          isPlayerAttacker ? playerParty : enemyParty),
                new AgentBattleAILogic(),
                new AgentVictoryLogic(),
                new MissionAgentPanicHandler(),
                new MissionHardBorderPlacer(),
                new MissionBoundaryPlacer(),
                new MissionBoundaryCrossingHandler(),
                new BattleMissionAgentInteractionLogic(),
                new FieldBattleController(),
                new AgentFadeOutLogic(),
                new AgentMoraleInteractionLogic(),
                new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, isPlayerInArmy: false, isPlayerSergeant ? Enumerable.Repeat(config.PlayerTeamConfig.General.CharacterObject.StringId, 1).ToList() : new List <string>()),
                new CreateBodyguardMissionBehavior(
                    isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                    !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                    null, null, true),
                new HighlightsController(),
                new BattleHighlightsController()
            }));
        }
        public static Mission OpenEnhancedBattleTestSiege(
            string scene,
            BattleConfig config,
            IEnhancedBattleTestCombatant playerParty,
            IEnhancedBattleTestCombatant enemyParty,
            float[] wallHitPointPercentages,
            Dictionary <SiegeEngineType, int> siegeWeaponsCountOfAttackers,
            Dictionary <SiegeEngineType, int> siegeWeaponsCountOfDefenders,
            bool isSallyOut          = false,
            bool isReliefForceAttack = false,
            float timeOfDay          = 6f)
        {
            bool hasAnySiegeTower = siegeWeaponsCountOfAttackers.ContainsKey(DefaultSiegeEngineTypes.SiegeTower);

            string levelString;

            switch (config.MapConfig.SceneLevel)
            {
            case 1:
                levelString = "level_1";
                break;

            case 2:
                levelString = "level_2";
                break;

            case 3:
                levelString = "level_3";
                break;

            default:
                levelString = "";
                break;
            }

            var sceneLevelString =
                !(isSallyOut | isReliefForceAttack) ? levelString + " siege" : levelString + " sally";
            var playerSide = config.BattleTypeConfig.PlayerSide;
            var enemySide  = config.BattleTypeConfig.PlayerSide.GetOppositeSide();


            var player = config.PlayerTeamConfig.General;

            if (player == null)
            {
                return(null);
            }
            bool hasPlayer        = config.PlayerTeamConfig.HasGeneral;
            bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker;

            IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2];
            bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer;

            troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true);
            troopSuppliers[(int)enemySide]  = CreateTroopSupplier(enemyParty, isMultiplayer, false);
            bool isPlayerGeneral  = config.BattleTypeConfig.PlayerType == PlayerType.Commander || !hasPlayer;
            bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant;

            List <CharacterObject> charactersInPlayerSideByPriority = null;
            List <CharacterObject> charactersInEnemySideByPriority  = null;
            string playerTeamGeneralName = null;
            string enemyTeamGeneralName  = null;

            if (!isMultiplayer)
            {
                var playerCharacter = player.CharacterObject as CharacterObject;
                if (playerCharacter == null)
                {
                    return(null);
                }
                charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig);
                var playerGeneral = hasPlayer && isPlayerGeneral
                    ? playerCharacter
                    : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter
                        ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault()
                        : charactersInPlayerSideByPriority.FirstOrDefault());
                if (playerGeneral != null)
                {
                    charactersInPlayerSideByPriority.Remove(playerGeneral);
                    playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        playerGeneral.Name
                    }).FirstOrDefault();
                }
                charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig);
                var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault();
                if (enemyGeneral != null)
                {
                    charactersInEnemySideByPriority.Remove(enemyGeneral);
                    enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        enemyGeneral.Name
                    }).FirstOrDefault();
                }
            }

            AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay);

            var attackerSiegeWeapons =
                GetSiegeWeaponTypes(siegeWeaponsCountOfAttackers);
            var defenderSiegeWeapons =
                GetSiegeWeaponTypes(siegeWeaponsCountOfDefenders);

            return(MissionState.OpenNew("EnhancedBattleTestSiegeBattle", new MissionInitializerRecord(scene)
            {
                PlayingInCampaignMode = false,
                AtmosphereOnCampaign = atmosphereInfo,
                SceneLevels = sceneLevelString,
                TimeOfDay = timeOfDay
            }, mission =>
            {
                List <MissionBehaviour> missionBehaviourList = new List <MissionBehaviour>
                {
                    new CommanderLogic(config),
                    new BattleSpawnLogic(isSallyOut
                        ? "sally_out_set"
                        : (isReliefForceAttack ? "relief_force_attack_set" : "battle_set")),
                    new MissionOptionsComponent(),
                    new BattleEndLogic(),
                    new MissionCombatantsLogic(null, playerParty,
                                               !isPlayerAttacker ? playerParty : enemyParty,
                                               isPlayerAttacker ? playerParty : enemyParty,
                                               !isSallyOut ? Mission.MissionTeamAITypeEnum.Siege : Mission.MissionTeamAITypeEnum.SallyOut,
                                               isPlayerSergeant),
                    new SiegeMissionPreparationHandler(isSallyOut, isReliefForceAttack, wallHitPointPercentages,
                                                       hasAnySiegeTower),
                    new MissionAgentSpawnLogic(troopSuppliers, playerSide),
                    new BattleObserverMissionLogic(),
                    new CustomBattleAgentLogic(),
                    new AgentBattleAILogic(),
                    new AmmoSupplyLogic(new List <BattleSideEnum> {
                        BattleSideEnum.Defender
                    }),
                    new AgentVictoryLogic(),
                    new MissionAgentPanicHandler(),
                    new SiegeMissionController(
                        attackerSiegeWeapons,
                        defenderSiegeWeapons,
                        isPlayerAttacker, isSallyOut),
                    new SiegeDeploymentHandler(isPlayerAttacker,
                                               isPlayerAttacker ? attackerSiegeWeapons : defenderSiegeWeapons),
                    new MissionBoundaryPlacer(),
                    new MissionBoundaryCrossingHandler(),
                    new AgentMoraleInteractionLogic(),
                    new HighlightsController(),
                    new BattleHighlightsController(),
                    new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, hasPlayer, charactersInPlayerSideByPriority?.Select(character => character.StringId).ToList()),
                    new CreateBodyguardMissionBehavior(
                        isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                        !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                        null, null, false),
                };
                if (isSallyOut)
                {
                    missionBehaviourList.Add(new EnhancedBattleTestSiegeSallyOutMissionSpawnHandler(
                                                 isPlayerAttacker ? enemyParty : playerParty,
                                                 isPlayerAttacker ? playerParty : enemyParty));
                }
                else
                {
                    missionBehaviourList.Add(new EnhancedBattleTestSiegeMissionSpawnHandler(
                                                 isPlayerAttacker ? enemyParty : playerParty,
                                                 isPlayerAttacker ? playerParty : enemyParty));
                    missionBehaviourList.Add(new AgentFadeOutLogic());
                }
                return missionBehaviourList;
            }));
        }