From 5b25eeff1952b22a74ed5b403b4d61ed2104374b Mon Sep 17 00:00:00 2001 From: Drekken Date: Mon, 8 Apr 2024 19:14:33 -0400 Subject: [PATCH] Added a Keep Safe to the Squad A and B if there are 5 enemy units near the pylon --- bot/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bot/main.py b/bot/main.py index 6502346..c5a0104 100644 --- a/bot/main.py +++ b/bot/main.py @@ -128,9 +128,13 @@ def _main_army_attack(self, main_attack_force: Units, attack_target: Point2, gro for Unit in main_attack_force: main_maneuver = CombatManeuver() # avoid the enemy units to attack the pylons - if enemy_pylon and cy_distance_to(Unit.position, enemy_pylon.position) < 10.0: - main_maneuver.add(PathUnitToTarget(Unit, ground_grid, enemy_pylon.position, success_at_distance=6.0)) - main_maneuver.add(AttackTarget(Unit, enemy_pylon)) + if enemy_pylon and cy_distance_to(Unit.position, enemy_pylon.position) < 15.0: + # attack the pylon if there are less than 3 enemy units nearby + if self.enemy_units.closer_than(10.0, enemy_pylon).amount < 5: + main_maneuver.add(PathUnitToTarget(Unit, ground_grid, enemy_pylon.position, success_at_distance=6.0)) + main_maneuver.add(AttackTarget(Unit, enemy_pylon)) + else: + main_maneuver.add(KeepUnitSafe(unit=Unit, grid=ground_grid)) else: main_maneuver.add(PathUnitToTarget(Unit, ground_grid, attack_target, success_at_distance=20.0, danger_distance=30.0, danger_threshold=6.0)) self.register_behavior(main_maneuver) @@ -144,9 +148,13 @@ def _b_army_attack(self, b_attack_force: Units, attack_target: Point2, ground_gr for Unit in b_attack_force: b_maneuver = CombatManeuver() # avoid the enemy units to attack the pylons - if enemy_pylon and cy_distance_to(Unit.position, enemy_pylon.position) < 10.0: - b_maneuver.add(PathUnitToTarget(Unit, ground_grid, enemy_pylon.position.to2.offset(self.offset), success_at_distance=3.0, danger_threshold=2.0)) - b_maneuver.add(AttackTarget(Unit, enemy_pylon)) + if enemy_pylon and cy_distance_to(Unit.position, enemy_pylon.position) < 15.0: + # attack the pylon if there are less than 3 enemy units nearby + if self.enemy_units.closer_than(10.0, enemy_pylon).amount < 5: + b_maneuver.add(PathUnitToTarget(Unit, ground_grid, enemy_pylon.position.to2.offset(self.offset), success_at_distance=3.0, danger_threshold=2.0)) + b_maneuver.add(AttackTarget(Unit, enemy_pylon)) + else: + b_maneuver.add(KeepUnitSafe(unit=Unit, grid=ground_grid)) else: b_maneuver.add(PathUnitToTarget(Unit, ground_grid, attack_target, success_at_distance=10.0, danger_distance=30.0, danger_threshold=6.0)) self.register_behavior(b_maneuver)