Exemplo n.º 1
0
 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.
Exemplo n.º 2
0
 public static void AttackNow_SettlementReinforcement_Postfix(SettlementUtility __instance, Caravan caravan, RimWorld.Planet.Settlement settlement)
 {
     RimWar.Planet.Settlement rwSettlement = WorldUtility.GetRimWarSettlementAtTile(settlement.Tile);
     if (rwSettlement != null && rwSettlement.RimWarPoints > 1050)
     {
         WorldUtility.CreateWarband((rwSettlement.RimWarPoints - 1000), WorldUtility.GetRimWarDataForFaction(rwSettlement.Faction), rwSettlement, rwSettlement.Tile, rwSettlement.Tile, WorldObjectDefOf.Settlement);
     }
 }
Exemplo n.º 3
0
        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)));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        private static void SendAttackLetter(Caravan caravan, Settlement settlement)
        {
            TaggedString letterLabel = "LetterLabelCaravanEnteredEnemyBase".Translate();
            TaggedString letterText  = "LetterCaravanEnteredEnemyBase".Translate(caravan.Label, settlement.Label.ApplyTag(TagType.Settlement, settlement.Faction.GetUniqueLoadID())).CapitalizeFirst();

            SettlementUtility.AffectRelationsOnAttacked(settlement, ref letterText);
            if (settlement.HasMap)
            {
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(settlement.Map.mapPawns.AllPawns, ref letterLabel, ref letterText, "LetterRelatedPawnsSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), true);
            }
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NeutralEvent, caravan.PawnsListForReading, settlement.Faction, null, null, null);
        }
Exemplo n.º 6
0
 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);
        }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
        public override void Arrived(List <ActiveDropPodInfo> pods, int tile)
        {
            Thing        lookTarget    = ByakheeArrivalActionUtility.GetLookTarget(pods);
            bool         flag          = !this.settlement.HasMap;
            Map          orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(this.settlement.Tile, null);
            TaggedString label         = "LetterLabelCaravanEnteredEnemyBase".Translate();
            TaggedString text          = "LetterTransportPodsLandedInEnemyBase".Translate(this.settlement.Label).CapitalizeFirst();

            SettlementUtility.AffectRelationsOnAttacked(this.settlement, ref text);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(orGenerateMap.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
            }
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, lookTarget, this.settlement.Faction, null, null, null);
            this.arrivalMode.Worker.TravelingTransportPodsArrived(pods, orGenerateMap);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public override void Arrived(int tile)
 {
     LongEventHandler.QueueLongEvent(delegate()
     {
         Map map            = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null);
         TaggedString label = "LetterLabelCaravanEnteredEnemyBase".Translate();
         TaggedString text  = "LetterTransportPodsLandedInEnemyBase".Translate(settlement.Label).CapitalizeFirst();
         SettlementUtility.AffectRelationsOnAttacked(settlement, ref text);
         if (!settlement.HasMap)
         {
             Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
             PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(map.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
         }
         Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, vehicle, settlement.Faction, null, null, null);
         AerialVehicleInFlight aerialVehicle = vehicle.GetAerialVehicle();
         arrivalModeDef.Worker.VehicleArrived(aerialVehicle, launchProtocol, settlement.Map);
         aerialVehicle.Destroy();
     }, "GeneratingMap", false, null, true);
 }
Exemplo n.º 12
0
 public void GenerateMapForRecon(int tile)
 {
     if (flightPath.InRecon && Find.WorldObjects.MapParentAt(tile) is MapParent mapParent && !mapParent.HasMap)
     {
         LongEventHandler.QueueLongEvent(delegate()
         {
             Map map            = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null);
             TaggedString label = "LetterLabelCaravanEnteredEnemyBase".Translate();
             TaggedString text  = "LetterTransportPodsLandedInEnemyBase".Translate(mapParent.Label).CapitalizeFirst();
             if (mapParent is Settlement settlement)
             {
                 SettlementUtility.AffectRelationsOnAttacked(settlement, ref text);
             }
             if (!mapParent.HasMap)
             {
                 Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                 PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(map.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
             }
             Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, vehicle, mapParent.Faction, null, null, null);
             Current.Game.CurrentMap = map;
             CameraJumper.TryHideWorld();
         }, "GeneratingMap", false, null, true);
     }
 }
        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));
 }
Exemplo n.º 15
0
 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);
 }