private TaskGroupShipControl CreateStandOffAttackGroup(List <Ship> ships) { float num1 = 0.0f; float val1 = float.MaxValue; foreach (Ship ship in ships) { num1 += CombatAI.GetMinEffectiveWeaponRange(ship, false); val1 = Math.Min(val1, ship.SensorRange); } float num2 = num1 / (float)ships.Count; float num3 = val1 * 0.75f; float minDist = num2 * 0.75f; float desiredDist = minDist + 500f; if ((double)desiredDist > (double)num3) { desiredDist = num3; minDist = 0.75f * desiredDist; } else if ((double)minDist >= (double)desiredDist) { minDist = desiredDist * 0.75f; } StandOffShipControl standOffShipControl = new StandOffShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, minDist, desiredDist); foreach (Ship ship in ships) { standOffShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)standOffShipControl); }
public BaseAttackShipControl(App game, TacticalObjective to, CombatAI commanderAI) : base(game, to, commanderAI) { this.m_ClearTargetsUpdate = 0; this.m_UpdateTargetSelection = 0; this.m_CanMerge = false; }
public override void Shutdown() { this.m_CommandAI = (CombatAI)null; this.m_PatrolObjective = (PatrolObjective)null; this.m_ThreatsInRange.Clear(); base.Shutdown(); }
public TaskGroup(App game, CombatAI commandAI) { this.m_Game = game; this.m_CommanderAI = commandAI; this.m_Objective = (TacticalObjective)null; this.m_Orders = TaskGroupOrders.None; this.m_Type = TaskGroupType.Aggressive; this.m_bIsPlayerOrder = false; this.m_bIsInContactWithEnemy = false; this.m_EnemyGroupInContact = (EnemyGroup)null; this.m_Ships = new List <Ship>(); this.m_Targets = new List <Ship>(); this.m_ShipControls = new List <TaskGroupShipControl>(); this.m_TargetGroup = (EnemyGroup)null; this.m_TargetTaskGroup = (TaskGroup)null; this.m_PatrolType = PatrolType.Circular; this.m_RequestedObjectiveType = ObjectiveType.NO_OBJECTIVE; this.m_NumShipTypes = new int[14]; for (int index = 0; index < 14; ++index) { this.m_NumShipTypes[index] = 0; } this.m_GroupSpeed = 0.0f; this.m_RequestRefreshShipControls = false; this.m_ChangeAttackTime = 4800; this.m_CurrentChangeAttackDelay = this.m_ChangeAttackTime; }
public void BeingAttacked(CombatAI attacker) { if (_currentTarget != attacker.Health) { Creature.ChangeState (State.Attack); GameController.CombatController.AddToCombat (this); _currentTarget = attacker.GetComponent<Health>(); HasTarget = true; } }
public WraithAbductorAssaultControl(App game, CombatAI commanderAI, Ship ship) : base(game, commanderAI, ship, WeaponEnums.TurretClasses.AssaultShuttle) { this.m_Ship = ship; this.m_CurrMaxLaunchDelay = 300; this.m_LaunchDelay = this.m_CurrMaxLaunchDelay; this.m_MinAttackDist = (float)((double)ship.MissionSection.ShipSectionAsset.MissionTime * (double)ship.Maneuvering.MaxShipSpeed * 0.5); this.m_Assaulting = false; }
public override void OnSpawn() { base.OnSpawn(); if (RightHand is ProjectileWeapon) _brain = new RangedAI(this); else _brain = new CombatAI(this); }
public ScoutTrailShipControl( App game, TacticalObjective to, CombatAI commanderAI, ScoutShipControl scoutShip) : base(game, to, commanderAI) { this.m_Type = ShipControlType.ScoutTrail; this.m_ScoutShip = scoutShip; }
public AttackRiderLaunchControl( App game, CombatAI commanderAI, Ship ship, WeaponEnums.TurretClasses weaponType) : base(game, commanderAI, ship, weaponType) { this.m_CurrMaxLaunchDelay = BattleRiderLaunchControl.kMinRiderHoldDuration * 5; this.m_LaunchDelay = this.m_CurrMaxLaunchDelay; }
public LargeRiderLaunchControl( App game, CombatAI commanderAI, Ship ship, WeaponEnums.TurretClasses weaponType) : base(game, commanderAI, ship, weaponType) { this.m_LaunchDelay = BattleRiderLaunchControl.kMinRiderHoldDuration; this.m_MinAttackDist = game.AssetDatabase.DefaultTacSensorRange; }
public SupportGroupShipControl( App game, TacticalObjective to, CombatAI commanderAI, TaskGroupShipControl supportTaskGroup) : base(game, to, commanderAI) { this.m_Type = ShipControlType.SupportGroup; this.m_SupportGroup = supportTaskGroup; }
protected override void OnLoad() { _brain = new CombatAI(this); if (_dispelTimer is null) { _dispelTimer = Timer.DelayCall(TimeSpan.FromMinutes(10.0), Kill); // TODO: Scale to facet time? } base.OnLoad(); }
public virtual int CurrentResources() { int num = 0; foreach (TaskGroup taskGroup in this.m_TaskGroups) { num += CombatAI.AssessGroupStrength(taskGroup.GetShips()); } return(num); }
public override int ResourceNeeds() { int num = 0; foreach (EnemyGroup enemyGroup in this.m_ThreatsInRange) { num += CombatAI.AssessGroupStrength(enemyGroup.m_Ships); } return(num); }
public RetreatShipControl( App game, TacticalObjective to, CombatAI commanderAI, bool useRetreatPos) : base(game, to, commanderAI) { this.m_Type = ShipControlType.Retreat; this.m_UseRetreatPos = useRetreatPos; }
public bool IsDetected(CombatAI detectingAi) { foreach (Ship ship in this.m_Ships) { if (detectingAi.IsShipDetected(ship)) { return(true); } } return(false); }
/// <inheritdoc/> public override void OnSpawn() { base.OnSpawn(); if (_brain != null) { return; } _brain = new CombatAI(this); }
private static void SimulateSwarmerNest( Random rand, GameSession game, int systemId, FleetInfo randomsFleet, int aiPlayerID, List <FleetInfo> aiPlayerFleets) { int numToKill = rand.NextInclusive(2, 4); Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets); shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)); if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => { if (x.Value.Count <= 0) { return(0); } return(x.Value.Sum <ShipInfo>((Func <ShipInfo, int>)(y => { if (y.DesignInfo == null) { return 0; } return CombatAI.GetShipStrength(y.DesignInfo.Class) / 3; }))); })) <= 2) { foreach (KeyValuePair <FleetInfo, List <ShipInfo> > keyValuePair in shipsInFleets) { foreach (ShipInfo shipInfo in keyValuePair.Value) { game.GameDatabase.RemoveShip(shipInfo.ID); } CombatSimulatorRandoms.FleetDestroyed(game, randomsFleet.PlayerID, keyValuePair.Key, (ShipInfo)null); game.GameDatabase.RemoveFleet(keyValuePair.Key.ID); } if (game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>().Count != 0) { return; } game.GameDatabase.RemoveFleet(randomsFleet.ID); } else { CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill); List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>(); if (list.Count > 0) { CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, list.First <ShipInfo>()); } game.GameDatabase.RemoveFleet(randomsFleet.ID); } }
public ScoutShipControl( App game, TacticalObjective to, CombatAI commanderAI, float sensorRange) : base(game, to, commanderAI) { this.m_Type = ShipControlType.Scout; this.m_EncounteredEnemy = false; this.m_SensorRange = sensorRange; }
protected override void OnCreate() { base.OnCreate(); if (_brain != null) { return; } _brain = new CombatAI(this); }
public ShipPsionicControl(App game, CombatAI commanderAI, Ship ship) { this.m_Game = game; this.m_CommanderAI = commanderAI; this.m_Ship = ship; this.m_HoldPsionic = (Psionic)null; this.m_MinFrames = ship.IsSuulka ? ShipPsionicControl.kSuulkaMinThinkDelay : ShipPsionicControl.kMinThinkDelay; this.m_MaxFrames = ship.IsSuulka ? ShipPsionicControl.kSuulkaMaxThinkDelay : ShipPsionicControl.kMaxThinkDelay; this.m_CurrMaxUpdateFrame = commanderAI.AIRandom.NextInclusive(this.m_MinFrames, this.m_MaxFrames); this.m_CurrUpdateFrame = this.m_CurrMaxUpdateFrame; this.m_State = PsionicControlState.Think; }
public SurroundShipControl( App game, TacticalObjective to, CombatAI commanderAI, Vector3 attackVector, float minDist, float desiredDist) : base(game, to, commanderAI, minDist, desiredDist) { this.m_Type = ShipControlType.Surround; this.m_AttackVec = attackVector; }
public AssaultShuttleLaunchControl(App game, CombatAI commanderAI, Ship ship) : base(game, commanderAI, ship, WeaponEnums.TurretClasses.AssaultShuttle) { this.m_CurrMaxLaunchDelay = BattleRiderLaunchControl.kMinRiderHoldDuration; this.m_LaunchDelay = this.m_CurrMaxLaunchDelay; this.m_AutoDisabled = true; if (this.m_Ship == null) { return; } this.m_Ship.PostSetProp("SetDisableAutoLaunching", true); }
public CombatAI Create(CombatController controller) { var ai = new CombatAI(); nodes.ForEach(n => { ai.AddNode(n.Create(controller)); }); ai.fallbackAbility = fallbackAbility.Create(controller); ai.controller = controller; return(ai); }
public FlyByShipControl(App game, TacticalObjective to, CombatAI commanderAI, float distPast) : base(game, to, commanderAI) { this.m_Type = ShipControlType.Flyby; this.m_DistancePast = distPast; this.m_CurrentDistPast = 0.0f; this.m_HoldDuration = FlyByShipControl.kHoldDuration; this.m_AttackMatrix = Matrix.Identity; this.m_InitialPass = true; this.m_CurrentHoldDelay = this.m_CommanderAI.AIRandom.NextInclusive(FlyByShipControl.kHoldDuration - 20, FlyByShipControl.kHoldDuration + 20); this.m_StuckDelay = FlyByShipControl.kStuckDuration; this.m_PrevPos = Vector3.Zero; }
public DefendPlanetObjective( StellarBody planet, CombatAI command, PatrolObjective patrolObjective) { this.m_ObjectiveType = ObjectiveType.DEFEND_TARGET; this.m_Planet = planet; this.m_CommandAI = command; this.m_TaskGroups = new List <TaskGroup>(); this.m_ThreatsInRange = new List <EnemyGroup>(); this.m_RequestTaskGroup = false; this.m_PatrolObjective = patrolObjective; }
public TaskGroupShipControl(App game, TacticalObjective to, CombatAI commanderAI) { this.m_Game = game; this.m_CommanderAI = commanderAI; this.m_Type = ShipControlType.None; this.m_Ships = new List <Ship>(); this.m_TaskGroupObjective = to; this.m_Formation = new ShipFormation(game); this.m_Formation.BackLineOffsetDist = 500f; this.m_SensorRange = game.AssetDatabase.DefaultTacSensorRange; this.m_CanMerge = true; this.m_GroupPriorityTarget = (Ship)null; }
protected override bool IsReadyToFire() { if (this.m_Ship.TaskGroup == null || this.m_Ship.TaskGroup.Objective.m_TargetEnemyGroup == null || (double)this.m_Ship.Maneuvering.Velocity.LengthSquared > 100.0) { return(false); } Vector3 desiredTargetPosition = this.GetDesiredTargetPosition(this.m_Ship.TaskGroup.Objective.m_TargetEnemyGroup); float num = this.m_MaxRange * 0.75f; Vector3 v1 = desiredTargetPosition - this.m_Ship.Position; v1.Y = 0.0f; if ((double)v1.Normalize() > (double)num) { return(false); } bool flag = false; foreach (Ship friendlyShip in this.m_CommanderAI.GetFriendlyShips()) { if (Ship.IsActiveShip(friendlyShip)) { Vector3 v0 = friendlyShip.Position - this.m_Ship.Position; v0.Y = 0.0f; if ((double)v0.Normalize() <= (double)this.m_MaxRange && (double)Vector3.Dot(v0, v1) > 0.899999976158142) { flag = true; break; } } } if (flag) { return(false); } if (CombatAI.AssessGroupStrength(this.m_Ship.TaskGroup.Objective.m_TargetEnemyGroup.m_Ships) < this.m_EnemyGroupStrngth) { return(true); } List <Ship> shipList = new List <Ship>(); foreach (Ship ship in this.m_Ship.TaskGroup.Objective.m_TargetEnemyGroup.m_Ships) { Vector3 v0 = ship.Position - this.m_Ship.Position; v0.Y = 0.0f; if ((double)v0.Normalize() <= (double)this.m_MaxRange && (double)Vector3.Dot(v0, v1) > 0.899999976158142) { shipList.Add(ship); } } return(CombatAI.AssessGroupStrength(this.m_Ship.TaskGroup.Objective.m_TargetEnemyGroup.m_Ships) >= this.m_EnemyGroupStrngth); }
private void ThinkTrack() { if (this.m_Target == null) { this.m_State = VonNeumannChildStates.INITFLEE; } else { float num1 = 0.0f; float val2 = 0.0f; Vector3 vector3_1 = Vector3.Zero; if (this.m_Target is Ship) { Ship target = this.m_Target as Ship; vector3_1 = target.Position; num1 = target.ShipSphere.radius; } else if (this.m_Target is StellarBody) { StellarBody target = this.m_Target as StellarBody; vector3_1 = target.Parameters.Position; num1 = target.Parameters.Radius; val2 = 750f; } WeaponBank bankWithWeaponTrait = this.m_VonNeumannChild.GetWeaponBankWithWeaponTrait(WeaponEnums.WeaponTraits.Disintegrating); if (bankWithWeaponTrait != null) { this.m_ApproachRange = Math.Max(bankWithWeaponTrait.Weapon.RangeTable.Effective.Range, 100f); bankWithWeaponTrait.PostSetProp("DisableAllTurrets", true); } else { this.m_ApproachRange = Math.Max(100f, CombatAI.GetMinEffectiveWeaponRange(this.m_VonNeumannChild, false)); } this.m_ApproachRange = Math.Max(this.m_ApproachRange, val2); this.m_ApproachRange += num1; Vector3 vector3_2 = vector3_1; Vector3 vector3_3 = this.m_VonNeumannChild.Position - vector3_2; double num2 = (double)vector3_3.Normalize(); Vector3 targetPos = vector3_2 + vector3_3 * this.m_ApproachRange; Vector3 look = vector3_3 * -1f; this.m_VonNeumannChild.Maneuvering.PostAddGoal(targetPos, look); float lengthSquared = (this.m_VonNeumannChild.Position - targetPos).LengthSquared; float num3 = this.m_ApproachRange + 200f; if ((double)lengthSquared >= (double)num3 * (double)num3) { return; } this.m_State = VonNeumannChildStates.INITCOLLECT; } }
public EvadeEnemyObjective( CombatAI command, PatrolObjective patrolObjective, float sensorRange) { this.m_ObjectiveType = ObjectiveType.EVADE_ENEMY; this.m_CommandAI = command; this.m_TaskGroups = new List <TaskGroup>(); this.m_ThreatsInRange = new List <EnemyGroup>(); this.m_RequestTaskGroup = false; this.m_IsUnsafe = false; this.m_PatrolObjective = patrolObjective; this.m_ShipSensorRange = sensorRange; }
public SystemDefenseBoatControl(App game, CombatAI commanderAI, Ship ship, StellarBody planet) : base(game, commanderAI, ship, WeaponEnums.TurretClasses.Standard) { this.m_MinRange = 10000f; if (planet != null) { this.m_MinRange += planet.Parameters.Radius; this.m_Pos = planet.Parameters.Position; } else { this.m_Pos = ship.Position; } }
public void AddToCombat(CombatAI combatAI) { _engagedAI.Add (combatAI); if (combatAI.GetComponent<Monster>() != null) { GameController.LevelGeneration.RemoveFromGrid(gameObject); foreach (Dog dog in GameController.MainCharacter.DogInventory) { if (dog.Creature.CurrentState == State.Follow && !dog.CombatAI.HasTarget) { dog.CombatAI.BeingAttacked(combatAI); } } } else if (combatAI.GetComponent<Dog>() != null) { foreach (CombatAI ai in EngagedAI) { if(ai != null && ai.GetComponent<Monster>() != null) ai.GetNewDogTarget(); } } }
public void RemoveFromCombat(CombatAI aiToRemove) { aiToRemove.HasTarget = false; _engagedAI.Remove (aiToRemove); int numEngagedMonsters = 0; foreach(CombatAI AI in _engagedAI){ if (AI != null && (AI.CurrentTarget == null || AI.CurrentTarget == aiToRemove.Health)) { AI.HasTarget = false; } if(AI != null && AI.GetComponent<Monster>() != null) { AI.GetNewDogTarget(); numEngagedMonsters++; } } if (numEngagedMonsters == 0) CombatOver(); }