public void RegenerateStock() { TryDestroyStock(); int itemsCount = Comp.Props.CountRange.RandomInRange; float valueRange = Comp.Props.ValueRange.RandomInRange; ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; parms.totalMarketValueRange = new FloatRange(valueRange, valueRange); parms.countRange = new IntRange(itemsCount, itemsCount); parms.filter = DarkNetPriceUtils.GetThingFilter(def.AvaliableGoods); maker.fixedParams = parms; var items = maker.Generate(); stock = new List <SellableItemWithModif>(); foreach (var item in items) { int itemValue = (int)((item.MarketValue * Character.Greed) * GetPriceModificatorByTechLevel(item.def.techLevel)); if (!DarkNetPriceUtils.TryMerge(item, stock)) { stock.Add(new SellableItemWithModif(item, itemValue, null)); } } }
public static List <Thing> generateRaidLoot(int lootLevel, TechLevel techLevel) { List <Thing> things = new List <Thing>(); ThingSetMaker thingSetMaker = new ThingSetMaker_MarketValue(); ThingSetMakerParams param = new ThingSetMakerParams(); param.totalMarketValueRange = new FloatRange(500 + (lootLevel * 200), 1000 + (lootLevel * 500)); param.filter = new ThingFilter(); param.techLevel = techLevel; param.countRange = new IntRange(3, 20); //set allow param.filter.SetAllow(ThingCategoryDefOf.Weapons, true); param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.filter.SetAllow(ThingCategoryDefOf.BuildingsArt, true); param.filter.SetAllow(ThingCategoryDefOf.Drugs, true); param.filter.SetAllow(ThingCategoryDefOf.Items, true); param.filter.SetAllow(ThingCategoryDefOf.Medicine, true); param.filter.SetAllow(ThingCategoryDefOf.Techprints, true); param.filter.SetAllow(ThingCategoryDefOf.Buildings, true); //set disallow param.filter.SetAllow(DefDatabase <ThingDef> .GetNamedSilentFail("Teachmat"), false); things = thingSetMaker.Generate(param); return(things); }
public void RegenerateStock() { TryDestroyStock(); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; foreach (var cat in stock) { CategoryItemSetting <Tab> settings = Comp.Props.CategoryItemSettings.First(x => x.Tab == cat.Tab); if (cat.Items == null) { cat.Items = new List <SellableItemWithModif>(); } int itemsCount = settings.CountRange.RandomInRange; float valueRange = settings.ValueRange.RandomInRange * itemsCount; parms.totalMarketValueRange = new FloatRange(valueRange, valueRange); parms.countRange = new IntRange(itemsCount, itemsCount); ThingFilter filter = DarkNetPriceUtils.GetThingFilter(settings.Goods); if (filter.AllowedDefCount == 0) { continue; } parms.filter = filter; maker.fixedParams = parms; var items = maker.Generate(); foreach (var item in items) { if (!DarkNetPriceUtils.TryMerge(item, cat.Items)) { int marketValue = (int)((item.MarketValue * Character.Greed) * settings.PriceMultiplier); var quality = item.TryGetComp <CompQuality>(); if (quality != null) { quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony); marketValue = (int)(marketValue * GetPriceMultiplierForQuality(quality.Quality)); } SellableItemWithModif newItem = new SellableItemWithModif(item, marketValue, null); cat.Items.Add(newItem); } } } }
public void RegenerateStock() { TryDestroyStock(); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; float tmpDiscount = discount; foreach (var cat in drugs) { DrugSettings settings = Comp.Props.DrugStockSettings.First(x => x.Tab == cat.Tab); if (cat.Items == null) { cat.Items = new List <SellableItemWithModif>(); } int itemsCount = settings.CountRange.RandomInRange; float valueRange = settings.ValueRange.RandomInRange * itemsCount; parms.totalMarketValueRange = new FloatRange(valueRange, valueRange); parms.countRange = new IntRange(itemsCount, itemsCount); ThingFilter filter = DarkNetPriceUtils.GetThingFilter(settings.Goods); if (filter.AllowedDefCount == 0) { continue; } parms.filter = filter; maker.fixedParams = parms; var items = maker.Generate(); foreach (var item in items) { if (!TryMerge(item, cat.Items)) { int marketValue = (int)((item.MarketValue * Character.Greed) * GetPriceModificatorByTechLevel(item.def.techLevel)); marketValue -= (int)(marketValue * tmpDiscount / 100); SellableItemWithModif newItem = new SellableItemWithModif(item, marketValue, null); cat.Items.Add(newItem); } } } }
public virtual void GenerateRewards(ThingFilter filter, FloatRange totalValue, IntRange countRange, TechLevel?techLevel, float?totalMass) { ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms2 = default; parms2.totalMarketValueRange = totalValue; parms2.countRange = countRange; parms2.filter = filter; parms2.techLevel = techLevel; parms2.maxTotalMass = totalMass; maker.fixedParams = parms2; Rewards = maker.Generate(); }
public override void OnReceived(EmailMessage message, EmailBox box) { ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms2 = default; parms2.totalMarketValueRange = TotalValue; parms2.filter = GetFilter(); parms2.techLevel = message.Faction.def.techLevel; maker.fixedParams = parms2; AssistCaravanWithFixedInventoryComp assistComp = new AssistCaravanWithFixedInventoryComp(maker.Generate(), Days * 60000, message.Faction, Find.AnyPlayerHomeMap); assistComp.id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID(); QuestsManager.Communications.RegisterComponent(assistComp); }
private void GenerateItems() { ThingFilter filter = new ThingFilter(); filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; parms.totalMarketValueRange = new FloatRange(1600, 3000); parms.countRange = new IntRange(10, 25); parms.filter = filter; maker.fixedParams = parms; items = maker.Generate(); }
public override void GenerateRewards(ThingFilter filter, FloatRange totalValue, IntRange countRange, TechLevel?techLevel, float?totalMass) { base.GenerateRewards(filter, totalValue, countRange, techLevel, totalMass); filter.SetDisallowAll(); filter.SetAllow(ThingCategoryDefOf.ResourcesRaw, true); filter.SetAllow(ThingCategoryDefOf.Items, true); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms2 = default; parms2.totalMarketValueRange = new FloatRange(300, 800); parms2.countRange = new IntRange(2, 4); parms2.filter = filter; maker.fixedParams = parms2; List <Thing> items = maker.Generate(); items.ForEach(i => Rewards.Add(i)); }
protected void GenerateAndSendHelp(int price, Map map, FloatRange priceRange, IntRange countRange, List <ThingDef> items) { if (!DarkNetPriceUtils.TakeSilverFromPlayer(price, map)) { return; } List <Thing> toDrop = new List <Thing>(); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; parms.totalMarketValueRange = priceRange; parms.countRange = countRange; ThingFilter filter = new ThingFilter(); foreach (var item in items) { filter.SetAllow(item, true); } parms.filter = filter; maker.fixedParams = parms; toDrop = maker.Generate(); DropItems(toDrop, map); totalUses++; alreadyUsed = true; if (totalUses >= 3) { lastHelpTicks = Find.TickManager.TicksGame; } }
public static List <Thing> generateRaidLoot(int lootLevel, TechLevel techLevel) { FactionFC faction = Find.World.GetComponent <FactionFC>(); float trait_LootMulitplier = 1f; if (faction.hasTrait(FCPolicyDefOf.raiders)) { trait_LootMulitplier = 1.2f; } List <Thing> things = new List <Thing>(); ThingSetMaker thingSetMaker = new ThingSetMaker_MarketValue(); ThingSetMakerParams param = new ThingSetMakerParams(); param.totalMarketValueRange = new FloatRange((500 + (lootLevel * 200)) * trait_LootMulitplier, (1000 + (lootLevel * 500)) * trait_LootMulitplier); param.filter = new ThingFilter(); param.techLevel = techLevel; param.countRange = new IntRange(3, 20); //set allow param.filter.SetAllow(ThingCategoryDefOf.Weapons, true); param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.filter.SetAllow(ThingCategoryDefOf.BuildingsArt, true); param.filter.SetAllow(ThingCategoryDefOf.Drugs, true); param.filter.SetAllow(ThingCategoryDefOf.Items, true); param.filter.SetAllow(ThingCategoryDefOf.Medicine, true); param.filter.SetAllow(ThingCategoryDefOf.Techprints, true); param.filter.SetAllow(ThingCategoryDefOf.Buildings, true); //set disallow param.filter.SetAllow(DefDatabase <ThingDef> .GetNamedSilentFail("Teachmat"), false); things = thingSetMaker.Generate(param); return(things); }
private void CheckAnswer(string answer) { if (answer == "конец") { return; } HelpCount--; int techLevel = (int)interaction.Faction.def.techLevel; bool useCaravan = techLevel < (int)TechLevel.Industrial; string caravanText = useCaravan ? "UsingCaravan".Translate() : "UsingCapsules".Translate(); if (answer == "resources") { ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms2 = default; parms2.totalMarketValueRange = new FloatRange(1000, 2000); parms2.filter = GetFilter(); parms2.techLevel = interaction.Faction.def.techLevel; maker.fixedParams = parms2; if (useCaravan) { AssistCaravanWithFixedInventoryComp assistComp = new AssistCaravanWithFixedInventoryComp(maker.Generate(), Rand.Range(1, 3) * 60000, interaction.Faction, speaker.Map); assistComp.id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID(); QuestsManager.Communications.RegisterComponent(assistComp); } else { SendCapsules(maker.Generate()); } Find.LetterStack.ReceiveLetter("Help_AskResoucesTitle".Translate(), "Help_AskResouces".Translate(interaction.Faction, caravanText), LetterDefOf.PositiveEvent); } if (answer == "power") { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = interaction.Faction, points = DiplomacyTuning.RequestedMilitaryAidPointsRange.RandomInRange, generateFightersOnly = true, groupKind = PawnGroupKindDefOf.Combat, raidStrategy = RaidStrategyDefOf.ImmediateAttack, forceOneIncap = true }; IncidentParms incidentParms = new IncidentParms(); incidentParms.target = speaker.Map; incidentParms.faction = interaction.Faction; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; incidentParms.points = DiplomacyTuning.RequestedMilitaryAidPointsRange.RandomInRange; interaction.Faction.lastMilitaryAidRequestTick = Find.TickManager.TicksGame; if (useCaravan) { incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidFriendly, Find.TickManager.TicksGame + 11000, incidentParms); } else { IncidentDefOf.RaidFriendly.Worker.TryExecute(incidentParms); } Find.LetterStack.ReceiveLetter("Help_AskPowerTitle".Translate(), "Help_AskPower".Translate(interaction.Faction, caravanText), LetterDefOf.PositiveEvent); } }
public virtual void RegenerateStock() { TryDestroyStock(); int raidsCount = Find.StoryWatcher.statsRecord.numRaidsEnemy - lastRaidsEnemy; lastRaidsEnemy = raidsCount; int itemsCount = (int)itemsCountPerRaidCurve.Evaluate(raidsCount); float valueRange = startMarketValue + (marketValueMultiplierPerMapEvent * raidsCount); ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue(); ThingSetMakerParams parms = default; parms.totalMarketValueRange = new FloatRange(valueRange, valueRange); parms.countRange = new IntRange(itemsCount, itemsCount); parms.filter = DarkNetPriceUtils.GetThingFilter(def.AvaliableGoods); maker.fixedParams = parms; var items = maker.Generate(); stock = new List <SellableItemWithModif>(); foreach (var item in items) { int itemValue = (int)(item.MarketValue * Character.Greed); if (PriceModificatorUtils.TryGetPriceModificator(item, def, out PriceModificatorDef modificator)) { itemValue = (int)(itemValue * modificator.PriceModficator); DarkNetPriceUtils.FinalizeItem(item, modificator); } MinifiedThing minifiedThing = item as MinifiedThing; if (minifiedThing != null) { var quality = minifiedThing.InnerThing.TryGetComp <CompQuality>(); if (quality != null) { quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony); itemValue = (int)(itemValue * GetPriceMultiplierForQuality(quality.Quality)); } } else { var quality = item.TryGetComp <CompQuality>(); if (quality != null) { quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony); itemValue = (int)(itemValue * GetPriceMultiplierForQuality(quality.Quality)); } } stock.Add(new SellableItemWithModif(item, itemValue, modificator)); } if (raidsCount >= minRaidsCountToGeneralGood && Rand.Chance(generalGoodsChance)) { parms.totalMarketValueRange = new FloatRange(specialGoodMarketValue, specialGoodMarketValue); parms.countRange = new IntRange(1, 1); parms.filter = specialGoodsFilter; maker.fixedParams = parms; Thing generalGood = maker.Generate().FirstOrDefault(); if (generalGood != null) { goodOfTheWeek = new SellableItemWithModif(generalGood, (int)(generalGood.MarketValue * Character.Greed), null); } } }
public static List<Thing> generateThing(double valueBase, string resourceOfThing) { regen: List<Thing> things = new List<Thing>(); ThingSetMaker thingSetMaker = new ThingSetMaker_MarketValue(); ThingSetMakerParams param = new ThingSetMakerParams(); param.totalMarketValueRange = new FloatRange((float)(valueBase-300),(float)(valueBase+300)); param.filter = new ThingFilter(); param.techLevel = FactionColonies.getPlayerColonyFaction().def.techLevel; switch (resourceOfThing) { case "food": //food param.filter.SetAllow(ThingCategoryDefOf.FoodMeals, true); param.countRange = new IntRange(1, 1); break; case "weapons": //weapons param.filter.SetAllow(ThingCategoryDefOf.Weapons, true); param.qualityGenerator = QualityGenerator.Gift; param.totalMarketValueRange = new FloatRange((float)(valueBase - valueBase*.5), (float)(valueBase * 2)); param.countRange = new IntRange(1, 1); break; case "apparel": //apparel param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.qualityGenerator = QualityGenerator.Gift; param.totalMarketValueRange = new FloatRange((float)(valueBase - valueBase * .5), (float)(valueBase * 2)); param.countRange = new IntRange(1, 1); break; case "armor": //armor param.qualityGenerator = QualityGenerator.Gift; param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamed("ApparelArmor"), true); param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.countRange = new IntRange(1, 1); param.totalMarketValueRange = new FloatRange((float)(valueBase - valueBase * .5), (float)(valueBase*2)); break; case "animals": //animals thingSetMaker = new ThingSetMaker_Animal(); param.techLevel = TechLevel.Undefined; param.totalMarketValueRange = new FloatRange((float)(valueBase - valueBase * .5), (float)(valueBase * 1.5)); //param.countRange = new IntRange(1,4); break; case "logging": //Logging param.filter.SetAllow(ThingDefOf.WoodLog, true); param.countRange = new IntRange(1, 10); break; case "mining": //Mining param.filter.SetAllow(StuffCategoryDefOf.Metallic, true); param.filter.SetAllow(ThingDefOf.Silver, false); //Android shit? param.filter.SetAllow(DefDatabase<ThingDef>.GetNamedSilentFail("Teachmat"), false); //Remove RimBees Beeswax param.filter.SetAllow(DefDatabase<StuffCategoryDef>.GetNamedSilentFail("RB_Waxy"), false); //Remove Alpha Animals skysteel param.filter.SetAllow(DefDatabase<ThingDef>.GetNamedSilentFail("AA_SkySteel"), false); param.countRange = new IntRange(1, 10); break; case "drugs": //drugs param.filter.SetAllow(ThingCategoryDefOf.Drugs, true); param.countRange = new IntRange(1, 2); break; default: //log error Log.Message("This is an error. Report this to the dev. generateThing - nonexistent case"); Log.Message(resourceOfThing); break; } //Log.Message(resourceID.ToString()); //thingSetMaker.root things = thingSetMaker.Generate(param); if(PaymentUtil.returnValueOfTithe(things) < param.totalMarketValueRange.Value.min) { goto regen; } return things; }
public static List<Thing> generateTithe(double valueBase, double valueDiff, int multiplier, int resourceID, double traitValueMod ) { FactionFC faction = Find.World.GetComponent<FactionFC>(); List <Thing> things = new List<Thing>(); ThingSetMaker thingSetMaker = new ThingSetMaker_MarketValue(); ThingSetMakerParams param = new ThingSetMakerParams(); param.totalMarketValueRange = new FloatRange((float)((valueBase* LoadedModManager.GetMod<FactionColoniesMod>().GetSettings<FactionColonies>().silverPerResource )- ((valueDiff + traitValueMod) *multiplier)), (float)((valueBase * LoadedModManager.GetMod<FactionColoniesMod>().GetSettings<FactionColonies>().silverPerResource) + ((valueDiff + traitValueMod) * multiplier))); param.filter = new ThingFilter(); param.techLevel = FactionColonies.getPlayerColonyFaction().def.techLevel; switch (resourceID) { case 0: //food param.filter.SetAllow(ThingCategoryDefOf.FoodMeals, true); param.countRange = new IntRange(1, 5+multiplier); break; case 1: //weapons param.filter.SetAllow(ThingCategoryDefOf.Weapons, true); param.countRange = new IntRange(1, 4+(2*multiplier)); break; case 2: //apparel param.filter.SetAllow(ThingCategoryDefOf.Apparel, true); param.countRange = new IntRange(1, 4+ (3*multiplier)); break; case 3: //animals thingSetMaker = new ThingSetMaker_Animals(); param.techLevel = TechLevel.Undefined; //param.countRange = new IntRange(1,4); break; case 4: //Logging param.filter.SetAllow(ThingDefOf.WoodLog, true); param.countRange = new IntRange(1, 5*multiplier); break; case 5: //Mining param.filter.SetAllow(StuffCategoryDefOf.Metallic, true); param.filter.SetAllow(ThingDefOf.Silver, false); //Android shit? param.filter.SetAllow(DefDatabase<ThingDef>.GetNamedSilentFail("Teachmat"), false); //Remove RimBees Beeswax param.filter.SetAllow(DefDatabase<StuffCategoryDef>.GetNamedSilentFail("RB_Waxy"), false); //Remove Alpha Animals skysteel param.filter.SetAllow(DefDatabase<ThingDef>.GetNamedSilentFail("AA_SkySteel"), false); param.countRange = new IntRange(1, 4*multiplier); break; case 6: //research Log.Message("generateTithe - Research Tithe - How did you get here?"); break; case 7: //Power Log.Message("generateTithe - Power Tithe - How did you get here?"); break; case 8: //Medicine/Bionics param.filter.SetAllow(ThingCategoryDefOf.Medicine, true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsNatural"), true); switch (faction.techLevel) { case TechLevel.Archotech: case TechLevel.Ultra: param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsUltra"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsBionic"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsProsthetic"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsNatural"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BionicProstheses") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BionicProstheses"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("AdvancedProstheses") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("AdvancedProstheses"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("SyntheticOrgans") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("SyntheticOrgans"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("Neurotrainers") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("Neurotrainers"), true); break; case TechLevel.Spacer: param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsBionic"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsProsthetic"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsNatural"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BionicProstheses") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BionicProstheses"), true); if (DefDatabase<ThingCategoryDef>.GetNamedSilentFail("SyntheticOrgans") != null) param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("SyntheticOrgans"), true); break; case TechLevel.Industrial: param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsProsthetic"), true); param.filter.SetAllow(DefDatabase<ThingCategoryDef>.GetNamedSilentFail("BodyPartsNatural"), true); break; default: break; } param.countRange = new IntRange(1, 2 * multiplier); break; } //Log.Message(resourceID.ToString()); //thingSetMaker.root things = thingSetMaker.Generate(param); return things; }