public CustomBattleMissionSpawnHandler( CustomBattleCombatant defenderParty, CustomBattleCombatant attackerParty) { this._defenderParty = defenderParty; this._attackerParty = attackerParty; }
public CustomBattleCombatant[] GetCustomBattleParties( BasicCharacterObject playerCharacter, BasicCharacterObject playerSideGeneralCharacter, BasicCharacterObject enemyCharacter, BasicCultureObject playerFaction, int[] playerNumbers, List <BasicCharacterObject>[] playerTroopSelections, BasicCultureObject enemyFaction, int[] enemyNumbers, List <BasicCharacterObject>[] enemyTroopSelections, bool isPlayerAttacker) { CustomBattleCombatant[] customBattleCombatantArray = new CustomBattleCombatant[2] { new CustomBattleCombatant(new TextObject("{=sSJSTe5p}Player Party"), playerFaction, Banner.CreateRandomBanner()), new CustomBattleCombatant(new TextObject("{=0xC75dN6}Enemy Party"), enemyFaction, Banner.CreateRandomBanner()) }; customBattleCombatantArray[0].Side = isPlayerAttacker ? BattleSideEnum.Attacker : BattleSideEnum.Defender; customBattleCombatantArray[0].AddCharacter(playerCharacter, 1); if (playerSideGeneralCharacter != null) { customBattleCombatantArray[0].AddCharacter(playerSideGeneralCharacter, 1); } customBattleCombatantArray[1].Side = customBattleCombatantArray[0].Side.GetOppositeSide(); customBattleCombatantArray[1].AddCharacter(enemyCharacter, 1); for (int index = 0; index < customBattleCombatantArray.Length; ++index) { this.PopulateListsWithDefaults(ref customBattleCombatantArray[index], index == 0 ? playerNumbers : enemyNumbers, index == 0 ? playerTroopSelections : enemyTroopSelections); } return(customBattleCombatantArray); }
public static Mission OpenCPUBenchmarkMission(string scene) { int realBattleSize = BannerlordConfig.GetRealBattleSize(); int attackerInfCount = realBattleSize / 100 * 18; int attackerRangedCount = realBattleSize / 100 * 10; int attackerCavCount = realBattleSize / 100 * 8; int defenderInfCount = realBattleSize / 100 * 59; int defenderCavCount = realBattleSize / 100 * 5; IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2]; BasicCultureObject culture = MBObjectManager.Instance.GetObject <BasicCultureObject>("empire"); Banner banner1 = new Banner("11.4.124.4345.4345.768.768.1.0.0.163.0.5.512.512.769.764.1.0.0"); Banner banner2 = new Banner("11.45.126.4345.4345.768.768.1.0.0.462.0.13.512.512.769.764.1.0.0"); CustomBattleCombatant playerParty = new CustomBattleCombatant(new TextObject("{=!}Player Party"), culture, banner1); playerParty.Side = BattleSideEnum.Attacker; playerParty.AddCharacter(MBObjectManager.Instance.GetObject <BasicCharacterObject>("imperial_legionary"), attackerInfCount); playerParty.AddCharacter(MBObjectManager.Instance.GetObject <BasicCharacterObject>("imperial_palatine_guard"), attackerRangedCount); playerParty.AddCharacter(MBObjectManager.Instance.GetObject <BasicCharacterObject>("imperial_cataphract"), attackerCavCount); CustomBattleCombatant enemyParty = new CustomBattleCombatant(new TextObject("{=!}Enemy Party"), culture, banner2); enemyParty.Side = BattleSideEnum.Defender; enemyParty.AddCharacter(MBObjectManager.Instance.GetObject <BasicCharacterObject>("battanian_wildling"), defenderInfCount); enemyParty.AddCharacter(MBObjectManager.Instance.GetObject <BasicCharacterObject>("battanian_horseman"), defenderCavCount); CustomBattleTroopSupplier battleTroopSupplier1 = new CustomBattleTroopSupplier(playerParty, true); troopSuppliers[(int)playerParty.Side] = (IMissionTroopSupplier)battleTroopSupplier1; CustomBattleTroopSupplier battleTroopSupplier2 = new CustomBattleTroopSupplier(enemyParty, false); troopSuppliers[(int)enemyParty.Side] = (IMissionTroopSupplier)battleTroopSupplier2; return(MissionState.OpenNew("CPUBenchmarkMission", new MissionInitializerRecord(scene) { DoNotUseLoadingScreen = false, PlayingInCampaignMode = false }, (InitializeMissionBehvaioursDelegate)(missionController => (IEnumerable <MissionBehaviour>) new MissionBehaviour[10] { (MissionBehaviour) new MissionCombatantsLogic((IEnumerable <IBattleCombatant>)null, (IBattleCombatant)playerParty, (IBattleCombatant)enemyParty, (IBattleCombatant)playerParty, Mission.MissionTeamAITypeEnum.FieldBattle, false), (MissionBehaviour) new MissionAgentSpawnLogic(troopSuppliers, BattleSideEnum.Attacker), (MissionBehaviour) new CPUBenchmarkMissionSpawnHandler(enemyParty, playerParty), (MissionBehaviour) new CPUBenchmarkMissionLogic(attackerInfCount, attackerRangedCount, attackerCavCount, defenderInfCount, defenderCavCount), (MissionBehaviour) new AgentBattleAILogic(), (MissionBehaviour) new AgentVictoryLogic(), (MissionBehaviour) new MissionHardBorderPlacer(), (MissionBehaviour) new MissionBoundaryPlacer(), (MissionBehaviour) new MissionBoundaryCrossingHandler(), (MissionBehaviour) new AgentFadeOutLogic() }))); }
private void PopulateListsWithDefaults( ref CustomBattleCombatant customBattleParties, int[] numbers, List <BasicCharacterObject>[] troopList) { BasicCultureObject basicCulture = customBattleParties.BasicCulture; if (troopList == null) { troopList = new List <BasicCharacterObject>[4] { new List <BasicCharacterObject>(), new List <BasicCharacterObject>(), new List <BasicCharacterObject>(), new List <BasicCharacterObject>() } } ; if (troopList[0].Count == 0) { troopList[0] = new List <BasicCharacterObject>() { CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(basicCulture, FormationClass.Infantry) } } ; if (troopList[1].Count == 0) { troopList[1] = new List <BasicCharacterObject>() { CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(basicCulture, FormationClass.Ranged) } } ; if (troopList[2].Count == 0) { troopList[2] = new List <BasicCharacterObject>() { CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(basicCulture, FormationClass.Cavalry) } } ; if (troopList[3].Count == 0) { troopList[3] = new List <BasicCharacterObject>() { CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(basicCulture, FormationClass.HorseArcher) } } ; if (!troopList[3].Any <BasicCharacterObject>() || troopList[3].All <BasicCharacterObject>((Func <BasicCharacterObject, bool>)(troop => troop == null))) { numbers[2] += numbers[3] / 3; numbers[1] += numbers[3] / 3; numbers[0] += numbers[3] / 3; numbers[0] += numbers[3] - numbers[3] / 3 * 3; numbers[3] = 0; } for (int index1 = 0; index1 < 4; ++index1) { int count = troopList[index1].Count; int number1 = numbers[index1]; if (number1 > 0) { for (int index2 = 0; index2 < count; ++index2) { int number2 = number1 / count; customBattleParties.AddCharacter(troopList[index1][index2], number2); numbers[index1] -= number2; if (index2 == count - 1 && numbers[index1] > 0) { customBattleParties.AddCharacter(troopList[index1][index2], numbers[index1]); numbers[index1] = 0; } } } } }