예제 #1
0
        public static DiaOption RequestFactionInfoOption(Faction faction, Pawn negotiator)
        {
            DiaOption diaOption1 = new DiaOption("FactionInfo".Translate());

            int     disposition = Utilities.FactionsWar().GetByFaction(faction).disposition;
            DiaNode diaNode1    = new DiaNode("FactionChose".Translate(disposition == 0 ? "FactionNeutral".Translate() : disposition > 0 ? (disposition > 4 ? "FactionGenocidal".Translate() : "FactionWarlike".Translate()) : disposition < -4 ? "FactionPacifistic".Translate() : "FactionPeacelike".Translate()) + (Prefs.DevMode ? " (Debug): (" + disposition + ")\n" : "\n") + "FactionDispositionInfo".Translate() + "FactionResourcesInfo".Translate(faction, Math.Floor(Utilities.FactionsWar().GetByFaction(faction).resources / Utilities.FactionsWar().MaxResourcesForFaction(faction) * 100)) + (Prefs.DevMode ? (" (DevMode) resources:" + Utilities.FactionsWar().GetByFaction(faction).resources) + ", Total Capacity: " + Utilities.FactionsWar().MaxResourcesForFaction(faction) : ""));

            // Faction History
            if (EndGame_Settings.FactionHistory)
            {
                DiaNode diaNode2 = new DiaNode((Utilities.FactionsWar().GetByFaction(faction).ancientHistory).CapitalizeFirst() + (Utilities.FactionsWar().GetByFaction(faction).history).CapitalizeFirst());

                diaNode1.options.Add(new DiaOption("FactionHistory".Translate())
                {
                    link = diaNode2
                });

                diaNode2.options.Add(new DiaOption("GoBack".Translate())
                {
                    link = diaNode1
                });
            }

            RequestVassalOptions(faction, diaNode1);

            diaNode1.options.Add(new DiaOption("GoBack".Translate())
            {
                linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction)
            });

            diaOption1.link = diaNode1;
            return(diaOption1);
        }
            public static bool Replacement(ref DiaOption __result, Map map)
            {
                int cost = GetCost(Hospitality_MapComponent.Instance(map).GetBribeCount(faction));
                //Log.Message(faction.name + ": " + Hospitality_MapComponent.Instance.GetBribeCount(faction) + " = " + cost);
                int silver = TradeUtility.AllLaunchableThings(map).Where(t => t.def == ThingDefOf.Silver).Sum(t => t.stackCount);

                if (silver < cost)
                {
                    var diaOption = new DiaOption("OfferGift".Translate());
                    diaOption.Disable("NeedSilverLaunchable".Translate(cost));
                    __result = diaOption;
                    return(false);
                }
                float goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.GiftImpact);
                var   diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(cost, goodwillDelta.ToString("#####0")) + ")");

                diaOption2.action = delegate {
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, cost, map, null);
                    faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta);
                    Hospitality_MapComponent.Instance(map).Bribe(faction);
                };
                string text = "SilverGiftSent".Translate(faction.leader.LabelIndefinite(), Mathf.RoundToInt(goodwillDelta)).CapitalizeFirst();

                diaOption2.link = new DiaNode(text)
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction)
                        }
                    }
                };
                __result = diaOption2;
                return(false);
            }
예제 #3
0
 public static Func <DiaNode> ResetToRoot(Faction faction, Pawn negotiator)
 {
     return(() => FactionDialogMaker.FactionDialogFor(negotiator, faction));
 }
예제 #4
0
        static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result)
        {
            TaggedString requestIntelString = "RequestIntel".Translate();

            // Cannot use if pawn has Social disabled
            if (negotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                DiaOption failSkill = new DiaOption(requestIntelString);
                failSkill.Disable("WorkTypeDisablesOption".Translate(SkillDefOf.Social.label));
                __result.options.Insert(__result.options.Count - 1, failSkill);
                return;
            }

            // Cannot use if not ally
            if (faction.PlayerRelationKind != FactionRelationKind.Ally)
            {
                DiaOption failAlly = new DiaOption(requestIntelString);
                failAlly.Disable("MustBeAlly".Translate());
                __result.options.Insert(__result.options.Count - 1, failAlly);
                return;
            }

            // Cannot use if too soon (TODO: separate variable)
            int num = faction.lastTraderRequestTick + 240000 - Find.TickManager.TicksGame;

            if (num > 0)
            {
                DiaOption failTime = new DiaOption(requestIntelString);
                failTime.Disable("WaitTime".Translate(num.ToStringTicksToPeriod()));
                __result.options.Insert(__result.options.Count - 1, failTime);
                return;
            }

            bool VFE_Vikings  = LoadedModManager.RunningModsListForReading.Any(x => x.PackageId == "oskarpotocki.vfe.vikings");
            bool VFE_Settlers = LoadedModManager.RunningModsListForReading.Any(x => x.PackageId == "oskarpotocki.vanillafactionsexpanded.settlersmodule");
            bool VFE_Medieval = LoadedModManager.RunningModsListForReading.Any(x => x.PackageId == "oskarpotocki.vanillafactionsexpanded.medievalmodule");
            bool GoExplore    = LoadedModManager.RunningModsListForReading.Any(x => x.PackageId == "albion.goexplore");
            bool IsVikingClan = VFE_Vikings && (faction.def.defName == "VFE_VikingsClan" || faction.def.defName == "VFE_VikingsSlaver");
            bool IsSettlers   = VFE_Settlers && (faction.def.defName == "SettlerCivil" || faction.def.defName == "SettlerRough");

            DiaOption diaOption = new DiaOption(requestIntelString);

            DiaNode nodeSent = new DiaNode("IntelSent".Translate(faction.leader).CapitalizeFirst());

            nodeSent.options.Add(new DiaOption("OK".Translate())
            {
                linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction)
            });

            DiaNode nodeChoose = new DiaNode("ChooseIntelKind".Translate(faction.leader).CapitalizeFirst());

            diaOption.link = nodeChoose;

            // Vikings will give you hunt quests
            if (IsVikingClan)
            {
                DiaOption optionHunt = new DiaOption("IntelKindHunt".Translate(10));
                optionHunt.link   = nodeSent;
                optionHunt.action = delegate
                {
                    GenerateIntelQuest(faction, VikingHunts[Rand.Range(0, VikingHunts.Length)], 10);
                };
                nodeChoose.options.Add(optionHunt);
            }

            // Settlers will give you bounties
            if (IsSettlers)
            {
                DiaOption optionBounty = new DiaOption("IntelKindBounty".Translate(10));
                optionBounty.link   = nodeSent;
                optionBounty.action = delegate
                {
                    GenerateIntelQuest(faction, "Settlers_Wanted", 10);
                };
                nodeChoose.options.Add(optionBounty);
            }

            // Combat quests
            DiaOption optionCombat = new DiaOption("IntelKindCombat".Translate(10));

            optionCombat.link   = nodeSent;
            optionCombat.action = delegate
            {
                List <WeightedIntel> list = new List <WeightedIntel>();
                list.Add(new WeightedIntel(100, delegate
                {
                    GenerateIntelQuest(faction, "OpportunitySite_BanditCamp", 10);
                }));

                if (VFE_Settlers)
                {
                    list.Add(new WeightedIntel(50, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "Settlers_CaravanRaid", parm, 10);
                    }));
                }

                if (GoExplore)
                {
                    list.Add(new WeightedIntel(50, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "PrisonCampLGE", parm, 10);
                    }));
                }

                WeightedIntel.Choose(list, faction);
            };
            nodeChoose.options.Add(optionCombat);

            DiaOption optionTrade = new DiaOption("IntelKindTrade".Translate(15));

            optionTrade.link   = nodeSent;
            optionTrade.action = delegate
            {
                GenerateIntelQuest(faction, "TradeRequest", 15);
            };
            nodeChoose.options.Add(optionTrade);

            DiaOption optionPlace = new DiaOption("IntelKindPlace".Translate(15));

            optionPlace.link   = nodeSent;
            optionPlace.action = delegate
            {
                List <WeightedIntel> list = new List <WeightedIntel>();

                list.Add(new WeightedIntel(100, delegate
                {
                    GenerateIntelQuest(faction, "OpportunitySite_ItemStash", 15);
                }));

                if (VFE_Vikings)
                {
                    if (!IsVikingClan)
                    {
                        list.Add(new WeightedIntel(5, delegate
                        {
                            GenerateIntelQuest(faction, "VFEV_OpportunitySite_LegendaryGrave", 15);
                        }));
                    }
                    list.Add(new WeightedIntel(10, delegate
                    {
                        GenerateIntelQuest(faction, "VFEV_OpportunitySite_AncientRuin", 15);
                    }));
                }

                if (VFE_Medieval)
                {
                    list.Add(new WeightedIntel(5, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "VFEM_Quest_MedievalTournament", parm, 15);
                    }));

                    list.Add(new WeightedIntel(30, delegate
                    {
                        GenerateIntelQuest(faction, "VFEV_OpportunitySite_CastleRuins", 15);
                    }));
                }

                if (GoExplore)
                {
                    list.Add(new WeightedIntel(10, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "LostCityLGE", parm, 15);
                    }));

                    list.Add(new WeightedIntel(15, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "AmbrosiaAnimalsLGE", parm, 15);
                    }));

                    list.Add(new WeightedIntel(2, delegate
                    {
                        IncidentParms parm = new IncidentParms();
                        GenerateIntelIncident(faction, "ShipCoreStartupLGE", parm, 15);
                    }));
                }

                WeightedIntel.Choose(list, faction);
            };
            nodeChoose.options.Add(optionPlace);

            DiaOption optionPawn = new DiaOption("IntelKindPawn".Translate(25));

            optionPawn.link   = nodeSent;
            optionPawn.action = delegate
            {
                List <WeightedIntel> list = new List <WeightedIntel>();

                list.Add(new WeightedIntel(100, delegate
                {
                    GenerateIntelQuest(faction, "OpportunitySite_DownedRefugee", 25);
                }));

                list.Add(new WeightedIntel(25, delegate
                {
                    GenerateIntelQuest(faction, "ThreatReward_Raid_Joiner", 25);
                }));

                if (VFE_Vikings && !IsVikingClan)
                {
                    list.Add(new WeightedIntel(25, delegate
                    {
                        GenerateIntelQuest(faction, "VFEV_ThreatReward_Raid_SlavesJoiner", 25);
                    }));
                }

                WeightedIntel.Choose(list, faction);
            };
            nodeChoose.options.Add(optionPawn);

            DiaOption optionBack = new DiaOption("GoBack".Translate());

            optionBack.linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction);
            nodeChoose.options.Add(optionBack);

            // Insert before the last disconnect option
            __result.options.Insert(__result.options.Count - 1, diaOption);
        }
예제 #5
0
        private void DrawInteractionButtons(Rect rect)
        {
            Text.Anchor = TextAnchor.MiddleCenter;

            Rect startRect = rect;

            startRect.height = Mathf.Max(25, Text.CalcHeight("CallOnRadio".Translate(currentFaction.Faction.Name), startRect.width));
            if (DrawCustomButton(startRect, "CallOnRadio".Translate(currentFaction.Faction.Name), Color.white))
            {
                Dialog_Negotiation dialog_Negotiation = new Dialog_Negotiation(speaker, currentFaction.Faction, FactionDialogMaker.FactionDialogFor(speaker, currentFaction.Faction), radioMode: true);
                dialog_Negotiation.soundAmbient = SoundDefOf.RadioComms_Ambience;
                Find.WindowStack.Add(dialog_Negotiation);
            }

            startRect.y     += startRect.height + 5;
            startRect.height = 25;
            foreach (var option in currentFaction.Options.OrderBy(o => o.SortOrder))
            {
                if (option.Enabled)
                {
                    if (DrawCustomButton(startRect, option.Label, option.TextColor))
                    {
                        option.DoAction(currentFaction, speaker, defendant);
                    }
                    startRect.y += 30;
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
        }