Example #1
0
        /// <summary>
        ///   We have no combat/delivery part in this mission, just accept it
        /// </summary>
        /// <returns></returns>
        public StorylineState PostAcceptMission(Storyline storyline)
        {
            // Close the market window (if its open)
            var directEve = Cache.Instance.DirectEve;

            return(StorylineState.CompleteMission);
        }
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
                return StorylineState.Arm;

            // Are we in a shuttle?  Yes, go to the agent
            if ((int)QuestorCache.Instance.ActiveShip.GroupID == (int)Group.Shuttle)
                return StorylineState.GotoAgent;

            // Open the ship hangar
            if (EveCom.Station.ShipHangar == null) return StorylineState.Arm;

            if (!EveCom.Station.ShipHangar.IsPrimed)
            {
                EveCom.Station.ShipHangar.Prime();
                return StorylineState.Arm;
            }

            //  Look for a shuttle
            EveCom.Item item = EveCom.Station.ShipHangar.Items.FirstOrDefault(i => i.Quantity == -1 && (int)i.GroupID == (int)Group.Shuttle);
            if (item != null)
            {
                Logging.Log("TransactionDataDelivery", "Switching to shuttle", Logging.White);

                _nextAction = DateTime.UtcNow.AddSeconds(10);

                item.ActivateShip();
                return StorylineState.Arm;
            }

            Logging.Log("TransactionDataDelivery", "No shuttle found, going in active ship", Logging.Orange);
            return StorylineState.GotoAgent;
        }
        /// <summary>
        ///   We have no combat/delivery part in this mission, just accept it
        /// </summary>
        /// <returns></returns>
        public StorylineState PostAcceptMission(Storyline storyline)
        {
            // Close the market window (if its open)
            var directEve = Cache.Instance.DirectEve;

            return StorylineState.CompleteMission;
        }
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
                return StorylineState.Arm;

            // Are we in a shuttle?  Yes, go to the agent
            DirectEve directEve = Cache.Instance.DirectEve;
            if (directEve.ActiveShip.GroupId == 31)
                return StorylineState.GotoAgent;

            // Open the ship hangar
            if (!Cache.Instance.ReadyShipsHangar("TransactionDataDelivery")) return StorylineState.Arm;

            //  Look for a shuttle
            DirectItem item = Cache.Instance.ShipHangar.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == 31);
            if (item != null)
            {
                Logging.Log("TransactionDataDelivery", "Switching to shuttle", Logging.White);

                _nextAction = DateTime.Now.AddSeconds(10);

                item.ActivateShip();
                return StorylineState.Arm;
            }

            Logging.Log("TransactionDataDelivery", "No shuttle found, going in active ship", Logging.Orange);
            return StorylineState.GotoAgent;
        }
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
            {
                return(StorylineState.Arm);
            }

            // Are we in a shuttle?  Yes, go to the agent
            if (Cache.Instance.ActiveShip.GroupId == (int)Group.Shuttle)
            {
                return(StorylineState.GotoAgent);
            }

            // Open the ship hangar
            if (!Cache.Instance.OpenShipsHangar("TransactionDataDelivery"))
            {
                return(StorylineState.Arm);
            }

            //  Look for a shuttle
            DirectItem item = Cache.Instance.ShipHangar.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == (int)Group.Shuttle);

            if (item != null)
            {
                Logging.Log("TransactionDataDelivery", "Switching to shuttle", Logging.White);

                _nextAction = DateTime.UtcNow.AddSeconds(10);

                item.ActivateShip();
                return(StorylineState.Arm);
            }

            Logging.Log("TransactionDataDelivery", "No shuttle found, going in active ship", Logging.Orange);
            return(StorylineState.GotoAgent);
        }
        /// <summary>
        ///   Goto the pickup location
        ///   Pickup the item
        ///   Goto drop off location
        ///   Drop the item
        ///   Goto Agent
        ///   Complete mission
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
                return StorylineState.ExecuteMission;

            switch (_state)
            {
                case TransactionDataDeliveryState.GotoPickupLocation:
                    if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Pick Up)"))
                        _state = TransactionDataDeliveryState.PickupItem;
                    break;

                case TransactionDataDeliveryState.PickupItem:
                    if (MoveItem(true))
                        _state = TransactionDataDeliveryState.GotoDropOffLocation;
                    break;

                case TransactionDataDeliveryState.GotoDropOffLocation:
                    if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Drop Off)"))
                        _state = TransactionDataDeliveryState.DropOffItem;
                    break;

                case TransactionDataDeliveryState.DropOffItem:
                    if (MoveItem(false))
                        return StorylineState.ReturnToAgent;
                    break;
            }

            return StorylineState.ExecuteMission;
        }
        /// <summary>
        ///   There are no pre-accept actions
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            _state = GenericCourierStorylineState.GotoPickupLocation;

            _States.CurrentTravelerState = TravelerState.Idle;
            Traveler.Destination         = null;

            return(StorylineState.AcceptMission);
        }
Example #8
0
        /// <summary>
        ///   There are no pre-accept actions
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            _state = TransactionDataDeliveryState.GotoPickupLocation;

            _traveler.State       = TravelerState.Idle;
            _traveler.Destination = null;

            return(StorylineState.AcceptMission);
        }
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
                return StorylineState.Arm;

            // Are we in a shuttle?  Yes, goto the agent
            var directEve = Cache.Instance.DirectEve;
            string materialshipName = Settings.Instance.MaterialShipName.ToLower();

            if (directEve.ActiveShip.GroupId == 31 || directEve.ActiveShip.GivenName == materialshipName)
                return StorylineState.GotoAgent;

            // Open the ship hangar
            var ships = directEve.GetShipHangar();
            if (ships.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening ship hangar");

                // No, command it to open
                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenShipHangar);
                return StorylineState.Arm;
            }

            // If the ship hangar is not ready then wait for it
            if (!ships.IsReady)
                return StorylineState.Arm;

            var ship = ships.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == 31);

            if (string.IsNullOrEmpty(materialshipName))
            {
                Logging.Log("MaterialsForWarPreparation: Could not find MaterialshipName: " + materialshipName + " in settings!");
            }
            else
                ship = ships.Items.FirstOrDefault(i => i.GivenName.ToLower() == materialshipName);

            if (ship != null)
            {
                Logging.Log("MaterialsForWarPreparation: Switching to ship");

                _nextAction = DateTime.Now.AddSeconds(10);

                ship.ActivateShip();
                return StorylineState.Arm;
            }
            else
            {
                Logging.Log("MaterialsForWarPreparation: No shuttle found, going in active ship");
                return StorylineState.GotoAgent;
            }
        }
Example #10
0
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
            {
                return(StorylineState.Arm);
            }

            // Are we in a shuttle?  Yes, goto the agent
            var directEve = Cache.Instance.DirectEve;

            if (directEve.ActiveShip.GroupId == 31)
            {
                return(StorylineState.GotoAgent);
            }

            // Open the ship hangar
            var ships = directEve.GetShipHangar();

            if (ships.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("TransactionDataDelivery: Opening ship hangar");

                // No, command it to open
                directEve.ExecuteCommand(DirectCmd.OpenShipHangar);
                return(StorylineState.Arm);
            }

            // If the ship hangar is not ready then wait for it
            if (!ships.IsReady)
            {
                return(StorylineState.Arm);
            }

            //  Look for a shuttle
            var item = ships.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == 31);

            if (item != null)
            {
                Logging.Log("TransactionDataDelivery: Switching to shuttle");

                _nextAction = DateTime.Now.AddSeconds(10);

                item.ActivateShip();
                return(StorylineState.Arm);
            }
            else
            {
                Logging.Log("TransactionDataDelivery: No shuttle found, going in active ship");
                return(StorylineState.GotoAgent);
            }
        }
Example #11
0
        /// <summary>
        ///   We check what ammo we need by starting a conversation with the agent and load the appropriate ammo
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_agentId != Cache.Instance.CurrentStorylineAgentId)
            {
                _neededAmmo.Clear();
                _agentId = Cache.Instance.CurrentStorylineAgentId;

                AgentInteraction.AgentId             = _agentId;
                AgentInteraction.ForceAccept         = true; // This makes agent interaction skip the offer-check
                _States.CurrentAgentInteractionState = AgentInteractionState.Idle;
                AgentInteraction.Purpose             = AgentInteractionPurpose.AmmoCheck;

                Modules.Actions.Arm.AgentId = _agentId;
                _States.CurrentArmState     = ArmState.Idle;
                Modules.Actions.Arm.AmmoToLoad.Clear();

                //Questor.AgentID = _agentId;

                _statistics.AgentID = _agentId;

                _combatMissionCtrl.AgentId            = _agentId;
                _States.CurrentCombatMissionCtrlState = CombatMissionCtrlState.Start;

                //_States.CurrentCombatState = CombatState.CheckTargets;

                _States.CurrentDroneState = DroneState.WaitingForTargets;
            }

            try
            {
                if (!Interact())
                {
                    return(StorylineState.Arm);
                }

                if (!LoadAmmo())
                {
                    return(StorylineState.Arm);
                }

                // We are done, reset agent id
                _agentId = 0;

                return(StorylineState.GotoAgent);
            }
            catch (Exception ex)
            {
                // Something went wrong!
                Logging.Log("GenericCombatStoryline", "Something went wrong, blacklist this agent [" + ex.Message + "]", Logging.Orange);
                return(StorylineState.BlacklistAgent);
            }
        }
        /// <summary>
        ///   We check what ammo we need by starting a conversation with the agent and load the appropriate ammo
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_agentId != Cache.Instance.CurrentStorylineAgentId)
            {
                _neededAmmo.Clear();
                _agentId = Cache.Instance.CurrentStorylineAgentId;

                AgentInteraction.AgentId = _agentId;
                AgentInteraction.ForceAccept = true; // This makes agent interaction skip the offer-check
                _States.CurrentAgentInteractionState = AgentInteractionState.Idle;
                AgentInteraction.Purpose = AgentInteractionPurpose.AmmoCheck;

                Modules.Actions.Arm.AgentId = _agentId;
                _States.CurrentArmState = ArmState.Idle;
                Modules.Actions.Arm.AmmoToLoad.Clear();

                //Questor.AgentID = _agentId;

                _statistics.AgentID = _agentId;

                _combatMissionCtrl.AgentId = _agentId;
                _States.CurrentCombatMissionCtrlState = CombatMissionCtrlState.Start;

                //_States.CurrentCombatState = CombatState.CheckTargets;

                _States.CurrentDroneState = DroneState.WaitingForTargets;
            }

            try
            {
                if (!Interact())
                    return StorylineState.Arm;

                if (!LoadAmmo())
                    return StorylineState.Arm;

                // We are done, reset agent id
                _agentId = 0;

                return StorylineState.GotoAgent;
            }
            catch (Exception ex)
            {
                // Something went wrong!
                Logging.Log("GenericCombatStoryline", "Something went wrong, blacklist this agent [" + ex.Message + "]", Logging.Orange);
                return StorylineState.BlacklistAgent;
            }
        }
Example #13
0
        /// <summary>
        ///   We check what ammo we need by convo'ing the agent and load the appropriate ammo
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_agentId != storyline.AgentId)
            {
                _neededAmmo.Clear();
                _agentId = storyline.AgentId;

                _agentInteraction.AgentId     = _agentId;
                _agentInteraction.ForceAccept = true; // This makes agent interaction skip the offer-check
                _agentInteraction.State       = AgentInteractionState.Idle;
                _agentInteraction.Purpose     = AgentInteractionPurpose.AmmoCheck;

                _arm.AgentId = _agentId;
                _arm.State   = ArmState.Idle;
                _arm.AmmoToLoad.Clear();

                _missionController.AgentId = _agentId;
                _missionController.State   = MissionControllerState.Start;

                _combat.State = CombatState.CheckTargets;

                _drones.State = DroneState.WaitingForTargets;
            }

            try
            {
                if (!Interact())
                {
                    return(StorylineState.Arm);
                }

                if (!LoadAmmo())
                {
                    return(StorylineState.Arm);
                }

                // We are done, reset agent id
                _agentId = 0;

                return(StorylineState.GotoAgent);
            }
            catch (Exception ex)
            {
                // Something went wrong!
                Logging.Log("GenericCombatStoryline: Something went wrong, blacklist this agent [" + ex.Message + "]");
                return(StorylineState.BlacklistAgent);
            }
        }
Example #14
0
        /// <summary>
        ///   We check what ammo we need by convo'ing the agent and load the appropriate ammo
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_agentId != storyline.AgentId)
            {
                _neededAmmo.Clear();
                _agentId = storyline.AgentId;

                _agentInteraction.AgentId = _agentId;
                _agentInteraction.ForceAccept = true; // This makes agent interaction skip the offer-check
                _agentInteraction.State = AgentInteractionState.Idle;
                _agentInteraction.Purpose = AgentInteractionPurpose.AmmoCheck;

                _arm.AgentId = _agentId;
                _arm.State = ArmState.Idle;
                _arm.AmmoToLoad.Clear();

                _missionController.AgentId = _agentId;
                _missionController.State = MissionControllerState.Start;

                _combat.State = CombatState.CheckTargets;

                _drones.State = DroneState.WaitingForTargets;
            }

            try
            {
                if (!Interact())
                    return StorylineState.Arm;

                if (!LoadAmmo())
                    return StorylineState.Arm;

                // We are done, reset agent id
                _agentId = 0;

                return StorylineState.GotoAgent;
            }
            catch(Exception ex)
            {
                // Something went wrong!
                Logging.Log("GenericCombatStoryline: Something went wrong, blacklist this agent [" + ex.Message + "]");
                return StorylineState.BlacklistAgent;
            }
        }
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
                return StorylineState.Arm;

            // Are we in a shuttle?  Yes, goto the agent
            var directEve = Cache.Instance.DirectEve;
            if (directEve.ActiveShip.GroupId == 31)
                return StorylineState.GotoAgent;

            // Open the ship hangar
            var ships = directEve.GetShipHangar();
            if (ships.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening ship hangar");

                // No, command it to open
                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenShipHangar);
                return StorylineState.Arm;
            }

            // If the ship hangar is not ready then wait for it
            if (!ships.IsReady)
                return StorylineState.Arm;

            //  Look for a shuttle
            var item = ships.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == 31);
            if (item != null)
            {
                Logging.Log("MaterialsForWarPreparation: Switching to shuttle");

                _nextAction = DateTime.Now.AddSeconds(10);

                item.ActivateShip();
                return StorylineState.Arm;
            }
            else
            {
                Logging.Log("MaterialsForWarPreparation: No shuttle found, going in active ship");
                return StorylineState.GotoAgent;
            }
        }
        public CombatMissionsBehavior()
        {
            _lastPulse = DateTime.MinValue;
            _random = new Random();
            _courierMissionCtrl = new CourierMissionCtrl();
            _combatMissionCtrl = new CombatMissionCtrl();
            _storyline = new Storyline();

            //
            // this is combat mission specific and needs to be generalized
            //
            QuestorSettings.Instance.SettingsLoaded += SettingsLoaded;

            // States.CurrentCombatMissionBehaviorState fixed on ExecuteMission
            _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Idle;
            _States.CurrentArmState = ArmState.Idle;
            _States.CurrentUnloadLootState = UnloadLootState.Idle;
            _States.CurrentTravelerState = TravelerState.AtDestination;
        }
        /// <summary>
        ///   Goto the pickup location
        ///   Pickup the item
        ///   Goto drop off location
        ///   Drop the item
        ///   Complete mission
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            if (_nextGenericCourierStorylineAction > DateTime.UtcNow)
            {
                return(StorylineState.ExecuteMission);
            }

            switch (_state)
            {
            case GenericCourierStorylineState.GotoPickupLocation:
                if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Pick Up)"))
                {
                    _state = GenericCourierStorylineState.PickupItem;
                }
                break;

            case GenericCourierStorylineState.PickupItem:
                if (MoveItem(true))
                {
                    _state = GenericCourierStorylineState.GotoDropOffLocation;
                }
                break;

            case GenericCourierStorylineState.GotoDropOffLocation:
                if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Drop Off)"))
                {
                    _state = GenericCourierStorylineState.DropOffItem;
                }
                break;

            case GenericCourierStorylineState.DropOffItem:
                if (MoveItem(false))
                {
                    return(StorylineState.CompleteMission);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }
Example #18
0
        /// <summary>
        ///   Goto the pickup location
        ///   Pickup the item
        ///   Goto drop off location
        ///   Drop the item
        ///   Goto Agent
        ///   Complete mission
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
            {
                return(StorylineState.ExecuteMission);
            }

            switch (_state)
            {
            case TransactionDataDeliveryState.GotoPickupLocation:
                if (GotoMissionBookmark(storyline.AgentId, "Objective (Pick Up)"))
                {
                    _state = TransactionDataDeliveryState.PickupItem;
                }
                break;

            case TransactionDataDeliveryState.PickupItem:
                if (MoveItem(true))
                {
                    _state = TransactionDataDeliveryState.GotoDropOffLocation;
                }
                break;

            case TransactionDataDeliveryState.GotoDropOffLocation:
                if (GotoMissionBookmark(storyline.AgentId, "Objective (Drop Off)"))
                {
                    _state = TransactionDataDeliveryState.DropOffItem;
                }
                break;

            case TransactionDataDeliveryState.DropOffItem:
                if (MoveItem(false))
                {
                    return(StorylineState.ReturnToAgent);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
                return StorylineState.Arm;
            if (!Cache.Instance.OpenShipsHangar("Arm"))
                return StorylineState.Arm;

            // Are we in an industrial?  Yes, goto the agent
            //var directEve = Cache.Instance.DirectEve;
            //if (directEve.ActiveShip.TypeId == 648 || directEve.ActiveShip.TypeId == 649 || directEve.ActiveShip.TypeId == 650 || directEve.ActiveShip.TypeId == 651 || directEve.ActiveShip.TypeId == 652 || directEve.ActiveShip.TypeId == 653 || directEve.ActiveShip.TypeId == 654 || directEve.ActiveShip.TypeId == 655 || directEve.ActiveShip.TypeId == 656 || directEve.ActiveShip.TypeId == 657 || directEve.ActiveShip.TypeId == 1944 || directEve.ActiveShip.TypeId == 19744)
            //    return StorylineState.GotoAgent;

            //// Open the ship hangar
            //if (!Cache.Instance.ReadyItemsHangar("GenericCourierStoryline: Arm")) return StorylineState.Arm;

            ////  Look for an industrial
            //var item = Cache.Instance.ShipHangar.Items.FirstOrDefault(i => i.Quantity == -1 && (i.TypeId == 648 || i.TypeId == 649 || i.TypeId == 650 || i.TypeId == 651 || i.TypeId == 652 || i.TypeId == 653 || i.TypeId == 654 || i.TypeId == 655 || i.TypeId == 656 || i.TypeId == 657 || i.TypeId == 1944 || i.TypeId == 19744));
            //if (item != null)
            //{
            //    Logging.Log("GenericCourier", "Switching to an industrial", Logging.White);

            //    _nextAction = DateTime.UtcNow.AddSeconds(10);

            //    item.ActivateShip();
            //    return StorylineState.Arm;
            //}
            //else
            //{
            //    Logging.Log("GenericCourier", "No industrial found, going in active ship", Logging.White);
            //    return StorylineState.GotoAgent;
            //}
            string transportshipName = Settings.Instance.TransportShipName.ToLower();

            if (string.IsNullOrEmpty(transportshipName))
            {
                _States.CurrentArmState = ArmState.NotEnoughAmmo;
                Logging.Log("Arm.ActivateTransportShip", "Could not find transportshipName: " + transportshipName + " in settings!", Logging.Orange);
                return StorylineState.BlacklistAgent;
            }
            try
            {
                if (Settings.Instance.DebugArm) Logging.Log("Arm.ActivateTransportShip", "try", Logging.White);
                if (Cache.Instance.DirectEve.ActiveShip.GivenName.ToLower() != transportshipName.ToLower())
                {
                    if (Settings.Instance.DebugArm) Logging.Log("Arm.ActivateTransportShip", "if (Cache.Instance.DirectEve.ActiveShip.GivenName.ToLower() != transportshipName.ToLower())", Logging.White);
                    if (!Cache.Instance.ShipHangar.Items.Any()) return StorylineState.Arm; //no ships?!?

                    if (Settings.Instance.DebugArm) Logging.Log("Arm.ActivateTransportShip", "if (!Cache.Instance.ShipHangar.Items.Any()) return StorylineState.Arm; done", Logging.White);

                    List<DirectItem> ships = Cache.Instance.ShipHangar.Items;
                    if (Settings.Instance.DebugArm) Logging.Log("Arm.ActivateTransportShip", "List<DirectItem> ships = Cache.Instance.ShipHangar.Items;", Logging.White);
                    foreach (DirectItem ship in ships.Where(ship => ship.GivenName != null && ship.GivenName.ToLower() == transportshipName.ToLower()))
                    {
                        Logging.Log("Arm", "Making [" + ship.GivenName + "] active", Logging.White);
                        ship.ActivateShip();
                        Cache.Instance.NextArmAction = DateTime.UtcNow.AddSeconds(Modules.Lookup.Time.Instance.SwitchShipsDelay_seconds);
                    }
                    return StorylineState.Arm;
                }
            }
            catch (Exception ex)
            {
                Logging.Log("GenericCourierStoryline", "Exception thrown while attempting to switch to transport ship:" + ex.Message, Logging.White);
                Logging.Log("GenericCourierStoryline", "blacklisting this storyline agent for this session because we could not switch to the configured transportship named [" + transportshipName + "]", Logging.White);
                return StorylineState.BlacklistAgent;
            }

            if (DateTime.UtcNow > Cache.Instance.NextArmAction) //default 7 seconds
            {
                if (Cache.Instance.DirectEve.ActiveShip.GivenName.ToLower() == transportshipName.ToLower())
                {
                    Logging.Log("Arm.ActivateTransportShip", "Done", Logging.White);
                    _States.CurrentArmState = ArmState.Done;
                    return StorylineState.GotoAgent;
                }
            }

            return StorylineState.Arm;
        }
        /// <summary>
        ///   There are no pre-accept actions
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            _state = GenericCourierStorylineState.GotoPickupLocation;

            _States.CurrentTravelerState = TravelerState.Idle;
            Traveler.Destination = null;

            return StorylineState.AcceptMission;
        }
Example #21
0
        /// <summary>
        /// Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            DirectEve directEve = Cache.Instance.DirectEve;

            if (_nextAction > DateTime.UtcNow)
            {
                return(StorylineState.PreAcceptMission);
            }

            // the ore and ore quantity can be stored in the characters settings xml this is to facility mission levels other than 4.
            //The defaults are for level 4 so it will not break for those people that do not include these in their settings file
            //  Level 1         <MaterialsForWarOreID>1230</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>999</MaterialsForWarOreQty>
            //  Level 4         <MaterialsForWarOreID>20</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>8000</MaterialsForWarOreQty>

            int oreid       = Settings.Instance.MaterialsForWarOreID;  //1230;
            int orequantity = Settings.Instance.MaterialsForWarOreQty; //999

            // Open the item hangar
            if (Cache.Instance.ItemHangar == null)
            {
                return(StorylineState.PreAcceptMission);
            }

            //if (Cache.Instance.ItemHangar.Window == null)
            //{
            //    Logging.Log("MaterialsForWar", "PreAcceptMission: ItemHangar is null", Logging.Orange);
            //    if (!Cache.Instance.ReadyItemsHangar("MaterialsForWarPreparation")) return StorylineState.PreAcceptMission;
            //    return StorylineState.PreAcceptMission;
            //}

            // Is there a market window?
            DirectMarketWindow marketWindow = directEve.Windows.OfType <DirectMarketWindow>().FirstOrDefault();

            // Do we have the ore we need in the Item Hangar?.

            if (Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                DirectItem thisOreInhangar = Cache.Instance.ItemHangar.Items.FirstOrDefault(i => i.TypeId == oreid);
                if (thisOreInhangar != null)
                {
                    Logging.Log("MaterialsForWarPreparation", "We have [" + Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity).ToString(CultureInfo.InvariantCulture) + "] " + thisOreInhangar.TypeName + " in the item hangar accepting mission", Logging.White);
                }

                // Close the market window if there is one
                if (marketWindow != null)
                {
                    marketWindow.Close();
                }

                return(StorylineState.AcceptMission);
            }

            if (Cache.Instance.CurrentShipsCargo == null)
            {
                return(StorylineState.PreAcceptMission);
            }

            if (Cache.Instance.CurrentShipsCargo.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                DirectItem thisOreInhangar = Cache.Instance.CurrentShipsCargo.Items.FirstOrDefault(i => i.TypeId == oreid);
                if (thisOreInhangar != null)
                {
                    Logging.Log("MaterialsForWarPreparation", "We have [" + Cache.Instance.CurrentShipsCargo.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity).ToString(CultureInfo.InvariantCulture) + "] " + thisOreInhangar.TypeName + " in the CargoHold accepting mission", Logging.White);
                }

                // Close the market window if there is one
                if (marketWindow != null)
                {
                    marketWindow.Close();
                }

                return(StorylineState.AcceptMission);
            }

            if (Cache.Instance.DirectEve.HasSupportInstances())
            {
                // We do not have enough ore, open the market window
                if (marketWindow == null)
                {
                    _nextAction = DateTime.UtcNow.AddSeconds(10);

                    Logging.Log("MaterialsForWarPreparation", "Opening market window", Logging.White);

                    directEve.ExecuteCommand(DirectCmd.OpenMarket);
                    return(StorylineState.PreAcceptMission);
                }

                // Wait for the window to become ready (this includes loading the ore info)
                if (!marketWindow.IsReady)
                {
                    return(StorylineState.PreAcceptMission);
                }

                // Are we currently viewing ore orders?
                if (marketWindow.DetailTypeId != oreid)
                {
                    // No, load the ore orders
                    marketWindow.LoadTypeId(oreid);

                    Logging.Log("MaterialsForWarPreparation", "Loading market window", Logging.White);

                    _nextAction = DateTime.UtcNow.AddSeconds(5);
                    return(StorylineState.PreAcceptMission);
                }

                // Get the median sell price
                InvType type     = Cache.Instance.InvTypesById[20];
                double? maxPrice = type.MedianSell * 4;

                // Do we have orders that sell enough ore for the mission?
                IEnumerable <DirectOrder> orders = marketWindow.SellOrders.Where(o => o.StationId == directEve.Session.StationId && o.Price < maxPrice).ToList();
                if (!orders.Any() || orders.Sum(o => o.VolumeRemaining) < orequantity)
                {
                    Logging.Log("MaterialsForWarPreparation", "Not enough (reasonably priced) ore available! Blacklisting agent for this Questor session!", Logging.Orange);

                    // Close the market window
                    marketWindow.Close();

                    // No, black list the agent in this Questor session (note we will never decline storylines!)
                    return(StorylineState.BlacklistAgent);
                }

                // How much ore do we still need?
                int neededQuantity = orequantity - Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity);
                if (neededQuantity > 0)
                {
                    // Get the first order
                    DirectOrder order = orders.OrderBy(o => o.Price).FirstOrDefault();
                    if (order != null)
                    {
                        // Calculate how much ore we still need
                        int remaining = Math.Min(neededQuantity, order.VolumeRemaining);
                        order.Buy(remaining, DirectOrderRange.Station);

                        Logging.Log("MaterialsForWarPreparation", "Buying [" + remaining + "] ore", Logging.White);

                        // Wait for the order to go through
                        _nextAction = DateTime.UtcNow.AddSeconds(10);
                    }
                }
                return(StorylineState.PreAcceptMission);
            }

            Logging.Log("MaterialsForWarPreparation", "No DirectEVE Instances Available: free version detected. Buy/Sell support not available. Blacklisting agent for this Questor session!", Logging.Orange);

            // Close the market window
            if (marketWindow != null)
            {
                marketWindow.Close();
            }
            // No, black list the agent in this Questor session (note we will never decline storylines!)
            return(StorylineState.BlacklistAgent);
        }
        /// <summary>
        /// Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
            {
                return StorylineState.Arm;
            }

            if (Cache.Instance.DirectEve.ActiveShip == null)
            {
                if (Settings.Instance.DebugArm) Logging.Log("StorylineState.Arm", "if (Cache.Instance.DirectEve.ActiveShip == null)", Logging.Debug);
                _nextAction = DateTime.UtcNow.AddSeconds(3);
                return StorylineState.Arm;
            }

            if (Cache.Instance.DirectEve.ActiveShip.GivenName.ToLower() != Settings.Instance.TransportShipName.ToLower())
            {
                // Open the ship hangar
                if (!Cache.Instance.OpenShipsHangar("MaterialsForWarPreparation")) return StorylineState.Arm;

                List<DirectItem> ships = Cache.Instance.ShipHangar.Items;
                foreach (DirectItem ship in ships.Where(ship => ship.GivenName != null && ship.GivenName.ToLower() == Settings.Instance.TransportShipName.ToLower()))
                {
                    Logging.Log("MaterialsForWarPreparation", "Making [" + ship.GivenName + "] active", Logging.White);
                    ship.ActivateShip();
                    Cache.Instance.NextArmAction = DateTime.UtcNow.AddSeconds(Modules.Lookup.Time.Instance.SwitchShipsDelay_seconds);
                    return StorylineState.Arm;
                }

                if (Cache.Instance.DirectEve.ActiveShip.GivenName.ToLower() != Settings.Instance.TransportShipName.ToLower())
                {
                    Logging.Log("StorylineState.Arm", "Missing TransportShip named [" + Settings.Instance.TransportShipName + "]", Logging.Debug);
                    return StorylineState.GotoAgent;
                }
            }

            if (!Cache.Instance.OpenItemsHangar("StorylineState.Arm")) return StorylineState.Arm;

            IEnumerable<DirectItem> items = Cache.Instance.ItemHangar.Items.Where(k => k.TypeId == Settings.Instance.MaterialsForWarOreID).ToList();
            if (!items.Any())
            {
                if (Settings.Instance.DebugArm) Logging.Log("StorylineState.Arm", "Ore for MaterialsForWar: typeID [" + Settings.Instance.MaterialsForWarOreID + "] not found in ItemHangar", Logging.Debug);
                if (!Cache.Instance.ReadyAmmoHangar("StorylineState.Arm")) return StorylineState.Arm;
                items = Cache.Instance.AmmoHangar.Items.Where(k => k.TypeId == Settings.Instance.MaterialsForWarOreID).ToList();
                if (!items.Any())
                {
                    if (Settings.Instance.DebugArm) Logging.Log("StorylineState.Arm", "Ore for MaterialsForWar: typeID [" + Settings.Instance.MaterialsForWarOreID + "] not found in AmmoHangar", Logging.Debug);
                    //
                    // if we do not have the ore... either we can blacklist it right here, or continue normally
                    //
                    return StorylineState.GotoAgent;
                    //return StorylineState.BlacklistAgent;
                }
            }

            Cache.Instance.CargoHold = Cache.Instance.DirectEve.GetShipsCargo();

            int oreIncargo = 0;
            foreach (DirectItem cargoItem in Cache.Instance.CargoHold.Items.ToList())
            {
                if (cargoItem.TypeId != Settings.Instance.MaterialsForWarOreID)
                    continue;

                oreIncargo += cargoItem.Quantity;
                continue;
            }

            int oreToLoad = Settings.Instance.MaterialsForWarOreQty - oreIncargo;
            if (oreToLoad <= 0)
            {
                //OreLoaded = true;
                return StorylineState.GotoAgent;
            }

            if (!Cache.Instance.ReadyAmmoHangar("StorylineState.Arm")) return StorylineState.Arm;

            DirectItem item = items.FirstOrDefault();
            if (item != null)
            {
                int moveOreQuantity = Math.Min(item.Stacksize, oreToLoad);
                Cache.Instance.CargoHold.Add(item, moveOreQuantity);
                Logging.Log("StorylineState.Arm", "Moving [" + moveOreQuantity + "] units of Ore [" + item.TypeName + "] Stacksize: [" + item.Stacksize + "] from hangar to CargoHold", Logging.White);
                _nextAction = DateTime.UtcNow.AddSeconds(Cache.Instance.RandomNumber(3,6));
                return StorylineState.Arm;  // you can only move one set of items per frame
            }

            Logging.Log("StorylineState.Arm", "defined TransportShip found, going in active ship", Logging.White);
            return StorylineState.GotoAgent;
        }
Example #23
0
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch (_state)
            {
            case GenericCombatStorylineState.GotoMission:
                var missionDestination = _traveler.Destination as MissionBookmarkDestination;
                if (missionDestination == null || missionDestination.AgentId != storyline.AgentId)     // We assume that this will always work "correctly" (tm)
                {
                    _traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(storyline.AgentId, "Encounter"));
                }

                if (Cache.Instance.PriorityTargets.Any(pt => pt != null && pt.IsValid))
                {
                    Logging.Log("GenericCombatStoryline: Priority targets found while traveling, engaging!");
                    _combat.ProcessState();
                }

                _traveler.ProcessState();
                if (_traveler.State == TravelerState.AtDestination)
                {
                    _state = GenericCombatStorylineState.ExecuteMission;
                    _traveler.Destination = null;
                }
                break;

            case GenericCombatStorylineState.ExecuteMission:
                _combat.ProcessState();
                _drones.ProcessState();
                _salvage.ProcessState();
                _missionController.ProcessState();

                // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                // and try the mission again
                if (_combat.State == CombatState.OutOfAmmo)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("GenericCombatStoryline: Out of Ammo!");
                    return(StorylineState.ReturnToAgent);
                }

                if (_missionController.State == MissionControllerState.Done)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();
                    return(StorylineState.ReturnToAgent);
                }

                // If in error state, just go home and stop the bot
                if (_missionController.State == MissionControllerState.Error)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("MissionController: Error");
                    return(StorylineState.ReturnToAgent);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }
        /// <summary>
        /// Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            DirectEve directEve = Cache.Instance.DirectEve;
            if (_nextAction > DateTime.Now)
                return StorylineState.PreAcceptMission;

            // the ore and ore quantity can be stored in the characters settings xml this is to facility mission levels other than 4.
            //The defaults are for level 4 so it will not break for those people that do not include these in their settings file
            //  Level 1         <MaterialsForWarOreID>1230</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>999</MaterialsForWarOreQty>
            //  Level 4         <MaterialsForWarOreID>20</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>8000</MaterialsForWarOreQty>

            int oreid = Settings.Instance.MaterialsForWarOreID; //1230;
            int orequantity = Settings.Instance.MaterialsForWarOreQty; //999

            // Open the item hangar
            if (!Cache.Instance.OpenItemsHangar("MaterialsForWarPreparation")) return StorylineState.PreAcceptMission;

            if (Cache.Instance.ItemHangar.Window == null)
            {
                Logging.Log("MaterialsForWar", "PreAcceptMission: ItemHangar is null", Logging.Orange);
                if (!Cache.Instance.OpenItemsHangar("MaterialsForWarPreparation")) return StorylineState.PreAcceptMission;
                return StorylineState.PreAcceptMission;
            }

            // Is there a market window?
            DirectMarketWindow marketWindow = directEve.Windows.OfType<DirectMarketWindow>().FirstOrDefault();

            // Do we have the ore we need.

            if (Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                DirectItem thisOreInhangar = Cache.Instance.ItemHangar.Items.FirstOrDefault(i => i.TypeId == oreid);
                if (thisOreInhangar != null)
                    Logging.Log("MaterialsForWarPreparation", "We have [" + Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity).ToString(CultureInfo.InvariantCulture) + "] " + thisOreInhangar.TypeName + " accepting mission", Logging.White);

                // Close the market window if there is one
                if (marketWindow != null)
                    marketWindow.Close();

                return StorylineState.AcceptMission;
            }

            // We do not have enough ore, open the market window
            if (marketWindow == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation", "Opening market window", Logging.White);

                directEve.ExecuteCommand(DirectCmd.OpenMarket);
                return StorylineState.PreAcceptMission;
            }

            // Wait for the window to become ready (this includes loading the ore info)
            if (!marketWindow.IsReady)
                return StorylineState.PreAcceptMission;

            // Are we currently viewing ore orders?
            if (marketWindow.DetailTypeId != oreid)
            {
                // No, load the ore orders
                marketWindow.LoadTypeId(oreid);

                Logging.Log("MaterialsForWarPreparation", "Loading market window", Logging.White);

                _nextAction = DateTime.Now.AddSeconds(5);
                return StorylineState.PreAcceptMission;
            }

            // Get the median sell price
            InvType type = Cache.Instance.InvTypesById[20];
            double? maxPrice = type.MedianSell * 4;

            // Do we have orders that sell enough ore for the mission?
            IEnumerable<DirectOrder> orders = marketWindow.SellOrders.Where(o => o.StationId == directEve.Session.StationId && o.Price < maxPrice).ToList();
            if (!orders.Any() || orders.Sum(o => o.VolumeRemaining) < orequantity)
            {
                Logging.Log("MaterialsForWarPreparation", "Not enough (reasonably priced) ore available! Blacklisting agent for this Questor session!", Logging.Orange);

                // Close the market window
                marketWindow.Close();

                // No, black list the agent in this Questor session (note we will never decline storylines!)
                return StorylineState.BlacklistAgent;
            }

            // How much ore do we still need?
            int neededQuantity = orequantity - Cache.Instance.ItemHangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity);
            if (neededQuantity > 0)
            {
                // Get the first order
                DirectOrder order = orders.OrderBy(o => o.Price).FirstOrDefault();
                if (order != null)
                {
                    // Calculate how much ore we still need
                    int remaining = Math.Min(neededQuantity, order.VolumeRemaining);
                    order.Buy(remaining, DirectOrderRange.Station);

                    Logging.Log("MaterialsForWarPreparation", "Buying [" + remaining + "] ore", Logging.White);

                    // Wait for the order to go through
                    _nextAction = DateTime.Now.AddSeconds(10);
                }
            }
            return StorylineState.PreAcceptMission;
        }
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextGenericCourierStorylineAction > DateTime.UtcNow)
            {
                return(StorylineState.Arm);
            }

            if (!Cache.Instance.OpenShipsHangar("Arm"))
            {
                return(StorylineState.Arm);
            }

            // Are we in an industrial?  Yes, goto the agent
            //var directEve = Cache.Instance.DirectEve;
            //if (Cache.Instance.ActiveShip.TypeId == 648 || Cache.Instance.ActiveShip.TypeId == 649 || Cache.Instance.ActiveShip.TypeId == 650 || Cache.Instance.ActiveShip.TypeId == 651 || Cache.Instance.ActiveShip.TypeId == 652 || Cache.Instance.ActiveShip.TypeId == 653 || Cache.Instance.ActiveShip.TypeId == 654 || Cache.Instance.ActiveShip.TypeId == 655 || Cache.Instance.ActiveShip.TypeId == 656 || Cache.Instance.ActiveShip.TypeId == 657 || Cache.Instance.ActiveShip.TypeId == 1944 || Cache.Instance.ActiveShip.TypeId == 19744)
            //    return StorylineState.GotoAgent;

            // Open the ship hangar
            if (!Cache.Instance.OpenShipsHangar("GenericCourierStoryline: Arm"))
            {
                _nextGenericCourierStorylineAction = DateTime.UtcNow.AddSeconds(5);
                return(StorylineState.Arm);
            }

            ////  Look for an industrial
            //var item = Cache.Instance.ShipHangar.Items.FirstOrDefault(i => i.Quantity == -1 && (i.TypeId == 648 || i.TypeId == 649 || i.TypeId == 650 || i.TypeId == 651 || i.TypeId == 652 || i.TypeId == 653 || i.TypeId == 654 || i.TypeId == 655 || i.TypeId == 656 || i.TypeId == 657 || i.TypeId == 1944 || i.TypeId == 19744));
            //if (item != null)
            //{
            //    Logging.Log("GenericCourier", "Switching to an industrial", Logging.White);

            //    _nextAction = DateTime.UtcNow.AddSeconds(10);

            //    item.ActivateShip();
            //    return StorylineState.Arm;
            //}
            //else
            //{
            //    Logging.Log("GenericCourier", "No industrial found, going in active ship", Logging.White);
            //    return StorylineState.GotoAgent;
            //}

            if (string.IsNullOrEmpty(Settings.Instance.TransportShipName.ToLower()))
            {
                _States.CurrentArmState = ArmState.NotEnoughAmmo;
                Logging.Log("Arm.ActivateTransportShip", "Could not find transportshipName in settings!", Logging.Orange);
                return(StorylineState.BlacklistAgent);
            }

            try
            {
                if (Settings.Instance.DebugArm)
                {
                    Logging.Log("Arm.ActivateTransportShip", "try", Logging.White);
                }
                if (Cache.Instance.ActiveShip.GivenName.ToLower() != Settings.Instance.TransportShipName.ToLower())
                {
                    if (Settings.Instance.DebugArm)
                    {
                        Logging.Log("Arm.ActivateTransportShip", "if (Cache.Instance.ActiveShip.GivenName.ToLower() != transportshipName.ToLower())", Logging.White);
                    }
                    if (!Cache.Instance.ShipHangar.Items.Any())
                    {
                        return(StorylineState.Arm);                                        //no ships?!?
                    }
                    if (Settings.Instance.DebugArm)
                    {
                        Logging.Log("Arm.ActivateTransportShip", "if (!Cache.Instance.ShipHangar.Items.Any()) return StorylineState.Arm; done", Logging.White);
                    }

                    List <DirectItem> ships = Cache.Instance.ShipHangar.Items;
                    if (Settings.Instance.DebugArm)
                    {
                        Logging.Log("Arm.ActivateTransportShip", "List<DirectItem> ships = Cache.Instance.ShipHangar.Items;", Logging.White);
                    }

                    foreach (DirectItem ship in ships.Where(ship => ship.GivenName != null && ship.GivenName.ToLower() == Settings.Instance.TransportShipName.ToLower()))
                    {
                        Logging.Log("Arm", "Making [" + ship.GivenName + "] active", Logging.White);
                        ship.ActivateShip();
                        _nextGenericCourierStorylineAction = DateTime.UtcNow.AddSeconds(Time.Instance.SwitchShipsDelay_seconds);
                        return(StorylineState.Arm);
                    }

                    return(StorylineState.Arm);
                }
            }
            catch (Exception exception)
            {
                Logging.Log("GenericCourierStoryline", "Exception thrown while attempting to switch to transport ship: [" + exception + "]", Logging.White);
                Logging.Log("GenericCourierStoryline", "blacklisting this storyline agent for this session because we could not switch to the configured TransportShip named [" + Settings.Instance.TransportShipName + "]", Logging.White);
                return(StorylineState.BlacklistAgent);
            }

            if (DateTime.UtcNow > Cache.Instance.NextArmAction) //default 7 seconds
            {
                if (Cache.Instance.ActiveShip.GivenName.ToLower() == Settings.Instance.TransportShipName.ToLower())
                {
                    Logging.Log("Arm.ActivateTransportShip", "Done", Logging.White);
                    _States.CurrentArmState = ArmState.Done;
                    return(StorylineState.GotoAgent);
                }
            }

            return(StorylineState.Arm);
        }
Example #26
0
        /// <summary>
        ///   Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            var directEve = Cache.Instance.DirectEve;

            if (_nextAction > DateTime.Now)
            {
                return(StorylineState.PreAcceptMission);
            }

            // Open the item hangar
            var hangar = directEve.GetItemHangar();

            if (hangar.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening hangar floor");

                directEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                return(StorylineState.PreAcceptMission);
            }

            // Wait for the item hangar to get ready
            if (!hangar.IsReady)
            {
                return(StorylineState.PreAcceptMission);
            }

            // Is there a market window?
            var marketWindow = directEve.Windows.OfType <DirectMarketWindow>().FirstOrDefault();

            // Do we have 8000 kernite?
            // TODO: Add lower level missions?
            if (hangar.Items.Where(i => i.TypeId == 20).Sum(i => i.Quantity) >= 8000)
            {
                Logging.Log("MaterialsForWarPreparation: We have [8000] kernite, accepting mission");

                // Close the market window if there is one
                if (marketWindow != null)
                {
                    marketWindow.Close();
                }

                return(StorylineState.AcceptMission);
            }

            // We do not have enough kernite, open the market window
            if (marketWindow == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening market window");

                directEve.ExecuteCommand(DirectCmd.OpenMarket);
                return(StorylineState.PreAcceptMission);
            }

            // Wait for the window to become ready (this includes loading the kernite info)
            if (!marketWindow.IsReady)
            {
                return(StorylineState.PreAcceptMission);
            }

            // Are we currently viewing kernite orders?
            if (marketWindow.DetailTypeId != 20)
            {
                // No, load the kernite orders
                marketWindow.LoadTypeId(20);

                Logging.Log("MaterialsForWarPreparation: Loading kernite into market window");

                _nextAction = DateTime.Now.AddSeconds(5);
                return(StorylineState.PreAcceptMission);
            }

            // Get the median sell price
            var type     = Cache.Instance.InvTypesById[20];
            var maxPrice = type.MedianSell * 2;

            // Do we have orders that sell enough kernite for the mission?
            var orders = marketWindow.SellOrders.Where(o => o.StationId == directEve.Session.StationId && o.Price < maxPrice);

            if (!orders.Any() || orders.Sum(o => o.VolumeRemaining) < 8000)
            {
                Logging.Log("MaterialsForWarPreparation: Not enough (reasonably priced) kernite available! Blacklisting agent for this Questor session!");

                // Close the market window
                marketWindow.Close();

                // No, black list the agent in this Questor session (note we will never decline storylines!)
                return(StorylineState.BlacklistAgent);
            }

            // How much kernite do we still need?
            var neededQuantity = 8000 - hangar.Items.Where(i => i.TypeId == 20).Sum(i => i.Quantity);

            if (neededQuantity > 0)
            {
                // Get the first order
                var order = orders.OrderBy(o => o.Price).FirstOrDefault();
                if (order != null)
                {
                    // Calculate how much kernite we still need
                    var remaining = Math.Min(neededQuantity, order.VolumeRemaining);
                    order.Buy(remaining, DirectOrderRange.Station);

                    Logging.Log("MaterialsForWarPreparation: Buying [" + remaining + "] kernite");

                    // Wait for the order to go through
                    _nextAction = DateTime.Now.AddSeconds(10);
                }
            }
            return(StorylineState.PreAcceptMission);
        }
Example #27
0
        public CombatMissionsBehavior()
        {
            _lastPulse = DateTime.MinValue;

            _random = new Random();
            _salvage = new Salvage();
            _localWatch = new LocalWatch();
            _combat = new Combat();
            _drones = new Drones();
            _traveler = new Traveler();
            _unloadLoot = new UnloadLoot();
            _agentInteraction = new AgentInteraction();
            _arm = new Arm();
            _courierMissionCtrl = new CourierMissionCtrl();
            _switchShip = new SwitchShip();
            _combatMissionCtrl = new CombatMissionCtrl();
            _panic = new Panic();
            _storyline = new Storyline();
            _statistics = new Statistics();
            _watch = new Stopwatch();

            //
            // this is combat mission specific and needs to be generalized
            //
            Settings.Instance.SettingsLoaded += SettingsLoaded;

            // States.CurrentCombatMissionBehaviorState fixed on ExecuteMission
            _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Idle;
            _States.CurrentArmState = ArmState.Idle;
            //_States.CurrentCombatState = CombatState.Idle;
            //_States.CurrentDroneState = DroneState.Idle;
            _States.CurrentUnloadLootState = UnloadLootState.Idle;
            _States.CurrentTravelerState = TravelerState.Idle;
        }
        /// <summary>
        ///   Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            var directEve = Cache.Instance.DirectEve;
            if (_nextAction > DateTime.Now)
                return StorylineState.PreAcceptMission;

            // Open the item hangar
            var hangar = directEve.GetItemHangar();
            if (hangar.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening hangar floor");

                directEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                return StorylineState.PreAcceptMission;
            }

            // Wait for the item hangar to get ready
            if (!hangar.IsReady)
                return StorylineState.PreAcceptMission;

            // Is there a market window?
            var marketWindow = directEve.Windows.OfType<DirectMarketWindow>().FirstOrDefault();

            // Do we have 8000 kernite?
            // TODO: Add lower level missions?
            if (hangar.Items.Where(i => i.TypeId == 20).Sum(i => i.Quantity) >= 8000)
            {
                Logging.Log("MaterialsForWarPreparation: We have [8000] kernite, accepting mission");

                // Close the market window if there is one
                if (marketWindow != null)
                    marketWindow.Close();

                return StorylineState.AcceptMission;
            }

            // We do not have enough kernite, open the market window
            if (marketWindow == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening market window");

                directEve.ExecuteCommand(DirectCmd.OpenMarket);
                return StorylineState.PreAcceptMission;
            }

            // Wait for the window to become ready (this includes loading the kernite info)
            if (!marketWindow.IsReady)
                return StorylineState.PreAcceptMission;

            // Are we currently viewing kernite orders?
            if (marketWindow.DetailTypeId != 20)
            {
                // No, load the kernite orders
                marketWindow.LoadTypeId(20);

                Logging.Log("MaterialsForWarPreparation: Loading kernite into market window");

                _nextAction = DateTime.Now.AddSeconds(5);
                return StorylineState.PreAcceptMission;
            }

            // Get the median sell price
            var type = Cache.Instance.InvTypesById[20];
            var maxPrice = type.MedianSell*2;

            // Do we have orders that sell enough kernite for the mission?
            var orders = marketWindow.SellOrders.Where(o => o.StationId == directEve.Session.StationId && o.Price < maxPrice);
            if (!orders.Any() || orders.Sum(o => o.VolumeRemaining) < 8000)
            {
                Logging.Log("MaterialsForWarPreparation: Not enough (reasonably priced) kernite available! Blacklisting agent for this Questor session!");

                // Close the market window
                marketWindow.Close();

                // No, black list the agent in this Questor session (note we will never decline storylines!)
                return StorylineState.BlacklistAgent;
            }

            // How much kernite do we still need?
            var neededQuantity = 8000 - (hangar.Items.Where(i => i.TypeId == 20).Sum(i => i.Quantity) ?? 0);
            if (neededQuantity > 0)
            {
                // Get the first order
                var order = orders.OrderBy(o => o.Price).FirstOrDefault();
                if (order != null)
                {
                    // Calculate how much kernite we still need
                    var remaining = Math.Min(neededQuantity, order.VolumeRemaining);
                    order.Buy(remaining, DirectOrderRange.Station);

                    Logging.Log("MaterialsForWarPreparation: Buying [" + remaining + "] kernite");

                    // Wait for the order to go through
                    _nextAction = DateTime.Now.AddSeconds(10);
                }
            }
            return StorylineState.PreAcceptMission;
        }
 /// <summary>
 /// We have no execute mission code
 /// </summary>
 /// <returns></returns>
 public StorylineState ExecuteMission(Storyline storyline)
 {
     return StorylineState.CompleteMission;
 }
Example #30
0
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch(_state)
            {
                case GenericCombatStorylineState.GotoMission:
                    var missionDestination = _traveler.Destination as MissionBookmarkDestination;
                    if (missionDestination == null || missionDestination.AgentId != storyline.AgentId) // We assume that this will always work "correctly" (tm)
                        _traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(storyline.AgentId, "Encounter"));

                    if (Cache.Instance.PriorityTargets.Any(pt => pt != null && pt.IsValid))
                    {
                        Logging.Log("GenericCombatStoryline: Priority targets found while traveling, engaging!");
                        _combat.ProcessState();
                    }

                    _traveler.ProcessState();
                    if (_traveler.State == TravelerState.AtDestination)
                    {
                        _state = GenericCombatStorylineState.ExecuteMission;
                        _traveler.Destination = null;
                    }
                    break;

                case GenericCombatStorylineState.ExecuteMission:
                    _combat.ProcessState();
                    _drones.ProcessState();
                    _salvage.ProcessState();
                    _missionController.ProcessState();

                    // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                    // and try the mission again
                    if (_combat.State == CombatState.OutOfAmmo)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();

                        Logging.Log("GenericCombatStoryline: Out of Ammo!");
                        return StorylineState.ReturnToAgent;
                    }

                    if (_missionController.State == MissionControllerState.Done)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();
                        return StorylineState.ReturnToAgent;
                    }

                    // If in error state, just go home and stop the bot
                    if (_missionController.State == MissionControllerState.Error)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();

                        Logging.Log("MissionController: Error");
                        return StorylineState.ReturnToAgent;
                    }
                    break;
            }

            return StorylineState.ExecuteMission;
        }
 /// <summary>
 /// We have no combat/delivery part in this mission, just accept it
 /// </summary>
 /// <returns></returns>
 public StorylineState PostAcceptMission(Storyline storyline)
 {
     // Close the market window (if its open)
     return StorylineState.CompleteMission;
 }
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch (_state)
            {
                case GenericCombatStorylineState.WarpOutStation:
                    DirectBookmark warpOutBookMark = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockBookmarkPrefix ?? "").OrderByDescending(b => b.CreatedOn).FirstOrDefault(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                    long solarid = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1;

                    if (warpOutBookMark == null)
                    {
                        Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark", Logging.Orange);
                        _state = GenericCombatStorylineState.GotoMission;
                        break;
                    }

                    if (warpOutBookMark.LocationId == solarid)
                    {
                        if (Traveler.Destination == null)
                        {
                            Logging.Log("GenericCombatStoryline.WarpOut", "Warp at " + warpOutBookMark.Title, Logging.White);
                            Traveler.Destination = new BookmarkDestination(warpOutBookMark);
                            Cache.Instance.DoNotBreakInvul = true;
                        }

                        Traveler.ProcessState();
                        if (_States.CurrentTravelerState == TravelerState.AtDestination)
                        {
                            Logging.Log("GenericCombatStoryline.WarpOut", "Safe!", Logging.White);
                            Cache.Instance.DoNotBreakInvul = false;
                            _state = GenericCombatStorylineState.GotoMission;
                            Traveler.Destination = null;
                            break;
                        }

                        break;
                    }

                    Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark in System", Logging.White);
                    _state = GenericCombatStorylineState.GotoMission;
                    break;

                case GenericCombatStorylineState.GotoMission:
                    MissionBookmarkDestination missionDestination = Traveler.Destination as MissionBookmarkDestination;
                    //
                    // if we have no destination yet... OR if missionDestination.AgentId != storyline.CurrentStorylineAgentId
                    //
                    //if (missionDestination != null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [" + missionDestination.AgentId + "] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                    //if (missionDestination == null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [ NULL ] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                    if (missionDestination == null || missionDestination.AgentId != Cache.Instance.CurrentStorylineAgentId) // We assume that this will always work "correctly" (tm)
                    {
                        string nameOfBookmark ="";
                        if (Settings.Instance.EveServerName == "Tranquility") nameOfBookmark = "Encounter";
                        if (Settings.Instance.EveServerName == "Serenity") nameOfBookmark = "遭遇战";
                        if (nameOfBookmark == "") nameOfBookmark = "Encounter";
                        Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + Cache.Instance.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.White);
                        Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(Cache.Instance.CurrentStorylineAgentId, nameOfBookmark));
                    }

                    if (Cache.Instance.PotentialCombatTargets.Any())
                    {
                        Logging.Log("GenericCombatStoryline", "Priority targets found while traveling, engaging!", Logging.White);
                        Combat.ProcessState();
                    }

                    Traveler.ProcessState();
                    if (_States.CurrentTravelerState == TravelerState.AtDestination)
                    {
                        _state = GenericCombatStorylineState.ExecuteMission;

                        //_States.CurrentCombatState = CombatState.CheckTargets;
                        Traveler.Destination = null;
                    }
                    break;

                case GenericCombatStorylineState.ExecuteMission:
                    Combat.ProcessState();
                    Drones.ProcessState();
                    Salvage.ProcessState();
                    _combatMissionCtrl.ProcessState();

                    // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                    // and try the mission again
                    if (_States.CurrentCombatState == CombatState.OutOfAmmo)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();

                        Logging.Log("GenericCombatStoryline", "Out of Ammo!", Logging.Orange);
                        return StorylineState.ReturnToAgent;
                    }

                    if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Done)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();
                        return StorylineState.ReturnToAgent;
                    }

                    // If in error state, just go home and stop the bot
                    if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error)
                    {
                        // Clear looted containers
                        Cache.Instance.LootedContainers.Clear();

                        Logging.Log("MissionController", "Error", Logging.Red);
                        return StorylineState.ReturnToAgent;
                    }
                    break;
            }

            return StorylineState.ExecuteMission;
        }
Example #33
0
 /// <summary>
 ///   We have no pre-accept steps
 /// </summary>
 /// <returns></returns>
 public StorylineState PreAcceptMission(Storyline storyline)
 {
     // Not really a step is it? :)
     _state = GenericCombatStorylineState.GotoMission;
     return(StorylineState.AcceptMission);
 }
Example #34
0
 /// <summary>
 ///   We have no execute mission code
 /// </summary>
 /// <returns></returns>
 public StorylineState ExecuteMission(Storyline storyline)
 {
     return(StorylineState.CompleteMission);
 }
        /// <summary>
        /// Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
                return StorylineState.PreAcceptMission;

            // the ore and ore quantity can be stored in the characters settings xml this is to facility mission levels other than 4.
            //The defaults are for level 4 so it will not break for those people that do not include these in their settings file
            //  Level 1         <MaterialsForWarOreID>1230</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>999</MaterialsForWarOreQty>
            //  Level 4         <MaterialsForWarOreID>20</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>8000</MaterialsForWarOreQty>

            int oreid = MissionSettings.Mission.Objective.TypeID; //1230;
            int orequantity = MissionSettings.Mission.Objective.Quantity; //999

            // Open the item hangar
            if (QuestorCache.Instance.ItemHangar == null) return StorylineState.PreAcceptMission;

            //if (Cache.Instance.ItemHangar.Window == null)
            //{
            //    Logging.Log("MaterialsForWar", "PreAcceptMission: ItemHangar is null", Logging.Orange);
            //    if (!Cache.Instance.ReadyItemsHangar("MaterialsForWarPreparation")) return StorylineState.PreAcceptMission;
            //    return StorylineState.PreAcceptMission;
            //}

            // Do we have the ore we need in the Item Hangar?.

            if (QuestorCache.Instance.ItemHangar.Items.Where(i => i.TypeID == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                EveCom.Item thisOreInhangar = QuestorCache.Instance.ItemHangar.Items.FirstOrDefault(i => i.TypeID == oreid);
                if (thisOreInhangar != null)
                {
                    Logging.Log("MaterialsForWarPreparation", "We have [" + QuestorCache.Instance.ItemHangar.Items.Where(i => i.TypeID == oreid).Sum(i => i.Quantity).ToString(CultureInfo.InvariantCulture) + "] " + thisOreInhangar.Type + " in the item hangar accepting mission", Logging.White);
                }

                // Close the market window if there is one
                //if (marketWindow != null)
                //{
                //    marketWindow.Close();
                //}

                return StorylineState.AcceptMission;
            }

            if (QuestorCache.Instance.CurrentShipsCargo == null) return StorylineState.PreAcceptMission;

            if (QuestorCache.Instance.CurrentShipsCargo.Items.Where(i => i.TypeID == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                EveCom.Item thisOreInhangar = QuestorCache.Instance.CurrentShipsCargo.Items.FirstOrDefault(i => i.TypeID == oreid);
                if (thisOreInhangar != null)
                {
                    Logging.Log("MaterialsForWarPreparation", "We have [" + QuestorCache.Instance.CurrentShipsCargo.Items.Where(i => i.TypeID == oreid).Sum(i => i.Quantity).ToString(CultureInfo.InvariantCulture) + "] " + thisOreInhangar.Type + " in the CargoHold accepting mission", Logging.White);
                }

                // Close the market window if there is one
                //if (marketWindow != null)
                //{
                //    marketWindow.Close();
                //}

                return StorylineState.AcceptMission;
            }

            if (true)
            {
                if (!EveCom.Order.OrdersLoaded(oreid))
                {
                    Logging.Log("MaterialsForWarPreparation", "Loading market orders for typeID [" + oreid + "]", Logging.White);
                    EveCom.Order.LoadOrders(oreid);
                    return StorylineState.PreAcceptMission;
                }

                // Get the median sell price
                //DirectInvType type;
                //Cache.Instance.EveCom.InvTypes.TryGetValue(20, out type);

                //EveCom.Item OreTypeNeededForThisMission = ;
                //double? maxPrice;

                //if (OreTypeNeededForThisMission != null)
                //{
                //    maxPrice = OreTypeNeededForThisMission.AveragePrice() * 4;
                //}

                // Do we have orders that sell enough ore for the mission?
                //IEnumerable<DirectOrder> orders = marketWindow.SellOrders.Where(o => o.StationId == EVECom.Session.StationId && o.Price < maxPrice).ToList();

                IEnumerable<Order> inStationOreOrders = EveCom.Order.Orders(oreid).Where(i => i.Sell && i.Jumps == 0 && i.StationID == EveCom.Session.StationID).ToList();
                if (!inStationOreOrders.Any() || inStationOreOrders.Sum(o => o.Remaining) < orequantity)
                {
                    Logging.Log("MaterialsForWarPreparation", "Not enough (reasonably priced) ore available! Blacklisting agent for this Questor session!", Logging.Orange);
                    // No, black list the agent in this Questor session (note we will never decline storylines!)
                    return StorylineState.BlacklistAgent;
                }

                // How much ore do we still need?
                int neededQuantity = orequantity - QuestorCache.Instance.ItemHangar.Items.Where(i => i.TypeID == oreid).Sum(i => i.Quantity);
                if (neededQuantity > 0)
                {
                    // Get the first order
                    EveCom.Order order = inStationOreOrders.OrderBy(o => o.Price).FirstOrDefault();
                    if (order != null)
                    {
                        // Calculate how much ore we still need
                        int remaining = Math.Min(neededQuantity, order.Remaining);
                        order.Buy(remaining);

                        Logging.Log("MaterialsForWarPreparation", "Buying [" + remaining + "] ore", Logging.White);

                        // Wait for the order to go through
                        _nextAction = DateTime.UtcNow.AddSeconds(10);
                    }
                }
                return StorylineState.PreAcceptMission;
            }
        }
Example #36
0
        /// <summary>
        ///   Check if we have kernite in station
        /// </summary>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            var directEve = Cache.Instance.DirectEve;

            if (_nextAction > DateTime.Now)
            {
                return(StorylineState.PreAcceptMission);
            }


            // the ore and ore quantity can be stored in the char.xml this is to facility mission levels other than 4.
            //The defaults are for level 4 so it will not break for those people that dont include these in their settings file
            //  Level 1         <MaterialsForWarOreID>1230</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>999</MaterialsForWarOreQty>
            //  Level 4         <MaterialsForWarOreID>20</MaterialsForWarOreID>
            //                  <MaterialsForWarOreQty>8000</MaterialsForWarOreQty>


            var oreid       = Settings.Instance.MaterialsForWarOreID;  //1230;
            var orequantity = Settings.Instance.MaterialsForWarOreQty; //999

            // Open the item hangar
            var hangar = directEve.GetItemHangar();

            if (hangar.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening hangar floor");

                directEve.ExecuteCommand(DirectCmd.OpenHangarFloor);
                return(StorylineState.PreAcceptMission);
            }

            // Wait for the item hangar to get ready
            if (!hangar.IsReady)
            {
                return(StorylineState.PreAcceptMission);
            }

            // Is there a market window?
            var marketWindow = directEve.Windows.OfType <DirectMarketWindow>().FirstOrDefault();

            // Do we have the ore we need.

            if (hangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity) >= orequantity)
            {
                Logging.Log(String.Format("MaterialsForWarPreparation: We have [{0}] {1}, accepting mission", hangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity).ToString(), hangar.Items.Where(i => i.TypeId == oreid).FirstOrDefault().TypeName));

                // Close the market window if there is one
                if (marketWindow != null)
                {
                    marketWindow.Close();
                }

                return(StorylineState.AcceptMission);
            }

            // We do not have enough ore, open the market window
            if (marketWindow == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening market window");

                directEve.ExecuteCommand(DirectCmd.OpenMarket);
                return(StorylineState.PreAcceptMission);
            }

            // Wait for the window to become ready (this includes loading the ore info)
            if (!marketWindow.IsReady)
            {
                return(StorylineState.PreAcceptMission);
            }

            // Are we currently viewing ore orders?
            if (marketWindow.DetailTypeId != oreid)
            {
                // No, load the ore orders
                marketWindow.LoadTypeId(oreid);


                Logging.Log("MaterialsForWarPreparation: Loading market window");

                _nextAction = DateTime.Now.AddSeconds(5);
                return(StorylineState.PreAcceptMission);
            }

            // Get the median sell price
            var type     = Cache.Instance.InvTypesById[20];
            var maxPrice = type.MedianSell * 4;

            // Do we have orders that sell enough ore for the mission?
            var orders = marketWindow.SellOrders.Where(o => o.StationId == directEve.Session.StationId && o.Price < maxPrice);

            if (!orders.Any() || orders.Sum(o => o.VolumeRemaining) < orequantity)
            {
                Logging.Log("MaterialsForWarPreparation: Not enough (reasonably priced) ore available! Blacklisting agent for this Questor session!");

                // Close the market window
                marketWindow.Close();

                // No, black list the agent in this Questor session (note we will never decline storylines!)
                return(StorylineState.BlacklistAgent);
            }

            // How much ore do we still need?
            var neededQuantity = orequantity - hangar.Items.Where(i => i.TypeId == oreid).Sum(i => i.Quantity);

            if (neededQuantity > 0)
            {
                // Get the first order
                var order = orders.OrderBy(o => o.Price).FirstOrDefault();
                if (order != null)
                {
                    // Calculate how much ore we still need
                    var remaining = Math.Min(neededQuantity, order.VolumeRemaining);
                    order.Buy(remaining, DirectOrderRange.Station);

                    Logging.Log("MaterialsForWarPreparation: Buying [" + remaining + "] ore");

                    // Wait for the order to go through
                    _nextAction = DateTime.Now.AddSeconds(10);
                }
            }
            return(StorylineState.PreAcceptMission);
        }
Example #37
0
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch (_state)
            {
            case GenericCombatStorylineState.WarpOutStation:
                DirectBookmark warpOutBookMark = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockBookmarkPrefix ?? "").OrderByDescending(b => b.CreatedOn).FirstOrDefault(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                long           solarid         = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1;

                if (warpOutBookMark == null)
                {
                    Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark", Logging.Orange);
                    _state = GenericCombatStorylineState.GotoMission;
                    break;
                }

                if (warpOutBookMark.LocationId == solarid)
                {
                    if (Traveler.Destination == null)
                    {
                        Logging.Log("GenericCombatStoryline.WarpOut", "Warp at " + warpOutBookMark.Title, Logging.White);
                        Traveler.Destination           = new BookmarkDestination(warpOutBookMark);
                        Cache.Instance.DoNotBreakInvul = true;
                    }

                    Traveler.ProcessState();
                    if (_States.CurrentTravelerState == TravelerState.AtDestination)
                    {
                        Logging.Log("GenericCombatStoryline.WarpOut", "Safe!", Logging.White);
                        Cache.Instance.DoNotBreakInvul = false;
                        _state = GenericCombatStorylineState.GotoMission;
                        Traveler.Destination = null;
                        break;
                    }

                    break;
                }

                Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark in System", Logging.White);
                _state = GenericCombatStorylineState.GotoMission;
                break;

            case GenericCombatStorylineState.GotoMission:
                MissionBookmarkDestination missionDestination = Traveler.Destination as MissionBookmarkDestination;
                //
                // if we have no destination yet... OR if missionDestination.AgentId != storyline.CurrentStorylineAgentId
                //
                //if (missionDestination != null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [" + missionDestination.AgentId + "] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                //if (missionDestination == null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [ NULL ] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                if (missionDestination == null || missionDestination.AgentId != Cache.Instance.CurrentStorylineAgentId)     // We assume that this will always work "correctly" (tm)
                {
                    string nameOfBookmark = "";
                    if (Settings.Instance.EveServerName == "Tranquility")
                    {
                        nameOfBookmark = "Encounter";
                    }
                    if (Settings.Instance.EveServerName == "Serenity")
                    {
                        nameOfBookmark = "遭遇战";
                    }
                    if (nameOfBookmark == "")
                    {
                        nameOfBookmark = "Encounter";
                    }
                    Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + Cache.Instance.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.White);
                    Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(Cache.Instance.CurrentStorylineAgentId, nameOfBookmark));
                }

                if (Cache.Instance.PotentialCombatTargets.Any())
                {
                    Logging.Log("GenericCombatStoryline", "Priority targets found while traveling, engaging!", Logging.White);
                    Combat.ProcessState();
                }

                Traveler.ProcessState();
                if (_States.CurrentTravelerState == TravelerState.AtDestination)
                {
                    _state = GenericCombatStorylineState.ExecuteMission;

                    //_States.CurrentCombatState = CombatState.CheckTargets;
                    Traveler.Destination = null;
                }
                break;

            case GenericCombatStorylineState.ExecuteMission:
                Combat.ProcessState();
                Drones.ProcessState();
                Salvage.ProcessState();
                _combatMissionCtrl.ProcessState();

                // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                // and try the mission again
                if (_States.CurrentCombatState == CombatState.OutOfAmmo)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("GenericCombatStoryline", "Out of Ammo!", Logging.Orange);
                    return(StorylineState.ReturnToAgent);
                }

                if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Done)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();
                    return(StorylineState.ReturnToAgent);
                }

                // If in error state, just go home and stop the bot
                if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("MissionController", "Error", Logging.Red);
                    return(StorylineState.ReturnToAgent);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }
Example #38
0
        /// <summary>
        /// Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
            {
                return(StorylineState.Arm);
            }

            if (Cache.Instance.ActiveShip == null || Cache.Instance.ActiveShip.GivenName == null)
            {
                if (Settings.Instance.DebugArm)
                {
                    Logging.Log("StorylineState.Arm", "if (Cache.Instance.ActiveShip == null)", Logging.Debug);
                }
                _nextAction = DateTime.UtcNow.AddSeconds(3);
                return(StorylineState.Arm);
            }

            if (Cache.Instance.ActiveShip.GivenName.ToLower() != Settings.Instance.TransportShipName.ToLower())
            {
                // Open the ship hangar
                if (!Cache.Instance.OpenShipsHangar("MaterialsForWarPreparation"))
                {
                    return(StorylineState.Arm);
                }

                List <DirectItem> ships = Cache.Instance.ShipHangar.Items;
                foreach (DirectItem ship in ships.Where(ship => ship.GivenName != null && ship.GivenName.ToLower() == Settings.Instance.TransportShipName.ToLower()))
                {
                    Logging.Log("MaterialsForWarPreparation", "Making [" + ship.GivenName + "] active", Logging.White);
                    ship.ActivateShip();
                    Cache.Instance.NextArmAction = DateTime.UtcNow.AddSeconds(Modules.Lookup.Time.Instance.SwitchShipsDelay_seconds);
                    return(StorylineState.Arm);
                }

                if (Cache.Instance.ActiveShip.GivenName.ToLower() != Settings.Instance.TransportShipName.ToLower())
                {
                    Logging.Log("StorylineState.Arm", "Missing TransportShip named [" + Settings.Instance.TransportShipName + "]", Logging.Debug);
                    return(StorylineState.GotoAgent);
                }
            }

            if (Cache.Instance.ItemHangar == null)
            {
                return(StorylineState.Arm);
            }

            IEnumerable <DirectItem> items = Cache.Instance.ItemHangar.Items.Where(k => k.TypeId == Settings.Instance.MaterialsForWarOreID).ToList();

            if (!items.Any())
            {
                if (Settings.Instance.DebugArm)
                {
                    Logging.Log("StorylineState.Arm", "Ore for MaterialsForWar: typeID [" + Settings.Instance.MaterialsForWarOreID + "] not found in ItemHangar", Logging.Debug);
                }
                items = Cache.Instance.AmmoHangar.Items.Where(k => k.TypeId == Settings.Instance.MaterialsForWarOreID).ToList();
                if (!items.Any())
                {
                    if (Settings.Instance.DebugArm)
                    {
                        Logging.Log("StorylineState.Arm", "Ore for MaterialsForWar: typeID [" + Settings.Instance.MaterialsForWarOreID + "] not found in AmmoHangar", Logging.Debug);
                    }
                    //
                    // if we do not have the ore... either we can blacklist it right here, or continue normally
                    //
                    return(StorylineState.GotoAgent);
                    //return StorylineState.BlacklistAgent;
                }
            }

            int oreIncargo = 0;

            foreach (DirectItem cargoItem in Cache.Instance.CurrentShipsCargo.Items.ToList())
            {
                if (cargoItem.TypeId != Settings.Instance.MaterialsForWarOreID)
                {
                    continue;
                }

                oreIncargo += cargoItem.Quantity;
                continue;
            }

            int oreToLoad = Settings.Instance.MaterialsForWarOreQty - oreIncargo;

            if (oreToLoad <= 0)
            {
                //OreLoaded = true;
                return(StorylineState.GotoAgent);
            }

            DirectItem item = items.FirstOrDefault();

            if (item != null)
            {
                int moveOreQuantity = Math.Min(item.Stacksize, oreToLoad);
                Cache.Instance.CurrentShipsCargo.Add(item, moveOreQuantity);
                Logging.Log("StorylineState.Arm", "Moving [" + moveOreQuantity + "] units of Ore [" + item.TypeName + "] Stack size: [" + item.Stacksize + "] from hangar to CargoHold", Logging.White);
                _nextAction = DateTime.UtcNow.AddSeconds(Cache.Instance.RandomNumber(3, 6));
                return(StorylineState.Arm);  // you can only move one set of items per frame
            }

            Logging.Log("StorylineState.Arm", "defined TransportShip found, going in active ship", Logging.White);
            return(StorylineState.GotoAgent);
        }
 /// <summary>
 ///   We have no pre-accept steps
 /// </summary>
 /// <returns></returns>
 public StorylineState PreAcceptMission(Storyline storyline)
 {
     // Not really a step is it? :)
     _state = GenericCombatStorylineState.WarpOutStation;
     return StorylineState.AcceptMission;
 }
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch (_state)
            {
            case GenericCombatStorylineState.WarpOutStation:
                var _bookmark = Cache.Instance.BookmarksByLabel(Settings.Instance.bookmarkWarpOut ?? "").OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).FirstOrDefault();
                var _solarid  = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1;

                if (_bookmark == null)
                {
                    Logging.Log("WarpOut: No Bookmark");
                    if (_state == GenericCombatStorylineState.WarpOutStation)
                    {
                        _state = GenericCombatStorylineState.GotoMission;
                    }
                }
                else if (_bookmark.LocationId == _solarid)
                {
                    if (_traveler.Destination == null)
                    {
                        Logging.Log("WarpOut: Warp at " + _bookmark.Title);
                        _traveler.Destination          = new BookmarkDestination(_bookmark);
                        Cache.Instance.DoNotBreakInvul = true;
                    }

                    _traveler.ProcessState();
                    if (_traveler.State == TravelerState.AtDestination)
                    {
                        Logging.Log("WarpOut: Safe!");
                        Cache.Instance.DoNotBreakInvul = false;
                        if (_state == GenericCombatStorylineState.WarpOutStation)
                        {
                            _state = GenericCombatStorylineState.GotoMission;
                        }
                        _traveler.Destination = null;
                    }
                }
                else
                {
                    Logging.Log("WarpOut: No Bookmark in System");
                    if (_state == GenericCombatStorylineState.WarpOutStation)
                    {
                        _state = GenericCombatStorylineState.GotoMission;
                    }
                }
                break;

            case GenericCombatStorylineState.GotoMission:
                var missionDestination = _traveler.Destination as MissionBookmarkDestination;
                if (missionDestination == null || missionDestination.AgentId != storyline.AgentId)     // We assume that this will always work "correctly" (tm)
                {
                    _traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(storyline.AgentId, "Encounter"));
                }

                if (Cache.Instance.PriorityTargets.Any(pt => pt != null && pt.IsValid))
                {
                    Logging.Log("GenericCombatStoryline: Priority targets found while traveling, engaging!");
                    _combat.ProcessState();
                }

                _traveler.ProcessState();
                if (_traveler.State == TravelerState.AtDestination)
                {
                    _state = GenericCombatStorylineState.ExecuteMission;
                    _traveler.Destination = null;
                }
                break;

            case GenericCombatStorylineState.ExecuteMission:
                _combat.ProcessState();
                _drones.ProcessState();
                _salvage.ProcessState();
                _missionController.ProcessState();

                // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                // and try the mission again
                if (_combat.State == CombatState.OutOfAmmo)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("GenericCombatStoryline: Out of Ammo!");
                    return(StorylineState.ReturnToAgent);
                }

                if (_missionController.State == MissionControllerState.Done)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();
                    return(StorylineState.ReturnToAgent);
                }

                // If in error state, just go home and stop the bot
                if (_missionController.State == MissionControllerState.Error)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("MissionController: Error");
                    return(StorylineState.ReturnToAgent);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }
Example #41
0
        /// <summary>
        ///   There are no pre-accept actions
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState PreAcceptMission(Storyline storyline)
        {
            _state = TransactionDataDeliveryState.GotoPickupLocation;

            _States.CurrentTravelerState = TravelerState.Idle;
            Traveler.Destination = null;

            return StorylineState.AcceptMission;
        }
        /// <summary>
        ///   Goto the pickup location
        ///   Pickup the item
        ///   Goto drop off location
        ///   Drop the item
        ///   Complete mission
        /// </summary>
        /// <param name="storyline"></param>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            if (_nextAction > DateTime.UtcNow)
                return StorylineState.ExecuteMission;

            switch (_state)
            {
                case GenericCourierStorylineState.GotoPickupLocation:
                    if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Pick Up)"))
                        _state = GenericCourierStorylineState.PickupItem;
                    break;

                case GenericCourierStorylineState.PickupItem:
                    if (MoveItem(true))
                        _state = GenericCourierStorylineState.GotoDropOffLocation;
                    break;

                case GenericCourierStorylineState.GotoDropOffLocation:
                    if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Drop Off)"))
                        _state = GenericCourierStorylineState.DropOffItem;
                    break;

                case GenericCourierStorylineState.DropOffItem:
                    if (MoveItem(false))
                        return StorylineState.CompleteMission;
                    break;
            }

            return StorylineState.ExecuteMission;
        }
Example #43
0
 /// <summary>
 /// We have no combat/delivery part in this mission, just accept it
 /// </summary>
 /// <returns></returns>
 public StorylineState PostAcceptMission(Storyline storyline)
 {
     // Close the market window (if its open)
     return(StorylineState.CompleteMission);
 }
Example #44
0
        /// <summary>
        ///   Arm does nothing but get into a (assembled) shuttle
        /// </summary>
        /// <returns></returns>
        public StorylineState Arm(Storyline storyline)
        {
            if (_nextAction > DateTime.Now)
            {
                return(StorylineState.Arm);
            }

            // Are we in a shuttle?  Yes, goto the agent
            var    directEve        = Cache.Instance.DirectEve;
            string materialshipName = Settings.Instance.MaterialShipName.ToLower();

            if (directEve.ActiveShip.GroupId == 31 || directEve.ActiveShip.GivenName == materialshipName)
            {
                return(StorylineState.GotoAgent);
            }

            // Open the ship hangar
            var ships = directEve.GetShipHangar();

            if (ships.Window == null)
            {
                _nextAction = DateTime.Now.AddSeconds(10);

                Logging.Log("MaterialsForWarPreparation: Opening ship hangar");

                // No, command it to open
                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenShipHangar);
                return(StorylineState.Arm);
            }

            // If the ship hangar is not ready then wait for it
            if (!ships.IsReady)
            {
                return(StorylineState.Arm);
            }

            var ship = ships.Items.FirstOrDefault(i => i.Quantity == -1 && i.GroupId == 31);

            if (string.IsNullOrEmpty(materialshipName))
            {
                Logging.Log("MaterialsForWarPreparation: Could not find MaterialshipName: " + materialshipName + " in settings!");
            }
            else
            {
                ship = ships.Items.FirstOrDefault(i => i.GivenName.ToLower() == materialshipName);
            }

            if (ship != null)
            {
                Logging.Log("MaterialsForWarPreparation: Switching to ship");

                _nextAction = DateTime.Now.AddSeconds(10);

                ship.ActivateShip();
                return(StorylineState.Arm);
            }
            else
            {
                Logging.Log("MaterialsForWarPreparation: No shuttle found, going in active ship");
                return(StorylineState.GotoAgent);
            }
        }