Example #1
0
        public override bool MeetRequirements()
        {
            /*if (ProgressTracking.Instance.NodeComplete("ReachedSpace"))
             *          {
             *                  return false;
             *          }*/
            RecordsAltitudeProbe recordsAltitude = ProgressTracking.Instance.FindNode("AltitudeRecordProbe") as RecordsAltitudeProbe;

            if (recordsAltitude != null)
            {
                if (targetAltitude > 0.0)
                {
                    if (recordsAltitude.record > targetAltitude)
                    {
                        return(false);
                    }
                }
            }
            if (base.ContractState != State.Active)
            {
                ProbeAltitudeRecord[] currentContracts = ContractSystem.Instance.GetCurrentContracts <ProbeAltitudeRecord>();
                for (int i = 0; i < currentContracts.Length; i++)
                {
                    if (currentContracts[i].TargetAltitude > TargetAltitude)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #2
0
        protected override bool Generate()
        {
            double newTarget = 10000.0;
            RecordsAltitudeProbe recordsAltitude = ProgressTracking.Instance.FindNode("AltitudeRecordProbe") as RecordsAltitudeProbe;

            if (recordsAltitude != null)
            {
                newTarget = recordsAltitude.record;
            }

            /*
             * We really want to make sure the player's next contract isn't goint to
             * be auto-completed by an existing vessel in orbit; however we can't enable
             * this code below until we can screen out asteroids; because of course
             * asteroids are vessels. o_O
             */
            // Trying new code:

            /*if ((object)FlightGlobals.Vessels != null)
             * {
             *  foreach (Vessel v in FlightGlobals.Vessels)
             *  {
             *      if ((object)v.orbit != null && v.orbit.referenceBody == Planetarium.fetch.Home && v.FindPartModulesImplementing<ModuleAsteroid>().Count == 0)
             *          if (newTarget < v.orbit.ApA)
             *              newTarget = v.orbit.ApA;
             *  }
             * }*/

            if (newTarget < 30000.0)
            {
                prestige       = Contract.ContractPrestige.Trivial;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget + 10000.0) / 1000f) * 1000f);
            }
            else if (newTarget < 100000.0)
            {
                prestige       = Contract.ContractPrestige.Significant;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget + 20000.0) / 5000f) * 5000f);
            }
            else
            {
                prestige       = Contract.ContractPrestige.Exceptional;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget * 1.5f) / 10000f) * 10000f);
                if (targetAltitude > (Planetarium.fetch.Home.sphereOfInfluence - Planetarium.fetch.Home.Radius) * 0.9f)
                {
                    return(false);
                }
            }
            AddParameter(new Contracts.Parameters.ProbeAltitudeRecord(targetAltitude), null);
            base.AddKeywordsRequired("Record");
            expiryType   = Contract.DeadlineType.None;
            deadlineType = Contract.DeadlineType.None;
            // RP-0 scale funds by 0.1x
            float reward = Mathf.Floor((float)(Math.Sqrt(Math.Sqrt(targetAltitude))));

            base.SetFunds(reward * 50f, reward * 250f, null);
            base.SetReputation(reward * 2f, null);
            return(true);
        }
Example #3
0
        private void OnProgressNodeAchieved(ProgressNode node)
        {
            RecordsAltitudeProbe recordsAltitude = node as RecordsAltitudeProbe;

            if (recordsAltitude != null)
            {
                if (recordsAltitude.record >= targetAltitude)
                {
                    base.SetComplete();
                }
            }
        }
Example #4
0
        protected override bool Generate()
        {
            double newTarget = 10000.0;
            RecordsAltitudeProbe recordsAltitude = ProgressTracking.Instance.FindNode("AltitudeRecordProbe") as RecordsAltitudeProbe;

            if (recordsAltitude != null)
            {
                newTarget = recordsAltitude.record;
            }
            if ((object)FlightGlobals.Vessels != null)
            {
                foreach (Vessel v in FlightGlobals.Vessels)
                {
                    if ((object)v.orbit != null)
                    {
                        if (newTarget < v.orbit.ApA)
                        {
                            newTarget = v.orbit.ApA;
                        }
                    }
                }
            }
            if (newTarget < 30000.0)
            {
                prestige       = Contract.ContractPrestige.Trivial;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget + 10000.0) / 1000f) * 1000f);
            }
            else if (newTarget < 100000.0)
            {
                prestige       = Contract.ContractPrestige.Significant;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget + 20000.0) / 5000f) * 5000f);
            }
            else
            {
                prestige       = Contract.ContractPrestige.Exceptional;
                targetAltitude = (double)(Mathf.Ceil((float)(newTarget * 1.5f) / 10000f) * 10000f);
                if (newTarget > (Planetarium.fetch.Home.sphereOfInfluence - Planetarium.fetch.Home.Radius) * 0.9f)
                {
                    return(false);
                }
            }
            AddParameter(new Contracts.Parameters.ProbeAltitudeRecord(targetAltitude), null);
            base.AddKeywordsRequired("Record");
            expiryType   = Contract.DeadlineType.None;
            deadlineType = Contract.DeadlineType.None;
            // RP-0 scale funds by 0.1x
            float reward = Mathf.Floor((float)(Math.Sqrt(Math.Sqrt(targetAltitude))));

            base.SetFunds(reward * 50f, reward * 250f, null);
            base.SetReputation(reward * 2f, null);
            return(true);
        }