private List <Thing> GenerateRewards(Faction alliedFaction = null) { ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.techLevel = TechLevel.Medieval; //new TechLevel?(alliedFaction.def.techLevel); return(ItemCollectionGeneratorDefOf.BanditCampQuestRewards.Worker.Generate(parms)); }
public override void Resolve(ResolveParams rp) { int? ancientCryptosleepCasketGroupID = rp.ancientCryptosleepCasketGroupID; int groupID = (!ancientCryptosleepCasketGroupID.HasValue) ? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID() : ancientCryptosleepCasketGroupID.Value; PodContentsType?podContentsType = rp.podContentsType; PodContentsType value = (!podContentsType.HasValue) ? Gen.RandomEnumValue <PodContentsType>(true) : podContentsType.Value; Rot4? thingRot = rp.thingRot; Rot4 rot = (!thingRot.HasValue) ? Rot4.North : thingRot.Value; Building_AncientCryptosleepCasket building_AncientCryptosleepCasket = (Building_AncientCryptosleepCasket)ThingMaker.MakeThing(ThingDefOf.AncientCryptosleepCasket, null); building_AncientCryptosleepCasket.groupID = groupID; ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.podContentsType = new PodContentsType?(value); List <Thing> list = ItemCollectionGeneratorDefOf.AncientPodContents.Worker.Generate(parms); for (int i = 0; i < list.Count; i++) { if (!building_AncientCryptosleepCasket.TryAcceptThing(list[i], false)) { Pawn pawn = list[i] as Pawn; if (pawn != null) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } else { list[i].Destroy(DestroyMode.Vanish); } } } GenSpawn.Spawn(building_AncientCryptosleepCasket, rp.rect.RandomCell, BaseGen.globalSettings.map, rot, false); }
protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings) { Messages.Message("TM item collection called", MessageSound.Benefit); if (Rand.Chance(0.9f)) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Luciferium, null); thing.stackCount = LuciferiumCountRange.RandomInRange; outThings.Add(thing); } if (Rand.Chance(0.9f)) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { ThingDef def = ItemCollectionGenerator_Artifacts.artifacts.RandomElement <ThingDef>(); Thing item = ThingMaker.MakeThing(def, null); outThings.Add(item); } } if (Rand.Chance(0.9f)) { Messages.Message("random create called", MessageSound.Benefit); int randomInRange = ArcaneScriptCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfInnerFire, null); outThings.Add(thing); Messages.Message("Book of fire should be created", MessageSound.Benefit); } } }
public void GenerateThings() { ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.traderDef = this.cargoKind; parms.tile = this.Map.Tile; this.things.TryAddRangeOrTransfer(ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms), true); }
private List <Thing> GenerateRewards(Faction alliedFaction) { ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.techLevel = new TechLevel?(alliedFaction.def.techLevel); parms.totalMarketValue = 8000f; List <Thing> list = new List <Thing>(); ItemCollectionGenerator_Internal_Arcane itc_ia = new ItemCollectionGenerator_Internal_Arcane(); return(itc_ia.Generate(parms, list)); //return ItemCollectionGeneratorDefOf.BanditCampQuestRewards.Worker.Generate(parms); }
private static List <Thing> GenerateBloodStone() { ItemCollectionGeneratorParams parms2 = default(ItemCollectionGeneratorParams); int?count = parms2.count; parms2.count = new int?((count == null) ? ItemCollectionGenerator_Meteorite.MineablesCountRange.RandomInRange : count.Value); parms2.extraAllowedDefs = Gen.YieldSingle <ThingDef>(UvhashDefOf.Uvhash_Bloodstone); List <Thing> list = new List <Thing>(ItemCollectionGeneratorDefOf.Standard.Worker.Generate(parms2)); return(list); }
public override void End() { IntVec3 thingLoc = centerLocation.ToIntVec3; List <Thing> thingList; Thing destroyable = null; thingList = thingLoc.GetThingList(base.Map); int z = 0; while (z < thingList.Count) { destroyable = thingList[z]; if (destroyable != null) { bool validator = destroyable is Building; if (validator) { if (destroyable.def == ThingDef.Named("TM_ElementalRift")) { destroyable.Destroy(DestroyMode.Vanish); } } } z++; } ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.disabled) { Thing thing = null; thing = ThingMaker.MakeThing(ThingDef.Named("Jade")); thing.stackCount = Rand.Range(35 * (int)settingsRef.riftChallenge, 60 * (int)settingsRef.riftChallenge); if (thing != null) { GenPlace.TryPlaceThing(thing, thingLoc, this.Map, ThingPlaceMode.Near, null); } ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.techLevel = TechLevel.Neolithic; parms.totalMarketValue = 1000f * (settingsRef.riftChallenge * settingsRef.riftChallenge); List <Thing> list = new List <Thing>(); ItemCollectionGenerator_Gemstones itc_g = new ItemCollectionGenerator_Gemstones(); list = itc_g.Generate(parms, list); for (int i = 0; i < list.Count; i++) { thing = list[i]; thing.stackCount = list[i].stackCount; GenPlace.TryPlaceThing(thing, thingLoc, this.Map, ThingPlaceMode.Near, null); } } base.End(); }
private void CalculatePossibleItemCollectionGenerators(TechLevel techLevel) { this.possibleItemCollectionGenerators.Clear(); if (techLevel >= ThingDefOf.AIPersonaCore.techLevel) { ItemCollectionGeneratorDef standard = ItemCollectionGeneratorDefOf.Standard; ItemCollectionGeneratorParams second = default(ItemCollectionGeneratorParams); second.extraAllowedDefs = Gen.YieldSingle <ThingDef>(ThingDefOf.AIPersonaCore); second.count = new int?(1); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard, second)); if (Rand.Chance(0.25f) && !this.PlayerOrItemStashHasAIPersonaCore()) { return; } } //if (techLevel >= ThingDefOf.MechSerumNeurotrainer.techLevel) //{ // ItemCollectionGeneratorDef standard2 = ItemCollectionGeneratorDefOf.Standard; // ItemCollectionGeneratorParams second2 = default(ItemCollectionGeneratorParams); // second2.extraAllowedDefs = Gen.YieldSingle<ThingDef>(ThingDefOf.MechSerumNeurotrainer); // second2.count = new int?(ItemCollectionGenerator_ItemStashQuest.NeurotrainersCountRange.RandomInRange); // this.possibleItemCollectionGenerators.Add(new Pair<ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard2, second2)); //} List <ThingDef> allGeneratableItems = ItemCollectionGeneratorUtility.allGeneratableItems; for (int i = 0; i < allGeneratableItems.Count; i++) { ThingDef thingDef = allGeneratableItems[i]; if (techLevel >= thingDef.techLevel && thingDef.itemGeneratorTags != null && thingDef.itemGeneratorTags.Contains(ItemCollectionGeneratorUtility.SpecialRewardTag)) { ItemCollectionGeneratorDef standard3 = ItemCollectionGeneratorDefOf.Standard; ItemCollectionGeneratorParams second3 = default(ItemCollectionGeneratorParams); second3.extraAllowedDefs = Gen.YieldSingle <ThingDef>(thingDef); second3.count = new int?(1); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard3, second3)); } } ItemCollectionGeneratorParams second4 = default(ItemCollectionGeneratorParams); second4.count = new int?(ThingsCountRange.RandomInRange); second4.totalMarketValue = new float?(TotalMarketValueRange.RandomInRange); second4.techLevel = new TechLevel?(techLevel); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Weapons, second4)); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.RawResources, second4)); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Apparel, second4)); // Added !!! this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.AncientTempleContents, second4)); }
public override void Resolve(ResolveParams rp) { ItemCollectionGeneratorParams value = default(ItemCollectionGeneratorParams); value.techLevel = ((rp.faction == null) ? TechLevel.Spacer : rp.faction.def.techLevel); value.totalNutrition = SymbolResolver_Interior_PrisonCell.TotalNutritionRange.RandomInRange; value.minPreferability = FoodPreferability.RawBad; ResolveParams resolveParams = rp; resolveParams.itemCollectionGeneratorDef = ItemCollectionGeneratorDefOf.Food; resolveParams.itemCollectionGeneratorParams = value; resolveParams.innerStockpileSize = 3; BaseGen.symbolStack.Push("innerStockpile", resolveParams); InteriorSymbolResolverUtility.PushBedroomHeatersCoolersAndLightSourcesSymbols(rp, false); BaseGen.symbolStack.Push("prisonerBed", rp); }
protected virtual void RegenerateStock() { this.TryDestroyStock(); this.stock = new ThingOwner <Thing>(this); if (this.settlement.Faction == null || !this.settlement.Faction.IsPlayer) { ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.traderDef = this.TraderKind; parms.tile = new int?(this.settlement.Tile); parms.traderFaction = this.settlement.Faction; this.stock.TryAddRangeOrTransfer(ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms), true, false); } for (int i = 0; i < this.stock.Count; i++) { Pawn pawn = this.stock[i] as Pawn; if (pawn != null) { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Decide); } } this.lastStockGenerationTicks = Find.TickManager.TicksGame; }
public List <Thing> Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings) { for (int j = 0; j < 10; j++) { //Torn Scripts if (Rand.Chance(0.3f) && (parms.totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.Torn_BookOfArcanist.BaseMarketValue / 2) { if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfInnerFire, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfHeartOfFrost, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfStormBorn, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfArcanist, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfValiant, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfSummoner, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfNature, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfUndead, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfPriest, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfBard, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } //Arcane Scripts if (Rand.Chance(0.1f) && (parms.totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.BookOfArcanist.BaseMarketValue / 2) { if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfInnerFire, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfHeartOfFrost, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfStormBorn, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfArcanist, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfValiant, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfSummoner, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfNecromancer, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfDruid, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfPriest, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfBard, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfGladiator, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfSniper, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfBladedancer, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfRanger, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } //Mana Potions if (Rand.Chance(0.2f) && (parms.totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.ManaPotion.BaseMarketValue * ManaPotionRange.RandomInRange) { int randomInRange = ManaPotionRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.ManaPotion, null); thing.stackCount = ManaPotionRange.RandomInRange; outThings.Add(thing); collectiveMarketValue += thing.MarketValue * thing.stackCount; } } //Artifacts if (Rand.Chance(ArtifactsChance) && (parms.totalMarketValue - collectiveMarketValue) > 1000f) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { ThingDef def = ItemCollectionGenerator_Artifacts.artifacts.RandomElement <ThingDef>(); Thing item = ThingMaker.MakeThing(def, null); outThings.Add(item); collectiveMarketValue += item.MarketValue; } } //Luciferium if (Rand.Chance(LuciferiumChance) && (parms.totalMarketValue - collectiveMarketValue) > ThingDefOf.Luciferium.BaseMarketValue * LuciferiumCountRange.RandomInRange) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Luciferium, null); thing.stackCount = LuciferiumCountRange.RandomInRange; outThings.Add(thing); collectiveMarketValue += thing.MarketValue * thing.stackCount; } //Ambrosia if (Rand.Chance(DrugChance)) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { //Thing thing = ThingMaker.MakeThing(, null); Thing thing = ThingMaker.MakeThing(ThingDef.Named("Ambrosia"), null); outThings.Add(thing); } } //Master Spells if (Rand.Chance(MasterSpellChance) && (parms.totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.SpellOf_Blizzard.BaseMarketValue) { Thing thing; float rnd = Rand.Range(0f, 18f); if (rnd > 16) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SummonPoppi, null); } else if (rnd > 14 && rnd <= 16) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_BattleHymn, null); } else if (rnd > 12 && rnd <= 14) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_HolyWrath, null); } else if (rnd > 10 && rnd <= 12) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_LichForm, null); } else if (rnd > 8 && rnd <= 10) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blizzard, null); } else if (rnd > 6 && rnd <= 8) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Firestorm, null); } else if (rnd > 4 && rnd <= 6) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_FoldReality, null); } else if (rnd > 2 && rnd <= 4) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Resurrection, null); } else { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_RegrowLimb, null); } outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } //Spells if (Rand.Chance(SpellChance) && (parms.totalMarketValue - collectiveMarketValue) > 1000f) { int randomInRange = SpellCountRange.RandomInRange; Thing thing = new Thing(); for (int i = 0; i < randomInRange; i++) { if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blink, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Teleport, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heal, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Rain, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heater, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Cooler, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_DryGround, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_WetGround, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_ChargeBattery, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SmokeCloud, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_EMP, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Extinguish, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SummonMinion, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_TransferMana, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SiphonMana, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_ManaShield, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_PowerNode, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Sunlight, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SpellMending, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_CauterizeWound, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_FertileLands, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } } //Skills if (Rand.Chance(SpellChance) && (parms.totalMarketValue - collectiveMarketValue) > 600f) { int randomInRange = SkillCountRange.RandomInRange; Thing thing = new Thing(); for (int i = 0; i < randomInRange; i++) { if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_Sprint, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_GearRepair, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_InnerHealing, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_HeavyBlow, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_StrongBack, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_ThickSkin, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_FightersFocus, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } } } return(outThings); }
public override void Generate(Map map) { System.Random random = new System.Random(); float num = Mathf.Min(10000f, (float)GenMath.RoundRandom(random.Next(10000, 12000))); ItemCollectionGenerator_Arcane itemCollectionGenerator_Arcane = new ItemCollectionGenerator_Arcane(); ItemCollectionGeneratorParams itemCollectionGeneratorParams = default(ItemCollectionGeneratorParams); itemCollectionGeneratorParams.techLevel = (TechLevel)5; itemCollectionGeneratorParams.totalMarketValue = num; itemCollectionGeneratorParams.count = Rand.RangeInclusive(10, 20); if (num > 12000f) { itemCollectionGeneratorParams.count = 1; } itemCollectionGeneratorParams.validator = ((ThingDef t) => t.defName != "Silver"); List <Thing> list = new List <Thing>(); Thing item = new Thing(); //random = new System.Random(); //int rnd = GenMath.RoundRandom(random.Next(0, 10)); //if (rnd < 2) //{ // item.def = TorannMagicDefOf.BookOfInnerFire; //} //else if (rnd >= 2 && rnd < 4) //{ // item.def = TorannMagicDefOf.BookOfHeartOfFrost; //} //else if (rnd >= 4 && rnd < 6) //{ // item.def = TorannMagicDefOf.BookOfStormBorn; //} //else if (rnd >= 6 && rnd < 8) //{ // item.def = TorannMagicDefOf.BookOfArcanist; //} //else //{ // item.def = TorannMagicDefOf.BookOfValiant; //} //item.stackCount = 1; //list.Add(item); foreach (Thing current in list) { if (current.stackCount > current.def.stackLimit) { current.stackCount = current.def.stackLimit; } IntVec3 intVec; if (CellFinderLoose.TryGetRandomCellWith((IntVec3 x) => GenGrid.Standable(x, map) && GridsUtility.Fogged(x, map) && GridsUtility.GetRoom(x, map, (RegionType)6).CellCount >= 2, map, 1000, out intVec)) { GenSpawn.Spawn(current, intVec, map, Rot4.Random, false); } } list = itemCollectionGenerator_Arcane.Generate(itemCollectionGeneratorParams); foreach (Thing current in list) { if (current.stackCount > current.def.stackLimit) { current.stackCount = current.def.stackLimit; } IntVec3 intVec; if (CellFinderLoose.TryGetRandomCellWith((IntVec3 x) => GenGrid.Standable(x, map) && GridsUtility.Fogged(x, map) && GridsUtility.GetRoom(x, map, (RegionType)6).CellCount >= 2, map, 1000, out intVec)) { GenSpawn.Spawn(current, intVec, map, Rot4.North, false); } } }
public List <Thing> Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings) { for (int j = 0; j < 10; j++) { //Raw Magicyte if (Rand.Chance(RawMagicyteChance) && (parms.totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.RawMagicyte.BaseMarketValue * 10) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.RawMagicyte, null); thing.stackCount = RawMagicyteRange.RandomInRange; outThings.Add(thing); collectiveMarketValue += thing.MarketValue * thing.stackCount; } //Minor Magicyte if (Rand.Chance(MinorMagicyteChance) && (parms.totalMarketValue - collectiveMarketValue) > ThingDef.Named("TM_EStone_maxMP_minor").BaseMarketValue) { Thing thing = null; int rnd = Rand.RangeInclusive(1, this.MagicyteTypes); switch (rnd) { case 1: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_maxMP_minor"), null); break; case 2: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpRegenRate_minor"), null); break; case 3: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpCost_minor"), null); break; case 4: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_coolDown_minor"), null); break; case 5: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_xpGain_minor"), null); break; } outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } //Magicyte if (Rand.Chance(MagicyteChance) && (parms.totalMarketValue - collectiveMarketValue) > ThingDef.Named("TM_EStone_maxMP").BaseMarketValue) { Thing thing = null; int rnd = Rand.RangeInclusive(1, this.MagicyteTypes); switch (rnd) { case 1: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_maxMP"), null); break; case 2: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpRegenRate"), null); break; case 3: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpCost"), null); break; case 4: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_coolDown"), null); break; case 5: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_xpGain"), null); break; } outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } //Major Magicyte if (Rand.Chance(MajorMagicyteChance) && (parms.totalMarketValue - collectiveMarketValue) > ThingDef.Named("TM_EStone_maxMP_major").BaseMarketValue) { Thing thing = null; int rnd = Rand.RangeInclusive(1, this.MagicyteTypes); switch (rnd) { case 1: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_maxMP_major"), null); break; case 2: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpRegenRate_major"), null); break; case 3: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_mpCost_major"), null); break; case 4: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_coolDown_major"), null); break; case 5: thing = ThingMaker.MakeThing(ThingDef.Named("TM_EStone_xpGain_major"), null); break; } outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } return(outThings); }
protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings) { if (Rand.Chance(1f)) { if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfInnerFire, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfHeartOfFrost, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfStormBorn, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfArcanist, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfValiant, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfSummoner, null); outThings.Add(thing); } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfGladiator, null); outThings.Add(thing); } } if (Rand.Chance(1f)) { int randomInRange = ManaPotionRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.ManaPotion, null); thing.stackCount = ManaPotionRange.RandomInRange; outThings.Add(thing); } } if (Rand.Chance(ArtifactsChance)) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { ThingDef def = ItemCollectionGenerator_Artifacts.artifacts.RandomElement <ThingDef>(); Thing item = ThingMaker.MakeThing(def, null); outThings.Add(item); } } if (Rand.Chance(LuciferiumChance)) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Luciferium, null); thing.stackCount = LuciferiumCountRange.RandomInRange; outThings.Add(thing); } if (Rand.Chance(DrugChance)) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { //Thing thing = ThingMaker.MakeThing(, null); Thing thing = ThingMaker.MakeThing(ThingDefOf.PlantAmbrosia, null); outThings.Add(thing); } } if (Rand.Chance(MasterSpellChance)) { Thing thing; if (Rand.Range(0, 10) > 5) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blizzard, null); } else { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Firestorm, null); } outThings.Add(thing); } if (Rand.Chance(SpellChance)) { int randomInRange = SpellCountRange.RandomInRange; Thing thing = new Thing(); for (int i = 0; i < randomInRange; i++) { if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blink, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Teleport, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heal, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Rain, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heater, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Cooler, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_DryGround, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_WetGround, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_ChargeBattery, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SmokeCloud, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_EMP, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Extinguish, null); outThings.Add(thing); } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SummonMinion, null); outThings.Add(thing); } } } }
private static bool TryConvertOnePawnToSmallTrader(List <Pawn> pawns, Faction faction, Map map) { if (faction.def.visitorTraderKinds.NullOrEmpty()) { return(false); } Pawn pawn = pawns.RandomElement(); Lord lord = pawn.GetLord(); pawn.mindState.wantsToTradeWithColony = true; PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, true); TraderKindDef traderKindDef = faction.def.visitorTraderKinds.RandomElementByWeight(traderDef => traderDef.commonality); pawn.trader.traderKind = traderKindDef; pawn.inventory.DestroyAll(); pawn.TryGiveBackpack(); ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams); parms.traderDef = traderKindDef; parms.forTile = map.Tile; parms.forFaction = faction; foreach (Thing current in ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms)) { Pawn slave = current as Pawn; if (slave != null) { if (slave.Faction != pawn.Faction) { slave.SetFaction(pawn.Faction); } IntVec3 loc = CellFinder.RandomClosewalkCellNear(pawn.Position, lord.Map, 5); GenSpawn.Spawn(slave, loc, lord.Map); lord.AddPawn(slave); } else { var spaceFor = pawn.GetInventorySpaceFor(current); if (current.Destroyed) { continue; } if (spaceFor <= 0) { current.Destroy(); continue; } current.stackCount = spaceFor; // Core stuff if (!pawn.inventory.innerContainer.TryAdd(current)) { current.Destroy(); } } } return(true); }
protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings) => outThings.AddRange(new HashSet <ThingDef>(Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(ThingDef))).SelectMany(t => t.AllSubclassesNonAbstract().Concat(new Type[1] { t })) .SelectMany(t => ((IEnumerable)typeof(DefDatabase <>).MakeGenericType(t).GetProperty(nameof(DefDatabase <Def> .AllDefs)).GetGetMethod().Invoke(null, null)).Cast <ThingDef>())). Select(d => ThingMaker.MakeThing(d, GenStuff.RandomStuffFor(d))));