Пример #1
0
        public static DiaNode RemedyDetail(Action successAction)
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;
            InterceptedIncident_HumanCrowd_RaidEnemy incident = caravan.incident as InterceptedIncident_HumanCrowd_RaidEnemy;
            RaidingGoal goal = incident.goal;

            if (incident == null)
            {
                return(null);
            }
            if (incident.raidGoalType == RaidGoalType.Smite)
            {
                return(null);
            }

            DiaNode RemedySuccessNode()
            {
                DiaNode diaNode = new DiaNode("PES_RaidNeg_Sub_success".Translate());

                diaNode.options.Add(DialogUtilities.CurtOption("PES_Reassuring", null, () =>
                {
                    successAction();
                    caravan.ApplyNegotiationCoolDown();
                    DialogUtilities.NegotiatorLearnSocial(true);
                }, true));
                return(diaNode);
            }

            DiaNode RemedyFailNode()
            {
                DiaNode diaNode = new DiaNode("PES_RaidNeg_Sub_Fail".Translate());

                diaNode.options.Add(DialogUtilities.CurtOption("PES_ASHAME", null, () => {
                    caravan.ApplyNegotiationCoolDown();
                    DialogUtilities.NegotiatorLearnSocial(false);
                }, true));
                return(diaNode);
            }

            DiaNode RemedySmiteNode()
            {
                DiaNode diaNode = new DiaNode("PES_raidNeg_NegDeeper_Bargain_Smite".Translate());

                diaNode.options.Add(DialogUtilities.CurtOption("PES_DAMNIT", null, () =>
                {
                    caravan.Communicable = false;
                    incident.goal        = new RaidingGoal_Smite();
                    caravan.ApplyNegotiationCoolDown();
                    DialogUtilities.NegotiatorLearnSocial(false);
                }, true));
                return(diaNode);
            }

            DiaNode   remedyNode = new DiaNode("PES_RaidNeg_Sub_Intro".Translate());
            DiaOption option;

            //Persuasion
            float         successOdds = Mathf.Clamp01(PES_Settings.BaseRemedyPersuasionChance * pawn.NegotiatePowerFactor());
            StringBuilder sb          = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_Persuade_noun".Translate(), goal.RemedyPersuasionStr));

            sb.AppendLine(OddsIndicator(successOdds, "PES_raidNeg_NegDeeper_Bargain_Success_Name"));
            option        = new DiaOption(sb.ToString());
            option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, RemedySuccessNode(), null, RemedyFailNode());
            remedyNode.options.Add(option);

            //Intimidation
            successOdds = Mathf.Clamp01(PES_Settings.BaseRemedyIntimidationSuccessChance * pawn.NegotiatePowerFactor());
            float smiteOdds = Mathf.Clamp01(PES_Settings.BaseRemedyIntimidationSmiteChance * pawn.NegotiatePowerFactorNeg());

            sb = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_intimidate_noun".Translate(), goal.RemedyIntimidationStr));
            sb.AppendLine(OddsIndicator(successOdds, "PES_raidNeg_NegDeeper_Bargain_Success_Name", smiteOdds, "PES_RaidNeg_Negdeeper_Bargain_Smite_Name"));
            option        = new DiaOption(sb.ToString());
            option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, RemedySuccessNode(), smiteOdds, null, RemedySmiteNode(), null, RemedyFailNode());
            remedyNode.options.Add(option);

            //Beguilement
            if (pawn.skills.GetSkill(SkillDefOf.Social).Level >= 15)
            {
                successOdds = Mathf.Clamp01(PES_Settings.BaseRemedyBeguilementChance * pawn.NegotiatePowerFactor());
                sb          = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_beguile_noun".Translate(), goal.RemedyBeguilementStr));
                sb.AppendLine(OddsIndicator(successOdds, "PES_raidNeg_NegDeeper_Bargain_Success_Name"));
                option        = new DiaOption(sb.ToString());
                option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, RemedySuccessNode(), null, RemedyFailNode());
                remedyNode.options.Add(option);
            }

            remedyNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));

            return(remedyNode);
        }
Пример #2
0
        public static DiaNode DelayNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;
            InterceptedIncident_HumanCrowd_RaidEnemy incident = caravan.incident as InterceptedIncident_HumanCrowd_RaidEnemy;

            if (incident == null)
            {
                return(null);
            }
            if (incident.raidGoalType == RaidGoalType.Smite)
            {
                return(null);
            }

            DiaNode delaySuccessNode()
            {
                DiaNode diaNode = new DiaNode("PES_RaidNeg_Delay_Success".Translate(caravan.CaravanTitle));

                diaNode.options.Add(DialogUtilities.CurtOption("PES_Reassuring", null, () => {
                    caravan.StageForThreeHours();
                    DialogUtilities.NegotiatorLearnSocial(true);
                }, true));
                return(diaNode);
            }

            DiaNode delayFailNode()
            {
                DiaNode diaNode = new DiaNode("PES_RaidNeg_Delay_Fail".Translate());

                diaNode.options.Add(DialogUtilities.CurtOption("PES_DAMNIT", null, () => {
                    caravan.ApplyDelayCoolDown();
                    DialogUtilities.NegotiatorLearnSocial(false);
                }, true));
                return(diaNode);
            }

            DiaNode delaySmiteNode()
            {
                DiaNode diaNode = new DiaNode("PES_RaidNeg_Delay_Smite".Translate());

                diaNode.options.Add(DialogUtilities.CurtOption("PES_DAMNIT", null, () =>
                {
                    caravan.Communicable = false;
                    incident.goal        = new RaidingGoal_Smite();
                    DialogUtilities.NegotiatorLearnSocial(false);
                }, true));
                return(diaNode);
            }

            DiaNode   delayNode = new DiaNode("PES_RaidNeg_Delay_Intro".Translate());
            DiaOption option;

            //Persuasion
            float         successOdds = Mathf.Clamp01(PES_Settings.BaseDelayPersuasionChance * pawn.NegotiatePowerFactor());
            StringBuilder sb          = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_Persuade_noun".Translate(), "PES_RaidNeg_Delay_Persuasion".Translate()));

            sb.AppendLine(OddsIndicator(successOdds, "PES_RaidNeg_Delay_Success_Name"));
            option        = new DiaOption(sb.ToString());
            option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, delaySuccessNode(), null, delayFailNode());
            delayNode.options.Add(option);

            //Intimidation
            successOdds = Mathf.Clamp01(PES_Settings.BaseDelayIntimidationSuccessChance * pawn.NegotiatePowerFactor());
            float  smiteOdds        = Mathf.Clamp01(PES_Settings.BaseDelayIntimidationSmiteChance * pawn.NegotiatePowerFactorNeg());
            string intimidationText = ("PES_RaidNeg_Delay_Intimidation_" + incident.raidGoalType.ToString()).Translate();

            sb = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_intimidate_noun".Translate(), intimidationText));
            sb.AppendLine(OddsIndicator(successOdds, "PES_RaidNeg_Delay_Success_Name", smiteOdds, "PES_RaidNeg_Delay_Smite_Name"));
            option        = new DiaOption(sb.ToString());
            option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, delaySuccessNode(), smiteOdds, null, delaySmiteNode(), null, delayFailNode());
            delayNode.options.Add(option);

            //Beguilement
            if (pawn.skills.GetSkill(SkillDefOf.Social).Level >= 15)
            {
                successOdds = Mathf.Clamp01(PES_Settings.BaseDelayBeguilementChance * pawn.NegotiatePowerFactor());
                string beguilementText = ("PES_RaidNeg_Delay_Beguilement_" + incident.raidGoalType.ToString()).Translate();
                sb = new StringBuilder(string.Format("[{0}]: {1}\n", "PES_beguile_noun".Translate(), beguilementText));
                sb.AppendLine(OddsIndicator(successOdds, "PES_RaidNeg_Delay_Success_Name"));
                option        = new DiaOption(sb.ToString());
                option.action = DialogUtilities.ResolveActionByOdds(successOdds, null, delaySuccessNode(), null, delayFailNode());
                delayNode.options.Add(option);
            }

            delayNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));

            return(delayNode);
        }
        public static DiaNode BroadCastMessageChoiceNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;

            if (!(caravan.incident is InterceptedIncident_HumanCrowd incident))
            {
                return(null);
            }

            string intro;

            if (incident.faction_revealed && incident.SourceFaction == Faction.OfMechanoids)
            {
                intro = "PES_BroadCastMessage_Mechanoid".Translate();
            }
            else
            {
                intro = "PES_BroadCastMessage".Translate(pawn.Name.ToStringShort);
            }

            DiaNode   diaNode = new DiaNode(intro);
            DiaOption option;

            //Mechanoid
            if (incident.faction_revealed && incident.SourceFaction == Faction.OfMechanoids)
            {
                option = new DiaOption("PES_TryContactPrologue_Mechanoid".Translate())
                {
                    link = MechanoidAnswers()
                };
                diaNode.options.Add(option);
            }
            else
            {
                string key;
                void CommEstablishAction()
                {
                    caravan.EstablishCommunication(); caravan.ApplyBroadCastCoolDown(); DialogUtilities.NegotiatorLearnSocial(true);
                }

                void LeaveAction()
                {
                    caravan.Dismiss(); caravan.ApplyBroadCastCoolDown(); DialogUtilities.NegotiatorLearnSocial(true);
                }

                void LeaveActionBad()
                {
                    caravan.Dismiss(); caravan.ApplyBroadCastCoolDown(); DialogUtilities.NegotiatorLearnSocial(false);
                }

                void FailAction()
                {
                    caravan.ApplyBroadCastCoolDown(); DialogUtilities.NegotiatorLearnSocial(false);
                }

                float MessageOdds = incident.SourceFaction == Faction.OfMechanoids ? 0f : DialogUtilities.MessageReceiveChance;

                #region Persuasion
                StringBuilder sb = new StringBuilder(string.Format(@"<b>[{0}]</b>  ", "PES_Persuade_noun".Translate().CapitalizeFirst()));

                //Odds
                float friendlyOdds = Mathf.Clamp01(PES_Settings.BasePersuadeChance_Friendly * pawn.NegotiatePowerFactor());
                float hostileOdds  = Mathf.Clamp01(PES_Settings.BasePersuadeChance_Hostile * pawn.NegotiatePowerFactor());

                //Choices
                if (incident.IntelLevel == IncidentIntelLevel.Unknown)
                {
                    key = "PES_TryContact_Persuasion_Unknown";
                    sb.AppendLine(string.Format(@"<i>{0}</i>", key.Translate(pawn.Name.ToStringShort, Faction.OfPlayer.Name)));
                    sb.AppendLine(OddsIndicator(1, friendlyOdds, "PES_TryOutcome_Positive"));
                    sb.AppendLine(OddsIndicator(2, hostileOdds, "PES_TryOutcome_Positive"));
                }
                else if (incident.IntelLevel == IncidentIntelLevel.Danger)
                {
                    key = "PES_TryContact_Persuasion_Hostile";
                    sb.AppendLine(string.Format(@"<i>{0}</i>", key.Translate(pawn.Name.ToStringShort, Faction.OfPlayer.Name)));
                    sb.AppendLine(OddsIndicator(0, hostileOdds, "PES_TryOutcome_Positive"));
                }
                else
                {
                    key = "PES_TryContact_Persuasion_Neutral";
                    sb.AppendLine(string.Format(@"<i>{0}</i>", key.Translate(pawn.Name.ToStringShort, Faction.OfPlayer.Name)));
                    sb.AppendLine(OddsIndicator(0, friendlyOdds, "PES_TryOutcome_Positive"));
                }

                //Action
                option = new DiaOption(sb.ToString());
                if (incident.IsHostileToPlayer)
                {
                    option.action = DialogUtilities.ResolveActionByOdds(hostileOdds * MessageOdds, CommEstablishAction, PersuasionSuccessNode(), FailAction, ContactFailNode());
                }
                else
                {
                    option.action = DialogUtilities.ResolveActionByOdds(friendlyOdds * MessageOdds, CommEstablishAction, PersuasionSuccessNode(), FailAction, ContactFailNode());
                }
                diaNode.options.Add(option);
                #endregion

                #region intimidation
                float friendlyContactOdds = Mathf.Clamp01(PES_Settings.BaseIntimidationContactChance_Friendly * pawn.NegotiatePowerFactor());
                float friendlyFleeOdds    = Mathf.Clamp01(PES_Settings.BaseIntimidationFrightenChance_Friendly * pawn.NegotiatePowerFactorNeg());
                float EnemyContactOdds    = Mathf.Clamp01(PES_Settings.BaseIntimidationContactChance_Hostile * pawn.NegotiatePowerFactor());
                float EnemyFleeOdds       = Mathf.Clamp01(PES_Settings.BaseIntimidationFrightenChance_Hostile * pawn.NegotiatePowerFactor());

                sb = new StringBuilder(string.Format(@"<b>[{0}]</b>  ", "PES_intimidate_noun".Translate()).CapitalizeFirst());
                sb.AppendLine(string.Format(@"<i>{0}</i>", "PES_TryContact_Intimidation_have_mortar".Translate()));
                if (incident.IntelLevel == IncidentIntelLevel.Unknown)
                {
                    sb.AppendLine(OddsIndicator(1, friendlyContactOdds, "PES_TryOutcome_Positive", friendlyFleeOdds, "PES_TryOutcome_Scared"));
                    sb.AppendLine(OddsIndicator(2, EnemyContactOdds, "PES_TryOutcome_Positive", EnemyFleeOdds, "PES_TryOutcome_Scared"));
                }
                else if (incident.IntelLevel == IncidentIntelLevel.Danger)
                {
                    sb.AppendLine(OddsIndicator(0, EnemyContactOdds, "PES_TryOutcome_Positive", EnemyFleeOdds, "PES_TryOutcome_Scared"));
                }
                else
                {
                    sb.AppendLine(OddsIndicator(0, friendlyContactOdds, "PES_TryOutcome_Positive", friendlyFleeOdds, "PES_TryOutcome_Scared"));
                }
                option = new DiaOption(sb.ToString());
                if (!incident.IsHostileToPlayer)
                {
                    option.action = DialogUtilities.ResolveActionByOdds(friendlyContactOdds * MessageOdds, CommEstablishAction, PersuasionSuccessNode(), friendlyFleeOdds * MessageOdds, LeaveActionBad, IntimidationSuccessNode(), FailAction, ContactFailNode());
                }
                else
                {
                    option.action = DialogUtilities.ResolveActionByOdds(EnemyContactOdds * MessageOdds, CommEstablishAction, PersuasionSuccessNode(), EnemyFleeOdds * MessageOdds, LeaveAction, IntimidationSuccessNode(), FailAction, ContactFailNode());
                }
                diaNode.options.Add(option);
                #endregion

                #region Beguilement
                if (incident.IntelLevel != IncidentIntelLevel.Neutral && pawn.skills.GetSkill(SkillDefOf.Social).Level >= 15)
                {
                    friendlyFleeOdds = Mathf.Clamp01(PES_Settings.BaseBeguilementFrightenChance_Friendly * pawn.NegotiatePowerFactor());
                    EnemyContactOdds = Mathf.Clamp01(PES_Settings.BaseBeguilementContactChance_Hostile * pawn.NegotiatePowerFactor());
                    float EnemyLeaveOdds = Mathf.Clamp01(PES_Settings.BaseBeguilementFrightenChance_Hostile * pawn.NegotiatePowerFactor());

                    sb = new StringBuilder(string.Format(@"<b>[{0}]</b>  ", "PES_beguile_noun".Translate().CapitalizeFirst()));
                    if (incident.faction_revealed)
                    {
                        sb.AppendLine(string.Format(@"<i>{0}</i>", "PES_TryContact_Beguilement_FactionConfirmed".Translate(pawn.Name.ToStringShort, incident.SourceFaction.Name, Faction.OfPlayer.Name)));
                        sb.AppendLine(OddsIndicator(0, EnemyContactOdds, "PES_TryOutcome_Positive", EnemyLeaveOdds, "PES_TryOutcome_Leave"));
                    }
                    else
                    {
                        sb.AppendLine(string.Format(@"<i>{0}</i>", "PES_TryContact_Beguilement".Translate(pawn.Name.ToStringShort, Faction.OfPlayer.Name)));
                        if (incident.IntelLevel == IncidentIntelLevel.Danger)
                        {
                            sb.AppendLine(OddsIndicator(0, EnemyContactOdds, "PES_TryOutcome_Positive", EnemyLeaveOdds, "PES_TryOutcome_Scared"));
                        }
                        else
                        {
                            sb.AppendLine(OddsIndicator(1, friendlyFleeOdds, "PES_TryOutcome_Scared"));
                            sb.AppendLine(OddsIndicator(2, EnemyContactOdds, "PES_TryOutcome_Positive", EnemyLeaveOdds, "PES_TryOutcome_Scared"));
                        }
                    }
                    option = new DiaOption(sb.ToString());
                    if (incident.IsHostileToPlayer)
                    {
                        option.action = DialogUtilities.ResolveActionByOdds(EnemyLeaveOdds * MessageOdds, LeaveAction, BeguilementSuccessNode(incident.faction_revealed), EnemyContactOdds * MessageOdds, CommEstablishAction, PersuasionSuccessNode(), FailAction, ContactFailNode());
                    }
                    else
                    {
                        option.action = DialogUtilities.ResolveActionByOdds(friendlyFleeOdds * MessageOdds, LeaveAction, BeguilementSuccessNode(incident.faction_revealed), FailAction, ContactFailNode());
                    }
                    diaNode.options.Add(option);
                }
                #endregion
            }

            diaNode.options.Add(DialogUtilities.NormalCancelOption());
            return(diaNode);
        }