Ejemplo n.º 1
0
        public void EVARepackChute()
        {
            if (this.parachute.deploymentState == ModuleParachute.deploymentStates.CUT)
            {
                _rnd = new Random();
                double adjustodds = new double();

                double    currentrandom = _rnd.NextDouble();
                KerbalEVA kerbal        = FlightGlobals.ActiveVessel.evaController;
                EVAKerbalName = kerbal.name.Substring(kerbal.name.IndexOf("(") + 1, (kerbal.name.IndexOf(")") - kerbal.name.IndexOf("(")) - 1);

                ProtoCrewMember pcm       = PCM;
                double          dumbstat  = pcm.stupidity;
                double          starLevel = pcm.experienceLevel;

                if (pcm.GetEffect(requiredSkill) != null)
                {
                    print("[Dumb Luck] Correct skill: " + requiredSkill.ToString());
                }
                else
                {
                    print("[Dumb Luck] Wrong Kerbal (" + pcm.experienceTrait.Title.ToString() + ") attempting to repack chute. Adjusting odds by additional " + nonEngineeraddonPercent.ToString("F2"));
                    adjustodds += nonEngineeraddonPercent;
                } // adjusting chance of failure for wrong Kerbal

                if (starLevel < minimumSkillLevel)
                {
                    print("[Dumb Luck] Inexperienced Kerbal (" + starLevel.ToString("F0") + ") attempting to repack chute. Adjusting odds by additional " + (minimumSkillLevel - starLevel).ToString("F0") + "*" + lowLeveladdonPercent.ToString("F2"));
                    adjustodds += (minimumSkillLevel - starLevel) * lowLeveladdonPercent;
                } // adjusting chance of failure for low level Kerbal


                print("[Dumb Luck] <" + (repairFailurePercent + adjustodds).ToString("F2") + " is a failure. This attempt: " + currentrandom.ToString("F3"));

                if ((currentrandom - adjustodds) <= repairFailurePercent)
                {
                    currentrandom = _rnd.NextDouble();
                    print("[Dumb Luck] > " + catastrophicFailureLevel.ToString("F2") + " is catastophic. rnd(" + currentrandom.ToString("F3") + ") dumb(" + dumbstat.ToString("F3") + ") lvl(" + starLevel.ToString("F0") + ") This Attempt: " + ((dumbstat / (starLevel + 1)) * currentrandom).ToString("F3"));
                    if ((dumbstat / (starLevel + 1)) * currentrandom >= catastrophicFailureLevel)
                    {
                        print("[Dumb Luck] Boom. Repack failed");
                        this.part.explosionPotential = 0;
                        this.part.explode();
                        return;
                    }
                }

                pcm = null;
            }
            this.parachute.Repack();
            if (this.parachute.deploymentState == ModuleParachute.deploymentStates.STOWED)
            {
                print("[Dumb Luck] Repack Success");
                this.Events["EVARepackChute"].active = false;
            }
        }
Ejemplo n.º 2
0
        public void EVAResetExperiement()
        {
            if (this.experiment.resettableOnEVA)
            {
                _rnd = new Random();
                double adjustodds = new double();

                double    currentrandom = _rnd.NextDouble();
                KerbalEVA kerbal        = FlightGlobals.ActiveVessel.evaController;
                EVAKerbalName = kerbal.name.Substring(kerbal.name.IndexOf("(") + 1, (kerbal.name.IndexOf(")") - kerbal.name.IndexOf("(")) - 1);

                ProtoCrewMember pcm       = PCM;
                double          dumbstat  = pcm.stupidity;
                double          starLevel = pcm.experienceLevel;

                //print("EVAKerbalName: " + EVAKerbalName.ToString());
                //print("setting dumb: " + dumbstat.ToString());
                //print("setting lvl: " + starLevel.ToString());
                //print("Trait: " + pcm.experienceTrait.Title.ToString());
                if (pcm.GetEffect(requiredSkill) != null)
                {
                }
                else
                {
                    //print("[Dumb Luck] Wrong Kerbal (" + pcm.experienceTrait.Title.ToString() + ") attempting to reset " + experiementname + ". Adjusting odds by additional " + nonScientistaddonPercent.ToString("F2"));
                    adjustodds += nonScientistaddonPercent;
                } // adjusting chance of failure for wrong Kerbal

                print("[Dumb Luck] <" + (repairFailurePercent + adjustodds).ToString("F2") + " is a failure. This attempt: " + currentrandom.ToString("F3"));

                if ((currentrandom - adjustodds) <= repairFailurePercent)
                {
                    currentrandom = _rnd.NextDouble();
                    print("[Dumb Luck] > " + catastrophicFailureLevel.ToString("F2") + " is catastophic. rnd(" + currentrandom.ToString("F3") + ") dumb(" + dumbstat.ToString("F3") + ") lvl(" + starLevel.ToString("F0") + ") This Attempt: " + ((dumbstat / (starLevel + 1)) * currentrandom).ToString("F3"));
                    if ((dumbstat / (starLevel + 1)) * currentrandom >= catastrophicFailureLevel)
                    {
                        print("[Dumb Luck] Boom. Reset failed");
                        this.part.explosionPotential = 0;
                        this.part.explode();
                        return;
                    }
                }

                pcm = null;

                this.Events["EVAResetExperiement"].active = false;
                if (this.experiment.GetScienceCount() > 0)
                {
                    this.experiment.ResetExperimentExternal();
                }
                else
                {
                    this.experiment.CleanUpExperimentExternal();
                }
            }
        }
Ejemplo n.º 3
0
        private double KerbalContribution(ProtoCrewMember crew)
        {
            string expstr     = KerbalExt.Get(crew, "experience:task=Workshop");
            float  experience = 0;

            if (expstr != null)
            {
                float.TryParse(expstr, out experience);
            }

            double contribution;

            if (crew.isBadass)
            {
                contribution = Baddass(crew.stupidity, crew.courage, experience);
            }
            else
            {
                contribution = Normal(crew.stupidity, crew.courage, experience);
            }
            bool hasConstructionSkill = crew.GetEffect <ELConstructionSkill> () != null;

            if (!hasConstructionSkill)
            {
                if (!enableUnskilled)
                {
                    // can't work here, but may not know to keep out of the way.
                    contribution = Math.Min(contribution, 0);
                }
                if (crew.experienceLevel >= 3)
                {
                    // can resist "ooh, what does this button do?"
                    contribution = Math.Max(contribution, 0);
                }
            }
            else
            {
                switch (crew.experienceLevel)
                {
                case 0:
                    if (!enableSkilled && !SupportInexperienced)
                    {
                        // can't work here, but knows to keep out of the way.
                        contribution = 0;
                    }
                    break;

                case 1:
                    break;

                case 2:
                    if (SupportInexperienced)
                    {
                        // He's learned the ropes.
                        contribution = HyperCurve(contribution);
                    }
                    break;

                default:
                    // He's learned the ropes very well.
                    contribution = HyperCurve(contribution);
                    break;
                }
            }

            /*
             * Debug.LogFormat ("[EL Workshop] Kerbal: "
             + "{0} s:{1} c:{2} b:{3} e:{4}({5}) c:{6} hs:{7} l:{8} es:{9} si:{10}",
             +                               crew.name, crew.stupidity, crew.courage,
             +                               crew.isBadass, experience, expstr,
             +                               contribution, hasConstructionSkill,
             +                               crew.experienceLevel,
             +                               enableSkilled, SupportInexperienced);
             */
            return(contribution);
        }
Ejemplo n.º 4
0
        private float KerbalContribution(ProtoCrewMember crew, float stupidity,
                                         float courage, bool isBadass)
        {
            string expstr     = KerbalExt.Get(crew, "experience:task=Workshop");
            float  experience = 0;

            if (expstr != null)
            {
                float.TryParse(expstr, out experience);
            }

            float contribution;

            if (isBadass)
            {
                contribution = Baddass(stupidity, courage, experience);
            }
            else
            {
                contribution = Normal(stupidity, courage, experience);
            }
            if (useSkill)
            {
                if (crew.GetEffect <ExConstructionSkill> () != null)
                {
                    if (!enableUnskilled)
                    {
                        // can't work here, but may not know to keep out of the way.
                        contribution = Mathf.Min(contribution, 0);
                    }
                    if (crew.experienceLevel >= 3)
                    {
                        // can resist "ooh, what does this button do?"
                        contribution = Mathf.Max(contribution, 0);
                    }
                }
                else
                {
                    switch (crew.experienceLevel)
                    {
                    case 0:
                        if (!enableSkilled && !SupportInexperienced)
                        {
                            // can't work here, but knows to keep out of the way.
                            contribution = 0;
                        }
                        break;

                    case 1:
                        break;

                    case 2:
                        if (SupportInexperienced)
                        {
                            // He's learned the ropes.
                            contribution = HyperCurve(contribution);
                        }
                        break;

                    default:
                        // He's learned the ropes very well.
                        contribution = HyperCurve(contribution);
                        break;
                    }
                }
            }
            Debug.Log(String.Format("[EL Workshop] Kerbal: "
                                    + "{0} {1} {2} {3} {4}({5}) {6} {7} {8} {9} {10}",
                                    crew.name, stupidity, courage, isBadass,
                                    experience, expstr, contribution,
                                    crew.GetEffect <ExConstructionSkill> () != null,
                                    crew.experienceLevel,
                                    enableSkilled, SupportInexperienced));
            return(contribution);
        }