Ejemplo n.º 1
0
        private void ActivateAction(Action action)
        {
            var target = action.GetParameterValue("target");

            // No parameter? Although we shouldnt really allow it, assume its the acceleration gate :)
            if (string.IsNullOrEmpty(target))
            {
                target = "Acceleration Gate";
            }

            var targets = Cache.Instance.EntitiesByName(target);

            if (targets == null || targets.Count() == 0)
            {
                Logging.Log("MissionController.Activate: Can't find [" + target + "] to activate! Stopping Questor!");
                State = MissionControllerState.Error;
                return;
            }

            var closest = targets.OrderBy(t => t.Distance).First();

            if (closest.Distance < 2500)
            {
                // Tell the drones module to retract drones
                Cache.Instance.IsMissionPocketDone = true;

                // We cant activate if we have drones out
                if (Cache.Instance.ActiveDrones.Count() > 0)
                {
                    return;
                }

                // Add bookmark (before we activate)
                if (Settings.Instance.CreateSalvageBookmarks)
                {
                    BookmarkPocketForSalvaging();
                }

                // Activate it and move to the next Pocket
                closest.Activate();

                // Do not change actions, if NextPocket gets a timeout (>2 mins) then it reverts to the last action
                Logging.Log("MissionController.Activate: Activate [" + closest.Name + "] and change state to 'NextPocket'");

                State = MissionControllerState.NextPocket;
                _lastActivateAction = DateTime.Now;
            }
            else
            {
                // Move to the target
                if (Cache.Instance.Approaching == null || Cache.Instance.Approaching.Id != closest.Id)
                {
                    Logging.Log("MissionController.Activate: Approaching target [" + closest.Name + "][" + closest.Id + "]");
                    closest.Approach();
                }
            }
        }
Ejemplo n.º 2
0
        private void PerformAction(Action action)
        {
            switch (action.State)
            {
            case ActionState.Activate:
                ActivateAction(action);
                break;

            case ActionState.ClearPocket:
                ClearPocketAction(action);
                break;

            case ActionState.Done:
                // Tell the drones module to retract drones
                Cache.Instance.IsMissionPocketDone = true;

                // We do not switch to "done" status if we still have drones out
                if (Cache.Instance.ActiveDrones.Count() > 0)
                {
                    return;
                }

                BookmarkPocketForSalvaging();
                State = MissionControllerState.Done;
                break;

            case ActionState.Kill:
                KillAction(action);
                break;

            case ActionState.MoveTo:
                MoveToAction(action);
                break;

            case ActionState.Loot:
                LootAction(action);
                break;

            case ActionState.LootItem:
                LootItemAction(action);
                break;

            case ActionState.Ignore:
                IgnoreAction(action);
                break;

            case ActionState.WaitUntilTargeted:
                WaitUntilTargeted(action);
                break;
            }
        }
Ejemplo n.º 3
0
        public void ProcessState()
        {
            // What? No ship entity?
            if (Cache.Instance.DirectEve.ActiveShip.Entity == null)
                return;

            switch (State)
            {
                case MissionControllerState.Idle:
                case MissionControllerState.Done:
                case MissionControllerState.Error:
                    break;

                case MissionControllerState.Start:
                    _pocket = 0;

                    // Reload the items needed for this mission from the XML file
                    Cache.Instance.RefreshMissionItems(AgentId);

                    // Update x/y/z so that NextPocket wont think we are there yet because its checking (very) old x/y/z cords
                    _lastX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
                    _lastY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
                    _lastZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;

                    State = MissionControllerState.LoadPocket;
                    break;

                case MissionControllerState.LoadPocket:
                    _pocketActions.Clear();
                    _pocketActions.AddRange(Cache.Instance.LoadMissionActions(AgentId, _pocket));

                    if (_pocketActions.Count == 0)
                    {
                        // No Pocket action, load default actions
                        Logging.Log("MissionController: No mission actions specified, loading default actions");

                        // Wait for 30 seconds to be targeted
                        _pocketActions.Add(new Action {State = ActionState.WaitUntilTargeted});
                        _pocketActions[0].AddParameter("timeout", "15");

                        // Clear the Pocket
                        _pocketActions.Add(new Action {State = ActionState.ClearPocket});

                        // Is there a gate?
                        var gates = Cache.Instance.EntitiesByName("Acceleration Gate");
                        if (gates != null && gates.Count() > 0)
                        {
                            // Activate it (Activate action also moves to the gate)
                            _pocketActions.Add(new Action {State = ActionState.Activate});
                            _pocketActions[_pocketActions.Count - 1].AddParameter("target", "Acceleration Gate");
                        }
                        else // No, were done
                            _pocketActions.Add(new Action {State = ActionState.Done});

                        // TODO: Check mission HTML to see if we need to pickup any items
                        // Not a priority, apparently retrieving HTML causes a lot of crashes
                    }

                    Logging.Log("MissionController: Pocket loaded, executing the following actions");
                    foreach (var a in _pocketActions)
                        Logging.Log("MissionController: Action." + a);

                    // Reset pocket information
                    _currentAction = 0;
                    Cache.Instance.IsMissionPocketDone = false;
                    Cache.Instance.IgnoreTargets.Clear();

                    State = MissionControllerState.ExecutePocketActions;
                    break;

                case MissionControllerState.ExecutePocketActions:
                    if (_currentAction >= _pocketActions.Count)
                    {
                        // No more actions, but we're not done?!?!?!
                        Logging.Log("MissionController: We're out of actions but did not process a 'Done' or 'Activate' action");

                        State = MissionControllerState.Error;
                        break;
                    }

                    var action = _pocketActions[_currentAction];
                    var currentAction = _currentAction;
                    PerformAction(action);

                    if (currentAction != _currentAction)
                    {
                        Logging.Log("MissionController: Finished Action." + action);

                        if (_currentAction < _pocketActions.Count)
                        {
                            action = _pocketActions[_currentAction];
                            Logging.Log("MissionController: Starting Action." + action);
                        }
                    }

                    if (Settings.Instance.DebugStates)
                        Logging.Log("Action.State = " + action);
                    break;

                case MissionControllerState.NextPocket:
                    var distance = Cache.Instance.DistanceFromMe(_lastX, _lastY, _lastZ);
                    if (distance > 100000)
                    {
                        Logging.Log("MissionController: We've moved to the next Pocket [" + distance + "]");

                        // If we moved more then 100km, assume next Pocket
                        _pocket++;
                        State = MissionControllerState.LoadPocket;
                    }
                    else if (DateTime.Now.Subtract(_lastActivateAction).TotalMinutes > 2)
                    {
                        Logging.Log("MissionController: We've timed out, retry last action");

                        // We have reached a timeout, revert to ExecutePocketActions (e.g. most likely Activate)
                        State = MissionControllerState.ExecutePocketActions;
                    }
                    break;
            }

            var newX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
            var newY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
            var newZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;

            // For some reason x/y/z returned 0 sometimes
            if (newX != 0 && newY != 0 && newZ != 0)
            {
                // Save X/Y/Z so that NextPocket can check if we actually went to the next Pocket :)
                _lastX = newX;
                _lastY = newY;
                _lastZ = newZ;
            }
        }
Ejemplo n.º 4
0
        private void PerformAction(Action action)
        {
            switch (action.State)
            {
                case ActionState.Activate:
                    ActivateAction(action);
                    break;

                case ActionState.ClearPocket:
                    ClearPocketAction(action);
                    break;

                case ActionState.Done:
                    // Tell the drones module to retract drones
                    Cache.Instance.IsMissionPocketDone = true;

                    // We do not switch to "done" status if we still have drones out
                    if (Cache.Instance.ActiveDrones.Count() > 0)
                        return;

                    BookmarkPocketForSalvaging();
                    State = MissionControllerState.Done;
                    break;

                case ActionState.Kill:
                    KillAction(action);
                    break;

                case ActionState.MoveTo:
                    MoveToAction(action);
                    break;

                case ActionState.Loot:
                    LootAction(action);
                    break;

                case ActionState.LootItem:
                    LootItemAction(action);
                    break;

                case ActionState.Ignore:
                    IgnoreAction(action);
                    break;

                case ActionState.WaitUntilTargeted:
                    WaitUntilTargeted(action);
                    break;
            }
        }
Ejemplo n.º 5
0
        private void ActivateAction(Action action)
        {
            var target = action.GetParameterValue("target");

            // No parameter? Although we shouldnt really allow it, assume its the acceleration gate :)
            if (string.IsNullOrEmpty(target))
                target = "Acceleration Gate";

            var targets = Cache.Instance.EntitiesByName(target);
            if (targets == null || targets.Count() == 0)
            {
                Logging.Log("MissionController.Activate: Can't find [" + target + "] to activate! Stopping Questor!");
                State = MissionControllerState.Error;
                return;
            }

            var closest = targets.OrderBy(t => t.Distance).First();
            if (closest.Distance < 2500)
            {
                // Tell the drones module to retract drones
                Cache.Instance.IsMissionPocketDone = true;

                // We cant activate if we have drones out
                if (Cache.Instance.ActiveDrones.Count() > 0)
                    return;

                // Add bookmark (before we activate)
                BookmarkPocketForSalvaging();

                // Activate it and move to the next Pocket
                closest.Activate();

                // Do not change actions, if NextPocket gets a timeout (>2 mins) then it reverts to the last action
                Logging.Log("MissionController.Activate: Activate [" + closest.Name + "] and change state to 'NextPocket'");

                State = MissionControllerState.NextPocket;
                _lastActivateAction = DateTime.Now;
            }
            else if (closest.Distance < 150000)
            {
                // Move to the target
                if (Cache.Instance.Approaching == null || Cache.Instance.Approaching.Id != closest.Id)
                {
                    Logging.Log("MissionController.Activate: Approaching target [" + closest.Name + "][" + closest.Id + "]");
                    closest.Approach();
                }
            }
            else
            {
                // We cant warp if we have drones out
                if (Cache.Instance.ActiveDrones.Count() > 0)
                    return;

                // Probably never happens
                closest.WarpTo();
            }
        }
Ejemplo n.º 6
0
        private void PerformAction(Action action)
        {
            switch (action.State)
            {
                case ActionState.Activate:
                    ActivateAction(action);
                    break;

                case ActionState.ClearPocket:
                    ClearPocketAction(action);
                    break;

                case ActionState.SalvageBookmark:
                    BookmarkPocketForSalvaging();

                    _currentAction++;
                    break;

                case ActionState.Done:
                    // Tell the drones module to retract drones
                    Cache.Instance.IsMissionPocketDone = true;

                    // We do not switch to "done" status if we still have drones out
                    if (Cache.Instance.ActiveDrones.Count() > 0)
                        return;

                    // Add bookmark (before we're done)
                    if (Settings.Instance.CreateSalvageBookmarks)
                        BookmarkPocketForSalvaging();

                    // Reload weapons
                    ReloadAll();

                    State = MissionControllerState.Done;
                    break;

                case ActionState.Kill:
                    KillAction(action);
                    break;

                case ActionState.MoveTo:
                    MoveToAction(action);
                    break;

                case ActionState.Loot:
                    LootAction(action);
                    break;

                case ActionState.LootItem:
                    LootItemAction(action);
                    break;

                case ActionState.Ignore:
                    IgnoreAction(action);
                    break;

                case ActionState.WaitUntilTargeted:
                    WaitUntilTargeted(action);
                    break;
            }
        }
Ejemplo n.º 7
0
        public void ProcessState()
        {
            switch (State)
            {
            case MissionControllerState.Idle:
            case MissionControllerState.Done:
            case MissionControllerState.Error:
                break;

            case MissionControllerState.Start:
                _pocket = 0;

                // Reload the items needed for this mission from the XML file
                Cache.Instance.RefreshMissionItems(AgentId);

                // Update x/y/z so that NextPocket wont think we are there yet because its checking (very) old x/y/z cords
                _lastX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
                _lastY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
                _lastZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;

                State = MissionControllerState.LoadPocket;
                break;

            case MissionControllerState.LoadPocket:
                _pocketActions.Clear();
                _pocketActions.AddRange(Cache.Instance.LoadMissionActions(AgentId, _pocket));

                if (_pocketActions.Count == 0)
                {
                    // No Pocket action, load default actions
                    Logging.Log("MissionController: No mission actions specified, loading default actions");

                    // Wait for 30 seconds to be targeted
                    _pocketActions.Add(new Action {
                        State = ActionState.WaitUntilTargeted
                    });
                    _pocketActions[0].AddParameter("timeout", "15");

                    // Clear the Pocket
                    _pocketActions.Add(new Action {
                        State = ActionState.ClearPocket
                    });

                    // Is there a gate?
                    var gates = Cache.Instance.EntitiesByName("Acceleration Gate");
                    if (gates != null && gates.Count() > 0)
                    {
                        // Activate it (Activate action also moves to the gate)
                        _pocketActions.Add(new Action {
                            State = ActionState.Activate
                        });
                        _pocketActions[_pocketActions.Count - 1].AddParameter("target", "Acceleration Gate");
                    }
                    else     // No, were done
                    {
                        _pocketActions.Add(new Action {
                            State = ActionState.Done
                        });
                    }

                    // TODO: Check mission HTML to see if we need to pickup any items
                    // Not a priority, apparently retrieving HTML causes a lot of crashes
                }

                Logging.Log("MissionController: Pocket loaded, executing the following actions");
                foreach (var a in _pocketActions)
                {
                    Logging.Log("MissionController: Action." + a);
                }

                // Reset pocket information
                _currentAction = 0;
                Cache.Instance.IsMissionPocketDone = false;
                Cache.Instance.IgnoreTargets.Clear();

                State = MissionControllerState.ExecutePocketActions;
                break;

            case MissionControllerState.ExecutePocketActions:
                if (_currentAction >= _pocketActions.Count)
                {
                    // No more actions, but we're not done?!?!?!
                    Logging.Log("MissionController: We're out of actions but did not process a 'Done' or 'Activate' action");

                    State = MissionControllerState.Error;
                    break;
                }

                var action        = _pocketActions[_currentAction];
                var currentAction = _currentAction;
                PerformAction(action);

                if (currentAction != _currentAction)
                {
                    Logging.Log("MissionController: Finished Action." + action);

                    if (_currentAction < _pocketActions.Count)
                    {
                        action = _pocketActions[_currentAction];
                        Logging.Log("MissionController: Starting Action." + action);
                    }
                }

                if (Settings.Instance.DebugStates)
                {
                    Logging.Log("Action.State = " + action);
                }
                break;

            case MissionControllerState.NextPocket:
                var distance = Cache.Instance.DistanceFromMe(_lastX, _lastY, _lastZ);
                if (distance > 100000)
                {
                    Logging.Log("MissionController: We've moved to the next Pocket [" + distance + "]");

                    // If we moved more then 100km, assume next Pocket
                    _pocket++;
                    State = MissionControllerState.LoadPocket;
                }
                else if (DateTime.Now.Subtract(_lastActivateAction).TotalMinutes > 2)
                {
                    Logging.Log("MissionController: We've timed out, retry last action");

                    // We have reached a timeout, revert to ExecutePocketActions (e.g. most likely Activate)
                    State = MissionControllerState.ExecutePocketActions;
                }
                break;
            }

            var newX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
            var newY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
            var newZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;

            // For some reason x/y/z returned 0 sometimes
            if (newX != 0 && newY != 0 && newZ != 0)
            {
                // Save X/Y/Z so that NextPocket can check if we actually went to the next Pocket :)
                _lastX = newX;
                _lastY = newY;
                _lastZ = newZ;
            }
        }
Ejemplo n.º 8
0
        private void PerformAction(Action action)
        {
            switch (action.State)
            {
            case ActionState.Activate:
                ActivateAction(action);
                break;

            case ActionState.ClearPocket:
                ClearPocketAction(action);
                break;

            case ActionState.SalvageBookmark:
                BookmarkPocketForSalvaging();

                _currentAction++;
                break;

            case ActionState.Done:
                // Tell the drones module to retract drones
                Cache.Instance.IsMissionPocketDone = true;

                // We do not switch to "done" status if we still have drones out
                if (Cache.Instance.ActiveDrones.Count() > 0)
                {
                    return;
                }

                // Add bookmark (before we're done)
                if (Settings.Instance.CreateSalvageBookmarks)
                {
                    BookmarkPocketForSalvaging();
                }

                // Reload weapons
                ReloadAll();

                State = MissionControllerState.Done;
                break;

            case ActionState.Kill:
                KillAction(action);
                break;

            case ActionState.MoveTo:
                MoveToAction(action);
                break;

            case ActionState.Loot:
                LootAction(action);
                break;

            case ActionState.LootItem:
                LootItemAction(action);
                break;

            case ActionState.Ignore:
                IgnoreAction(action);
                break;

            case ActionState.WaitUntilTargeted:
                WaitUntilTargeted(action);
                break;
            }
        }