public virtual void GiveSoldThingToPlayer(Thing toGive, int countToGive, Pawn playerNegotiator) { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerBuys, playerNegotiator, this); TradeUtility.SpawnDropPod(DropCellFinder.TradeDropSpot(Find.CurrentMap), Find.CurrentMap, thing); }
public override void TryExecute() { ThingDef itemDef = ThingDef.Named("DropPodIncoming"); Thing itemThing = new Thing(); ThingDef stuff = null; ThingDef itemThingDef = ThingDef.Named(item.defname); if (itemThingDef.race != null) { TryExecuteAnimal(itemThingDef, quantity); return; } if (itemThingDef.MadeFromStuff) { if (!(from x in GenStuff.AllowedStuffsFor(itemThingDef, TechLevel.Undefined) where !PawnWeaponGenerator.IsDerpWeapon(itemThingDef, x) select x).TryRandomElementByWeight((ThingDef x) => x.stuffProps.commonality, out stuff)) { stuff = GenStuff.RandomStuffByCommonalityFor(itemThingDef, TechLevel.Undefined); } } itemThing = ThingMaker.MakeThing(itemThingDef, (stuff != null) ? stuff : null); QualityCategory q = new QualityCategory(); if (itemThing.TryGetQuality(out q)) { ItemHelper.setItemQualityRandom(itemThing); } Map map = Helper.AnyPlayerMap; IntVec3 vec = DropCellFinder.TradeDropSpot(map); if (itemThingDef.Minifiable) { itemThingDef = itemThingDef.minifiedDef; MinifiedThing minifiedThing = (MinifiedThing)ThingMaker.MakeThing(itemThingDef, null); minifiedThing.InnerThing = itemThing; minifiedThing.stackCount = quantity; TradeUtility.SpawnDropPod(vec, map, minifiedThing); } else { itemThing.stackCount = quantity; TradeUtility.SpawnDropPod(vec, map, itemThing); } string letter = Helper.ReplacePlaceholder("TwitchStoriesDescription80".Translate(), from: Viewer.username, amount: quantity.ToString(), item: item.abr.CapitalizeFirst()); LetterDef letterDef = ItemHelper.GetLetterFromValue(price); Find.LetterStack.ReceiveLetter(item.abr.Truncate(15, true).CapitalizeFirst(), letter, letterDef, new TargetInfo(vec, map, false)); EndCarePackage(); }
public override void DoWindowContents(Rect inRect) { Listing_Standard listingStandard = new Listing_Standard(); listingStandard.Begin(inRect); listingStandard.Label("RansomBargain".Translate(this.prisoner.Name.ToStringFull, this.prisoner.Faction.Name)); listingStandard.Gap(); listingStandard.Gap(); listingStandard.Gap(); listingStandard.Label(label: $"RansomDemandAmount".Translate(RansomSettings.MarketValuePercentage(this.prisoner, this.percentage).ToString(CultureInfo.CurrentCulture), ThingDefOf.Silver.LabelCap)); this.percentage = listingStandard.Slider(this.percentage, -50f, 50f); listingStandard.Gap(); listingStandard.Label(label: $"RansomDemandChance".Translate(Mathf.RoundToInt(RansomSettings.RansomChance(this.prisoner, this.handler, this.percentage) * 100).ToString(CultureInfo.CurrentCulture))); if (listingStandard.ButtonText("RansomSendOffer".Translate())) { Faction faction = this.prisoner.Faction; if (Rand.Value < RansomSettings.RansomChance(this.prisoner, this.handler, this.percentage)) { Messages.Message(text: "RansomFactionDeliveredMessage".Translate(), def: MessageTypeDefOf.PositiveEvent); Thing silver = ThingMaker.MakeThing(def: ThingDefOf.Silver); silver.stackCount = RansomSettings.MarketValuePercentage(this.prisoner, this.percentage); TradeUtility.SpawnDropPod(dropSpot: DropCellFinder.TradeDropSpot(map: this.prisoner.Map), map: this.prisoner.Map, t: silver); if (this.prisoner.Spawned) { GenGuest.PrisonerRelease(p: this.prisoner); this.prisoner.DeSpawn(); } //TaleRecorder.RecordTale(TaleDefOf.SoldPrisoner, this.handler, this.prisoner); //faction.TryAffectGoodwillWith(other: Faction.OfPlayer, RansomSettings.settings.ransomGoodwill); Find.WindowStack.Add(new Dialog_MessageBox("RansomPrisonerSend".Translate())); } else { Find.WindowStack.Add(new Dialog_MessageBox("RansomNotAccepted".Translate())); //faction.TryAffectGoodwillWith(other: Faction.OfPlayer, goodwillChange: RansomSettings.settings.ransomGoodwillFail); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, this.prisoner.Map); incidentParms.faction = faction; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + RansomSettings.settings.ransomRaidDelay, incidentParms, RansomSettings.settings.ransomRaidDelay); } this.Close(); } if (listingStandard.ButtonText("Back".Translate())) { this.Close(); } }
public static IntVec3 Rain(ThingDef thingDef, Thing thing) { IntVec3 intVec; if (!GetRandomVec3(thingDef, Helper.AnyPlayerMap, out intVec, 5)) { return(intVec); } Map any = Helper.AnyPlayerMap; intVec = DropCellFinder.TradeDropSpot(any); TradeUtility.SpawnDropPod(intVec, any, thing); return(intVec); }
public static void SpawnItem(IntVec3 position, Map map, Thing item) { var hatcher = item.TryGetComp <CompHatcher>(); if (hatcher != null) { hatcher.hatcheeFaction = Faction.OfPlayer; } if (Current.Game.GetComponent <Coordinator>()?.TrySpawnItem(map, item) == true) { return; } TradeUtility.SpawnDropPod(position, map, item); }
public void GiveSoldThingToPlayer(Thing toGive, int countToGive, Pawn playerNegotiator) { if (toGive as Pawn != null) { Log.Error("Slave trade with a remnant colony is not supported!"); return; } if (playerNegotiator.Map == null) { Log.Error("Trade with a remnant colony is expected to take place via a com console and not via caravans!"); return; } Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerBuys, playerNegotiator, this); TradeUtility.SpawnDropPod(DropCellFinder.TradeDropSpot(playerNegotiator.Map), playerNegotiator.Map, thing); }
// Token: 0x06000038 RID: 56 RVA: 0x00003318 File Offset: 0x00001518 protected override bool TryExecuteWorker(IncidentParms parms) { ThingSetMakerParams parms2 = default; parms2.techLevel = new TechLevel?(parms.faction.def.techLevel); parms2.countRange = new IntRange?(new IntRange(1, 4)); parms2.totalMarketValueRange = new FloatRange?(new FloatRange(parms.points, parms.points)); parms2.podContentsType = new PodContentsType?(PodContentsType.Empty); List <Thing> list = ThingSetMakerDefOf.VisitorGift.root.Generate(parms2); var map = parms.target as Map; for (var i = 0; i < list.Count; i++) { TradeUtility.SpawnDropPod(DropCellFinder.TradeDropSpot(map), map, list[i]); } Messages.Message(TranslatorFormattedStringExtensions.Translate("RAZ_MessagePaymentArrived", parms.faction.Name), MessageTypeDefOf.PositiveEvent, true); return(true); }
public static IntVec3 Rain(ThingDef thingDef, MinifiedThing thing) { IntVec3 intVec; if (!GetRandomVec3(thingDef, Helper.AnyPlayerMap, out intVec, 5)) { return(intVec); } //SkyfallerMaker.SpawnSkyfaller(thingDef, new List<Thing> { thing }, intVec, Helper.AnyPlayerMap); //DropPodUtility.DropThingsNear(intVec, Helper.AnyPlayerMap, new List<Thing> { thing }, 110, false, true, true); Map any = Helper.AnyPlayerMap; intVec = DropCellFinder.TradeDropSpot(any); TradeUtility.SpawnDropPod(intVec, any, thing); return(intVec); }
public static void createDropFromDef(ThingDef thingDef, int amount, string title, string desc, bool showMessage = true, ThingDef stuff = null) { Thing newthing = ThingMaker.MakeThing(thingDef, stuff ?? null); newthing.stackCount = amount; newthing.SetForbidden(true); if (newthing != null) { var currentMap = Find.CurrentMap; IntVec3 dropVector = DropCellFinder.TradeDropSpot(Find.CurrentMap); TradeUtility.SpawnDropPod(dropVector, currentMap, newthing); if (showMessage) { string messageString = "RimConnectionPositiveDroppodMailBody".Translate(amount, title, desc); AlertManager.ResourceDropNotification(messageString, dropVector); } } }
public void DropPods() { List <Thing> thingsToDrop = new List <Thing>(); foreach (ThingDefCountClass tdcc in dropThings) { int numToDrop = tdcc.count; int stackSize = tdcc.thingDef.stackLimit; Rand.PushState(Find.TickManager.TicksAbs); //for MP compat, thanks Pelador while (numToDrop > 0) { Thing thing = ThingMaker.MakeThing(tdcc.thingDef); int rand = Rand.RangeInclusive(stackSize / 2, stackSize); thing.stackCount = rand > numToDrop ? numToDrop : rand; thingsToDrop.Add(thing); numToDrop -= rand; } Rand.PopState(); } Map toSendTo; if ((toSendTo = Find.AnyPlayerHomeMap) != null) { IntVec3 spot = DropCellFinder.TradeDropSpot(toSendTo); foreach (Thing t in thingsToDrop) { TradeUtility.SpawnDropPod(spot, toSendTo, t); } } else { Log.Warning("[ChickenScenParts] Provisioner couldn't find a player home map. This isn't necessarily a problem."); } if (!SentFirstLetter) { Find.LetterStack.ReceiveLetter(startLetterLabelKey.Translate(), startLetterTextKey.Translate(Faction.OfPlayer.def.LabelCap), StartLetterDef); SentFirstLetter = true; } else { Messages.Message(dropMessageKey.Translate(Faction.OfPlayer.def.LabelCap), MessageTypeDefOf.PositiveEvent); } }
public override void Execute(int amount, string boughtBy) { var amountOfDrops = 20; var currentMap = Find.CurrentMap; var pawnGenerationRequest = new PawnGenerationRequest(PawnKindDefOf.Colonist, allowDead: true); for (int i = 0; i < amountOfDrops; i++) { var newPawn = PawnGenerator.GeneratePawn(pawnGenerationRequest); IntVec3 dropVector = DropCellFinder.TradeDropSpot(currentMap); TradeUtility.SpawnDropPod(dropVector, currentMap, newPawn); HealthUtility.DamageUntilDead(newPawn); newPawn.equipment.DestroyAllEquipment(); newPawn.apparel.DestroyAll(); } AlertManager.NormalEventNotification("It's Raining men, hallelujah!"); }
public override void DoEffect(Pawn user) { if (Props.thingDef == null) { return; } IntVec3 dropSpot; Thing thing = ThingMaker.MakeThing(Props.thingDef); if (thing != null) { if (Props.amount > 0) { thing.stackCount = Props.amount; } if (thing != null && DropCellFinder.TryFindDropSpotNear(parent.PositionHeld, parent.MapHeld, out dropSpot, false, false, false)) { TradeUtility.SpawnDropPod(dropSpot, parent.MapHeld, thing); } } }
static void Postfix(Thing toGive, int countToGive, Pawn playerNegotiator) { if (!ZTribbleSettings.flagTradeship) { return; } if (Rand.Chance(0.9f)) { return; } Map map = playerNegotiator.Map; IntVec3 loc = DropCellFinder.TradeDropSpot(map); PawnKindDef tribbleKind = PawnKindDef.Named("ZTrib_Tribble"); Pawn tribble = PawnGenerator.GeneratePawn(tribbleKind); // spawn extra drop pod containing tribble TradeUtility.SpawnDropPod(loc, map, tribble); TribbleUtility.ResetInterval(map); }
public override bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith(c => map.reachability.CanReachColony(c), map, out spawnSpot)) { return(false); } #region CHANGED Func <Pawn, bool> selector = other => other.RaceProps.Humanlike && other.Faction != null && other.Faction.HostileTo(Faction.OfPlayer) && HasGroupMakers(other.Faction); Pawn refugee = GenericUtility.GetAnyRelatedWorldPawn(selector, 100); if (refugee == null) { // Just ANYONE Find.WorldPawns.AllPawnsAlive.Where(selector).TryRandomElement(out refugee); } if (refugee == null) { return(false); } refugee.relations.everSeenByPlayer = true; Faction enemyFac = refugee.Faction; string text = "RefugeeChasedInitial".Translate(new object[] { refugee.Name.ToStringFull, refugee.GetTitle().ToLower(), enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears }); text = text.AdjustedFor(refugee); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate()); diaOption.action = delegate { if (refugee == enemyFac.leader) { enemyFac.GenerateNewLeader(); } Find.WorldPawns.RemovePawn(refugee); var canDrop = enemyFac.def.techLevel >= TechLevel.Spacer; if (canDrop) { spawnSpot = DropCellFinder.TradeDropSpot(map); TradeUtility.SpawnDropPod(spawnSpot, map, refugee); } else { GenSpawn.Spawn(refugee, spawnSpot, map); } refugee.SetFaction(Faction.OfPlayer); Find.CameraDriver.JumpTo(spawnSpot); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, map); incidentParms.forced = true; incidentParms.faction = enemyFac; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = canDrop ? PawnsArriveMode.CenterDrop : PawnsArriveMode.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= RaidPointsFactor; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "RefugeeChasedRejected".Translate(new object[] { refugee.NameStringShort }); DiaNode diaNode2 = new DiaNode(text2); DiaOption diaOption2 = new DiaOption("OK".Translate()); diaOption2.resolveTree = true; diaNode2.options.Add(diaOption2); DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate()); diaOption3.action = delegate { HealthUtility.GiveInjuriesToKill(refugee); //Log.Message(refugee.Name + " dead? " + refugee.Dead); //Find.WorldPawns.PassToWorld(refugee,PawnDiscardDecideMode.Discard); }; #endregion diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true)); return(true); }