protected override bool Generate() { if (!GetBodies_Reached(true, true).Contains(FlightGlobals.Bodies[1])) { return(false); } int total = ContractSystem.Instance.GetCurrentContracts <DMAsteroidSurveyContract>().Count(); if (total >= DMUtils.maxAsteroid) { return(false); } if (this.Prestige == ContractPrestige.Trivial) { return(false); } else if (this.Prestige == ContractPrestige.Significant) { size = rand.Next(0, 3); } else if (this.Prestige == ContractPrestige.Exceptional) { size = rand.Next(2, 4); } else { return(false); } hash = DMUtils.sizeHash(size); //Make sure that the grappling device is available AvailablePart aPart = PartLoader.getPartInfoByName("GrapplingDevice"); if (aPart == null) { return(false); } if (!ResearchAndDevelopment.PartModelPurchased(aPart)) { return(false); } sciList.AddRange(DMUtils.availableScience[DMScienceType.Asteroid.ToString()].Values); //Generates new asteroid science experiments for (i = 0; i < 4; i++) { if (sciList.Count > 0) { DMScience = sciList[rand.Next(0, sciList.Count)]; newParams[i] = DMAsteroidGenerator.fetchAsteroidParameter(size, DMScience); sciList.Remove(DMScience); } else { newParams[i] = null; } } //Add in all acceptable paramaters to the contract foreach (DMAsteroidParameter DMAP in newParams) { if (DMAP != null) { this.AddParameter(DMAP, "collectDMScience"); float modifier = ((float)rand.Next(85, 116) / 100f); DMAP.SetScience(DMAP.Container.exp.baseValue * 2f * DMUtils.science * DMUtils.asteroidSubjectVal(1f, size), null); DMAP.SetFunds(8000f * DMUtils.reward * DMUtils.asteroidSubjectVal(1f, size) * modifier, 6000f * DMUtils.penalty * (size + 1) * modifier, null); DMAP.SetReputation(15f * DMUtils.reward * (size + 1) * modifier, 10f * DMUtils.penalty * (size + 1) * modifier, null); DMUtils.DebugLog("Asteroid Survey Parameter Added"); } } if (this.ParameterCount < 3) { return(false); } float primaryModifier = ((float)rand.Next(85, 116) / 100f); this.agent = AgentList.Instance.GetAgent("DMagic"); base.SetExpiry(10 * DMUtils.deadline, 20 * DMUtils.deadline); base.SetDeadlineYears(2.8f * DMUtils.deadline * primaryModifier, null); base.SetReputation(newParams.Length * 5f * DMUtils.reward * (size + 1) * primaryModifier, newParams.Length * 3f * DMUtils.penalty * primaryModifier, null); base.SetFunds(12000 * newParams.Length * DMUtils.forward * (size + 1) * primaryModifier, 11000 * newParams.Length * DMUtils.reward * (size + 1) * primaryModifier, 9000 * newParams.Length * DMUtils.penalty * (size + 1) * primaryModifier, null); return(true); }