private void DestroySiegeWeapons() { if (this._mainInfantryFormation != null) { this._mainInfantryFormation.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._mainInfantryFormation); BehaviorDefend behaviorDefend = this._mainInfantryFormation.AI.SetBehaviorWeight <BehaviorDefend>(1f); Vec2 vec2 = (this._teamAISallyOutAttacker.OuterGate.GameEntity.GlobalPosition.AsVec2 - this._teamAISallyOutAttacker.InnerGate.GameEntity.GlobalPosition.AsVec2).Normalized(); WorldPosition worldPosition1 = new WorldPosition(Mission.Current.Scene, UIntPtr.Zero, this._teamAISallyOutAttacker.OuterGate.GameEntity.GlobalPosition, false); worldPosition1.SetVec2(worldPosition1.AsVec2 + (3f + this._mainInfantryFormation.Depth) * vec2); WorldPosition worldPosition2 = worldPosition1; behaviorDefend.DefensePosition = worldPosition2; this._mainInfantryFormation.AI.SetBehaviorWeight <BehaviorDestroySiegeWeapons>(1f); } GameEntity[] array1 = this._teamAISallyOutAttacker.ArcherPositions.ToArray <GameEntity>(); int length = array1.Length; if (length > 0) { Formation[] array2 = this._archerFormations.ToArray(); for (int index = 0; index < array2.Length; ++index) { array2[index].AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(array2[index]); array2[index].AI.SetBehaviorWeight <BehaviorShootFromCastleWalls>(1f); array2[index].AI.GetBehavior <BehaviorShootFromCastleWalls>().ArcherPosition = array1[index % length]; } } foreach (Formation cavalryFormation in this._cavalryFormations) { cavalryFormation.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(cavalryFormation); cavalryFormation.AI.SetBehaviorWeight <BehaviorDestroySiegeWeapons>(1f); } }
private void OrganizedRetreat() { if (this.team.IsPlayerTeam && !this.team.IsPlayerGeneral && this.team.IsPlayerSergeant) { this.SoundTacticalHorn(TacticComponent.RetreatHornSoundIndex); } if (this._mainInfantry != null) { this._mainInfantry.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._mainInfantry); BehaviorDefend behaviorDefend = this._mainInfantry.AI.SetBehaviorWeight <BehaviorDefend>(1f); WorldPosition positionForFormation = Mission.Current.GetClosestFleePositionForFormation(this._mainInfantry); positionForFormation.SetVec2(Mission.Current.GetClosestBoundaryPosition(positionForFormation.AsVec2)); this._retreatPosition = positionForFormation.AsVec2; WorldPosition worldPosition = positionForFormation; behaviorDefend.DefensePosition = worldPosition; this._mainInfantry.AI.SetBehaviorWeight <BehaviorPullBack>(1f); } if (this._archers != null) { this._archers.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._archers); this._archers.AI.SetBehaviorWeight <BehaviorScreenedSkirmish>(1f); this._archers.AI.SetBehaviorWeight <BehaviorPullBack>(1.5f); } if (this._leftCavalry != null) { this._leftCavalry.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._leftCavalry); this._leftCavalry.AI.SetBehaviorWeight <BehaviorProtectFlank>(1f).FlankSide = FormationAI.BehaviorSide.Left; this._leftCavalry.AI.SetBehaviorWeight <BehaviorCavalryScreen>(1f); this._leftCavalry.AI.SetBehaviorWeight <BehaviorPullBack>(1.5f); } if (this._rightCavalry != null) { this._rightCavalry.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._rightCavalry); this._rightCavalry.AI.SetBehaviorWeight <BehaviorProtectFlank>(1f).FlankSide = FormationAI.BehaviorSide.Right; this._rightCavalry.AI.SetBehaviorWeight <BehaviorCavalryScreen>(1f); this._rightCavalry.AI.SetBehaviorWeight <BehaviorPullBack>(1.5f); } if (this._rangedCavalry == null) { return; } this._rangedCavalry.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._rangedCavalry); this._rangedCavalry.AI.SetBehaviorWeight <BehaviorMountedSkirmish>(1f); this._rangedCavalry.AI.SetBehaviorWeight <BehaviorPullBack>(1.5f); this._rangedCavalry.AI.SetBehaviorWeight <BehaviorHorseArcherSkirmish>(1f); }
private void CavalryRetreat() { if (this._mainInfantryFormation != null) { this._mainInfantryFormation.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(this._mainInfantryFormation); BehaviorDefend behaviorDefend = this._mainInfantryFormation.AI.SetBehaviorWeight <BehaviorDefend>(1f); Vec2 vec2 = (this._teamAISallyOutAttacker.OuterGate.GameEntity.GlobalPosition.AsVec2 - this._teamAISallyOutAttacker.InnerGate.GameEntity.GlobalPosition.AsVec2).Normalized(); WorldPosition worldPosition1 = new WorldPosition(Mission.Current.Scene, UIntPtr.Zero, this._teamAISallyOutAttacker.OuterGate.GameEntity.GlobalPosition, false); worldPosition1.SetVec2(worldPosition1.AsVec2 + (3f + this._mainInfantryFormation.Depth) * vec2); WorldPosition worldPosition2 = worldPosition1; behaviorDefend.DefensePosition = worldPosition2; } foreach (Formation cavalryFormation in this._cavalryFormations) { cavalryFormation.AI.ResetBehaviorWeights(); TacticComponent.SetDefaultBehaviorWeights(cavalryFormation); cavalryFormation.AI.SetBehaviorWeight <BehaviorRetreatToKeep>(1f); } }