public override void Execute() => OwnWorkers.Where(w => w.IsIdle) .Where(w => !MyUnits.TrackedUnits.ContainsKey(w) || !MyUnits.TrackedUnits[w].StartsWith("MoveDroneTo")) .ForEach(w => { MyUnits.SetActivity(w, nameof(IdleWorkersToMineral)); GatherClosestMineral(w); });
public override void Execute() { if (Game.FrameCount % 5 != 0) { return; } var ownGroundRangedUnits = Game.Self.Units .Where(u => u.UnitType.Type == UnitType.Zerg_Hydralisk).Where(u => !MyUnits.TrackedUnits.ContainsKey(u) || MyUnits.TrackedUnits[u] != nameof(RetreatIfOutnumbered)); foreach (var attacker in ownGroundRangedUnits) { var candidateTargets = EnemyUnitsInSight(attacker); if (!candidateTargets.Any()) { continue; } var target = GetHighestPrioTarget(attacker, candidateTargets); if (ShouldKite(attacker, target)) { Kite(attacker, target); return; } MyUnits.SetActivity(attacker, nameof(RangedKite)); attacker.Attack(target, false); } }
public override void Execute() { OwnFighters.Where(u => u.IsIdle).ForEach(u => { u.Move(_rellyFightersTo, false); MyUnits.SetActivity(u, nameof(FightersRallyPoint)); }); }
private void RetreatToClosestReinforcement(Unit u) { MyUnits.SetActivity(u, nameof(RetreatIfOutnumbered)); var natural = _gameInfo.MyBases.FirstOrDefault(b => b.IsNatural); var any = _gameInfo.MyBases.FirstOrDefault(); var retreatPoint = (natural ?? any)?.BaseRegion.ContentTiles.First().AsWalkTile().ToPixelTile() ?? _mapCenter; u.Move(retreatPoint, false); }
private static void AttackClosestEnemyBuilding(IReadOnlyCollection <Unit> idleUnitsOfWantedTypeInMyBase) { var closestEnemyBuilding = GameMemory.EnemyBuildings.MinBy(b => b.CalcApproximateDistance(idleUnitsOfWantedTypeInMyBase.First().Position)); idleUnitsOfWantedTypeInMyBase.ForEach(u => { MyUnits.SetActivity(u, nameof(OrderIdleUnitsToAttack)); u.Attack(closestEnemyBuilding, false); }); }
private static void ShiftAttackAllStartLocations(IEnumerable <Unit> units) { var notMyBaseStartLocations = Game.StartLocations.Except(new[] { Game.Self.StartLocation }) .Select(loc => new Position(loc.X * 32, loc.Y * 32)) .ToList(); units.ForEach(u => notMyBaseStartLocations.ForEach(position => { MyUnits.SetActivity(u, nameof(OrderIdleUnitsToAttack)); u.Attack(position, true); })); }
private static void Kite(Unit kiter, Unit target) { const int extraDistance = 32; var retreatVector = GetRetreatVector(target, kiter); var wantedDistance = kiter.SelfGroundRangePx() + extraDistance; var fleeToX = Round(retreatVector.X * wantedDistance + target.Position.X); var fleeToY = Round(retreatVector.Y * wantedDistance + target.Position.Y); var fleeTo = new Position(fleeToX, fleeToY); MyUnits.SetActivity(kiter, nameof(RangedKite)); kiter.Move(fleeTo, false); }
public override void Execute() { if (!EnemiesInBase.Any()) { return; } OwnFighters.Where(u => u.IsIdle) .ForEach(u => { MyUnits.SetActivity(u, nameof(AttackEnemiesInBase)); u.Attack(EnemiesInBase.First().Position, false); }); }
public override void Execute() { var triggeringUnits = MyCombatUnits.Where(u => u.IsIdle).Where(IsOutsideOfBase).ToList(); if (!triggeringUnits.Any()) { return; } var visibleEnemyUnits = Game.Enemy.Units .Where(eu => eu.UnitType.Type != UnitType.Unknown) .Where(eu => !eu.IsCloaked) .ToList(); if (visibleEnemyUnits.Any()) { triggeringUnits.ForEach(u => { MyUnits.SetActivity(u, nameof(IdleFightersAttackClosestEnemy) + "Unit"); u.Attack(visibleEnemyUnits.ClosestTo(u).Position, false); }); return; } if (!GameMemory.EnemyBuildings.Any()) { triggeringUnits.ForEach(u => { MyUnits.SetActivity(u, nameof(IdleFightersAttackClosestEnemy) + "Searching"); u.Attack(RandomResourceSitePosition, false); }); return; } triggeringUnits.ForEach(u => { var closestEnemyBuilding = GameMemory.EnemyBuildings.MinBy(b => u.Position.CalcApproximateDistance(b)); MyUnits.SetActivity(u, nameof(IdleFightersAttackClosestEnemy) + "Building"); u.Attack(closestEnemyBuilding, false); }); }
public override void Execute() { OwnWorkers.Where(u => u.IsUnderAttack).ForEach(worker => { var closeUnits = worker.UnitsInRadius(64); var closeEnemyUnits = closeUnits.Where(Game.Enemy.Units.Contains).ToList(); if (!closeEnemyUnits.Any()) { return; } var closeAlliedUnits = closeUnits.Where(Game.Self.Units.Contains) .Where(w => w.IsGatheringMinerals || w.IsGatheringGas).Where(w => !ShouldFlee(w)); closeAlliedUnits.ForEach(u => { MyUnits.SetActivity(u, nameof(WorkersAttackClosestEnemy)); u.Attack(closeEnemyUnits.First(), false); }); if (ShouldFlee(worker)) { GatherBaseMineralFarFromAttacker(worker, closeEnemyUnits.First()); } }); }
private static bool MoveDroneToExpandLocation(Unit drone, Position expandLocation) { MyUnits.SetActivity(drone, "MoveDroneToExpansion"); return(drone.Move(expandLocation, false)); }