示例#1
0
        private void CloseEveWindows()
        {
            var methodName = "CloseEveWindows";

            LogTrace(methodName);

            //First check for any "MessageBox" template windows
            using (var infoWindow = _eveWindowProvider.GetWindowByName("MessageBox"))
            {
                if (infoWindow.IsValid)
                {
                    infoWindow.Close();
                }
            }

            using (var modalWindow = _eveWindowProvider.GetWindowByName("modal"))
            {
                if (modalWindow.IsValid)
                {
                    //If it's a mission warning, click 'yes'
                    if (modalWindow.Text.StartsWith("This mission involves objectives requiring a total capacity of ",
                                                    StringComparison.InvariantCultureIgnoreCase))
                    {
                        modalWindow.ClickButtonYes();
                    }
                    //Fleet invitations are message boxes. Close it if we're not currently invited to a fleet
                    else if (!StealthBot.MeCache.Me.Fleet.Invited || StealthBot.MeCache.Me.Fleet.InvitationText == "NULL")
                    {
                        modalWindow.ClickButtonClose();
                    }
                }
            }
        }
示例#2
0
        protected override void ProcessPulseState()
        {
            var methodName = "ProcessPulseState";

            LogTrace(methodName);

            switch (_missionRunnerState)
            {
            //Update the mission cache:
            case MissionRunnerStates.UpdateMissionCache:
                //Initially shut the journal. Needs to be opened by ISXEVE or funky shit happens.
                if (!_startupJournalShut)
                {
                    _startupJournalShut = true;
                    using (var journalWindow = _eveWindowProvider.GetWindowByName(WINDOWNAME_JOURNAL))
                    {
                        if (!LavishScriptObject.IsNullOrInvalid(journalWindow))
                        {
                            journalWindow.Close();
                            return;
                        }
                    }
                }

                if (Core.StealthBot.MissionCache.UpdateCache(0, true))
                {
                    _missionRunnerState = MissionRunnerStates.SelectAgent;
                }
                break;

            //Pick an agent to use
            case MissionRunnerStates.SelectAgent:
                if (_hasMaxRuntimeExpired)
                {
                    return;
                }

                //If downtime is near, don't select an agent. Instead, pause.
                if (Core.StealthBot.MeCache.IsDowntimeNear)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "We're getting close to standard EVE downtime and are pausing missioning.");
                    IsEnabled = false;
                    return;
                }

                //Set the active agent
                SelectAgent();

                //If we didn't get an agent, return.
                if (SelectedAgent == null)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "There are currently no agents available. We're waiting 5 minutes before checking again.");
                    DelayNextPulseBySeconds(300);
                    return;
                }

                //See if we have a matching, accepted mission
                var cachedMission = Core.StealthBot.MissionCache.GetCachedMissionForAgentId(SelectedAgent.Id);
                if (cachedMission != null && cachedMission.State == (int)MissionStates.Accepted)
                {
                    //Set it active.
                    ActiveMission = cachedMission;

                    //Go to the MoveToStart state.
                    _missionRunnerState = MissionRunnerStates.RunMission;
                    goto case MissionRunnerStates.RunMission;
                }

                //No cached mission returned or it wasn't accepted, means we need to go get a mission.
                _missionRunnerState = MissionRunnerStates.MoveToAgent;
                goto case MissionRunnerStates.MoveToAgent;

            case MissionRunnerStates.MoveToAgent:
                //If I'm at the agent, go to MissionStart.
                if (Core.StealthBot.MeCache.SolarSystemId == SelectedAgent.SolarSystemId &&
                    Core.StealthBot.MeCache.InStation && Core.StealthBot.MeCache.StationId == SelectedAgent.StationId)
                {
                    _missionRunnerState = MissionRunnerStates.GetMissionFromAgent;
                    goto case MissionRunnerStates.GetMissionFromAgent;
                }

                if (Core.StealthBot.MeCache.InStation && Core.StealthBot.MeCache.StationId != SelectedAgent.StationId)
                {
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.Undock));
                }

                //If I'm not in the same system, first move there
                if (Core.StealthBot.MeCache.SolarSystemId != SelectedAgent.SolarSystemId)
                {
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.SolarSystem, SelectedAgent.SolarSystemId));
                }
                else if (!Core.StealthBot.MeCache.InStation)
                {
                    //Try to find a matching entitywrapper
                    var stationEntity = Core.StealthBot.EntityProvider.EntityWrappers.FirstOrDefault(
                        entityWrapper => entityWrapper.Name == SelectedAgent.Station);

                    //This will satisfy the conditions of the outer If check, thus it'll hit after dock.
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.Entity, stationEntity.ID)
                    {
                        Distance = 200, Dock = true
                    });
                }
                break;

            case MissionRunnerStates.GetMissionFromAgent:
                switch (_getMissionState)
                {
                case GetMissionStates.Idle:
                    _getMissionState = GetMissionStates.GetMission;
                    goto case GetMissionStates.GetMission;

                case GetMissionStates.GetMission:
                    GetMissionFromAgent();
                    break;

                case GetMissionStates.CheckLoadout:
                    var npcResistanceProfiles = Core.StealthBot.MissionDatabase.GetNpcResistanceProfiles(ActiveMission);
                    var doneRearming          = Core.StealthBot.Ship.RearmShip(npcResistanceProfiles);

                    if (doneRearming)
                    {
                        _getMissionState    = GetMissionStates.Idle;
                        _missionRunnerState = MissionRunnerStates.RunMission;
                    }
                    break;
                }
                break;

            case MissionRunnerStates.RunMission:
                if (_duringMissionRandomWaitObject.ShouldWait())
                {
                    return;
                }

                RunMission();
                break;

            case MissionRunnerStates.TurnInMission:
                if (_betweenMissionsRandomWaitObject.ShouldWait())
                {
                    return;
                }

                TurnInMission();
                break;
            }
        }
示例#3
0
        public override void Pulse()
        {
            var methodName = "Pulse";

            LogTrace(methodName);

            if (!ShouldPulse())
            {
                return;
            }

            if (LavishScriptObject.IsNullOrInvalid(Me))
            {
                return;
            }

            StartPulseProfiling();

            EveTime = new EVETime();

            GameHour           = GetGameHour();
            GameMinute         = GetGameMinute();
            IsDowntimeNear     = GetIsDowntimeNear();
            IsDowntimeImminent = GetIsDowntimeImminent();

            WalletBalance = Me.Wallet.Balance;

            //StartMethodProfiling("Name");
            Name           = Me.Name;
            IsFleetInvited = Me.Fleet.Invited;
            //EndMethodProfiling();

            //StartMethodProfiling("Fleet");
            if (Me.Fleet.ID > -1)
            {
                var fleetMembers = Me.Fleet.GetMembers();
                if (fleetMembers != null)
                {
                    foreach (var fleetMember in
                             fleetMembers.Where(fleetMember => !_fleetMembersById.ContainsKey(fleetMember.CharID)))
                    {
                        _fleetMembersById.Add(fleetMember.CharID, fleetMember);
                        _fleetMembers.Add(fleetMember);
                    }
                    fleetMembers.Clear();
                }
                else
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "Me.Fleet.GetMembers returned a null list.");
                }
            }
            //EndMethodProfiling();

            //StartMethodProfiling("Corp");
            var corp = Me.Corp;

            if (corp.ID >= 0)
            {
                if (corp.ID != CorporationId)
                {
                    if (StealthBot.CorporationCache.IsInitialized)
                    {
                        if (StealthBot.CorporationCache.CachedCorporationsById.ContainsKey(corp.ID))
                        {
                            var corporation = StealthBot.CorporationCache.CachedCorporationsById[corp.ID];
                            Corporation       = corporation.Name;
                            CorporationTicker = corporation.Ticker;
                            CorporationId     = corp.ID;
                        }
                        else
                        {
                            StealthBot.CorporationCache.GetCorporationInfo(corp.ID);
                        }
                    }
                }
            }
            else
            {
                CorporationId     = -1;
                Corporation       = String.Empty;
                CorporationTicker = String.Empty;
            }
            //EndMethodProfiling();

            //StartMethodProfiling("Alliance");
            if (Me.AllianceID >= 0)
            {
                if (Me.AllianceID != AllianceId)
                {
                    if (StealthBot.AllianceCache.IsInitialized)
                    {
                        if (StealthBot.AllianceCache.CachedAlliancesById.ContainsKey(Me.AllianceID))
                        {
                            var alliance = StealthBot.AllianceCache.CachedAlliancesById[Me.AllianceID];
                            Alliance       = alliance.Name;
                            AllianceTicker = alliance.Ticker;
                            AllianceId     = Me.AllianceID;
                        }
                        else
                        {
                            StealthBot.AllianceCache.RegenerateAllianceDatabase();
                        }
                    }
                }
            }
            else
            {
                AllianceId     = -1;
                Alliance       = String.Empty;
                AllianceTicker = String.Empty;
            }
            //EndMethodProfiling();

            //StartMethodProfiling("Drones");
            ShipId               = Me.ShipID;
            CharId               = Me.CharID;
            MaxLockedTargets     = Me.MaxLockedTargets;
            MaxActiveDrones      = Me.MaxActiveDrones;
            DroneControlDistance = Me.DroneControlDistance;
            //EndMethodProfiling();

            //StartMethodProfiling("Buddies");
            using (var addressBookWindow = _eveWindowProvider.GetWindowByName("addressbook"))
            {
                if (_buddyListOpened && !_buddyListClosed && addressBookWindow.IsValid)
                {
                    addressBookWindow.Close();
                    _buddyListClosed = true;
                }
            }
            if (!_buddyListOpened)
            {
                _buddyListOpened = true;
                _isxeveProvider.Eve.Execute(ExecuteCommand.OpenPeopleAndPlaces);
                _isxeveProvider.Eve.RefreshBookmarks();
            }

            if (_buddyListOpened && _buddyListClosed)
            {
                var buddies = _isxeveProvider.Eve.GetBuddies();

                if (buddies == null)
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "EVE.GetBuddies returned a null list.");
                }
                else
                {
                    _buddies.AddRange(buddies);
                }
            }

            var agentMissions = _isxeveProvider.Eve.GetAgentMissions();

            if (agentMissions == null)
            {
                LogMessage(methodName, LogSeverityTypes.Debug, "EVE.GetAgentMissions returned a null list.");
            }
            else
            {
                _agentMissions.AddRange(agentMissions);
            }

            //EndMethodProfiling();
            if (!InStation && InSpace)
            {
                var activeDrones = Me.GetActiveDrones();

                if (activeDrones == null)
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "Me.GetActiveDrones returned a null list.");
                }
                else
                {
                    _activeDrones.AddRange(activeDrones);
                }

                //Pulse the entitypopulator
                StartMethodProfiling("EntityPopulator.Pulse");
                try
                {
                    StealthBot.EntityProvider.Pulse();
                }
                catch (Exception e)
                {
                    LogException(e, "EntityPopulator Pulse", "Caught exception while pulsing EntityPopulator:");
                    return;
                }
                EndMethodProfiling();

                //StartMethodProfiling("BuildTargets");
                foreach (var entity in StealthBot.EntityProvider.EntityWrappers)
                {
                    if (entity.IsLockedTarget)
                    {
                        _targets.Add(entity);
                    }
                    if (entity.IsTargetingMe)
                    {
                        _targetedBy.Add(entity);
                    }
                }
                //EndMethodProfiling();

                //StartMethodProfiling("GetActiveTarget");
                if (!LavishScriptObject.IsNullOrInvalid(Me.ActiveTarget))
                {
                    ActiveTargetId = Me.ActiveTarget.ID;
                    ActiveTarget   = Targets.FirstOrDefault(entity => entity.ID == ActiveTargetId);
                }
                else
                {
                    ActiveTargetId = -1;
                    ActiveTarget   = null;
                }
                //EndMethodProfiling();

                //Get Attackers
                var attackers = Me.GetAttackers();
                if (attackers != null)
                {
                    foreach (var attacker in attackers)
                    {
                        //F*****g ISXEVE unable to determine if something's valid or not.
                        //Keeps returning invalid attackers with invalid entities.
                        //F**k. Can't ever just have something in that library *work right*
                        if (LavishScriptObject.IsNullOrInvalid(attacker))
                        {
                            continue;
                        }

                        var entityId = attacker.ID;

                        //Check for invalidity again, just to be f*****g sure.
                        //F*****g ISXEVE.
                        if (entityId == -1)
                        {
                            continue;
                        }

                        //Here, another validity check. Make sure we recognize the entity it's
                        //saying is the originator.
                        //if (!StealthBot.EntityPopulator.EntityWrappersByID.ContainsKey(entityID))
                        //{
                        //continue;
                        //}

                        if (_attackersById.ContainsKey(entityId))
                        {
                            continue;
                        }

                        _attackersById.Add(entityId, attacker);
                        _attackers.Add(attacker);
                    }
                    attackers.Clear();
                }
            }

            if (InStation && !InSpace && Me.StationID > 0)
            {
                if (StealthBot.Ship.IsInventoryOpen && StealthBot.Ship.IsInventoryReady)
                {
                    var hangarItems = Me.GetHangarItems();
                    if (hangarItems == null)
                    {
                        LogMessage(methodName, LogSeverityTypes.Debug, "Me.GetHangarItems() returned a null list.");
                    }
                    else
                    {
                        _hangarItems.AddRange(hangarItems);
                    }

                    var hangarShips = Me.GetHangarShips();
                    if (hangarShips == null)
                    {
                        LogMessage(methodName, LogSeverityTypes.Debug, "Me.GetHangarShips() returned a null list.");
                    }
                    else
                    {
                        _hangarShips.AddRange(hangarShips);
                    }
                }
            }

            EndPulseProfiling();
        }