private static bool TryFindMarriageSeeker(out Pawn marriageSeeker) => (from x in Find.WorldPawns.AllPawnsAlive where x.Faction != null && !x.Faction.def.hidden && !x.Faction.def.permanentEnemy && !x.Faction.IsPlayer && x.Faction.PlayerGoodwill <= 50 && !x.Faction.defeated && x.Faction.leader != null && !x.Faction.leader.IsPrisoner && !x.Faction.leader.Spawned && x.Faction.def.techLevel <= TechLevel.Medieval && !x.IsPrisoner && !x.Spawned && x.relations != null && x.RaceProps.Humanlike && !SettlementUtility.IsPlayerAttackingAnySettlementOf(faction : x.Faction) && !PeaceTalksExist(faction : x.Faction) && (!LovePartnerRelationUtility.HasAnyLovePartner(pawn : x) || LovePartnerRelationUtility.ExistingMostLikedLovePartner(p : x, allowDead : false)?.Faction == Faction.OfPlayer) select x).TryRandomElement(result : out marriageSeeker); //todo: make more likely to select hostile.
private bool IsGoodFaction(Faction faction, Slate slate) { if (faction.def.hidden && (this.allowedHiddenFactions.GetValue(slate) == null || !this.allowedHiddenFactions.GetValue(slate).Contains(faction))) { return(false); } if (this.ofPawn.GetValue(slate) != null && faction != this.ofPawn.GetValue(slate).Faction) { return(false); } if (this.exclude.GetValue(slate) != null && this.exclude.GetValue(slate).Contains(faction)) { return(false); } if (this.mustBePermanentEnemy.GetValue(slate) && !faction.def.permanentEnemy) { return(false); } if (!this.allowEnemy.GetValue(slate) && faction.HostileTo(Faction.OfPlayer)) { return(false); } if (!this.allowNeutral.GetValue(slate) && faction.PlayerRelationKind == FactionRelationKind.Neutral) { return(false); } if (!this.allowAlly.GetValue(slate) && faction.PlayerRelationKind == FactionRelationKind.Ally) { return(false); } if (!(this.allowPermanentEnemy.GetValue(slate) ?? true) && faction.def.permanentEnemy) { return(false); } if (this.playerCantBeAttackingCurrently.GetValue(slate) && SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)) { return(false); } if (this.peaceTalksCantExist.GetValue(slate)) { if (this.PeaceTalksExist(faction)) { return(false); } string tag = QuestNode_QuestUnique.GetProcessedTag("PeaceTalks", faction); if (Find.QuestManager.questsInDisplayOrder.Any((Quest q) => q.tags.Contains(tag))) { return(false); } } if (this.leaderMustBeSafe.GetValue(slate) && (faction.leader == null || faction.leader.Spawned || faction.leader.IsPrisoner)) { return(false); } Thing value = this.mustBeHostileToFactionOf.GetValue(slate); return(value == null || value.Faction == null || (value.Faction != faction && faction.HostileTo(value.Faction))); }
public bool TryAffectGoodwillWith(Faction other, int goodwillChange, bool canSendMessage = true, bool canSendHostilityLetter = true, string reason = null, GlobalTargetInfo?lookTarget = null) { if (this.def.hidden || other.def.hidden || this.def.permanentEnemy || other.def.permanentEnemy || this.defeated || other.defeated || other == this) { return(false); } if (goodwillChange > 0 && ((this.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(other)) || (other.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(this)))) { return(false); } if (goodwillChange == 0) { return(true); } int num = this.GoodwillWith(other); int num2 = Mathf.Clamp(num + goodwillChange, -100, 100); if (num == num2) { return(true); } FactionRelation factionRelation = this.RelationWith(other, false); factionRelation.goodwill = num2; bool flag; factionRelation.CheckKindThresholds(this, canSendHostilityLetter, reason, (!lookTarget.HasValue) ? GlobalTargetInfo.Invalid : lookTarget.Value, out flag); FactionRelation factionRelation2 = other.RelationWith(this, false); FactionRelationKind kind = factionRelation2.kind; factionRelation2.goodwill = factionRelation.goodwill; factionRelation2.kind = factionRelation.kind; bool flag2; if (kind != factionRelation2.kind) { other.Notify_RelationKindChanged(this, kind, canSendHostilityLetter, reason, (!lookTarget.HasValue) ? GlobalTargetInfo.Invalid : lookTarget.Value, out flag2); } else { flag2 = false; } if (canSendMessage && !flag && !flag2 && Current.ProgramState == ProgramState.Playing && (this.IsPlayer || other.IsPlayer)) { Faction faction = (!this.IsPlayer) ? this : other; string text; if (!reason.NullOrEmpty()) { text = "MessageGoodwillChangedWithReason".Translate(faction.name, num.ToString("F0"), factionRelation.goodwill.ToString("F0"), reason); } else { text = "MessageGoodwillChanged".Translate(faction.name, num.ToString("F0"), factionRelation.goodwill.ToString("F0")); } Messages.Message(text, (!lookTarget.HasValue) ? GlobalTargetInfo.Invalid : lookTarget.Value, ((float)goodwillChange <= 0f) ? MessageTypeDefOf.NegativeEvent : MessageTypeDefOf.PositiveEvent, true); } return(true); }
public bool CanChangeGoodwillFor(Faction other, int goodwillChange) { if (def.hidden || other.def.hidden || def.permanentEnemy || other.def.permanentEnemy || defeated || other.defeated || other == this || (def.permanentEnemyToEveryoneExceptPlayer && !other.IsPlayer) || (other.def.permanentEnemyToEveryoneExceptPlayer && !IsPlayer)) { return(false); } if (goodwillChange > 0 && ((IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(other)) || (other.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(this)))) { return(false); } return(true); }
public static DiaNode FactionDialogFor(Pawn negotiator, Faction faction) { Map map = negotiator.Map; FactionDialogMaker.negotiator = negotiator; FactionDialogMaker.faction = faction; string text = (faction.leader != null) ? faction.leader.Name.ToStringFull : faction.Name; if (faction.PlayerGoodwill < -70.0) { FactionDialogMaker.root = new DiaNode("FactionGreetingHostile".Translate(text)); } else if (faction.PlayerGoodwill < 40.0) { string text2 = "FactionGreetingWary".Translate(text, negotiator.LabelShort); text2 = text2.AdjustedFor(negotiator); FactionDialogMaker.root = new DiaNode(text2); if (!SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)) { FactionDialogMaker.root.options.Add(FactionDialogMaker.OfferGiftOption(negotiator.Map)); } if (!faction.HostileTo(Faction.OfPlayer) && negotiator.Spawned && negotiator.Map.IsPlayerHome) { FactionDialogMaker.root.options.Add(FactionDialogMaker.RequestTraderOption(map, 1100)); } } else { FactionDialogMaker.root = new DiaNode("FactionGreetingWarm".Translate(text, negotiator.LabelShort)); if (!SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)) { FactionDialogMaker.root.options.Add(FactionDialogMaker.OfferGiftOption(negotiator.Map)); } if (!faction.HostileTo(Faction.OfPlayer) && negotiator.Spawned && negotiator.Map.IsPlayerHome) { FactionDialogMaker.root.options.Add(FactionDialogMaker.RequestTraderOption(map, 700)); FactionDialogMaker.root.options.Add(FactionDialogMaker.RequestMilitaryAidOption(map)); } } if (Prefs.DevMode) { foreach (DiaOption item in FactionDialogMaker.DebugOptions()) { FactionDialogMaker.root.options.Add(item); } } DiaOption diaOption = new DiaOption("(" + "Disconnect".Translate() + ")"); diaOption.resolveTree = true; FactionDialogMaker.root.options.Add(diaOption); return(FactionDialogMaker.root); }
static bool Prerequirments(Faction faction, Faction other, float goodwillChange) { if (faction.def.hidden || other.def.hidden) { return(false); } if (goodwillChange > 0f && faction.def.permanentEnemy) { return(false); } if (goodwillChange > 0f && ((faction.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(other)) || (other.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)))) { return(false); } return(true); }
public bool AffectGoodwillWith(Faction other, float goodwillChange) { if (!this.def.hidden && !other.def.hidden) { if (goodwillChange > 0.0 && !this.def.appreciative) { return(false); } if (goodwillChange > 0.0) { if (this.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(other)) { goto IL_0076; } if (other.IsPlayer && SettlementUtility.IsPlayerAttackingAnySettlementOf(this)) { goto IL_0076; } } float num = this.GoodwillWith(other); float value = num + goodwillChange; FactionRelation factionRelation = this.RelationWith(other, false); factionRelation.goodwill = Mathf.Clamp(value, -100f, 100f); if (!this.HostileTo(other) && this.GoodwillWith(other) < -80.0) { this.SetHostileTo(other, true); if (Current.ProgramState == ProgramState.Playing && Find.TickManager.TicksGame > 100 && other == Faction.OfPlayer) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChangeBad".Translate(), "RelationsBrokenDown".Translate(this.name), LetterDefOf.NegativeEvent, (string)null); } } if (this.HostileTo(other) && this.GoodwillWith(other) > 0.0) { this.SetHostileTo(other, false); if (Current.ProgramState == ProgramState.Playing && Find.TickManager.TicksGame > 100 && other == Faction.OfPlayer) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChangeGood".Translate(), "RelationsWarmed".Translate(this.name), LetterDefOf.PositiveEvent, (string)null); } } return((this.IsPlayer || other.IsPlayer) && !this.HostileTo(other) && this.def.appreciative && (goodwillChange > 0.0 || factionRelation.goodwill != num)); } return(false); IL_0076: return(false); }
public static DiaNode FactionDialogFor(Pawn negotiator, Faction faction) { var map = negotiator.Map; JecsToolsFactionDialogMaker.negotiator = negotiator; JecsToolsFactionDialogMaker.faction = faction; var text = (faction.leader != null) ? faction.leader.Name.ToStringFull : faction.Name; var factionSettings = faction?.def?.GetModExtension <FactionSettings>(); var greetingHostileKey = factionSettings?.greetingHostileKey ?? "FactionGreetingHostile"; var greetingWaryKey = factionSettings?.greetingWaryKey ?? "FactionGreetingWary"; var greetingWarmKey = factionSettings?.greetingWarmKey ?? "FactionGreetingWarm"; var waryMinimum = factionSettings?.waryMinimumRelations ?? -70f; var warmMinimum = factionSettings?.warmMinimumRelations ?? 40f; var greetingHostile = greetingHostileKey.Translate(text); var greetingWary = greetingWaryKey.Translate(new object[] { text, negotiator.LabelShort }); var greetingWarm = greetingWarmKey.Translate(new object[] { text, negotiator.LabelShort }); if (faction.PlayerGoodwill < waryMinimum) { root = new DiaNode(greetingHostile); if (!SettlementUtility.IsPlayerAttackingAnySettlementOf(faction) && negotiator.Spawned && negotiator.Map.IsPlayerHome) { root.options.Add(PeaceTalksOption(faction, negotiator.Map)); } } else { if (faction.PlayerGoodwill < warmMinimum) { greetingWary = greetingWary.AdjustedFor(negotiator); root = new DiaNode(greetingWary); if (!SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)) { root.options.Add(OfferGiftOption(negotiator.Map)); } if (!faction.HostileTo(Faction.OfPlayer) && negotiator.Spawned && negotiator.Map.IsPlayerHome) { root.options.Add(RequestTraderOption(map, 1100)); } } else { root = new DiaNode(greetingWarm); if (!SettlementUtility.IsPlayerAttackingAnySettlementOf(faction)) { root.options.Add(OfferGiftOption(negotiator.Map)); } if (!faction.HostileTo(Faction.OfPlayer) && negotiator.Spawned && negotiator.Map.IsPlayerHome) { root.options.Add(RequestTraderOption(map, 700)); root.options.Add(RequestMilitaryAidOption(map)); } } } if (Prefs.DevMode) { foreach (var item in DebugOptions()) { root.options.Add(item); } } var diaOption = new DiaOption("(" + "Disconnect".Translate() + ")"); diaOption.resolveTree = true; root.options.Add(diaOption); return(root); }
private bool TryFindFaction(out Faction faction) { return((from x in Find.FactionManager.AllFactions where !x.def.hidden && !x.def.permanentEnemy && !x.IsPlayer && !x.defeated && !SettlementUtility.IsPlayerAttackingAnySettlementOf(x) select x).TryRandomElement(out faction)); }
private bool TryFindFaction(out Faction faction) { return((from x in Find.FactionManager.AllFactions where !x.def.hidden && !x.def.permanentEnemy && !x.IsPlayer && x.HostileTo(Faction.OfPlayer) && !x.defeated && !SettlementUtility.IsPlayerAttackingAnySettlementOf(x) && !PeaceTalksExist(x) && x.leader != null && !x.leader.IsPrisoner && !x.leader.Spawned select x).TryRandomElement(out faction)); }
private bool TryFindFaction(out Faction faction) { return((from x in Find.FactionManager.AllFactions where !x.def.hidden && x.def.appreciative && !x.IsPlayer && x.HostileTo(Faction.OfPlayer) && !x.defeated && !SettlementUtility.IsPlayerAttackingAnySettlementOf(x) && !this.PeaceTalksExist(x) select x).TryRandomElement <Faction>(out faction)); }
private bool <TryFindFaction> m__0(Faction x) { return(!x.def.hidden && !x.def.permanentEnemy && !x.IsPlayer && x.HostileTo(Faction.OfPlayer) && !x.defeated && !SettlementUtility.IsPlayerAttackingAnySettlementOf(x) && !this.PeaceTalksExist(x) && x.leader != null && !x.leader.IsPrisoner && !x.leader.Spawned); }