public bool CombatOrbit(Vector3D target)
        {
            if (!Avoiding && _shipControls != null)
            {
                var distance = (target - Ship.GetPosition()).Length();
                //MaxSpeed = ;
                //MaxSpeed = (target - Ship.GetPosition()).Length() < FollowRange*.8 ? 20 : MaxSpeed;

                //oh no... a turnary inside a turnary... someone burn me on a stick... nah its okay if I do it this one time
                MaxSpeed = MaxSpeed <10 ? 10 :
                                     distance> FollowRange ? distance / ApproachSpeedMod : 20;



                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    //Util.Notify("cp1");
                    //validateTarget(); //This is just to make sure our owner/target was not destoried
                    ResetOrbitCoords(target, FollowRange);


                    NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord], (IMyEntity)_shipControls);

                    //_toPosition - _fromPosition for distance or to generate a vector twords target
                    if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length() * .66)
                    {
                        _previousCoord = _currentCoord;
                        _currentCoord++;

                        if (_currentCoord >= _coords.Count)
                        {
                            _currentCoord = 0;
                        }
                    }

                    if (Math.Abs(nav.Direction.LengthSquared()) > 0 || Math.Abs(nav.Rotation.LengthSquared()) > 0)
                    {
                        _shipControls.MoveAndRotate(nav.Direction, Vector2.Zero, nav.Roll);

                        //this calculates max speed based on distance
                        if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                }
                return(true);
            }

            //indicates the drone was avoiding rather than orbiting
            return(false);
        }
        public bool Follow(Vector3D position, int followDistance)
        {
            if (Ship != null && !Avoiding && _shipControls != null)
            {
                NavInfo nav = new NavInfo(Ship.GetPosition(), position, (IMyEntity)_shipControls);

                var distance = (position - Ship.GetPosition()).Length();
                MaxSpeed = distance > followDistance ? distance / ApproachSpeedMod : 40;
                if (distance > 100)
                {
                    MaxSpeed = distance > followDistance ? distance / ApproachSpeedMod : 100;
                }

                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    AlignTo(position);

                    if (nav.Direction.Length() < followDistance)
                    {
                        if (Ship.Physics.LinearVelocity.Normalize() > 0)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                    {
                        if (Math.Abs(nav.Direction.Length()) > followDistance)
                        {
                            _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);
                            AlignTo(position);
                        }
                    }

                    if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                }
                return(true);
            }

            //indicates the drone was avoiding rather than following
            return(false);
        }
Exemplo n.º 3
0
        public void OrbitAttackTarget(Vector3D p, Vector3D v)
        {
            var distance = (p - Ship.GetPosition()).Length();
            var m        = Ship.Physics.LinearVelocity;

            //what is this you may ask? the enemy position plus their velocity, minus the drones velocity for lead shooting
            Vector3D position;
            NavInfo  nav;

            {
                position = new Vector3D(p.X + (v.X) - m.X, p.Y + (v.Y) - m.Y, p.Z + (v.Z) - m.Z);
                //position = new Vector3D(p.X + (v.X), p.Y + (v.Y), p.Z + (v.Z));

                nav = new NavInfo(Ship.GetPosition(), position, (IMyEntity)ShipControls);
                navigation.MaxSpeed = (v.Normalize() + 10) * 1.5;
            }

            if (!navigation.Avoiding)
            {
                if (distance > navigation.FollowRange / 2)
                {
                    CombatOrbit(position);
                }
            }

            var alignAngle = navigation.AlignTo(position);

            if (nav.Direction.Length() < _maxAttackRange && alignAngle < 3)
            {
                ManualFire(true);
            }
            else
            {
                ManualFire(false);
            }

            NameBeacon();
        }
Exemplo n.º 4
0
        //Working. this sorts through the list of nearbyentities and calculates a single avoidance vector


        public void ApproachLocation(Vector3D position)
        {
            Util.GetInstance().Log("Inside Approach Location Method", logPath);
            if (Ship != null && _shipControls != null)
            {
                Util.GetInstance().Log("ship not null, _controlls not nul", logPath);
                //NavInfo nav = new NavInfo(Ship.GetPosition(), position, (IMyEntity)_shipControls);
                var dir      = position - Ship.GetPosition();
                var distance = (position - Ship.GetPosition()).Length();
                MaxSpeed = 5;//distance > FollowRange ? distance / ApproachSpeedMod : 40;
                bool shipMovingTooFast       = Ship.Physics.LinearVelocity.Normalize() > MaxSpeed;
                bool isShipAlignedToLocation = FlyingTwords(dir);
                bool isShipWithinFollowRange = Math.Abs(dir.Length()) < FollowRange;
                bool isShipStopped           = Math.Abs(Ship.Physics.LinearVelocity.Normalize()) < 0;
                Util.GetInstance().Log("distance " + distance, logPath);
                Util.GetInstance().Log("maxSpeed " + MaxSpeed, logPath);

                Util.GetInstance().Log("currentSpeed " + Ship.Physics.LinearVelocity.Normalize(), logPath);

                if (shipMovingTooFast)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    Util.GetInstance().Log("dir/aligned/range/stopped/toofast " + dir + "/" + isShipAlignedToLocation + "/" + isShipWithinFollowRange + isShipStopped + "/" + shipMovingTooFast, logPath);
                    NavInfo navInfo = new NavInfo(Ship.GetPosition(), position, _shipControls.Entity);
                    _shipControls.MoveAndRotate(navInfo.Direction, navInfo.Rotation, navInfo.Roll);

                    //MyRemoteControl remote = _shipControls as MyRemoteControl;
                    //remote.PreviousControlledEntity.MoveAndRotate();
                    //_shipControls.MoveAndRotate(dir, new Vector2(), 0);
                    //MyAPIGateway.Session.GPS.AddLocalGps(MyAPIGateway.Session.GPS.Create("destination", "null", Ship.GetPosition() + dir, true, true));
                }
            }
        }
        //Working. this sorts through the list of nearbyentities and calculates a single avoidance vector
        public bool AvoidNearbyEntities()
        {
            //avoiding and avoiding stage two are what I use as "AirBreaks" to bring acceleration down
            //most of the time avoiding requires a direction change so this makes it easier to slow down and change direction
            //rather than just going full power in an new direction sice dampaners slow down the ship much faster than max opposite power it prevents
            //drones from drifting into one another while trying to avoid
            if (Avoiding)
            {
                Avoiding = false;
            }

            try{
                if (_shipControls != null && Ship != null)
                {
                    if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                    else if (Ship != null)
                    {
                        List <Vector3D> avoidanceVectors = new List <Vector3D>();
                        Vector2         avoidanceRot     = Vector2.Zero;

                        //from the list of my nearby entities select
                        //only targets that have a mass > 20% my mass (otherwise theres no real need to dodge)
                        //order them by distance
                        //select only the top _avoidNumTargets
                        var topEntities =
                            _nearbyFloatingObjects
                            .Where(y => y != null && (y.Physics.Mass > Ship.Physics.Mass * .2) &&
                                   (y != Ship))
                            //to rule out the chance of the ship avoiding its self... which is annoying
                            .OrderBy(x => (x.GetPosition() - Ship.GetPosition()).Length())
                            .Take(_avoidNumTargets).ToList();

                        //Dodge the _avoidNumTargets Entities found by building a single avoidance direction
                        foreach (var item in topEntities)
                        {
                            if (item != null)
                            {
                                var distance             = Math.Abs((item.GetPosition() - Ship.GetPosition()).Length());
                                var enemyBoundingBoxSize = (item.GetPosition() - item.LocalAABB.Max).Length() / 2;

                                if (distance < FollowRange / 8)
                                {
                                    avoidanceRot += NavInfo.CalculateRotation(item.GetPosition(),
                                                                              _shipControls as IMyEntity);


                                    var temp = (Ship.GetPosition() - item.GetPosition());
                                    var val2 = item.Physics.Mass / Ship.Physics.Mass > 75 ? 75 : item.Physics.Mass / Ship.Physics.Mass;
                                    if (val2 < 30)
                                    {
                                        val2 = 30;
                                    }


                                    double[] vals = { temp.X, temp.Y, temp.Z };
                                    double   min  = vals.Min();
                                    if ((int)min == 0)
                                    {
                                        min = 1;
                                    }
                                    temp = temp / min * val2;
                                    Util.GetInstance().Log("[DroneNavigation.AvoidNearbyEntities] " + Ship.DisplayName + " avoiding Ship -> Distance: " + distance + " Mass: " + item.Physics.Mass);
                                    Util.GetInstance().Log("^^avoiding power x:" + temp.X + " y:" + temp.Y + " z:" + temp.Z);

                                    avoidanceVectors.Add(temp);
                                    // * (item.Physics.Mass / biggestMass));
                                }
                            }
                        }

                        foreach (var item in _nearbyAsteroids)
                        {
                            if (item != null)
                            {
                                var distance             = Math.Abs((item.GetPosition() - Ship.GetPosition()).Length());
                                var enemyBoundingBoxSize = item.LocalAABB.Max.Normalize();

                                MaxSpeed = MaxSpeed > distance / ApproachSpeedMod ? distance / ApproachSpeedMod : MaxSpeed;
                                var detectRange = _avoidanceRange + enemyBoundingBoxSize;
                                if (distance < detectRange)
                                {
                                    avoidanceRot += NavInfo.CalculateRotation(item.GetPosition(), _shipControls as IMyEntity);
                                    var temp = (Ship.GetPosition() - item.GetPosition());
                                    var rx   = (detectRange - Math.Abs(temp.X)) * (temp.X / temp.X);
                                    var y    = (detectRange - Math.Abs(temp.Y)) * (temp.Y / temp.Y);
                                    var z    = (detectRange - Math.Abs(temp.Z)) * (temp.Z / temp.Z);

                                    double[] vals = new[] { rx, y, z };
                                    double   max  = vals.Max(x => Math.Abs(x));
                                    if (max == 0)
                                    {
                                        max = vals.Average() != 0?vals.Average():1;
                                    }

                                    var SpeedPowerBoostBasedOnRange = distance / 100;
                                    temp = new Vector3D(rx, y, z) / max * SpeedPowerBoostBasedOnRange * 20;
                                    Util.GetInstance().Log("[DroneNavigation.AvoidNearbyEntities] " + Ship.DisplayName + " avoiding asteroid -> Distance: " + (distance - detectRange));
                                    Util.GetInstance().Log("^^avoiding power x:" + temp.X + " y:" + temp.Y + " z:" + temp.Z);
                                    avoidanceVectors.Add(temp);
                                }
                            }
                        }

                        if (avoidanceVectors.Count > 0)
                        {
                            avoidanceVectors = avoidanceVectors.OrderBy(x => x.Length()).ToList();
                            var avoidanceVector = avoidanceVectors[0];

                            for (int i = 1; i < avoidanceVectors.Count && i < 5; i++)
                            {
                                var temp = avoidanceVectors[i];
                                avoidanceVector += temp;
                            }
                            avoidanceVector = (avoidanceVector / avoidanceVectors.Count);
                            double[] vals = { avoidanceVector.X, avoidanceVector.Y, avoidanceVector.Z };
                            double   max  = vals.Max(x => Math.Abs(x));
                            if (max == 0)
                            {
                                max = vals.Average() != 0 ? vals.Average() : 1;
                            }
                            avoidanceVector = avoidanceVector / max * 104;
                            if (_nearbyAsteroids.Count > 0)
                            {
                                Util.GetInstance().Log("[DroneNavigation.AvoidNearbyEntities] final avoiding power -> x:" + avoidanceVector.X + " y:" + avoidanceVector.Y + " z:" + avoidanceVector.Z);
                            }
                            if (MaxSpeed < 10)
                            {
                                MaxSpeed = 10;
                            }
                            AvoidTarget(avoidanceVector);
                            Avoiding = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                // i dont care about this error
                //Util.GetInstance().LogError(e.ToString());
            }
            return(Avoiding);
        }
        public bool Orbit(List <Vector3D> targets)
        {
            try
            {
                if (!Avoiding && _shipControls != null)
                {
                    if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                    else
                    {
                        ResetOrbitCoords(targets);
                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] number coords: " + _coords.Count() + " current coord " + _currentCoord,
                            "mothershipFlightPath.txt");
                        if ((_coords[_currentCoord] - Ship.GetPosition()).Length() < FollowRange / 2)
                        {
                            //Util.Notify("Skipping");
                            _currentCoord = _currentCoord + 1;
                        }

                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp1",
                            "mothershipFlightPath.txt");
                        if (_currentCoord >= _coords.Count)
                        {
                            _currentCoord = 0;
                        }

                        NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord],
                                                  (IMyEntity)_shipControls);
                        AlignTo(_coords[_currentCoord]);
                        //_toPosition - _fromPosition
                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp2",
                            "mothershipFlightPath.txt");
                        if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length() * .66)
                        {
                            _previousCoord = _currentCoord;
                            _currentCoord++;

                            if (_currentCoord >= _coords.Count)
                            {
                                _currentCoord = 0;
                            }
                        }

                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp3",
                            "mothershipFlightPath.txt");

                        if (Math.Abs(nav.Direction.LengthSquared()) > 0 ||
                            Math.Abs(nav.Rotation.LengthSquared()) > 0)
                        {
                            _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);

                            //this calculates max speed based on distance
                            if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                            {
                                _shipControls.MoveAndRotateStopped();
                            }
                        }
                        else
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    return(true);
                }
            } //indicates the drone was avoiding rather than orbiting
            catch (Exception e)
            {
                Util.GetInstance().LogError(e.ToString());
            }
            return(false);
        }
        //Working,
        public bool Orbit(Vector3D target)
        {
            if (!Avoiding && _shipControls != null)
            {
                //MyAPIGateway.Session.Factions.TryGetPlayerFaction();
                var distance = (target - Ship.GetPosition()).Length();
                MaxSpeed = distance / ApproachSpeedMod;

                if (MaxSpeed > 40)
                {
                    MaxSpeed = 40;
                }

                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    //Util.Notify("cp1");/
                    //validateTarget(); //This is just to make sure our owner/target was not destoried
                    ResetOrbitCoords(target, FollowRange);


                    if (((_coords[_currentCoord + 1 >= _coords.Count ? 0 : _currentCoord + 1] - Ship.GetPosition()).Length()
                         < (_coords[_currentCoord] - Ship.GetPosition()).Length()) && (_coords[_currentCoord] - Ship.GetPosition()).Length() < FollowRange / 4)
                    {
                        //Util.Notify("Skipping");
                        _currentCoord = _currentCoord + 1;
                    }


                    if (_currentCoord >= _coords.Count)
                    {
                        _currentCoord = 0;
                    }

                    NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord], (IMyEntity)_shipControls);
                    AlignTo(_coords[_currentCoord]);
                    //_toPosition - _fromPosition
                    if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length() * .66)
                    {
                        _previousCoord = _currentCoord;
                        _currentCoord++;

                        if (_currentCoord >= _coords.Count)
                        {
                            _currentCoord = 0;
                        }
                    }

                    if (Math.Abs(nav.Direction.LengthSquared()) > 0 || Math.Abs(nav.Rotation.LengthSquared()) > 0)
                    {
                        _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);

                        //this calculates max speed based on distance
                        if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                }
                return(true);
            }

            //indicates the drone was avoiding rather than orbiting
            return(false);
        }
Exemplo n.º 8
0
        public void OrbitAttackTarget(Vector3D p, Vector3D v)
        {
            var distance = (p - Ship.GetPosition()).Length();
            var m = Ship.Physics.LinearVelocity;

            //what is this you may ask? the enemy position plus their velocity, minus the drones velocity for lead shooting
            Vector3D position;
            NavInfo nav;

            {
                position = new Vector3D(p.X + (v.X) - m.X, p.Y + (v.Y) - m.Y, p.Z + (v.Z) - m.Z);
                //position = new Vector3D(p.X + (v.X), p.Y + (v.Y), p.Z + (v.Z));

                nav = new NavInfo(Ship.GetPosition(), position, (IMyEntity)ShipControls);
                navigation.MaxSpeed = (v.Normalize() + 10) * 1.5;
            }

            if (!navigation.Avoiding)
            {
                if (distance > navigation.FollowRange/2)
                    CombatOrbit(position);
            }

            var alignAngle = navigation.AlignTo(position);

            if (nav.Direction.Length() < _maxAttackRange && alignAngle < 3)
            {

                ManualFire(true);
            }
            else
            {
                ManualFire(false);
            }

            NameBeacon();
        }
        public bool Orbit(List<Vector3D> targets)
        {
            try
            {
                if (!Avoiding && _shipControls != null)
                {
                    if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                    else
                    {

                        ResetOrbitCoords(targets);
                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] number coords: " + _coords.Count() + " current coord " + _currentCoord,
                            "mothershipFlightPath.txt");
                        if ((_coords[_currentCoord] - Ship.GetPosition()).Length() < FollowRange/2)
                        {
                            //Util.Notify("Skipping");
                            _currentCoord = _currentCoord + 1;
                        }

                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp1",
                            "mothershipFlightPath.txt");
                        if (_currentCoord >= _coords.Count)
                            _currentCoord = 0;

                        NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord],
                            (IMyEntity) _shipControls);
                        AlignTo(_coords[_currentCoord]);
                        //_toPosition - _fromPosition
                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp2",
                            "mothershipFlightPath.txt");
                        if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length()*.66)
                        {
                            _previousCoord = _currentCoord;
                            _currentCoord++;

                            if (_currentCoord >= _coords.Count)
                                _currentCoord = 0;
                        }

                        Util.GetInstance()
                        .Log(
                            "[ConquestDroneManager.GenerateMission] cp3",
                            "mothershipFlightPath.txt");

                        if (Math.Abs(nav.Direction.LengthSquared()) > 0 ||
                            Math.Abs(nav.Rotation.LengthSquared()) > 0)
                        {
                            _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);

                            //this calculates max speed based on distance
                            if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                            {
                                _shipControls.MoveAndRotateStopped();
                            }
                        }
                        else
                            _shipControls.MoveAndRotateStopped();
                    }
                    return true;

                }
            } //indicates the drone was avoiding rather than orbiting
            catch (Exception e)
            {
                Util.GetInstance().LogError(e.ToString());
            }
            return false;
        }
        //Working,
        public bool Orbit(Vector3D target)
        {
            if (!Avoiding && _shipControls != null)
            {
                //MyAPIGateway.Session.Factions.TryGetPlayerFaction();
                var distance = (target - Ship.GetPosition()).Length();
                MaxSpeed = distance/ApproachSpeedMod;

                if (MaxSpeed > 40)
                    MaxSpeed = 40;

                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    //Util.Notify("cp1");/
                    //validateTarget(); //This is just to make sure our owner/target was not destoried
                    ResetOrbitCoords(target, FollowRange);

                    if (((_coords[_currentCoord + 1 >= _coords.Count ? 0 : _currentCoord + 1] - Ship.GetPosition()).Length()
                        < (_coords[_currentCoord] - Ship.GetPosition()).Length()) && (_coords[_currentCoord] - Ship.GetPosition()).Length()<FollowRange/4)
                    {
                        //Util.Notify("Skipping");
                        _currentCoord = _currentCoord + 1;
                    }

                    if (_currentCoord >= _coords.Count)
                        _currentCoord = 0;

                    NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord], (IMyEntity) _shipControls);
                    AlignTo(_coords[_currentCoord]);
                    //_toPosition - _fromPosition
                    if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length()*.66)
                    {
                        _previousCoord = _currentCoord;
                        _currentCoord++;

                        if (_currentCoord >= _coords.Count)
                            _currentCoord = 0;
                    }

                    if (Math.Abs(nav.Direction.LengthSquared()) > 0 || Math.Abs(nav.Rotation.LengthSquared()) > 0)
                    {
                        _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);

                        //this calculates max speed based on distance
                        if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                        _shipControls.MoveAndRotateStopped();
                }
                return true;
            }

            //indicates the drone was avoiding rather than orbiting
            return false;
        }
        public bool Follow(Vector3D position, int followDistance)
        {
            if (Ship != null && !Avoiding && _shipControls != null)
            {
                NavInfo nav = new NavInfo(Ship.GetPosition(), position, (IMyEntity)_shipControls);

                var distance = (position - Ship.GetPosition()).Length();
                MaxSpeed = distance > followDistance ? distance / ApproachSpeedMod : 40;
                if (distance > 100)
                    MaxSpeed = distance > followDistance ? distance / ApproachSpeedMod : 100;

                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    AlignTo(position);

                    if (nav.Direction.Length() < followDistance)
                    {
                        if (Ship.Physics.LinearVelocity.Normalize() > 0)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                    {
                        if (Math.Abs(nav.Direction.Length()) > followDistance)
                        {
                            _shipControls.MoveAndRotate(nav.Direction, nav.Rotation, nav.Roll);
                            AlignTo(position);
                        }
                    }

                    if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                    {
                        _shipControls.MoveAndRotateStopped();
                    }
                }
                return true;
            }

            //indicates the drone was avoiding rather than following
            return false;
        }
        public bool CombatOrbit(Vector3D target)
        {
            if (!Avoiding && _shipControls != null)
            {
                var distance = (target - Ship.GetPosition()).Length();
                //MaxSpeed = ;
                //MaxSpeed = (target - Ship.GetPosition()).Length() < FollowRange*.8 ? 20 : MaxSpeed;

                //oh no... a turnary inside a turnary... someone burn me on a stick... nah its okay if I do it this one time
                MaxSpeed = MaxSpeed < 10 ? 10 :
                                distance > FollowRange ? distance / ApproachSpeedMod : 20;

                if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                {
                    _shipControls.MoveAndRotateStopped();
                }
                else
                {
                    //Util.Notify("cp1");
                    //validateTarget(); //This is just to make sure our owner/target was not destoried
                    ResetOrbitCoords(target, FollowRange);

                    NavInfo nav = new NavInfo(Ship.GetPosition(), _coords[_currentCoord], (IMyEntity) _shipControls);

                    //_toPosition - _fromPosition for distance or to generate a vector twords target
                    if (nav.Direction.Length() < (_coords[_currentCoord] - _coords[_previousCoord]).Length()*.66)
                    {
                        _previousCoord = _currentCoord;
                        _currentCoord++;

                        if (_currentCoord >= _coords.Count)
                            _currentCoord = 0;
                    }

                    if (Math.Abs(nav.Direction.LengthSquared()) > 0 || Math.Abs(nav.Rotation.LengthSquared()) > 0)
                    {
                        _shipControls.MoveAndRotate(nav.Direction, Vector2.Zero, nav.Roll);

                        //this calculates max speed based on distance
                        if (Ship.Physics.LinearVelocity.Normalize() > MaxSpeed)
                        {
                            _shipControls.MoveAndRotateStopped();
                        }
                    }
                    else
                        _shipControls.MoveAndRotateStopped();
                }
                return true;
            }

            //indicates the drone was avoiding rather than orbiting
            return false;
        }