public bool agentCharacterIsExpendable(Agent agent) { IEnumerable <Agent> nearbyAgents = base.Mission.GetNearbyAgents(agent.GetWorldPosition().AsVec2, 10f); BasicCharacterObject affectedCharacter = agent.Character; if (affectedCharacter != null) { if (affectedCharacter.getAttributes().Contains("Expendable")) { Helpers.Say(affectedCharacter.GetName() + " died, but is Expendable. Nearby allies lost 0 morale."); float moraleSum = 0f; nearbyAgents.ToList().ForEach(a => { VampireMoraleAgentComponent moraleComponent = a.GetComponent <VampireMoraleAgentComponent>(); if (moraleComponent != null) { moraleSum += moraleComponent.Morale; } else if (a.GetComponent <MoraleAgentComponent>() != null) { moraleSum += a.GetMorale(); } } ); float averageMorale = moraleSum / nearbyAgents.ToList().Count; Helpers.Say("Average morale of nearby allies: " + averageMorale); return(true); } } return(false); }
public static List <string> GetAttributes(this BasicCharacterObject character) { if (character != null) { string characterName = character.GetName().ToString(); List <string> attributeList; if (TroopNameToAttributeList.TryGetValue(characterName, out attributeList)) { return(attributeList); } } return(new List <string>()); }
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() }))); }