private static void LordHaveFunWIthPrisoner(Settlement settlement, MobileParty captorParty, Hero prisoner)
        {
            PartyBase settlementParty = settlement.Party;

            if (settlementParty == null)
            {
                return;
            }

            prisoner.StayingInSettlementOfNotable = settlement;

            if (Romance.GetRomanticLevel(captorParty.LeaderHero, prisoner) <= Romance.RomanceLevelEnum.Untested)
            {
                ChangeRomanticStateAction.Apply(captorParty.LeaderHero, prisoner, (Romance.RomanceLevelEnum)ZenDzeeRomanceHelper.RomanceLevel_Prisoner);
            }

            if (prisoner.IsHumanPlayerCharacter)
            {
                GameMenu.SwitchToMenu("zendzee_settlement_prisoner_wait");
            }

#if ENABLE_LOGS
            InformationManager.DisplayMessage(new InformationMessage(captorParty.LeaderHero.Name + " having fun with the prisoner " + prisoner.Name));
#endif // ENABLE_LOGS
        }
예제 #2
0
        private bool conversation_begin_courtship_for_hero_on_condition()
        {
            ISettingsProvider settings = new MASettings();

            if (Hero.OneToOneConversationHero.Age >= Campaign.Current.Models.AgeModel.HeroComesOfAge)
            {
                if (settings.Debug)
                {
                    MAHelper.Print("MCM: " + MASettings.UsingMCM);
                    MAHelper.Print("Difficulty: " + settings.Difficulty);
                    MAHelper.Print("Orientation: " + settings.SexualOrientation);
                    MAHelper.Print("Cheating: " + settings.Cheating);
                    MAHelper.Print("Polygamy: " + settings.Polygamy);
                    MAHelper.Print("Incest: " + settings.Incest);
                    MAHelper.Print("Romantic Level: " + Romance.GetRomanticLevel(Hero.MainHero, Hero.OneToOneConversationHero).ToString());
                }

                // OnNeNousDitPasTout/GrandesMaree Patch
                // In Fact we can't go through Romance.RomanceLevelEnum.Untested
                // because for the next modification, there will be another romance status
                // And we must have only have one romance status for each relation
                if (Romance.GetRomanticLevel(Hero.MainHero, Hero.OneToOneConversationHero) == Romance.RomanceLevelEnum.Untested)
                {
                    Util.Util.CleanRomance(Hero.MainHero, Hero.OneToOneConversationHero);
                    bool areMarried = Util.Util.AreMarried(Hero.MainHero, Hero.OneToOneConversationHero);
                    if (areMarried)
                    {
                        ChangeRomanticStateAction.Apply(Hero.MainHero, Hero.OneToOneConversationHero, Romance.RomanceLevelEnum.Ended);
                        MAHelper.Print("PATCH Married New Romantic Level: " + Romance.GetRomanticLevel(Hero.MainHero, Hero.OneToOneConversationHero).ToString());
                    }
                }
            }
            return(Hero.OneToOneConversationHero.IsWanderer && Hero.OneToOneConversationHero.IsPlayerCompanion);
        }
        private static void OnDailyTickHero(Hero hero)
        {
            if (!hero.IsTemplate &&
                hero.IsNoble && hero.IsAlive && hero.IsActive &&
                hero.Clan != null &&
                hero.Clan != Clan.PlayerClan &&
                hero.Age >= ZenDzeeRomanceHelper.LoversAgeMin &&
                (!hero.IsFemale || hero.Age < ZenDzeeRomanceHelper.PregnancyAgeMax) &&
                (hero.Spouse == null ||
                 hero.Spouse.IsDead ||
                 (hero.Spouse.IsFemale && hero.Spouse.Age > ZenDzeeRomanceHelper.PregnancyAgeMax)) &&
                hero.Clan.Heroes.Count(h => h.IsAlive) < 6 &&
                hero.Children.Count(c => c.IsAlive && c.Clan == hero.Clan) == 0)
            {
                // Next day after birthday.
                if ((int)(hero.BirthDay.ElapsedDaysUntilNow - 1) % CampaignTime.DaysInYear == 0)
                {
                    Hero lover = ZenDzeeRomanceHelper.GetLover(hero);
                    if (lover == null)
                    {
                        // Find a lover. TODO maybe this should had random chance?
                        IEnumerable <Hero> list = hero.Clan.SupporterNotables;
                        if (list != null)
                        {
                            lover = GetSuitableLoverForHero(hero, list);
                            if (lover != null)
                            {
                                ChangeRomanticStateAction.Apply(hero, lover, (Romance.RomanceLevelEnum)ZenDzeeRomanceHelper.RomanceLevel_Lovers);
                                return;
                            }
                        }

                        if (hero.Age >= DesperateToFindSpouseAge && lover == null)
                        {
                            list = Hero.All.Where(h => h.IsWanderer &&
                                                  h.CurrentSettlement != null &&
                                                  h.CurrentSettlement.MapFaction == hero.MapFaction &&
                                                  h.Clan != Clan.PlayerClan &&
                                                  IsHeroSuitableLoverForHero(hero, h));

                            if (list != null)
                            {
                                lover = GetSuitableLoverForHero(hero, list);
                                if (lover != null)
                                {
                                    ChangeRomanticStateAction.Apply(hero, lover, (Romance.RomanceLevelEnum)ZenDzeeRomanceHelper.RomanceLevel_Lovers);
                                    return;
                                }
                            }
                        }

                        // Add here other romance options
                    }
                }
            }
        }
예제 #4
0
        private void conversation_courtship_success_on_consequence()
        {
            ISettingsProvider settings = new MASettings();
            Hero hero          = Hero.MainHero;
            Hero spouse        = Hero.OneToOneConversationHero;
            Hero oldSpouse     = hero.Spouse;
            Hero cheatedSpouse = spouse.Spouse;

            // If you are marrying a kingdom ruler as a kingdom ruler yourself,
            // the kingdom ruler will have to give up being clan head.
            // Apparently causes issues if this is not done.
            if (spouse.IsFactionLeader && !spouse.IsMinorFactionHero)
            {
                if (hero.Clan.Kingdom != spouse.Clan.Kingdom)
                {
                    if (hero.Clan.Kingdom?.Leader != hero)
                    {
                        // Join kingdom due to lowborn status
                        if (hero.Clan.Leader == Hero.MainHero)
                        {
                            ChangeClanLeaderAction.ApplyWithoutSelectedNewLeader(hero.Clan);
                            if (hero.Clan.Leader == Hero.MainHero)
                            {
                                MAHelper.Print("No Heirs");
                                DestroyClanAction.Apply(hero.Clan);
                                MAHelper.Print("Eliminated Player Clan");
                            }
                        }
                        foreach (Hero companion in hero.Clan.Companions.ToList())
                        {
                            bool inParty = false;
                            if (companion.PartyBelongedTo == MobileParty.MainParty)
                            {
                                inParty = true;
                            }
                            RemoveCompanionAction.ApplyByFire(hero.Clan, companion);
                            AddCompanionAction.Apply(spouse.Clan, companion);
                            if (inParty)
                            {
                                AddHeroToPartyAction.Apply(companion, MobileParty.MainParty, true);
                            }
                        }
                        hero.Clan = spouse.Clan;
                        var current = Traverse.Create <Campaign>().Property("Current").GetValue <Campaign>();
                        Traverse.Create(current).Property("PlayerDefaultFaction").SetValue(spouse.Clan);
                        MAHelper.Print("Lowborn Player Married to Kingdom Ruler");
                    }
                    else
                    {
                        ChangeClanLeaderAction.ApplyWithoutSelectedNewLeader(spouse.Clan);
                        MAHelper.Print("Kingdom Ruler Stepped Down and Married to Player");
                    }
                }
            }
            // New nobility
            MAHelper.OccupationToLord(spouse.CharacterObject);
            if (!spouse.IsNoble)
            {
                spouse.IsNoble = true;
                MAHelper.Print("Spouse to Noble");
            }
            // Dodge the party crash for characters part 1
            bool dodge = false;

            if (spouse.PartyBelongedTo == MobileParty.MainParty)
            {
                AccessTools.Property(typeof(Hero), "PartyBelongedTo").SetValue(spouse, null, null);
                MAHelper.Print("Spouse Already in Player's Party");
                dodge = true;
            }
            // Apply marriage
            ChangeRomanticStateAction.Apply(hero, spouse, Romance.RomanceLevelEnum.Marriage);
            MAHelper.Print("Marriage Action Applied");
            if (oldSpouse is not null)
            {
                MAHelper.RemoveExSpouses(oldSpouse);
            }
            // Dodge the party crash for characters part 2
            if (dodge)
            {
                AccessTools.Property(typeof(Hero), "PartyBelongedTo").SetValue(spouse, MobileParty.MainParty, null);
            }
            // Activate character if not already activated
            if (!spouse.HasMet)
            {
                spouse.HasMet = true;
            }
            if (!spouse.IsActive)
            {
                spouse.ChangeState(Hero.CharacterStates.Active);
                MAHelper.Print("Activated Spouse");
            }
            if (spouse.IsPlayerCompanion)
            {
                spouse.CompanionOf = null;
                MAHelper.Print("Spouse No Longer Companion");
            }
            if (settings.Cheating && cheatedSpouse is not null)
            {
                MAHelper.RemoveExSpouses(cheatedSpouse, true);
                MAHelper.RemoveExSpouses(spouse, true);
                MAHelper.Print("Spouse Broke Off Past Marriage");
            }
            MAHelper.RemoveExSpouses(hero);
            MAHelper.RemoveExSpouses(spouse);
            PlayerEncounter.LeaveEncounter = true;
            // New fix to stop some kingdom rulers from disappearing
            if (spouse.PartyBelongedTo != MobileParty.MainParty)
            {
                AddHeroToPartyAction.Apply(spouse, MobileParty.MainParty, true);
            }
        }
        public static bool conversation_player_can_open_courtship_on_condition()
        {
            ISettingsProvider settings = new MASettings();

            if (Hero.OneToOneConversationHero is null)
            {
                return(false);
            }
            bool flag = Hero.MainHero.IsFemale && settings.SexualOrientation == "Heterosexual" || !Hero.MainHero.IsFemale && settings.SexualOrientation == "Homosexual" || !Hero.OneToOneConversationHero.IsFemale && settings.SexualOrientation == "Bisexual";

            Romance.RomanceLevelEnum romanceLevel = Romance.GetRomanticLevel(Hero.MainHero, Hero.OneToOneConversationHero); // better to use a local variable
            MAHelper.Print("Courtship Possible: " + Romance.MarriageCourtshipPossibility(Hero.MainHero, Hero.OneToOneConversationHero).ToString());
            MAHelper.Print("Romantic Level: " + romanceLevel.ToString());
            MAHelper.Print("Retry Courtship: " + settings.RetryCourtship.ToString());

            if (Romance.MarriageCourtshipPossibility(Hero.MainHero, Hero.OneToOneConversationHero) && romanceLevel == Romance.RomanceLevelEnum.Untested)
            {
                if (Hero.OneToOneConversationHero.IsNoble || Hero.OneToOneConversationHero.IsMinorFactionHero)
                {
                    if (Hero.OneToOneConversationHero.Spouse is null)
                    {
                        MBTextManager.SetTextVariable("FLIRTATION_LINE",
                                                      flag
                                ? "{=lord_flirt}My lord, I note that you have not yet taken a spouse."
                                : "{=v1hC6Aem}My lady, I wish to profess myself your most ardent admirer.", false);
                    }
                    else
                    {
                        MBTextManager.SetTextVariable("FLIRTATION_LINE",
                                                      flag
                                ? "{=lord_cheating_flirt}My lord, I note that you might wish for a new spouse."
                                : "{=v1hC6Aem}My lady, I wish to profess myself your most ardent admirer.", false);
                    }
                }
                else
                {
                    MBTextManager.SetTextVariable("FLIRTATION_LINE",
                                                  flag
                            ? "{=goodman_flirt}Goodman, I note that you have not yet taken a spouse."
                            : "{=goodwife_flirt}Goodwife, I wish to profess myself your most ardent admirer.", false);
                }
                return(true);
            }

            bool areMarried = Util.Util.AreMarried(Hero.MainHero, Hero.OneToOneConversationHero);

            if (romanceLevel == Romance.RomanceLevelEnum.FailedInCompatibility ||
                romanceLevel == Romance.RomanceLevelEnum.FailedInPracticalities ||
                (romanceLevel == Romance.RomanceLevelEnum.Ended && settings.RetryCourtship && !areMarried)
                )
            {
                if (Hero.OneToOneConversationHero.IsNoble || Hero.OneToOneConversationHero.IsMinorFactionHero)
                {
                    MBTextManager.SetTextVariable("FLIRTATION_LINE",
                                                  flag
                            ? "{=2WnhUBMM}My lord, may you give me another chance to prove myself?"
                            : "{=4iTaEZKg}My lady, may you give me another chance to prove myself?", false);
                }
                else
                {
                    MBTextManager.SetTextVariable("FLIRTATION_LINE",
                                                  flag
                            ? "{=goodman_chance}Goodman, may you give me another chance to prove myself?"
                            : "{=goodwife_chance}Goodwife, may you give me another chance to prove myself?", false);
                }
                // Retry Courtship feature!
                if (settings.RetryCourtship)
                {
                    if (romanceLevel == Romance.RomanceLevelEnum.Ended)
                    {
                        // OnNeNousDitPasTout/GrandesMaree Patch
                        // Patch we must have only have one romance status for each relation
                        Util.Util.CleanRomance(Hero.MainHero, Hero.OneToOneConversationHero);
                    }

                    if (romanceLevel == Romance.RomanceLevelEnum.FailedInCompatibility || romanceLevel == Romance.RomanceLevelEnum.Ended)
                    {
                        ChangeRomanticStateAction.Apply(Hero.MainHero, Hero.OneToOneConversationHero, Romance.RomanceLevelEnum.CourtshipStarted);
                    }
                    else if (romanceLevel == Romance.RomanceLevelEnum.FailedInPracticalities)
                    {
                        ChangeRomanticStateAction.Apply(Hero.MainHero, Hero.OneToOneConversationHero, Romance.RomanceLevelEnum.CoupleDecidedThatTheyAreCompatible);
                    }
                }
                return(true);
            }
            return(false);
        }