public override void Update() { var ballMap = Game.GameManager.Navigation.PotentialMaps["BallMap"]; if (PlayerAI.Player.Ball != null) { var target = Game.GameManager.Players[0]; var dir = target.Position - PlayerAI.Position; PlayerAI.AimAtPosition(target.Position); if (!PlayerAI.Player.IsShotCharging) { PlayerAI.StartShotCharge(); } if (PlayerAI.Player.IsShotCharged) { PlayerAI.ShootCharged(dir); } } else if (Game.GameManager.Ball != null && Game.GameManager.Ball.Player == null) { PlayerAI.NavigateToBall(); } }
private void DefenseMode() { var ballMap = Game.GameManager.Navigation.PotentialMaps["BallMap"]; float ballValue = PlayerAI.MapValue(ballMap, PlayerAI.Player.Position); float teamMateBallValue = PlayerAI.MapValue(ballMap, PlayerAI.Player.TeamMate.Position); bool canTakeBall = PlayerAI.Player.BallTrigger.Enabled && !Game.GameManager.Ball.Properties.Untakable && !Game.GameManager.Ball.Properties.PassThroughPlayer; bool otherTeamHasBall = canTakeBall && Game.GameManager.Ball != null && Game.GameManager.Ball.Player != null; float defenseValue = GetDefenseValue(PlayerAI.Player.Team, PlayerAI.Player.Position); float attackValue = GetShootValue(PlayerAI.Player.Team, PlayerAI.Player.Position); float relativePosition = attackValue / defenseValue; float teamMateDefenseValue = GetDefenseValue(PlayerAI.Player.Team, PlayerAI.Player.TeamMate.Position); float teamMateAttackValue = GetShootValue(PlayerAI.Player.Team, PlayerAI.Player.TeamMate.Position); float teamMateRelativePosition = teamMateAttackValue / teamMateDefenseValue; float otherTeamAttackValue = float.NegativeInfinity; if (otherTeamHasBall) { otherTeamAttackValue = GetDefenseValue(PlayerAI.Player.Team, Game.GameManager.Ball.Position); } float ballDefensePosition = GetDefenseValue(PlayerAI.Player.Team, Game.GameManager.Ball.Position); float ballAttackPosition = GetShootValue(PlayerAI.Player.Team, Game.GameManager.Ball.Position); float ballRelativePosition = ballAttackPosition / ballDefensePosition; //ballRelativePosition > 1 if in attack float ballThreshold = 0.9f; float defThreshold = 0.65f; float mateDefThreshold = 0.85f; Engine.Debug.Screen.AddCircle(PlayerAI.Position, 180); if ((PlayerAI.Info.BallInGoal || Game.Arena.SelectedLauncher != null) && (PlayerAI.Info.GoalTeam != null && PlayerAI.Player.Team != PlayerAI.Info.GoalTeam)) { MoveToInitialPosition(); //MoveToDefense(); } else if (canTakeBall && ballValue >= teamMateBallValue) { PlayerAI.TackleIfInRange(); PlayerAI.NavigateToBall(); } else if (defenseValue < teamMateDefenseValue && ballDefensePosition > ballThreshold && defenseValue < defThreshold && teamMateDefenseValue < mateDefThreshold) { if (PlayerAI.AiState.TeleportToDefense && !PlayerAI.Player.TeamMate.Properties.Blink) { PlayerAI.Blink(Vector2.Zero); } else { MoveToDefense(); } } else if (!PlayerAI.Player.BallTrigger.Enabled) { //MoveToInitialPosition(); MoveToDefense(); } else { PlayerAI.TackleIfInRange(); PlayerAI.NavigateToAssistPosition(); } }