From 4913ecaa8049c92da0efb07f0ef9c496b3e6e85c Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 09:30:06 -0600 Subject: [PATCH 01/17] (3000-mass)/3500 or 0.1 if over 3000 --- source/Ship.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/Ship.cpp b/source/Ship.cpp index b65dd31c99c8..b9006b550dc0 100644 --- a/source/Ship.cpp +++ b/source/Ship.cpp @@ -2090,15 +2090,22 @@ void Ship::Move(vector &visuals, list> &flotsam) } // Lateral Thrust functionality. // This pulls "lateral thrust ratio" from the ship definition, - // and if there isn't one, it uses the default value of 0.25. - // Future thought: move this default into a gamerule or interfaces.txt + // and if there isn't one, it uses the default value of 0.25, + // which is listed as a gamerule value. double latThrustCommand = commands.LateralThrust(); double latThrust = 0.; double lateralThrustValue = 0.; if(attributes.Get("lateral thrust ratio")) lateralThrustValue = attributes.Get("lateral thrust ratio"); - else if(!attributes.Get("lateral thrust ratio")) - lateralThrustValue = GameData::GetGamerules().DefaultLateralThrustRatio(); + else if (!attributes.Get("lateral thrust ratio")) + { + // lateralThrustValue = GameData::GetGamerules().DefaultLateralThrustRatio(); + if (mass < 3000) + lateralThrustValue = (3000 - mass) / 3500; + else + lateralThrustValue = 0.1; + } + if(latThrustCommand) { // Check if we are able to apply this thrust. From 2ee13f0e5bc2259f0d9823018ae71277d7c0f350 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 09:58:46 -0600 Subject: [PATCH 02/17] Change to < 2500 --- source/Ship.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Ship.cpp b/source/Ship.cpp index b9006b550dc0..3ce280b26ef4 100644 --- a/source/Ship.cpp +++ b/source/Ship.cpp @@ -2100,7 +2100,7 @@ void Ship::Move(vector &visuals, list> &flotsam) else if (!attributes.Get("lateral thrust ratio")) { // lateralThrustValue = GameData::GetGamerules().DefaultLateralThrustRatio(); - if (mass < 3000) + if (mass < 2500) lateralThrustValue = (3000 - mass) / 3500; else lateralThrustValue = 0.1; From b0ac3e1051eb1f5ae5b47ffb2debaad6eaa900a4 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 10:16:06 -0600 Subject: [PATCH 03/17] white space removal --- source/Ship.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Ship.cpp b/source/Ship.cpp index 3ce280b26ef4..c4ba31f6e6f8 100644 --- a/source/Ship.cpp +++ b/source/Ship.cpp @@ -2097,10 +2097,10 @@ void Ship::Move(vector &visuals, list> &flotsam) double lateralThrustValue = 0.; if(attributes.Get("lateral thrust ratio")) lateralThrustValue = attributes.Get("lateral thrust ratio"); - else if (!attributes.Get("lateral thrust ratio")) + else if(!attributes.Get("lateral thrust ratio")) { // lateralThrustValue = GameData::GetGamerules().DefaultLateralThrustRatio(); - if (mass < 2500) + if(mass < 2500) lateralThrustValue = (3000 - mass) / 3500; else lateralThrustValue = 0.1; From 7525f98fa9488f9806a54a9d37dcc1333238b7ea Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:40:42 -0600 Subject: [PATCH 04/17] AttackRear --- source/AI.cpp | 195 +++++++++++++++++++++++++++++++++++++++++++++++++- source/AI.h | 4 ++ 2 files changed, 198 insertions(+), 1 deletion(-) diff --git a/source/AI.cpp b/source/AI.cpp index 18d6f07be550..031cdc6a6641 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2046,6 +2046,38 @@ bool AI::MoveTo(Ship &ship, Command &command, const Point &targetPosition, +bool AI::MoveThrough(Ship& ship, Command& command, const Point& targetPosition, const Point& targetVelocity, double radius, double slow) +{ + const Point& position = ship.Position(); + const Point& velocity = ship.Velocity(); + const Angle& angle = ship.Facing(); + Point dp = targetPosition - position; + Point dv = targetVelocity - velocity; + + double speed = dv.Length(); + + bool isClose = (dp.Length() < radius); + if (isClose && speed < slow) + return true; + + bool shouldReverse = false; + //dp = targetPosition - StoppingPoint(ship, targetVelocity, shouldReverse); + bool isFacing = (dp.Unit().Dot(angle.Unit()) > .95); + if (!isClose || (!isFacing && !shouldReverse)) + command.SetTurn(TurnToward(ship, dp)); + if (isFacing) + command |= Command::FORWARD; + else if (shouldReverse) + { + command.SetTurn(TurnToward(ship, velocity)); + command |= Command::BACK; + } + + return false; +} + + + bool AI::Stop(Ship &ship, Command &command, double maxSpeed, const Point direction) { const Point &velocity = ship.Velocity(); @@ -2113,6 +2145,163 @@ bool AI::Stop(Ship &ship, Command &command, double maxSpeed, const Point directi +void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) +{ + int targetTurretRange = target.GetAICache().TurretRange(); + int weaponsRange = 864; // need to calculate turn around distance v attacker gun range. + Point direction = ship.Position() - target.Position(); + double length = direction.Length(); + + Point northUnit = target.Facing().Unit(); + Point westUnit(northUnit.Y(), -northUnit.X()); + Point eastUnit(-northUnit.Y(), northUnit.X()); + + //Point east = (target.Position() + eastUnit * targetTurretRange); + //Point west = (target.Position() + westUnit * targetTurretRange); + + //Point frontAvoid = (direction.Unit().Cross(target.Facing().Unit()) < 0. ? west : east); + //Point velocity = ship.Velocity(); + bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .9; + bool isFacing = direction.Unit().Dot(ship.Facing().Unit()) < 0; + bool outerRadius = direction.Length() < targetTurretRange * 1.2; //should be max (target gun range, turget turret range) + // double speed = ship.MaxVelocity(); + + if (outerRadius) + { + /* if(inFront && isFacing) + { + MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); + if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) + command |= Command::AFTERBURNER; + } + else if(inFront) + { + command |= Command::FORWARD; + } + */ + if (inFront && isFacing) + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::LATERALLEFT; + command |= Command::FORWARD; + } + else if (length >= weaponsRange) + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::FORWARD; + } + else if (length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) > .7) + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::FORWARD; + } + else if (length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) < .7) + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + } + else if (length < weaponsRange) + { + command |= Command::FORWARD; + } + } + else + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::FORWARD; + } +} + + + +void AI::AttackRear(Ship& ship, Command& command, const Ship& target) +{ + int weaponsRange = 864; //attacker weapon range this will be passed in eventually + int targetTurretRange = target.GetAICache().TurretRange(); + Point offset = target.Position() - target.Facing().Unit() * weaponsRange; + Point direction = ship.Position() - target.Position(); + Point d = (target.Position() + target.Velocity()) - (ship.Position() + ship.Velocity()); + + Point northUnit = target.Facing().Unit(); + Point southUnit = -target.Facing().Unit(); + Point westUnit(northUnit.Y(), -northUnit.X()); + Point eastUnit(-northUnit.Y(), northUnit.X()); + + Point northWestUnit(northUnit.X() + westUnit.X(), northUnit.Y() + westUnit.Y()); + Point northWest = (target.Position() + northWestUnit * targetTurretRange / 1.41); + + Point northEastUnit(northUnit.X() + eastUnit.X(), northUnit.Y() + eastUnit.Y()); + Point northEast = (target.Position() + northEastUnit * targetTurretRange / 1.41); + + Point southWestUnit(southUnit.X() + westUnit.X(), southUnit.Y() + westUnit.Y()); + Point southWest = (target.Position() + southWestUnit * targetTurretRange / 1.41); + + Point southEastUnit(southUnit.X() + eastUnit.X(), southUnit.Y() + eastUnit.Y()); + Point southEast = (target.Position() + southEastUnit * targetTurretRange / 1.41); + + Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); + Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); + + bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.75; + bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; + bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; + bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .75; + + bool atSide = (!inFront && !isBehind); + bool inRange = direction.Length() < weaponsRange; + bool tooClose = direction.Length() < weaponsRange * .9; + bool outerRadius = direction.Length() < weaponsRange * 2; + double reverseSpeed = ship.MaxReverseVelocity(); + double speed = ship.MaxVelocity(); + + + if (outerRadius) + { + if (inFront) + { + MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); + } + else if (atSide) + { + MoveThrough(ship, command, rearAvoid, target.Velocity(), 20., speed); + } + else if (!isBehind) //not behind target + { + MoveTo(ship, command, offset, target.Velocity(), 80., 20); + } + else if (!inRange) //behind but too far away + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::FORWARD; + } + else if (tooClose) //behind target but too close + { + if (reverseSpeed && target.Velocity().Dot(-d.Unit()) <= reverseSpeed) + { + command.SetTurn(TurnToward(ship, d)); + if (ship.Facing().Unit().Dot(d) >= 0.) + command |= Command::BACK; + } + else + { + MoveTo(ship, command, offset, target.Velocity(), 80., 20); + } + } + else if (inRange) //behind target, in sweet spot. + { + if (justRight) command |= Command::LATERALLEFT; + else if (justLeft) command |= Command::LATERALRIGHT; + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + } + } + else + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command |= Command::FORWARD; + } +} + + + void AI::PrepareForHyperspace(Ship &ship, Command &command) { bool hasHyperdrive = ship.JumpNavigation().HasHyperdrive(); @@ -2376,11 +2565,15 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target) } } // Fire if we can or move closer to use all weapons. - else + if(target.TrueTurnRate() < ship.Acceleration() * 1.2) AttackRear(ship, command, target); + else if(ship.Attributes().Get("rear")) StrikeThrough(ship, command, target); + else if(ship.Attributes().Get("strike")) StrikeThrough(ship, command, target); + else if(weaponDistanceFromTarget < shortestRange * .75) AimToAttack(ship, command, target); else MoveToAttack(ship, command, target); + } diff --git a/source/AI.h b/source/AI.h index 11e595ec85c3..c0b857ba4fe8 100644 --- a/source/AI.h +++ b/source/AI.h @@ -108,9 +108,13 @@ template static bool MoveToPlanet(Ship &ship, Command &command); static bool MoveTo(Ship &ship, Command &command, const Point &targetPosition, const Point &targetVelocity, double radius, double slow); + static bool MoveThrough(Ship &ship, Command &command, const Point &targetPosition, + const Point &targetVelocity, double radius, double slow); static bool Stop(Ship &ship, Command &command, double maxSpeed = 0., const Point direction = Point()); static void PrepareForHyperspace(Ship &ship, Command &command); static void CircleAround(Ship &ship, Command &command, const Body &target); + static void StrikeThrough(Ship &ship, Command &command, const Ship &target); + static void AttackRear(Ship& ship, Command& command, const Ship& target); static void Swarm(Ship &ship, Command &command, const Body &target); static void KeepStation(Ship &ship, Command &command, const Body &target); static void Attack(Ship &ship, Command &command, const Ship &target); From e6a9003a389b8e137d4104e96056ee4f7d1d4450 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:56:58 -0600 Subject: [PATCH 05/17] whitespace --- source/AI.cpp | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index 031cdc6a6641..e056f43fc03f 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2046,28 +2046,28 @@ bool AI::MoveTo(Ship &ship, Command &command, const Point &targetPosition, -bool AI::MoveThrough(Ship& ship, Command& command, const Point& targetPosition, const Point& targetVelocity, double radius, double slow) +bool AI::MoveThrough(Ship &ship, Command &command, const Point &targetPosition, const Point &targetVelocity, double radius, double slow) { - const Point& position = ship.Position(); - const Point& velocity = ship.Velocity(); - const Angle& angle = ship.Facing(); + const Point &position = ship.Position(); + const Point &velocity = ship.Velocity(); + const Angle &angle = ship.Facing(); Point dp = targetPosition - position; Point dv = targetVelocity - velocity; double speed = dv.Length(); bool isClose = (dp.Length() < radius); - if (isClose && speed < slow) + if(isClose && speed < slow) return true; bool shouldReverse = false; - //dp = targetPosition - StoppingPoint(ship, targetVelocity, shouldReverse); + // dp = targetPosition - StoppingPoint(ship, targetVelocity, shouldReverse); bool isFacing = (dp.Unit().Dot(angle.Unit()) > .95); - if (!isClose || (!isFacing && !shouldReverse)) + if(!isClose || (!isFacing && !shouldReverse)) command.SetTurn(TurnToward(ship, dp)); - if (isFacing) + if(isFacing) command |= Command::FORWARD; - else if (shouldReverse) + else if(shouldReverse) { command.SetTurn(TurnToward(ship, velocity)); command |= Command::BACK; @@ -2156,17 +2156,17 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) Point westUnit(northUnit.Y(), -northUnit.X()); Point eastUnit(-northUnit.Y(), northUnit.X()); - //Point east = (target.Position() + eastUnit * targetTurretRange); - //Point west = (target.Position() + westUnit * targetTurretRange); + // Point east = (target.Position() + eastUnit * targetTurretRange); + // Point west = (target.Position() + westUnit * targetTurretRange); - //Point frontAvoid = (direction.Unit().Cross(target.Facing().Unit()) < 0. ? west : east); - //Point velocity = ship.Velocity(); + // Point frontAvoid = (direction.Unit().Cross(target.Facing().Unit()) < 0. ? west : east); + // Point velocity = ship.Velocity(); bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .9; bool isFacing = direction.Unit().Dot(ship.Facing().Unit()) < 0; bool outerRadius = direction.Length() < targetTurretRange * 1.2; //should be max (target gun range, turget turret range) // double speed = ship.MaxVelocity(); - if (outerRadius) + if(outerRadius) { /* if(inFront && isFacing) { @@ -2179,27 +2179,27 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) command |= Command::FORWARD; } */ - if (inFront && isFacing) + if(inFront && isFacing) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command |= Command::LATERALLEFT; command |= Command::FORWARD; } - else if (length >= weaponsRange) + else if(length >= weaponsRange) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command |= Command::FORWARD; } - else if (length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) > .7) + else if(length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) > .7) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command |= Command::FORWARD; } - else if (length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) < .7) + else if(length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) < .7) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); } - else if (length < weaponsRange) + else if(length < weaponsRange) { command |= Command::FORWARD; } @@ -2254,31 +2254,31 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) double speed = ship.MaxVelocity(); - if (outerRadius) + if(outerRadius) { - if (inFront) + if(inFront) { MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); } - else if (atSide) + else if(atSide) { MoveThrough(ship, command, rearAvoid, target.Velocity(), 20., speed); } - else if (!isBehind) //not behind target + else if(!isBehind) //not behind target { MoveTo(ship, command, offset, target.Velocity(), 80., 20); } - else if (!inRange) //behind but too far away + else if(!inRange) //behind but too far away { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command |= Command::FORWARD; } - else if (tooClose) //behind target but too close + else if(tooClose) //behind target but too close { - if (reverseSpeed && target.Velocity().Dot(-d.Unit()) <= reverseSpeed) + if(reverseSpeed && target.Velocity().Dot(-d.Unit()) <= reverseSpeed) { command.SetTurn(TurnToward(ship, d)); - if (ship.Facing().Unit().Dot(d) >= 0.) + if(ship.Facing().Unit().Dot(d) >= 0.) command |= Command::BACK; } else @@ -2286,10 +2286,10 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) MoveTo(ship, command, offset, target.Velocity(), 80., 20); } } - else if (inRange) //behind target, in sweet spot. + else if(inRange) //behind target, in sweet spot. { - if (justRight) command |= Command::LATERALLEFT; - else if (justLeft) command |= Command::LATERALRIGHT; + if(justRight) command |= Command::LATERALLEFT; + else if(justLeft) command |= Command::LATERALRIGHT; command.SetTurn(TurnToward(ship, TargetAim(ship, target))); } } From 814e622257d3c53265621f2f7120d8e07d29b757 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 18:04:53 -0600 Subject: [PATCH 06/17] More stylistic fixes --- source/AI.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index e056f43fc03f..b0d977253f79 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2046,7 +2046,8 @@ bool AI::MoveTo(Ship &ship, Command &command, const Point &targetPosition, -bool AI::MoveThrough(Ship &ship, Command &command, const Point &targetPosition, const Point &targetVelocity, double radius, double slow) +bool AI::MoveThrough(Ship &ship, Command &command, const Point &targetPosition, + const Point &targetVelocity, double radius, double slow) { const Point &position = ship.Position(); const Point &velocity = ship.Velocity(); @@ -2163,22 +2164,22 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) // Point velocity = ship.Velocity(); bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .9; bool isFacing = direction.Unit().Dot(ship.Facing().Unit()) < 0; - bool outerRadius = direction.Length() < targetTurretRange * 1.2; //should be max (target gun range, turget turret range) + bool outerRadius = direction.Length() < targetTurretRange * 1.2; // should be max (target gun range, turget turret range) // double speed = ship.MaxVelocity(); if(outerRadius) { - /* if(inFront && isFacing) - { - MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); - if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) - command |= Command::AFTERBURNER; - } - else if(inFront) - { - command |= Command::FORWARD; - } - */ + // if(inFront && isFacing) + // { + // MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); + // if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) + // command |= Command::AFTERBURNER; + // } + // else if(inFront) + // { + // command |= Command::FORWARD; + // } + if(inFront && isFacing) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); @@ -2215,7 +2216,7 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { - int weaponsRange = 864; //attacker weapon range this will be passed in eventually + int weaponsRange = 864; // attacker weapon range this will be passed in eventually int targetTurretRange = target.GetAICache().TurretRange(); Point offset = target.Position() - target.Facing().Unit() * weaponsRange; Point direction = ship.Position() - target.Position(); From 1e5e4379eb97e8aca33fa7acf5fcc344460a1959 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 20:32:11 -0600 Subject: [PATCH 07/17] style fixes --- source/AI.cpp | 35 +++++++++++++++++------------------ source/AI.h | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index b0d977253f79..8e98ab5be806 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2164,22 +2164,22 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) // Point velocity = ship.Velocity(); bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .9; bool isFacing = direction.Unit().Dot(ship.Facing().Unit()) < 0; - bool outerRadius = direction.Length() < targetTurretRange * 1.2; // should be max (target gun range, turget turret range) + bool outerRadius = direction.Length() < targetTurretRange * 1.2; // should be max target gun & turget turret range // double speed = ship.MaxVelocity(); if(outerRadius) { - // if(inFront && isFacing) - // { - // MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); - // if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) - // command |= Command::AFTERBURNER; - // } - // else if(inFront) - // { - // command |= Command::FORWARD; - // } - + // if(inFront && isFacing) + // { + // MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); + // if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) + // command |= Command::AFTERBURNER; + // } + // else if(inFront) + // { + // command |= Command::FORWARD; + // } + if(inFront && isFacing) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); @@ -2265,16 +2265,16 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { MoveThrough(ship, command, rearAvoid, target.Velocity(), 20., speed); } - else if(!isBehind) //not behind target + else if(!isBehind) // not behind target { MoveTo(ship, command, offset, target.Velocity(), 80., 20); } - else if(!inRange) //behind but too far away + else if(!inRange) // behind but too far away { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command |= Command::FORWARD; } - else if(tooClose) //behind target but too close + else if(tooClose) // behind target but too close { if(reverseSpeed && target.Velocity().Dot(-d.Unit()) <= reverseSpeed) { @@ -2287,7 +2287,7 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) MoveTo(ship, command, offset, target.Velocity(), 80., 20); } } - else if(inRange) //behind target, in sweet spot. + else if(inRange) // behind target, in sweet spot. { if(justRight) command |= Command::LATERALLEFT; else if(justLeft) command |= Command::LATERALRIGHT; @@ -2569,12 +2569,11 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target) if(target.TrueTurnRate() < ship.Acceleration() * 1.2) AttackRear(ship, command, target); else if(ship.Attributes().Get("rear")) StrikeThrough(ship, command, target); else if(ship.Attributes().Get("strike")) StrikeThrough(ship, command, target); - else + else if(weaponDistanceFromTarget < shortestRange * .75) AimToAttack(ship, command, target); else MoveToAttack(ship, command, target); - } diff --git a/source/AI.h b/source/AI.h index c0b857ba4fe8..c3e1b4261bdc 100644 --- a/source/AI.h +++ b/source/AI.h @@ -114,7 +114,7 @@ template static void PrepareForHyperspace(Ship &ship, Command &command); static void CircleAround(Ship &ship, Command &command, const Body &target); static void StrikeThrough(Ship &ship, Command &command, const Ship &target); - static void AttackRear(Ship& ship, Command& command, const Ship& target); + static void AttackRear(Ship &ship, Command &command, const Ship &target); static void Swarm(Ship &ship, Command &command, const Body &target); static void KeepStation(Ship &ship, Command &command, const Body &target); static void Attack(Ship &ship, Command &command, const Ship &target); From 487d12be3feee12f777da8ef2ddfbfbf60736903 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 20 Apr 2023 21:59:37 -0600 Subject: [PATCH 08/17] Fixing more whitespace --- source/AI.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index 8e98ab5be806..52bb67b70097 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2174,11 +2174,11 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) // MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); // if(command.Has(Command::FORWARD) && ShouldUseAfterburner(ship)) // command |= Command::AFTERBURNER; - // } - // else if(inFront) - // { + // } + // else if(inFront) + // { // command |= Command::FORWARD; - // } + // } if(inFront && isFacing) { From 112611c15217c5f79d4c38dabba0683235a76d33 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:03:13 -0600 Subject: [PATCH 09/17] command fixes and teseting swizzles Testing swizzles are using the finchtest ship sprite, which has lots of extra orange painted on it. cloaking red if in front default 0 if atSide salmon if notbehind blue if behind but too far away purplish if behind but too close neon green if behind and in range pink is all else --- images/ship/finchtest.png | Bin 0 -> 15550 bytes source/AI.cpp | 26 ++++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 images/ship/finchtest.png diff --git a/images/ship/finchtest.png b/images/ship/finchtest.png new file mode 100644 index 0000000000000000000000000000000000000000..609e911a5cf7e03146acf90669e57aad5cd0fed1 GIT binary patch literal 15550 zcmeHtbzD^4+V;@h-7tXU3)Q9a_g*_*Pe+vqpB^6o01&CGDH))CrBEL| zTx`_0@({Hl06?1*Y-HwZ01sgG^6_+Vc0;iG26-V^5rNJQ06^euNw%{;M{|12wH;ME zrWQ%J4suZU8XCAx;-{+ou-?W!wSOwetur5&~Ni@k4rlL21} zXihKpEaMkNiA!m9@dpnjOD^c-#;*rUI&(($vT$+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k2r5)isgbC?R{~v1H8SQPQ)HMtQToh7@yvzPBZ4DsUafzX8p?Xe6QuL z6vL;2iBx+Ej9X$-89D@GyMvBgvbaqX8GOTqB$^dwpSQQ2#9u#b{jJJCCBe7`f z+;=j&H@dHJ2mpwBZYt%rGFxLVks8Om{z{Ju$^9)g4f5nU5$(N^P2r~`nUaZ(Q7*HW z_o_9G4U0m2)q*bEM%w%Cu+b;5Q733BY+ok2e>w4DniwfzoW2EtX1}_OINy6%pW4W% z#pLk#vEsVeX<7q+_s@ zF!5*cXC%?MeG+jBW!|T8+-r4V!ugz!wu$-MhAJm3d>L_=J-?4ZZow>}4LQItMOorMrz^k`8~4 z^u>tq&YWz0iz|(B zsMvxgrHIXur>Z%HA66pwg3Tdgbl!t3#sXZUilcU6{Fi4#l@H}Ryz3v0t}M00iv@oo zu$;BETRA3w6iUVsMmgf=u`3xWE@9W7YG>@}TexnN?tH0CKo&|e3) zpxUy+;H;+w6CA4mlE!fNw>~&MG9J;Ucu05rI%2VS<2&V>;8$sx1{<7uOZV|e$2Y`x z{m!p$)Gn4&G1u@R|`jr5HQUi^&+(?<9 zUQvp94npx}9e6d2u+Y94@h3@kTa$*j=|lOm+*g|3(t#eg(94Ll88dJ6p>AQ2DI%BTblNe<^kJXFb( z)8O`90&q!MYyaarGzMo+yOw;=??3>9%8!JPs;U!3#ZsJpr~3l>nQLWSLoeNzKn=_C5k2ZW%pW}^6kp^ z?f}$2vl-2l^QKf(+^x*6_Kfby4<;_E)}#ke3z$EFS#ozF04Y);;sc*%uCD=Nd0zJL UQZz2qO&~yBSx2c_!6x$m07~~YN&o-= literal 0 HcmV?d00001 diff --git a/source/AI.cpp b/source/AI.cpp index 52bb67b70097..c1dae1bb361c 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2067,11 +2067,11 @@ bool AI::MoveThrough(Ship &ship, Command &command, const Point &targetPosition, if(!isClose || (!isFacing && !shouldReverse)) command.SetTurn(TurnToward(ship, dp)); if(isFacing) - command |= Command::FORWARD; + command.SetThrust(1.); else if(shouldReverse) { command.SetTurn(TurnToward(ship, velocity)); - command |= Command::BACK; + command.SetThrust(-1.); } return false; @@ -2260,19 +2260,23 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) if(inFront) { MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); + ship.SetSwizzle(27); } else if(atSide) { MoveThrough(ship, command, rearAvoid, target.Velocity(), 20., speed); + ship.SetSwizzle(0); } else if(!isBehind) // not behind target { MoveTo(ship, command, offset, target.Velocity(), 80., 20); + ship.SetSwizzle(8); } else if(!inRange) // behind but too far away { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::FORWARD; + command.SetThrust(1.); + ship.SetSwizzle(5); } else if(tooClose) // behind target but too close { @@ -2280,24 +2284,27 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { command.SetTurn(TurnToward(ship, d)); if(ship.Facing().Unit().Dot(d) >= 0.) - command |= Command::BACK; + command.SetThrust(-1.); } else { MoveTo(ship, command, offset, target.Velocity(), 80., 20); } + ship.SetSwizzle(14); } else if(inRange) // behind target, in sweet spot. { - if(justRight) command |= Command::LATERALLEFT; - else if(justLeft) command |= Command::LATERALRIGHT; + if (justRight) command.SetLateralThrust(-1.); + else if (justLeft) command.SetLateralThrust(1.); command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + ship.SetSwizzle(3); } } else { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::FORWARD; + command.SetThrust(1.); + ship.SetSwizzle(26); } } @@ -2506,7 +2513,10 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target) MoveToAttack(ship, command, target); return; } - + if (target.TrueTurnRate() < ship.Acceleration() * 1.2) + { + AttackRear(ship, command, target); + } // Check if this ship is fast enough to keep distance from target. // Have a 10% minimum to avoid ships getting in a chase loop. const bool isAbleToRun = target.MaxVelocity() * SAFETY_MULTIPLIER < ship.MaxVelocity(); From 560faaa7dbb6ede474d2e077e8ded8a3de904814 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:06:45 -0600 Subject: [PATCH 10/17] A few additional commands --- source/AI.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index c1dae1bb361c..a51d4e44340f 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2183,18 +2183,18 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) if(inFront && isFacing) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::LATERALLEFT; - command |= Command::FORWARD; + command.SetLateralThrust(-1); + command.SetThrust(1.); } else if(length >= weaponsRange) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::FORWARD; + command.SetThrust(1.); } else if(length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) > .7) { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::FORWARD; + command.SetThrust(1.); } else if(length < weaponsRange && ship.Facing().Unit().Dot(ship.Velocity().Unit()) < .7) { @@ -2202,13 +2202,13 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) } else if(length < weaponsRange) { - command |= Command::FORWARD; + command.SetThrust(1.); } } else { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command |= Command::FORWARD; + command.SetThrust(1.); } } From 03368ca241b338ed525230edfc063916c942c343 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Sat, 22 Apr 2023 08:43:14 -0600 Subject: [PATCH 11/17] Shortening the weaponsrange to match more typical fighter weapons --- source/AI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AI.cpp b/source/AI.cpp index a51d4e44340f..51a3bbdf11f3 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2216,7 +2216,7 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { - int weaponsRange = 864; // attacker weapon range this will be passed in eventually + int weaponsRange = 370; // attacker weapon range this will be passed in eventually int targetTurretRange = target.GetAICache().TurretRange(); Point offset = target.Position() - target.Facing().Unit() * weaponsRange; Point direction = ship.Position() - target.Position(); From b9c3a15bb6682866b420fb483edd5ded56b64fed Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Sat, 22 Apr 2023 08:45:25 -0600 Subject: [PATCH 12/17] Whitespace errors --- source/AI.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index 51a3bbdf11f3..4cf37084ca25 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2294,8 +2294,8 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) } else if(inRange) // behind target, in sweet spot. { - if (justRight) command.SetLateralThrust(-1.); - else if (justLeft) command.SetLateralThrust(1.); + if(justRight) command.SetLateralThrust(-1.); + else if(justLeft) command.SetLateralThrust(1.); command.SetTurn(TurnToward(ship, TargetAim(ship, target))); ship.SetSwizzle(3); } @@ -2513,7 +2513,7 @@ void AI::Attack(Ship &ship, Command &command, const Ship &target) MoveToAttack(ship, command, target); return; } - if (target.TrueTurnRate() < ship.Acceleration() * 1.2) + if(target.TrueTurnRate() < ship.Acceleration() * 1.2) { AttackRear(ship, command, target); } From 2934c5a48b30780873814dc17a22569b23ae8d73 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Sun, 23 Apr 2023 09:30:55 -0600 Subject: [PATCH 13/17] Lateral circling basic --- source/AI.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/AI.cpp b/source/AI.cpp index 4cf37084ca25..67746284a72a 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2255,9 +2255,15 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) double speed = ship.MaxVelocity(); - if(outerRadius) + if (outerRadius) { - if(inFront) + if (!isBehind) // not behind the target + { + command.SetTurn(TurnToward(ship, TargetAim(ship, target))); + command.SetLateralThrust(1.); + ship.SetSwizzle(27); + } + /*if (inFront) { MoveThrough(ship, command, frontAvoid, target.Velocity(), 20., speed); ship.SetSwizzle(27); @@ -2271,7 +2277,7 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { MoveTo(ship, command, offset, target.Velocity(), 80., 20); ship.SetSwizzle(8); - } + }*/ else if(!inRange) // behind but too far away { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); From 37bd67f0d651d5e223bd298e3ced4978895dd15b Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:21:01 -0600 Subject: [PATCH 14/17] Getting more of the intended behavior --- images/ship/finchtest.png | Bin 15550 -> 0 bytes source/AI.cpp | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 images/ship/finchtest.png diff --git a/images/ship/finchtest.png b/images/ship/finchtest.png deleted file mode 100644 index 609e911a5cf7e03146acf90669e57aad5cd0fed1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15550 zcmeHtbzD^4+V;@h-7tXU3)Q9a_g*_*Pe+vqpB^6o01&CGDH))CrBEL| zTx`_0@({Hl06?1*Y-HwZ01sgG^6_+Vc0;iG26-V^5rNJQ06^euNw%{;M{|12wH;ME zrWQ%J4suZU8XCAx;-{+ou-?W!wSOwetur5&~Ni@k4rlL21} zXihKpEaMkNiA!m9@dpnjOD^c-#;*rUI&(($vT$+s`1X*W_F8sNZ6~GUzh3n}_+|`N z^}k5E*>XI1Cb<9goJL%_ecvn?+kuL#7XY32xNhDVTS1i|yPz7GkhQ7Uhht54H zV=R;?MA+fU@rftR`RSR3H0ZiLf4-UG`bmE91uXwIU(~_jccy@jJEWiA>}*i=3$TCs zviV@OnJk8Ss5!hr_NpVG`Fvx9Uj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q7*HW z_o_9G4U0m2)q*bEM%w%Cu+b;5Q733BY+ok2e>w4DniwfzoW2EtX1}_OINy6%pW4W% z#pLk#vEsVeX<7q+_s@ zF!5*cXC%?MeG+jBW!|T8+-r4V!ugz!wu$-MhAJm3d>L_=J-?4ZZow>}4LQItMOorMrz^k`8~4 z^u>tq&YWz0iz|(B zsMvxgrHIXur>Z%HA66pwg3Tdgbl!t3#sXZUilcU6{Fi4#l@H}Ryz3v0t}M00iv@oo zu$;BETRA3w6iUVsMmgf=u`3xWE@9W7YG>@}TexnN?tH0CKo&|e3) zpxUy+;H;+w6CA4mlE!fNw>~&MG9J;Ucu05rI%2VS<2&V>;8$sx1{<7uOZV|e$2Y`x z{m!p$)Gn4&G1u@R|`jr5HQUi^&+(?<9 zUQvp94npx}9e6d2u+Y94@h3@kTa$*j=|lOm+*g|3(t#eg(94Ll88dJ6p>AQ2DI%BTblNe<^kJXFb( z)8O`90&q!MYyaarGzMo+yOw;=??3>9%8!JPs;U!3#ZsJpr~3l>nQLWSLoeNzKn=_C5k2ZW%pW}^6kp^ z?f}$2vl-2l^QKf(+^x*6_Kfby4<;_E)}#ke3z$EFS#ozF04Y);;sc*%uCD=Nd0zJL UQZz2qO&~yBSx2c_!6x$m07~~YN&o-= diff --git a/source/AI.cpp b/source/AI.cpp index 67746284a72a..a19afbacd567 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2259,8 +2259,9 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { if (!isBehind) // not behind the target { - command.SetTurn(TurnToward(ship, TargetAim(ship, target))); - command.SetLateralThrust(1.); + command.SetTurn(TurnToward(ship, TargetAim(ship, target))-0.2); + command.SetLateralThrust(TurnToward(ship, TargetAim(ship, target))); + if(!inRange) command.SetThrust(1.); ship.SetSwizzle(27); } /*if (inFront) @@ -2277,31 +2278,34 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) { MoveTo(ship, command, offset, target.Velocity(), 80., 20); ship.SetSwizzle(8); - }*/ + } else if(!inRange) // behind but too far away { command.SetTurn(TurnToward(ship, TargetAim(ship, target))); command.SetThrust(1.); ship.SetSwizzle(5); - } + }*/ else if(tooClose) // behind target but too close { if(reverseSpeed && target.Velocity().Dot(-d.Unit()) <= reverseSpeed) { - command.SetTurn(TurnToward(ship, d)); + command.SetTurn(TurnToward(ship, d)-0.2); + command.SetLateralThrust(-1.); if(ship.Facing().Unit().Dot(d) >= 0.) command.SetThrust(-1.); } else { - MoveTo(ship, command, offset, target.Velocity(), 80., 20); + command.SetTurn(TurnToward(ship, d) - 0.2); + command.SetLateralThrust(-1.); } ship.SetSwizzle(14); } else if(inRange) // behind target, in sweet spot. { - if(justRight) command.SetLateralThrust(-1.); - else if(justLeft) command.SetLateralThrust(1.); + // if(justRight) command.SetLateralThrust(-1.); + // else if(justLeft) command.SetLateralThrust(1.); + command.SetLateralThrust(-1.); command.SetTurn(TurnToward(ship, TargetAim(ship, target))); ship.SetSwizzle(3); } From 867a285f0680cdf1c8eceefc9c9d217a0814cc56 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:41:06 -0600 Subject: [PATCH 15/17] More to the rear --- source/AI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AI.cpp b/source/AI.cpp index a19afbacd567..44af6f09a95e 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2242,7 +2242,7 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); - bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.75; + bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.90; bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .75; From 845545c58edf3348733e631329f511118fd1e75e Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 27 Apr 2023 08:42:54 -0600 Subject: [PATCH 16/17] A tighter "isbehind" value for closer to fully at the rear positioning --- source/AI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AI.cpp b/source/AI.cpp index 44af6f09a95e..56a7b8534572 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2242,7 +2242,7 @@ void AI::AttackRear(Ship& ship, Command& command, const Ship& target) Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); - bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.90; + bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.98; bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .75; From 34ab72bbc501415f58c10e5ca87c9b24a13ceed7 Mon Sep 17 00:00:00 2001 From: Zitchas <32169904+Zitchas@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:20:10 -0400 Subject: [PATCH 17/17] Apply suggestions from code review by TheGiraffe3 Thanks for spotting this! Co-authored-by: Loymdayddaud <145969603+TheGiraffe3@users.noreply.github.com> --- source/AI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/AI.cpp b/source/AI.cpp index 455aa07fbbed..3aa53beea5f6 100644 --- a/source/AI.cpp +++ b/source/AI.cpp @@ -2547,7 +2547,7 @@ void AI::StrikeThrough(Ship& ship, Command& command, const Ship& target) // Point velocity = ship.Velocity(); bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .9; bool isFacing = direction.Unit().Dot(ship.Facing().Unit()) < 0; - bool outerRadius = direction.Length() < targetTurretRange * 1.2; // should be max target gun & turget turret range + bool outerRadius = direction.Length() < targetTurretRange * 1.2; // should be max target gun & turret range // double speed = ship.MaxVelocity(); if(outerRadius)