public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            if (m_done)
            {
                return;
            }
            //SimObject me = dmView.AllObjects[m_thisID];
            //LocationValue myLocation = me.Location;
            SimObject     track         = dmView.AllObjects[m_targetID];
            LocationValue trackLocation = track.Location;

            m_absoluteLoiterPattern = m_relativeLoiterPattern.ToAbsolute(trackLocation);


            if (ShouldTrack(serverConnection, dmView))
            {
                serverConnection.SendMoveObjectRequest(m_thisID, trackLocation, 1);

                m_trackTarget = true;
            }
            else
            {
                if (m_trackTarget)
                {
                    StartLoiter(serverConnection, dmView);
                    m_trackTarget = false;
                }
                ContinueLoiter(serverConnection, dmView);
            }
        }
Exemple #2
0
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            if (m_done)
            {
                return;
            }
            SimObject me   = dmView.AllObjects[m_thisID];
            SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation   = me.Location;
            LocationValue destLocation = dest.Location;
            VelocityValue myVelocity   = me.Velocity;


            if (ObjectMath.IsWithinRange(0.1, myLocation, destLocation))
            {
                m_done = true;
                return;
            }

            if (myVelocity.VX == 0 && myVelocity.VY == 0 && myVelocity.VZ == 0)
            {
                serverConnection.SendMoveObjectRequest(m_thisID, destLocation, 1);
            }
        }
        public void Start(DDDServerConnection serverConnection, DMView dmView)
        {
            m_dmView = dmView;
            //Console.Out.WriteLine(String.Format("MoveWithAvoidanceBehavior.Start(){0}",m_thisID));
            LogWriter.Write(m_dmView.DecisionMakerID + "_" + m_thisID, dmView.SimTime, String.Format("MoveWithAvoidanceBehavior.Start,{0},{1}", m_destLocation.ToXML(), m_throttle));
            m_wasBlocked = false;


            SimObject me = dmView.AllObjects[m_thisID];
            //SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation = me.Location;

            //LocationValue destLocation = dest.Location;


            if (BehaviorHelper.LocationIsEqual(myLocation, m_destLocation))
            {
                m_done = true;
                return;
            }

            if (!IsBlocked2())
            {
                m_wasBlocked = false;
                serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, m_destLocation, m_throttle);
            }
            else
            {
                m_wasBlocked = true;
            }
        }
Exemple #4
0
        public void Start(DDDServerConnection serverConnection, DMView dmView)
        {
            m_dmView = dmView;

            SimObject     me         = dmView.AllObjects[m_thisID];
            LocationValue myLocation = me.Location;

            m_destWaypoint = m_absoluteLoiterPattern.GetWaypointClosestTo(myLocation);
            serverConnection.SendMoveObjectRequest(m_thisID, m_destWaypoint.Location, 1);
        }
        void StartLoiter(DDDServerConnection serverConnection, DMView dmView)
        {
            SimObject     me            = dmView.AllObjects[m_thisID];
            LocationValue myLocation    = me.Location;
            SimObject     track         = dmView.AllObjects[m_targetID];
            LocationValue trackLocation = track.Location;

            m_absoluteLoiterPattern = m_relativeLoiterPattern.ToAbsolute(trackLocation);
            m_destWaypoint          = m_absoluteLoiterPattern.GetWaypointClosestTo(myLocation);
            m_relativeLoiterPattern.NextWaypointIndex    = m_absoluteLoiterPattern.NextWaypointIndex;
            m_relativeLoiterPattern.CurrentWaypointIndex = m_absoluteLoiterPattern.CurrentWaypointIndex;
            serverConnection.SendMoveObjectRequest(m_thisID, m_destWaypoint.Location, 1);
        }
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            //Console.Out.WriteLine(String.Format("MoveWithAvoidanceBehavior.Update() {0}", m_thisID));
            if (m_done)
            {
                return;
            }
            SimObject me = dmView.AllObjects[m_thisID];
            //SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation = me.Location;

            VelocityValue myVelocity = me.Velocity;


            if (ObjectMath.IsWithinRange(0.1, myLocation, m_destLocation))
            {
                m_done = true;
                return;
            }

            if (!IsBlocked2())
            {
                if (m_wasBlocked)
                {
                    m_wasBlocked = false;
                    serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, m_destLocation, m_throttle);
                }
                else if (myVelocity.VX == 0 && myVelocity.VY == 0 && myVelocity.VZ == 0)
                {
                    serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, m_destLocation, m_throttle);
                }
            }
            else
            {
                m_wasBlocked = true;
                serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, myLocation, 0);
            }
        }
        void ContinueLoiter(DDDServerConnection serverConnection, DMView dmView)
        {
            SimObject     me            = dmView.AllObjects[m_thisID];
            LocationValue myLocation    = me.Location;
            SimObject     track         = dmView.AllObjects[m_targetID];
            LocationValue trackLocation = track.Location;

            if (BehaviorHelper.LocationIsEqual(myLocation, m_destWaypoint.Location))
            {
                m_destWaypoint = m_absoluteLoiterPattern.GetNextWaypoint();
                m_relativeLoiterPattern.NextWaypointIndex    = m_absoluteLoiterPattern.NextWaypointIndex;
                m_relativeLoiterPattern.CurrentWaypointIndex = m_absoluteLoiterPattern.CurrentWaypointIndex;
                serverConnection.SendMoveObjectRequest(m_thisID, m_destWaypoint.Location, 1);
            }
        }
Exemple #8
0
        public void Start(DDDServerConnection serverConnection, DMView dmView)
        {
            SimObject me   = dmView.AllObjects[m_thisID];
            SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation   = me.Location;
            LocationValue destLocation = dest.Location;

            if (ObjectMath.IsWithinRange(0.1, myLocation, destLocation))
            {
                m_done = true;
                return;
            }

            serverConnection.SendMoveObjectRequest(m_thisID, destLocation, 1);
        }
Exemple #9
0
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            if (m_done)
            {
                return;
            }
            SimObject     me         = dmView.AllObjects[m_thisID];
            LocationValue myLocation = me.Location;


            if (BehaviorHelper.LocationIsEqual(myLocation, m_destWaypoint.Location))
            {
                m_destWaypoint = m_absoluteLoiterPattern.GetNextWaypoint();
                serverConnection.SendMoveObjectRequest(m_thisID, m_destWaypoint.Location, 1);
            }
        }
        public void Start(DDDServerConnection serverConnection, DMView dmView)
        {
            m_dmView = dmView;

            SimObject     me            = dmView.AllObjects[m_thisID];
            LocationValue myLocation    = me.Location;
            SimObject     track         = dmView.AllObjects[m_targetID];
            LocationValue trackLocation = track.Location;


            m_trackTarget = ShouldTrack(serverConnection, dmView);


            if (m_trackTarget)
            {
                serverConnection.SendMoveObjectRequest(m_thisID, trackLocation, 1);
            }
            else
            {
                StartLoiter(serverConnection, dmView);
            }
        }
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            if (m_done)
            {
                return;
            }
            SimObject     me            = dmView.AllObjects[m_thisID];
            LocationValue myLocation    = me.Location;
            SimObject     track         = dmView.AllObjects[m_targetID];
            LocationValue trackLocation = track.Location;

            m_absoluteLoiterPattern = m_relativeLoiterPattern.ToAbsolute(trackLocation);


            switch (m_engagementState)
            {
            case EngagementState.Tracking:
                if (ShouldTrack(serverConnection, dmView))
                {
                    serverConnection.SendMoveObjectRequest(m_thisID, trackLocation, 1);
                }
                else
                {
                    m_engagementState = EngagementState.Attacking;
                    StartLoiter(serverConnection, dmView);
                }
                break;

            case EngagementState.Attacking:
                ContinueLoiter(serverConnection, dmView);
                if (!m_attackInProcess)     // start the attack
                {
                    // start with weapons
                    if (me.DockedWeapons.Count > 0)
                    {
                        m_attackWeaponID = me.DockedWeapons[0];
                        serverConnection.SendWeaponLaunchRequest(m_thisID, m_attackWeaponID, m_targetID);
                        m_attackEndTime   = dmView.SimTime + 12000;   // give a two minute time window to start, AttackUpdate will modify this
                        m_attackInProcess = true;
                        m_attackIsWeapon  = true;
                    }
                    else     // use native capabilities
                    {
                        // figure out capability/vulnerability match up
                        String cap = DetermineCapability(me.CapabilityList, track.VulnerabilityList);
                        if (cap != String.Empty)
                        {
                            serverConnection.SendAttackObjectRequest(m_thisID, m_targetID, cap);
                            m_attackInProcess = true;
                            m_attackIsWeapon  = false;
                            m_attackEndTime   = dmView.SimTime + 12000;
                        }
                        else     //  I don't have the right capabilities, finish up
                        {
                            ResetAttack();
                            if (m_returnAfter)
                            {
                                m_engagementState = EngagementState.Returning;
                                m_dddServer.SendMoveObjectRequest(m_thisID, m_originalLocation, 1);
                            }
                            else
                            {
                                m_done = true;
                            }
                        }
                    }
                }
                else     // check to see if the attack was succesful
                {
                    // if we are still in attack mode 2 seconds after attack was supposed to end
                    // start another attack
                    if (dmView.SimTime > m_attackEndTime + 2000)
                    {
                        ResetAttack();
                    }
                }
                break;

            case EngagementState.Returning:
                if (BehaviorHelper.Distance(myLocation, m_originalLocation) < 1)
                {
                    m_done = true;
                }
                break;
            }
        }