Example #1
0
        //Used for initial orbital and surface survey parameter
        internal static DMCollectScience fetchSurveyScience(Contract.ContractPrestige c, List <CelestialBody> cR, List <CelestialBody> cUR, DMScienceContainer DMScience)
        {
            CelestialBody        body;
            ExperimentSituations targetSituation;
            ScienceSubject       sub;
            string name;
            string biome = "";

            if (!DMUtils.availableScience.ContainsKey("All"))
            {
                return(null);
            }

            name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key;

            //Determine if the science part is available if applicable
            if (DMScience.SciPart != "None")
            {
                if (!DMUtils.partAvailable(new List <string>(1)
                {
                    DMScience.SciPart
                }))
                {
                    return(null);
                }
            }

            List <CelestialBody>       bodies = new List <CelestialBody>();
            Func <CelestialBody, bool> cb     = null;

            switch (c)
            {
            case Contract.ContractPrestige.Trivial:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }

                    if (b.scienceValues.RecoveryValue > 4)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb));
                break;

            case Contract.ContractPrestige.Significant:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }

                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }

                    if (b.scienceValues.RecoveryValue > 8)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb));
                break;

            case Contract.ContractPrestige.Exceptional:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }

                    if (Planetarium.fetch.Home.orbitingBodies.Count > 0)
                    {
                        foreach (CelestialBody B in Planetarium.fetch.Home.orbitingBodies)
                        {
                            if (b == B)
                            {
                                return(false);
                            }
                        }
                    }

                    if (b.scienceValues.RecoveryValue < 4)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(4, cb));
                break;
            }

            if (bodies.Count <= 0)
            {
                return(null);
            }

            body = bodies[rand.Next(0, bodies.Count)];

            if (body == null)
            {
                return(null);
            }

            //Make sure our experiment is OK
            if (DMScience.Exp == null)
            {
                return(null);
            }

            if (!body.atmosphere && DMScience.Exp.requireAtmosphere)
            {
                return(null);
            }
            if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh && ((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow)
            {
                if (rand.Next(0, 2) == 0)
                {
                    targetSituation = ExperimentSituations.InSpaceHigh;
                }
                else
                {
                    targetSituation = ExperimentSituations.InSpaceLow;
                }
            }
            else if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh)
            {
                targetSituation = ExperimentSituations.InSpaceHigh;
            }
            else
            {
                targetSituation = ExperimentSituations.InSpaceLow;
            }

            if (DMUtils.biomeRelevant(targetSituation, (int)DMScience.Exp.biomeMask) && targetSituation != ExperimentSituations.SrfSplashed)
            {
                List <string> bList = DMUtils.fetchBiome(body, DMScience.Exp, targetSituation);
                if (bList.Count == 0)
                {
                    return(null);
                }
                else
                {
                    biome = bList[rand.Next(0, bList.Count)];
                }
            }

            //Make sure that our chosen science subject has science remaining to be gathered
            string subId = string.Format("{0}@{1}{2}{3}", DMScience.Exp.id, body.bodyName, targetSituation, biome.Replace(" ", ""));

            if (ResearchAndDevelopment.GetSubjects().Any(s => s.id == subId))
            {
                sub = ResearchAndDevelopment.GetSubjectByID(subId);
                if (sub.scientificValue < 0.5f)
                {
                    return(null);
                }
            }

            return(new DMCollectScience(body, targetSituation, "", name, 0));
        }
Example #2
0
        protected override bool Generate()
        {
            DMMagneticSurveyContract[] magContracts = ContractSystem.Instance.GetCurrentContracts <DMMagneticSurveyContract>();
            int offers    = 0;
            int active    = 0;
            int maxOffers = DMContractDefs.DMMagnetic.maxOffers;
            int maxActive = DMContractDefs.DMMagnetic.maxActive;

            for (int i = 0; i < magContracts.Length; i++)
            {
                DMMagneticSurveyContract m = magContracts[i];
                if (m.ContractState == State.Offered)
                {
                    offers++;
                }
                else if (m.ContractState == State.Active)
                {
                    active++;
                }
            }

            if (offers >= maxOffers)
            {
                return(false);
            }
            if (active >= maxActive)
            {
                return(false);
            }

            //Make sure that the parts are available
            if (!DMUtils.partAvailable(DMContractDefs.DMMagnetic.magParts) || !DMUtils.partAvailable(DMContractDefs.DMMagnetic.rpwsParts))
            {
                return(false);
            }

            List <CelestialBody>       bodies = new List <CelestialBody>();
            Func <CelestialBody, bool> cb     = null;

            switch (prestige)
            {
            case ContractPrestige.Trivial:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }

                    if (b.scienceValues.RecoveryValue > 4)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb));
                break;

            case ContractPrestige.Significant:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }

                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }

                    if (b.scienceValues.RecoveryValue > 8)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb));
                break;

            case ContractPrestige.Exceptional:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }

                    if (Planetarium.fetch.Home.orbitingBodies.Count > 0)
                    {
                        foreach (CelestialBody B in Planetarium.fetch.Home.orbitingBodies)
                        {
                            if (b == B)
                            {
                                return(false);
                            }
                        }
                    }

                    if (b.scienceValues.RecoveryValue < 4)
                    {
                        return(false);
                    }

                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(4, cb));
                break;
            }

            if (bodies.Count <= 0)
            {
                return(false);
            }

            body = bodies[rand.Next(0, bodies.Count)];

            if (body == null)
            {
                return(false);
            }

            DMScienceContainer magContainer  = null;
            DMScienceContainer rpwsContainer = null;

            if (!DMUtils.availableScience.ContainsKey("All"))
            {
                return(false);
            }

            if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMMagnetic.magnetometerExperimentTitle))
            {
                return(false);
            }

            magContainer = DMUtils.availableScience["All"][DMContractDefs.DMMagnetic.magnetometerExperimentTitle];

            if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMMagnetic.rpwsExperimentTitle))
            {
                return(false);
            }

            rpwsContainer = DMUtils.availableScience["All"][DMContractDefs.DMMagnetic.rpwsExperimentTitle];

            magParams[0] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, magContainer);
            magParams[1] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceHigh, magContainer);
            magParams[2] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, rpwsContainer);
            magParams[3] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceHigh, rpwsContainer);

            double eccMod  = 0.2;
            double incMod  = 20;
            double timeMod = 2160000;

            switch (prestige)
            {
            case ContractPrestige.Trivial:
                eccMod  = DMContractDefs.DMMagnetic.trivialEccentricityMultiplier;
                incMod  = DMContractDefs.DMMagnetic.trivialInclinationMultiplier;
                timeMod = DMContractDefs.DMMagnetic.trivialTimeModifier * 6 * 3600;
                break;

            case ContractPrestige.Significant:
                eccMod  = DMContractDefs.DMMagnetic.significantEccentricityMultiplier;
                incMod  = DMContractDefs.DMMagnetic.significantInclinationMultiplier;
                timeMod = DMContractDefs.DMMagnetic.significantTimeModifier * 6 * 3600;
                break;

            case ContractPrestige.Exceptional:
                eccMod  = DMContractDefs.DMMagnetic.exceptionalEccentricityMultiplier;
                incMod  = DMContractDefs.DMMagnetic.exceptionalInclinationMultiplier;
                timeMod = DMContractDefs.DMMagnetic.exceptionalTimeModifier * 6 * 3600;
                break;
            }

            double time  = timeMod * ((double)rand.Next(6, 17) / 10d);
            double eccen = eccMod * ((double)rand.Next(8, 13) / 10d);

            if (eccen > 0.7)
            {
                eccen = 0.7;
            }
            double inclination = incMod * ((double)rand.Next(7, 14) / 10d);

            if (inclination > 75)
            {
                inclination = 75;
            }

            DictionaryValueList <int, List <string> > parts = new DictionaryValueList <int, List <string> >();

            parts.Add(0, DMContractDefs.DMMagnetic.magParts);
            parts.Add(1, DMContractDefs.DMMagnetic.rpwsParts);

            DMLongOrbitParameter   longParam      = new DMLongOrbitParameter(time);
            DMOrbitalParameters    eccentricParam = new DMOrbitalParameters(eccen, 0, longParam);
            DMOrbitalParameters    inclinedParam  = new DMOrbitalParameters(inclination, 1, longParam);
            DMPartRequestParameter partRequest    = new DMPartRequestParameter(parts, DMContractDefs.DMMagnetic.useVesselWaypoints, body);

            this.AddParameter(longParam);
            longParam.AddParameter(eccentricParam);
            longParam.AddParameter(inclinedParam);
            longParam.AddParameter(partRequest);

            longParam.setPartRequest(partRequest);

            if (eccentricParam == null || inclinedParam == null)
            {
                return(false);
            }

            //Add the science collection parent parameter
            DMCompleteParameter DMcp = new DMCompleteParameter(1, 0);

            this.AddParameter(DMcp);

            foreach (DMCollectScience DMCS in magParams)
            {
                if (DMCS == null)
                {
                    return(false);
                }
                else
                {
                    if (DMCS.Container == null)
                    {
                        continue;
                    }

                    float modifier = ((float)rand.Next(85, 116) / 100f);
                    DMcp.addToSubParams(DMCS);
                    DMCS.SetFunds(DMContractDefs.DMMagnetic.Funds.ParamReward * modifier, DMContractDefs.DMMagnetic.Funds.ParamFailure * modifier, body);
                    DMCS.SetScience(DMContractDefs.DMMagnetic.Science.ParamReward * DMUtils.fixSubjectVal(DMCS.Situation, 1f, body), null);
                    DMCS.SetReputation(DMContractDefs.DMMagnetic.Reputation.ParamReward * modifier, DMContractDefs.DMMagnetic.Reputation.ParamFailure * modifier, null);
                }
            }

            if (this.ParameterCount == 0)
            {
                return(false);
            }

            float primaryModifier = ((float)rand.Next(80, 121) / 100f);
            float diffModifier    = 1 + ((float)this.Prestige * 0.5f);

            float Mod = primaryModifier * diffModifier;

            this.agent = AgentList.Instance.GetAgent("DMagic");

            if (this.agent == null)
            {
                this.agent = AgentList.Instance.GetAgentRandom();
            }

            base.SetExpiry(DMContractDefs.DMMagnetic.Expire.MinimumExpireDays, DMContractDefs.DMMagnetic.Expire.MaximumExpireDays);
            base.SetDeadlineDays((float)(time / 3600) * DMContractDefs.DMMagnetic.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.8f) * primaryModifier, null);
            base.SetReputation(DMContractDefs.DMMagnetic.Reputation.BaseReward * Mod, DMContractDefs.DMMagnetic.Reputation.BaseFailure * Mod, null);
            base.SetFunds(DMContractDefs.DMMagnetic.Funds.BaseAdvance * Mod, DMContractDefs.DMMagnetic.Funds.BaseReward * Mod, DMContractDefs.DMMagnetic.Funds.BaseFailure * Mod, body);
            base.SetScience(DMContractDefs.DMMagnetic.Science.BaseReward * Mod, body);
            return(true);
        }
        protected override bool Generate()
        {
            DMReconContract[] reconContracts = ContractSystem.Instance.GetCurrentContracts <DMReconContract>();
            int offers    = 0;
            int active    = 0;
            int maxOffers = DMContractDefs.DMRecon.maxOffers;
            int maxActive = DMContractDefs.DMRecon.maxActive;

            for (int i = 0; i < reconContracts.Length; i++)
            {
                DMReconContract r = reconContracts[i];
                if (r.ContractState == State.Offered)
                {
                    offers++;
                }
                else if (r.ContractState == State.Active)
                {
                    active++;
                }
            }

            if (offers >= maxOffers)
            {
                return(false);
            }
            if (active >= maxActive)
            {
                return(false);
            }

            List <CelestialBody> customReachedBodies = new List <CelestialBody>();

            switch (prestige)
            {
            case ContractPrestige.Trivial:
                Func <CelestialBody, bool> cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }

                    if (b.pqsController == null)
                    {
                        return(false);
                    }

                    return(true);
                };
                customReachedBodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb));
                customReachedBodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb));
                var activeBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => activeBodies.Contains(a));
                var completedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => completedBodies.Contains(a));
                break;

            case ContractPrestige.Significant:
                customReachedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Trivial).Select(r => r.body).ToList();
                var activeSigBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => activeSigBodies.Contains(a));
                var completedSigBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => completedSigBodies.Contains(a));
                break;

            case ContractPrestige.Exceptional:
                customReachedBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Significant).Select(r => r.body).ToList();
                var activeExcBodies = ContractSystem.Instance.GetCurrentActiveContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Exceptional).Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => activeExcBodies.Contains(a));
                var completedExcBodies = ContractSystem.Instance.GetCompletedContracts <DMReconContract>().Where(r => r.prestige == ContractPrestige.Exceptional).Select(r => r.body).ToList();
                customReachedBodies.RemoveAll(a => completedExcBodies.Contains(a));
                break;
            }

            if (customReachedBodies.Count <= 0)
            {
                return(false);
            }

            body = customReachedBodies[rand.Next(0, customReachedBodies.Count)];

            if (body == null)
            {
                return(false);
            }

            double time = 0;

            OrbitType orbitType = OrbitType.POLAR;

            Dictionary <int, List <string> > parts = new Dictionary <int, List <string> >();
            Orbit o = new Orbit();

            double incMod  = (rand.NextDouble() * 10) - 5;
            double timeMod = 1080000;

            if (!DMUtils.availableScience.ContainsKey("All"))
            {
                return(false);
            }

            DMScienceContainer container = null;

            switch (prestige)
            {
            case ContractPrestige.Trivial:
                if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconTrivialParts))
                {
                    return(false);
                }

                parts.Add(0, DMContractDefs.DMRecon.reconTrivialParts);

                if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.trivialExperimentTitle))
                {
                    return(false);
                }

                container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.trivialExperimentTitle];

                o = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.15, ContractDefs.Satellite.TrivialInclinationDifficulty);

                double st = o.semiMajorAxis - o.referenceBody.Radius;

                double mt = o.referenceBody.scienceValues.spaceAltitudeThreshold * 5 * .95;

                if (st > mt)
                {
                    o.semiMajorAxis = (mt * Math.Max(0.4, rand.NextDouble())) + o.referenceBody.Radius;
                }

                timeMod = DMContractDefs.DMRecon.trivialTimeModifier * 6 * 3600;
                break;

            case ContractPrestige.Significant:
                if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconSignificantParts))
                {
                    return(false);
                }

                parts.Add(0, DMContractDefs.DMRecon.reconSignificantParts);

                if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.significantExperimentTitle))
                {
                    return(false);
                }

                container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.significantExperimentTitle];

                if (SystemUtilities.CoinFlip(rand))
                {
                    if (CelestialUtilities.CanBodyBeKolniya(body))
                    {
                        orbitType = OrbitType.KOLNIYA;
                    }
                    else if (CelestialUtilities.CanBodyBeTundra(body))
                    {
                        orbitType = OrbitType.TUNDRA;
                    }
                    else
                    {
                        orbitType = OrbitType.POLAR;
                    }
                }
                else
                {
                    if (CelestialUtilities.CanBodyBeTundra(body))
                    {
                        orbitType = OrbitType.TUNDRA;
                    }
                    else if (CelestialUtilities.CanBodyBeKolniya(body))
                    {
                        orbitType = OrbitType.KOLNIYA;
                    }
                    else
                    {
                        orbitType = OrbitType.POLAR;
                    }
                }
                o       = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.5, ContractDefs.Satellite.TrivialInclinationDifficulty);
                timeMod = DMContractDefs.DMRecon.significantTimeModifier * 6 * 3600;
                incMod  = 0;
                break;

            case ContractPrestige.Exceptional:
                if (!DMUtils.partAvailable(DMContractDefs.DMRecon.reconExceptionalParts))
                {
                    return(false);
                }

                parts.Add(0, DMContractDefs.DMRecon.reconExceptionalParts);

                if (!DMUtils.availableScience["All"].ContainsKey(DMContractDefs.DMRecon.exceptionalExperimentTitle))
                {
                    return(false);
                }

                container = DMUtils.availableScience["All"][DMContractDefs.DMRecon.exceptionalExperimentTitle];

                o = CelestialUtilities.GenerateOrbit(orbitType, this.MissionSeed, body, 0.15, ContractDefs.Satellite.TrivialInclinationDifficulty);

                double se = o.semiMajorAxis - o.referenceBody.Radius;

                double me = o.referenceBody.scienceValues.spaceAltitudeThreshold * 5 * .95;

                if (se > me)
                {
                    o.semiMajorAxis = (me * Math.Max(0.4, rand.NextDouble())) + o.referenceBody.Radius;
                }

                timeMod = DMContractDefs.DMRecon.exceptionalTimeModifier * 6 * 3600;
                break;
            }

            if (container == null)
            {
                return(false);
            }

            time           = timeMod * ((double)rand.Next(6, 17) / 10d);
            o.inclination += incMod;

            DMLongOrbitParameter     longOrbit   = new DMLongOrbitParameter(time);
            DMPartRequestParameter   partRequest = new DMPartRequestParameter(parts, DMContractDefs.DMRecon.useVesselWaypoints, body);
            DMSpecificOrbitParameter reconParam  = new DMSpecificOrbitParameter(orbitType, o.inclination, o.eccentricity, o.semiMajorAxis, o.LAN, o.argumentOfPeriapsis, o.meanAnomalyAtEpoch, o.epoch, body, ContractDefs.Satellite.SignificantDeviation, longOrbit);

            this.AddParameter(longOrbit);
            longOrbit.AddParameter(reconParam);
            longOrbit.AddParameter(partRequest);
            longOrbit.setPartRequest(partRequest);

            sciParams[0] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, "SouthernHemisphere", container);
            sciParams[1] = DMCollectContractGenerator.fetchScienceContract(body, ExperimentSituations.InSpaceLow, "NorthernHemisphere", container);

            //Add the science collection parent parameter
            DMCompleteParameter DMcp = new DMCompleteParameter(1, 0);

            this.AddParameter(DMcp);

            foreach (DMCollectScience DMCS in sciParams)
            {
                if (DMCS == null)
                {
                    return(false);
                }
                else
                {
                    if (DMCS.Container == null)
                    {
                        continue;
                    }

                    float modifier = ((float)rand.Next(85, 116) / 100f);
                    DMcp.addToSubParams(DMCS);
                    DMCS.SetFunds(DMContractDefs.DMRecon.Funds.ParamReward * modifier, DMContractDefs.DMRecon.Funds.ParamFailure * modifier, body);
                    DMCS.SetScience(DMContractDefs.DMRecon.Science.ParamReward * DMUtils.fixSubjectVal(DMCS.Situation, 1f, body), null);
                    DMCS.SetReputation(DMContractDefs.DMRecon.Reputation.ParamReward * modifier, DMContractDefs.DMRecon.Reputation.ParamFailure * modifier, null);
                }
            }

            if (this.ParameterCount == 0)
            {
                return(false);
            }

            float primaryModifier = ((float)rand.Next(80, 121) / 100f);
            float diffModifier    = 1 + ((float)this.Prestige * 0.5f);

            float Mod = primaryModifier * diffModifier;

            int t = rand.Next(0, 4);

            if (t == 0)
            {
                this.agent = AgentList.Instance.GetAgent("DMagic");
            }
            else
            {
                this.agent = AgentList.Instance.GetAgentRandom();
            }

            if (this.agent == null)
            {
                this.agent = AgentList.Instance.GetAgentRandom();
            }

            base.SetExpiry(DMContractDefs.DMRecon.Expire.MinimumExpireDays, DMContractDefs.DMRecon.Expire.MaximumExpireDays);
            base.SetDeadlineDays((float)(time / ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).KerbinDay) * DMContractDefs.DMRecon.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.4f) * primaryModifier, null);
            base.SetReputation(DMContractDefs.DMRecon.Reputation.BaseReward * Mod, DMContractDefs.DMRecon.Reputation.BaseFailure * Mod, null);
            base.SetFunds(DMContractDefs.DMRecon.Funds.BaseAdvance * Mod, DMContractDefs.DMRecon.Funds.BaseReward * Mod, DMContractDefs.DMRecon.Funds.BaseFailure * Mod, body);
            base.SetScience(DMContractDefs.DMRecon.Science.BaseReward * Mod, body);
            return(true);
        }
Example #4
0
        protected override bool Generate()
        {
            EnterSOI[] SOIContracts = ContractSystem.Instance.GetCurrentContracts <EnterSOI>();
            int        offers       = 0;
            int        active       = 0;
            int        MaxOffers    = 1;
            int        MaxActive    = 3;

            for (int i = 0; i < SOIContracts.Length; i++)
            {
                EnterSOI m = SOIContracts[i];
                if (m.ContractState == State.Offered)
                {
                    offers++;
                }
                else if (m.ContractState == State.Active)
                {
                    active++;
                }
            }

            if (offers >= MaxOffers)
            {
                return(false);
            }

            else if (active >= MaxActive)
            {
                return(false);
            }

            List <CelestialBody>       bodies = new List <CelestialBody>();
            Func <CelestialBody, bool> cb     = null;

            switch (prestige)
            {
            case ContractPrestige.Trivial:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }
                    if (b.scienceValues.RecoveryValue > 4)
                    {
                        return(false);
                    }
                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb));
                break;

            case ContractPrestige.Significant:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Sun)
                    {
                        return(false);
                    }
                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }
                    if (b.scienceValues.RecoveryValue > 8)
                    {
                        return(false);
                    }
                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb));
                break;

            case ContractPrestige.Exceptional:
                cb = delegate(CelestialBody b)
                {
                    if (b == Planetarium.fetch.Home)
                    {
                        return(false);
                    }

                    if (Planetarium.fetch.Home.orbitingBodies.Count > 0)
                    {
                        foreach (CelestialBody B in Planetarium.fetch.Home.orbitingBodies)
                        {
                            if (b == B)
                            {
                                return(false);
                            }
                        }
                    }

                    if (b.scienceValues.RecoveryValue < 4)
                    {
                        return(false);
                    }
                    return(true);
                };
                bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb));
                bodies.AddRange(ProgressUtilities.GetNextUnreached(4, cb));
                break;
            }

            if (bodies.Count <= 0)
            {
                return(false);
            }

            body = bodies[rand.Next(0, bodies.Count)];

            if (body == null)
            {
                return(false);
            }

            this.AddParameter(new Contracts.Parameters.EnterSOI());

            if (this.ParameterCount == 0)
            {
                return(false);
            }

            float primaryModifier = ((float)rand.Next(80, 121) / 100f);
            float diffModifier    = 1 + ((float)this.Prestige * 0.5f);

            float Mod = primaryModifier * diffModifier;

            this.agent = AgentList.Instance.GetAgent("Kerbin World - Firsts Record - Keeping Society");


            base.SetExpiry(1, 100);
            base.SetScience(20F);
            base.SetDeadlineYears(100F);
            base.SetReputation(5F, -2F);
            base.SetFunds(30000F, 50000F, -3000F);

            return(true);
        }