Пример #1
0
        private void buttonAuto_MouseDown(object sender, MouseEventArgs e)
        {
            pilot.state ^= PilotJumper.PilotState.Enabled;

            if (pilot.state.HasFlag(PilotJumper.PilotState.Enabled))
            {
                Sounds.Play("autopilot engaged.mp3");
            }

            keyboard.Clear();
            pilot.Reset(soft: false);

            Focusize();

            lastClick = DateTime.UtcNow;
        }
Пример #2
0
        /// <summary>
        /// This handles cruising behaviour. The main function is already keeping us aligned;
        /// we just need to drop to 75% speed.
        /// This function could also do the final part:
        ///  1. press G when the "SAFE DISENGAGE" graphic is detected
        ///  2. Wait 5 seconds
        ///  3. Press Tab, X, 1,E,E,Space,S,Space to boost, cut throttle, and request docking (so the docking computer takes over).
        /// </summary>
        private void Cruise()
        {
            if (SecondsSinceFaceplant > 20 && OncePerJump(PilotState.cruiseStart))
            {
                Sounds.Play("cruise mode engaged.mp3");
                keyboard.Tap(keyThrottle100);      // full throttle
                keyboard.Tap(keyThrottleReduce25); // drop 25% throttle, to 75%
            }

            if (!state.HasFlag(PilotState.CruiseEnd) && cruiseSensor.MatchSafDisengag())
            {
                keyboard.Tap(keyHyperspace); // "Safe Disengage"
                state |= PilotState.DisengageStarted;
                return;
            }

            // disengage can take a while so wait for it to finish before continuing
            if (!state.HasFlag(PilotState.CruiseEnd) &&
                state.HasFlag(PilotState.DisengageStarted) &&
                !cruiseSensor.MatchSafDisengag())
            {
                state |= PilotState.CruiseEnd;
                state &= ~PilotState.Enabled;                                   // disable! we've arrived!
                // these commands will initiate docking if we have a computer
                Task.Delay(1000).ContinueWith(t => keyboard.Tap(keyBoost));     // boost
                Task.Delay(5000).ContinueWith(t => keyboard.Tap(keyThrottle0)); // cut throttle
                Task.Delay(8000).ContinueWith(t =>                              // request docking
                {
                    if (!state.HasFlag(PilotState.Cruise))
                    {
                        return; // abort docking request if cruise gets turned off
                    }
                    Sounds.PlayOneOf("time to dock.mp3", "its dock oclock.mp3", "autopilot disengaged.mp3");
                    keyboard.TapWait(keyNavMenu);      // nav menu
                    keyboard.TapWait(keyMenuTabRight); // tab right
                    keyboard.Tap(keyMenuTabRight);     // tab right
                    keyboard.Tap(keySelect);           // select first contact (the station)
                    keyboard.Tap(keyDown);             // down to the second option (request docking)
                    keyboard.Tap(keySelect);           // select request docking
                    keyboard.Tap(keyNavMenu);          // close nav menu

                    state &= ~PilotState.Cruise;       // disable! we've arrived!
                });
            }
        }
Пример #3
0
        /// <summary>
        /// Fly close past the star
        /// </summary>
        private void Scoop()
        {
            int scoopWaitSeconds   = Properties.Settings.Default.scoopWaitSeconds;
            int scoopFinishSeconds = Properties.Settings.Default.scoopFinishSeconds;

            //RIP-- WIP, I guess
            if (cruiseSensor.EmergencyDrop())
            {
                keyboard.Tap(keyThrottle0);
                state &= ~PilotState.Enabled; // disable! we're f****d!
                Sounds.Play("oh f**k.mp3");
                return;
            }

            // if we try to select the star earlier than this, sometimes it selects the wrong thing
            if (SecondsSinceFaceplant < 2)
            {
                return;
            }

            // roll so that the star is below (makes pitch up quicker -- less likely to collide in slow ships)
            if (OncePerJump(PilotState.SelectStar))
            {
                if (!SelectStar())
                {
                    keyboard.TapWait(keyThrottle0);
                    state &= ~PilotState.Enabled; // disable! we're f****d!
                    keyboard.TapWait(keySuperCruise);
                    Sounds.Play("oh f**k.mp3");
                    return;
                }
            }
            AlignCompass(bPitchYaw: false);

            //Set a value to confirm that we've actually started scooping
            if (OncePerJump(PilotState.ScoopStart))
            {
                keyboard.Tap(keyThrottle50); // 50% throttle
            }
            // (barely) avoid crashing into the star
            bool collisionImminent = cruiseSensor.MatchImpact() || compassRecognizer.MatchFaceplant();

            keyboard.SetKeyState(keyPitchUp, collisionImminent);

            // start speeding up towards the end so we don't crash/overheat
            // Keep the scoopwaitseconds as a "general idea" of when to start pulling up, at least until maybe a check for "full tank"
            if (SecondsSinceFaceplant > scoopWaitSeconds && OncePerJump(PilotState.ScoopMiddle))
            {
                keyboard.Tap(keyThrottle100);
            }

            //If the fueling is complete, we probably want to GTFO
            if (cruiseSensor.FuelComplete())
            {
                if (OncePerJump(PilotState.ScoopMiddle))
                {
                    keyboard.Tap(keyThrottle100);
                }
            }


            //If we've passed the expected wait point and the Scoop Active display is gone, flag appropriately and wait for scoopFinishSeconds to pass
            if (state.HasFlag(PilotState.ScoopMiddle) && !state.HasFlag(PilotState.ScoopDeactive) && !cruiseSensor.MatchScooping())
            {
                SecondsUntilScoopComplete = SecondsSinceFaceplant + scoopFinishSeconds;
                Console.WriteLine(string.Format("Match scooping is not true at {0}", SecondsSinceFaceplant));
                OncePerJump(PilotState.ScoopDeactive);
                status += string.Format("Finalizing scoop + {0:0.0}\n", SecondsSinceFaceplant);


                //We're far enough away from the scoop range for heat to be a non-issue
            }
            else if (state.HasFlag(PilotState.ScoopDeactive) && SecondsSinceFaceplant > SecondsUntilScoopComplete)
            {
                state  |= PilotState.scoopComplete;
                status += string.Format("Finalizing scoop + {0:0.0}\n", SecondsSinceFaceplant);
            }
            else
            {
                status += string.Format("Scoop wait + {0:0.0}\n", SecondsSinceFaceplant);
            }
        }