public static Mission OpenCustomBattleMission( string scene, BasicCharacterObject character, CustomBattleCombatant playerParty, CustomBattleCombatant enemyParty, bool isPlayerGeneral, BasicCharacterObject playerSideGeneralCharacter, string sceneLevels = "", string seasonString = "", float timeOfDay = 6f) { BattleSideEnum playerSide = playerParty.Side; bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker; IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2]; CustomBattleTroopSupplier battleTroopSupplier1 = new CustomBattleTroopSupplier(playerParty, true); troopSuppliers[(int)playerParty.Side] = (IMissionTroopSupplier)battleTroopSupplier1; CustomBattleTroopSupplier battleTroopSupplier2 = new CustomBattleTroopSupplier(enemyParty, false); troopSuppliers[(int)enemyParty.Side] = (IMissionTroopSupplier)battleTroopSupplier2; bool isPlayerSergeant = !isPlayerGeneral; return(MissionState.OpenNew("CustomBattle", new MissionInitializerRecord(scene) { DoNotUseLoadingScreen = false, PlayingInCampaignMode = false, AtmosphereOnCampaign = BannerlordMissions.CreateAtmosphereInfoForMission(seasonString, (int)timeOfDay), SceneLevels = sceneLevels, TimeOfDay = timeOfDay }, (InitializeMissionBehvaioursDelegate)(missionController => (IEnumerable <MissionBehaviour>) new MissionBehaviour[20] { (MissionBehaviour) new MissionOptionsComponent(), (MissionBehaviour) new BattleEndLogic(), (MissionBehaviour) new MissionCombatantsLogic((IEnumerable <IBattleCombatant>)null, (IBattleCombatant)playerParty, !isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, Mission.MissionTeamAITypeEnum.FieldBattle, isPlayerSergeant), (MissionBehaviour) new BattleObserverMissionLogic(), (MissionBehaviour) new CustomBattleAgentLogic(), (MissionBehaviour) new MissionAgentSpawnLogic(troopSuppliers, playerSide), (MissionBehaviour) new CustomBattleMissionSpawnHandler(!isPlayerAttacker ? playerParty : enemyParty, isPlayerAttacker ? playerParty : enemyParty), (MissionBehaviour) new AgentBattleAILogic(), (MissionBehaviour) new AgentVictoryLogic(), (MissionBehaviour) new MissionAgentPanicHandler(), (MissionBehaviour) new MissionHardBorderPlacer(), (MissionBehaviour) new MissionBoundaryPlacer(), (MissionBehaviour) new MissionBoundaryCrossingHandler(), (MissionBehaviour) new BattleMissionAgentInteractionLogic(), (MissionBehaviour) new AgentFadeOutLogic(), (MissionBehaviour) new AgentMoraleInteractionLogic(), (MissionBehaviour) new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, false, isPlayerSergeant ? Enumerable.Repeat <string>(character.StringId, 1).ToList <string>() : new List <string>()), (MissionBehaviour) new CreateBodyguardMissionBehavior(isPlayerAttacker & isPlayerGeneral ? character.GetName().ToString() : (isPlayerAttacker & isPlayerSergeant ? playerSideGeneralCharacter.GetName().ToString() : (string)null), !isPlayerAttacker & isPlayerGeneral ? character.GetName().ToString() : (!isPlayerAttacker & isPlayerSergeant ? playerSideGeneralCharacter.GetName().ToString() : (string)null)), (MissionBehaviour) new HighlightsController(), (MissionBehaviour) new BattleHighlightsController() }))); }
public CustomBattleAgentOrigin( CustomBattleCombatant customBattleCombatant, BasicCharacterObject characterObject, CustomBattleTroopSupplier troopSupplier, bool isPlayerSide, int rank = -1, UniqueTroopDescriptor uniqueNo = default(UniqueTroopDescriptor)) { this.CustomBattleCombatant = customBattleCombatant; this.Troop = characterObject; this._descriptor = !uniqueNo.IsValid ? new UniqueTroopDescriptor(Game.Current.NextUniqueTroopSeed) : uniqueNo; this.Rank = rank == -1 ? MBRandom.RandomInt(10000) : rank; this._troopSupplier = troopSupplier; this._isPlayerSide = isPlayerSide; }
public static Mission OpenSiegeMissionWithDeployment( string scene, BasicCharacterObject character, CustomBattleCombatant playerParty, CustomBattleCombatant enemyParty, bool isPlayerGeneral, float[] wallHitPointPercentages, bool hasAnySiegeTower, Dictionary <SiegeEngineType, int> siegeWeaponsCountOfAttackers, Dictionary <SiegeEngineType, int> siegeWeaponsCountOfDefenders, bool isPlayerAttacker, int sceneUpgradeLevel = 0, string seasonString = "", bool isSallyOut = false, bool isReliefForceAttack = false, float timeOfDay = 6f) { string str1; switch (sceneUpgradeLevel) { case 1: str1 = "level_1"; break; case 2: str1 = "level_2"; break; default: str1 = "level_3"; break; } string str2 = str1 + " siege"; BattleSideEnum playerSide = playerParty.Side; IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2]; CustomBattleTroopSupplier battleTroopSupplier1 = new CustomBattleTroopSupplier(playerParty, true); troopSuppliers[(int)playerParty.Side] = (IMissionTroopSupplier)battleTroopSupplier1; CustomBattleTroopSupplier battleTroopSupplier2 = new CustomBattleTroopSupplier(enemyParty, false); troopSuppliers[(int)enemyParty.Side] = (IMissionTroopSupplier)battleTroopSupplier2; bool isPlayerSergeant = !isPlayerGeneral; return(MissionState.OpenNew("CustomSiegeBattle", new MissionInitializerRecord(scene) { PlayingInCampaignMode = false, AtmosphereOnCampaign = BannerlordMissions.CreateAtmosphereInfoForMission(seasonString, (int)timeOfDay), SceneLevels = str2, TimeOfDay = timeOfDay }, (InitializeMissionBehvaioursDelegate)(mission => { List <MissionBehaviour> missionBehaviourList = new List <MissionBehaviour>(); missionBehaviourList.Add((MissionBehaviour) new BattleSpawnLogic(isSallyOut ? "sally_out_set" : (isReliefForceAttack ? "relief_force_attack_set" : "battle_set"))); missionBehaviourList.Add((MissionBehaviour) new MissionOptionsComponent()); missionBehaviourList.Add((MissionBehaviour) new BattleEndLogic()); missionBehaviourList.Add((MissionBehaviour) new MissionCombatantsLogic((IEnumerable <IBattleCombatant>)null, (IBattleCombatant)playerParty, !isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, !isSallyOut ? Mission.MissionTeamAITypeEnum.Siege : Mission.MissionTeamAITypeEnum.SallyOut, isPlayerSergeant)); missionBehaviourList.Add((MissionBehaviour) new SiegeMissionPreparationHandler(isSallyOut, isReliefForceAttack, wallHitPointPercentages, hasAnySiegeTower)); missionBehaviourList.Add((MissionBehaviour) new MissionAgentSpawnLogic(troopSuppliers, playerSide)); if (isSallyOut) { missionBehaviourList.Add((MissionBehaviour) new CustomSiegeSallyOutMissionSpawnHandler(!isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty)); } else { missionBehaviourList.Add((MissionBehaviour) new CustomSiegeMissionSpawnHandler(!isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty, isPlayerAttacker ? (IBattleCombatant)playerParty : (IBattleCombatant)enemyParty)); missionBehaviourList.Add((MissionBehaviour) new AgentFadeOutLogic()); } missionBehaviourList.Add((MissionBehaviour) new BattleObserverMissionLogic()); missionBehaviourList.Add((MissionBehaviour) new CustomBattleAgentLogic()); missionBehaviourList.Add((MissionBehaviour) new AgentBattleAILogic()); if (!isSallyOut) { missionBehaviourList.Add((MissionBehaviour) new AmmoSupplyLogic(new List <BattleSideEnum>() { BattleSideEnum.Defender })); } missionBehaviourList.Add((MissionBehaviour) new AgentVictoryLogic()); missionBehaviourList.Add((MissionBehaviour) new SiegeMissionController(BannerlordMissions.GetSiegeWeaponTypes(siegeWeaponsCountOfAttackers), BannerlordMissions.GetSiegeWeaponTypes(siegeWeaponsCountOfDefenders), isPlayerAttacker, isSallyOut)); missionBehaviourList.Add((MissionBehaviour) new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, false)); SiegeDeploymentHandler deploymentHandler = new SiegeDeploymentHandler(isPlayerAttacker, isPlayerAttacker ? BannerlordMissions.GetSiegeWeaponTypes(siegeWeaponsCountOfAttackers) : BannerlordMissions.GetSiegeWeaponTypes(siegeWeaponsCountOfDefenders)); missionBehaviourList.Add((MissionBehaviour)deploymentHandler); missionBehaviourList.Add((MissionBehaviour) new MissionAgentPanicHandler()); missionBehaviourList.Add((MissionBehaviour) new MissionBoundaryPlacer()); missionBehaviourList.Add((MissionBehaviour) new MissionBoundaryCrossingHandler()); missionBehaviourList.Add((MissionBehaviour) new AgentMoraleInteractionLogic()); missionBehaviourList.Add((MissionBehaviour) new HighlightsController()); missionBehaviourList.Add((MissionBehaviour) new BattleHighlightsController()); return (IEnumerable <MissionBehaviour>)missionBehaviourList.ToArray(); }))); }