Esempio n. 1
0
        internal void CECaptivityContinue(ref MenuCallbackArgs args)
        {
            CEPersistence.animationPlayEvent = false;

            try
            {
                if (PlayerCaptivity.CaptorParty != null)
                {
                    string waitingList = new WaitingList().CEWaitingList();

                    if (waitingList != null)
                    {
                        GameMenu.ActivateGameMenu(waitingList);
                    }
                    else
                    {
                        new CESubModule().LoadTexture("default");

                        GameMenu.SwitchToMenu(PlayerCaptivity.CaptorParty.IsSettlement
                                                  ? "settlement_wait"
                                                  : "prisoner_wait");
                    }
                }
                else
                {
                    new CESubModule().LoadTexture("default");
                    GameMenu.ExitToLast();
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Critical Error: CECaptivityContinue : " + e);
            }
        }
Esempio n. 2
0
        internal void SkillModifier(Hero hero, string skill, int amount, int xp, bool display = true, string color = "gray")
        {
            bool found = false;


            foreach (SkillObject skillObjectCustom in CESkills.CustomSkills)
            {
                if (skillObjectCustom.Name.ToString().Equals(skill, StringComparison.InvariantCultureIgnoreCase) || skillObjectCustom.StringId == skill)
                {
                    found = true;
                    SkillObjectModifier(skillObjectCustom, PickColor(color), hero, skill, amount, xp, display);
                    break;
                }
            }

            if (found)
            {
                return;
            }

            foreach (SkillObject skillObject in SkillObject.All)
            {
                if (skillObject.Name.ToString().Equals(skill, StringComparison.InvariantCultureIgnoreCase) || skillObject.StringId == skill)
                {
                    found = true;
                    SkillObjectModifier(skillObject, PickColor(color), hero, skill, amount, xp, display);
                    break;
                }
            }

            if (!found)
            {
                CECustomHandler.ForceLogToFile("Unable to find : " + skill);
            }
        }
Esempio n. 3
0
 public void AddCustomLines(CampaignGameStarter campaignGameStarter, List <CEScene> CECustomScenes)
 {
     try
     {
         foreach (CEScene CustomScene in CECustomScenes)
         {
             foreach (Line CustomLine in CustomScene.Dialogue.Lines)
             {
                 if (CustomLine.Ref != null && CustomLine.Ref.ToLower() == "ai")
                 {
                     campaignGameStarter.AddDialogLine(CustomLine.Id, CustomLine.InputToken, CustomLine.OutputToken, CustomLine.Text, () => { return(ConversationCECustomScenes(CustomScene.Name)); }, null);
                 }
                 else
                 {
                     campaignGameStarter.AddPlayerLine(CustomLine.Id, CustomLine.InputToken, CustomLine.OutputToken, CustomLine.Text, null, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         TextObject textObject = new TextObject("{=CEEVENTS0999}Error: failed to initialize scenes");
         InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Red));
         CECustomHandler.ForceLogToFile("Error: failed to initialize scenes");
         CECustomHandler.ForceLogToFile(e.Message + " : " + e);
     }
 }
        private void CalculatePregnancyWeight(Pregnancy pregnancy)
        {
            try
            {
                if (pregnancy == null || pregnancy.AlreadyOccured)
                {
                    return;
                }

                if (pregnancy.DueDate.RemainingDaysFromNow < 1f)
                {
                    ChangeWeight(pregnancy.Mother, 3);
                }
                else if (pregnancy.DueDate.RemainingDaysFromNow < 10f)
                {
                    ChangeWeight(pregnancy.Mother, 2);
                }
                else if (pregnancy.DueDate.RemainingDaysFromNow < 20f)
                {
                    ChangeWeight(pregnancy.Mother, 1);
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed to handle alerts. CalculatePregnancyWeight");
                CECustomHandler.ForceLogToFile(e.Message + " : " + e);
            }
        }
Esempio n. 5
0
 public static CESkillNode FindSkillNode(string skill)
 {
     try
     {
         return(_Skills.Find(skillNode => skillNode.Id == skill));
     }
     catch (Exception e)
     {
         CECustomHandler.ForceLogToFile(skill + " : " + e);
         return(null);
     }
 }
Esempio n. 6
0
        public int GetIntFromXML(string numpassed)
        {
            try
            {
                int number = 0;

                if (numpassed == null)
                {
                    return(number);
                }

                if (numpassed.StartsWith("R"))
                {
                    string[] splitPass = numpassed.Split(' ');

                    switch (splitPass.Length)
                    {
                    case 3:
                        int numberOne = int.Parse(splitPass[1]);
                        int numberTwo = int.Parse(splitPass[2]);

                        number = numberOne < numberTwo
                                ? MBRandom.RandomInt(numberOne, numberTwo)
                                : MBRandom.RandomInt(numberTwo, numberOne);

                        break;

                    case 2:
                        number = MBRandom.RandomInt(int.Parse(splitPass[1]));
                        break;

                    default:
                        number = MBRandom.RandomInt();
                        break;
                    }
                }
                else
                {
                    number = int.Parse(numpassed);
                }

                return(number);
            }
            catch (Exception)
            {
                CECustomHandler.ForceLogToFile("Failed to parse int " + numpassed);

                return(0);
            }
        }
Esempio n. 7
0
        private void ConversationCEEventInCellOnConsequence()
        {
            try
            {
                CEPersistence.captivePlayEvent = true;
                CEPersistence.captiveToPlay    = CharacterObject.OneToOneConversationCharacter;

                CEPersistence.gameEntity     = Mission.Current.Scene.GetFirstEntityWithName("_barrier_passage_center");
                CEPersistence.agentTalkingTo = Mission.Current.Agents.FirstOrDefault(agent => agent.Character == CharacterObject.OneToOneConversationCharacter);
                CEPersistence.dungeonState   = CEPersistence.DungeonState.StartWalking;
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed to launch ConversationCEEventInCellOnConsequence : " + e);
            }
        }
Esempio n. 8
0
        private void ConsequenceRelease(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.Leave))
            {
                return;
            }

            try
            {
                EndCaptivityAction.ApplyByReleasing(hero);
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failure of ConsequenceRelease: " + e.ToString());
            }
        }
        public void OnDailyTick()
        {
            try
            {
                if (!Hero.MainHero.IsPregnant)
                {
                    return;
                }
                Pregnancy pregnancydue = _heroPregnancies.Find(pregnancy => pregnancy.Mother == Hero.MainHero);

                if (pregnancydue == null || pregnancydue.AlreadyOccured)
                {
                    return;
                }
                TextObject textObject40;

                if (pregnancydue.DueDate.RemainingDaysFromNow < 1f)
                {
                    textObject40 = new TextObject("{=CEEVENTS1061}You are about to give birth...");
                }
                else if (pregnancydue.DueDate.RemainingDaysFromNow < 10f)
                {
                    textObject40 = new TextObject("{=CEEVENTS1062}Your baby begins kicking, you have {DAYS_REMAINING} days remaining.");
                    textObject40.SetTextVariable("DAYS_REMAINING", Math.Floor(pregnancydue.DueDate.RemainingDaysFromNow).ToString(CultureInfo.InvariantCulture));
                }
                else if (pregnancydue.DueDate.RemainingDaysFromNow < 20f)
                {
                    textObject40 = new TextObject("{=CEEVENTS1063}Your pregnant belly continues to swell, you have {DAYS_REMAINING} days remaining.");
                    textObject40.SetTextVariable("DAYS_REMAINING", Math.Floor(pregnancydue.DueDate.RemainingDaysFromNow).ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    textObject40 = new TextObject("{=CEEVENTS1064}You're pregnant, you have {DAYS_REMAINING} days remaining.");
                    textObject40.SetTextVariable("DAYS_REMAINING", Math.Floor(pregnancydue.DueDate.RemainingDaysFromNow).ToString(CultureInfo.InvariantCulture));
                }

                if (CESettings.Instance != null && CESettings.Instance.PregnancyMessages)
                {
                    InformationManager.DisplayMessage(new InformationMessage(textObject40.ToString(), Colors.Gray));
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed to handle alerts. pregenancy");
                CECustomHandler.ForceLogToFile(e.Message + " : " + e);
            }
        }
Esempio n. 10
0
        internal static List <string> GetModulePaths(string[] modulesFound, out List <ModuleInfo> modules)
        {
            List <string> modulePaths = new List <string>();

            List <ModuleInfo> findingModules = new List <ModuleInfo>();

            foreach (string moduleID in modulesFound)
            {
                try
                {
                    ModuleInfo moduleInfo = ModuleHelper.GetModules().FirstOrDefault(searchInfo => searchInfo.Id == moduleID);

                    if (moduleInfo != null && !moduleInfo.DependedModules.Exists(item => item.ModuleId == "zCaptivityEvents"))
                    {
                        continue;
                    }

                    try
                    {
                        if (moduleInfo == null)
                        {
                            continue;
                        }
                        CECustomHandler.ForceLogToFile("Added to ModuleLoader: " + moduleInfo.Name);
                        modulePaths.Insert(0, Path.GetDirectoryName(ModuleHelper.GetPath(moduleInfo.Id)));

                        findingModules.Add(moduleInfo);
                    }
                    catch (Exception)
                    {
                        if (moduleInfo != null)
                        {
                            CECustomHandler.ForceLogToFile("Failed to Load " + moduleInfo.Name + " Events");
                        }
                    }
                }
                catch (Exception)
                {
                    CECustomHandler.ForceLogToFile("Failed to fetch DependedModuleIds from " + moduleID);
                }
            }

            modules = findingModules;

            return(modulePaths);
        }
Esempio n. 11
0
        internal void TraitModifier(Hero hero, string trait, int amount, int xp, bool display = true, string color = "gray")
        {
            bool found = false;

            foreach (TraitObject traitObject in DefaultTraits.Personality)
            {
                if (traitObject.Name.ToString().Equals(trait, StringComparison.InvariantCultureIgnoreCase) || traitObject.StringId == trait)
                {
                    found = true;
                    TraitObjectModifier(traitObject, PickColor(color), hero, trait, amount, xp, display);
                }
            }

            if (!found)
            {
                foreach (TraitObject traitObject in DefaultTraits.SkillCategories)
                {
                    if (traitObject.Name.ToString().Equals(trait, StringComparison.InvariantCultureIgnoreCase) || traitObject.StringId == trait)
                    {
                        found = true;
                        TraitObjectModifier(traitObject, PickColor(color), hero, trait, amount, xp, display);
                    }
                }
            }

            if (found)
            {
                return;
            }

            {
                foreach (TraitObject traitObject in DefaultTraits.All)
                {
                    if (traitObject.Name.ToString().Equals(trait, StringComparison.InvariantCultureIgnoreCase) || traitObject.StringId == trait)
                    {
                        found = true;
                        TraitObjectModifier(traitObject, PickColor(color), hero, trait, amount, xp, display);
                    }
                }

                if (!found)
                {
                    CECustomHandler.ForceLogToFile("Unable to find : " + trait);
                }
            }
        }
Esempio n. 12
0
        public void SpawnTheTroops(SpawnTroop[] variables, PartyBase party)
        {
            foreach (SpawnTroop troop in variables)
            {
                try
                {
                    int             num             = new CEVariablesLoader().GetIntFromXML(troop.Number);
                    int             numWounded      = new CEVariablesLoader().GetIntFromXML(troop.WoundedNumber);
                    CharacterObject characterObject = MBObjectManager.Instance.GetObject <CharacterObject>(troop.Id);

                    if (characterObject == null)
                    {
                        foreach (CharacterObject characterObject2 in MBObjectManager.Instance.GetObjectTypeList <CharacterObject>())
                        {
                            if (characterObject2.Occupation == Occupation.Soldier && string.Equals(characterObject2.Name.ToString(), troop.Id, StringComparison.OrdinalIgnoreCase))
                            {
                                characterObject = characterObject2;
                                break;
                            }
                        }
                    }

                    if (characterObject != null)
                    {
                        if (num > 0)
                        {
                            if (troop.Ref != null && troop.Ref.ToLower() == "troop")
                            {
                                party.MemberRoster.AddToCounts(characterObject, num, false, numWounded, 0, true, -1);
                            }
                            else
                            {
                                party.PrisonRoster.AddToCounts(characterObject, num, false, numWounded, 0, true, -1);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    CECustomHandler.ForceLogToFile("Failed to SpawnTheTroops : " + e);
                }
            }
        }
Esempio n. 13
0
        internal void CEKillPlayer(Hero killer)
        {
            GameMenu.ExitToLast();

            try
            {
                if (killer != null)
                {
                    KillCharacterAction.ApplyByMurder(Hero.MainHero, killer);
                }
                else
                {
                    KillCharacterAction.ApplyByMurder(Hero.MainHero);
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed CEKillPlayer " + e);
            }
        }
Esempio n. 14
0
        private void CheckEquipmentToReturn(ReturnEquipment returnEquipment)
        {
            try
            {
                if (returnEquipment.Captive.IsPrisoner || returnEquipment.Captive.PartyBelongedToAsPrisoner != null)
                {
                    return;
                }

                foreach (EquipmentCustomIndex index in Enum.GetValues(typeof(EquipmentCustomIndex)))
                {
                    EquipmentIndex i = (EquipmentIndex)index;

                    try
                    {
                        EquipmentElement fetchedEquipment = returnEquipment.BattleEquipment.GetEquipmentFromSlot(i);
                        returnEquipment.Captive.BattleEquipment.AddEquipmentToSlotWithoutAgent(i, fetchedEquipment);
                    }
                    catch (Exception) { }

                    try
                    {
                        EquipmentElement fetchedEquipment2 = returnEquipment.CivilianEquipment.GetEquipmentFromSlot(i);
                        returnEquipment.Captive.CivilianEquipment.AddEquipmentToSlotWithoutAgent(i, fetchedEquipment2);
                    }
                    catch (Exception) { }
                }

                returnEquipment.AlreadyOccured = true;
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Bad Equipment");
                CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                TextObject textObject = new TextObject("{=CEEVENTS1009}Error: bad equipment in return equipment list");
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black));
                returnEquipment.AlreadyOccured = true;
            }
        }
Esempio n. 15
0
 private void OnChildConceived(Hero hero)
 {
     try
     {
         if (CEHelper.spouseOne == null && CEHelper.spouseTwo == null)
         {
             return;
         }
         Hero father = CEHelper.spouseOne == hero
             ? CEHelper.spouseTwo
             : CEHelper.spouseOne;
         CECustomHandler.ForceLogToFile("Added " + hero.Name + "'s Pregnancy");
         if (CESettings.Instance != null)
         {
             _heroPregnancies.Add(new Pregnancy(hero, father, CampaignTime.DaysFromNow(CESettings.Instance.PregnancyDurationInDays)));
         }
     }
     catch (Exception e)
     {
         CECustomHandler.ForceLogToFile("Failed to handle OnChildConceivedEvent.");
         CECustomHandler.ForceLogToFile(e.Message + " : " + e);
     }
 }
Esempio n. 16
0
        private bool ConversationCEEventResponseInPartyOnCondition()
        {
            try
            {
                CharacterObject captive = CharacterObject.OneToOneConversationCharacter;

                if (captive != null && captive.IsHero && captive.HeroObject.GetSkillValue(CESkills.IsSlave) == 1)
                {
                    if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 250)
                    {
                        MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1073}Finally![ib:confident][rb:very_positive]");
                    }
                    else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 100)
                    {
                        MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1071}Yes {?PLAYER.GENDER}mistress{?}master{\\?} [ib:confident2][rb:positive]");
                    }
                    else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 50)
                    {
                        MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1070}Alright.[ib:weary][rb:unsure]");
                    }
                    else
                    {
                        MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1072}What?! [ib:aggressive][rb:very_negative]");
                    }
                }
                else
                {
                    MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1109}Wait what?[ib:nervous][rb:very_negative]");
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed to launch ConversationCEEventResponseInPartyOnCondition : " + e);
            }

            return(true);
        }
Esempio n. 17
0
        public void SpawnTheHero(SpawnHero[] variables, PartyBase party)
        {
            foreach (SpawnHero heroVariables in variables)
            {
                try
                {
                    bool isFemale = heroVariables.Gender != null && heroVariables.Gender.ToLower() == "female";

                    string culture = null;
                    if (heroVariables.Culture != null)
                    {
                        switch (heroVariables.Culture.ToLower())
                        {
                        case "player":
                            culture = Hero.MainHero.Culture.StringId;
                            break;

                        case "captor":
                            culture = party.Culture.StringId;
                            break;

                        default:
                            culture = heroVariables.Culture;
                            break;
                        }
                    }
                    else
                    {
                        culture = heroVariables.Culture;
                    }

                    CharacterObject wanderer = (from x in CharacterObject.Templates
                                                where x.Occupation == Occupation.Wanderer && (culture == null || x.Culture != null && x.Culture.StringId == culture.ToLower()) && (heroVariables.Gender == null || x.IsFemale == isFemale)
                                                select x).GetRandomElementInefficiently();
                    Settlement randomElement = (from settlement in Settlement.All
                                                where settlement.Culture == wanderer.Culture && settlement.IsTown
                                                select settlement).GetRandomElementInefficiently();

                    Hero hero = HeroCreator.CreateSpecialHero(wanderer, randomElement, Clan.BanditFactions.GetRandomElementInefficiently(), null, -1);

                    GiveGoldAction.ApplyBetweenCharacters(null, hero, 20000, true);
                    hero.HasMet = true;
                    hero.ChangeState(Hero.CharacterStates.Active);
                    if (heroVariables.Clan != null)
                    {
                        switch (heroVariables.Clan.ToLower())
                        {
                        case "captor":
                            AddCompanionAction.Apply(party.Owner.Clan, hero);
                            break;

                        case "player":
                            AddCompanionAction.Apply(Clan.PlayerClan, hero);
                            break;

                        default:
                            break;
                        }
                    }

                    try
                    {
                        int level = 0;
                        int xp    = 0;

                        if (heroVariables.SkillsToLevel != null)
                        {
                            foreach (SkillToLevel skillToLevel in heroVariables.SkillsToLevel)
                            {
                                if (!string.IsNullOrWhiteSpace(skillToLevel.ByLevel))
                                {
                                    level = new CEVariablesLoader().GetIntFromXML(skillToLevel.ByLevel);
                                }
                                else if (!string.IsNullOrWhiteSpace(skillToLevel.ByXP))
                                {
                                    xp = new CEVariablesLoader().GetIntFromXML(skillToLevel.ByXP);
                                }

                                new Dynamics().SkillModifier(hero, skillToLevel.Id, level, xp, !skillToLevel.HideNotification, skillToLevel.Color);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        CECustomHandler.ForceLogToFile("Failed to level spawning Hero" + e);
                    }

                    if (heroVariables.Ref == "Prisoner" || heroVariables.Ref == "prisoner")
                    {
                        TakePrisonerAction.Apply(party, hero);
                    }
                    else
                    {
                        if (!party.IsMobile)
                        {
                            AddHeroToPartyAction.Apply(hero, party.Settlement.Party.MobileParty, true);
                        }
                        else
                        {
                            AddHeroToPartyAction.Apply(hero, party.MobileParty, true);
                        }
                    }

                    CampaignEventDispatcher.Instance.OnHeroCreated(hero, false);
                }
                catch (Exception e)
                {
                    CECustomHandler.ForceLogToFile("Failed to SpawnTheHero : " + e);
                }
            }
        }
Esempio n. 18
0
        private bool LaunchCaptorEvent(CEEvent OverrideEvent = null)
        {
            if (CESettings.Instance.EventCaptorNotifications)
            {
                if (notificationCaptorExists || progressEventExists)
                {
                    return(false);
                }
            }

            CEEvent returnedEvent;

            if (OverrideEvent == null)
            {
                CharacterObject captive = MobileParty.MainParty.Party.PrisonRoster.GetTroopRoster().GetRandomElement().Character;
                returnedEvent = CEEventManager.ReturnWeightedChoiceOfEventsPartyLeader(captive);
            }
            else
            {
                returnedEvent = OverrideEvent;
            }

            if (returnedEvent == null)
            {
                return(false);
            }
            notificationCaptorExists = true;

            if (CESettings.Instance.EventCaptorNotifications)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(returnedEvent.NotificationName))
                    {
                        new CESubModule().LoadCampaignNotificationTexture(returnedEvent.NotificationName);
                    }
                    else if (returnedEvent.SexualContent)
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_sexual_notification");
                    }
                    else
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_castle_notification");
                    }
                }
                catch (Exception e)
                {
                    InformationManager.DisplayMessage(new InformationMessage("LoadCampaignNotificationTextureFailure", Colors.Red));

                    CECustomHandler.ForceLogToFile("LoadCampaignNotificationTexture");
                    CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                }

                Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new CECaptorMapNotification(returnedEvent, new TextObject("{=CEEVENTS1090}Captor event is ready")));
            }
            else
            {
                if (Game.Current.GameStateManager.ActiveState is MapState mapState)
                {
                    Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode;

                    if (!mapState.AtMenu)
                    {
                        _extraVariables.menuToSwitchBackTo = null;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = null;
                        GameMenu.ActivateGameMenu("prisoner_wait");
                    }
                    else
                    {
                        _extraVariables.menuToSwitchBackTo = mapState.GameMenuId;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName;
                    }

                    GameMenu.SwitchToMenu(returnedEvent.Name);
                }
            }

            return(true);
        }
Esempio n. 19
0
        private void OnHourlyTick()
        {
            if (CESettings.Instance.EventCaptorOn && Hero.MainHero.IsPartyLeader && CheckEventHourly())
            {
                CECustomHandler.LogToFile("Checking Campaign Events");

                try
                {
                    bool shouldEventsFire = !progressEventExists;

                    if (delayedEvents.Count > 0 && shouldEventsFire)
                    {
                        CEEvent captorEventCheck = CheckDelayedCaptorEvent();
                        CEEvent randomEventCheck = CheckDelayedRandomEvent();

                        if (captorEventCheck != null)
                        {
                            notificationCaptorExists = false;
                            LaunchCaptorEvent(captorEventCheck);
                        }
                        else if (randomEventCheck != null)
                        {
                            notificationEventExists = false;
                            LaunchCaptorEvent(randomEventCheck);
                        }
                        else
                        {
                            shouldEventsFire = true;
                        }
                    }

                    if (shouldEventsFire)
                    {
                        if (MobileParty.MainParty.Party.PrisonRoster.Count > 0)
                        {
                            if (CESettings.Instance.EventRandomEnabled)
                            {
                                int randomNumber = MBRandom.RandomInt(100);

                                if (randomNumber < CESettings.Instance.EventRandomFireChance && !LaunchRandomEvent())
                                {
                                    LaunchCaptorEvent();
                                }
                                if (randomNumber > CESettings.Instance.EventRandomFireChance && !LaunchCaptorEvent())
                                {
                                    LaunchRandomEvent();
                                }
                            }
                            else
                            {
                                LaunchCaptorEvent();
                            }
                        }
                        else if (CESettings.Instance.EventRandomEnabled)
                        {
                            LaunchRandomEvent();
                        }
                    }
                }
                catch (Exception e)
                {
                    CECustomHandler.ForceLogToFile("CheckEventHourly Failure");
                    CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                }
            }

            // Pregnancies
            try
            {
                _heroPregnancies.ForEach(item =>
                {
                    if (item.Mother != null)
                    {
                        item.Mother.IsPregnant = true;
                        CheckOffspringsToDeliver(item);
                    }
                    else
                    {
                        item.AlreadyOccured = true;
                    }
                });

                _heroPregnancies.RemoveAll(item => item.AlreadyOccured);
            }
            catch (Exception e)
            {
                TextObject textObject = new TextObject("{=CEEVENTS1007}Error: resetting the CE pregnancy list");
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black));
                _heroPregnancies = new List <Pregnancy>();
                CECustomHandler.ForceLogToFile("Failed _heroPregnancies ForEach");
                CECustomHandler.ForceLogToFile(e.Message + " : " + e);
            }

            // Gear
            if (CESettings.Instance.EventCaptorGearCaptives)
            {
                try
                {
                    _returnEquipment.ForEach(CheckEquipmentToReturn);

                    _returnEquipment.RemoveAll(item => item.AlreadyOccured);
                }
                catch (Exception e)
                {
                    TextObject textObject = new TextObject("{=CEEVENTS1006}Error: resetting the return equipment list");
                    InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black));
                    _returnEquipment = new List <ReturnEquipment>();
                    CECustomHandler.ForceLogToFile("Failed _returnEquipment ForEach");
                    CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Behavior Duplicate found In PregnancyCampaignBehavior
        /// </summary>
        /// <param name="pregnancy"></param>
        private void CheckOffspringsToDeliver(Pregnancy pregnancy)
        {
            try
            {
                if (!pregnancy.Mother.IsAlive)
                {
                    pregnancy.AlreadyOccured = true;
                    return;
                }

                CalculatePregnancyWeight(pregnancy);

                if (pregnancy.DueDate.IsFuture)
                {
                    return;
                }
                PregnancyModel pregnancyModel = Campaign.Current.Models.PregnancyModel;

                Hero        mother          = pregnancy.Mother;
                bool        flag            = MBRandom.RandomFloat <= pregnancyModel.DeliveringTwinsProbability;
                List <Hero> aliveOffsprings = new List <Hero>();

                int num            = flag ? 2 : 1;
                int stillbornCount = 0;

                for (int i = 0; i < 1; i++)
                {
                    if (MBRandom.RandomFloat > pregnancyModel.StillbirthProbability)
                    {
                        bool isOffspringFemale = MBRandom.RandomFloat <= pregnancyModel.DeliveringFemaleOffspringProbability;

                        try
                        {
                            Hero item = DeliverOffSpring(pregnancy.Mother, pregnancy.Father, isOffspringFemale, 0);
                            aliveOffsprings.Add(item);
                        }
                        catch (Exception e)
                        {
                            CECustomHandler.ForceLogToFile("Bad pregnancy " + (isOffspringFemale ? "Female" : "Male"));
                            CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                            Hero item = HeroCreator.DeliverOffSpring(pregnancy.Mother, pregnancy.Father, !isOffspringFemale, null, 0);
                            aliveOffsprings.Add(item);
                        }
                    }
                    else
                    {
                        if (mother == Hero.MainHero)
                        {
                            TextObject textObject = new TextObject("{=pw4cUPEn}{MOTHER.LINK} has delivered stillborn.");
                            StringHelpers.SetCharacterProperties("MOTHER", mother.CharacterObject, textObject);
                            InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
                        }

                        stillbornCount++;
                    }
                }

                if (mother == Hero.MainHero || pregnancy.Father == Hero.MainHero)
                {
                    TextObject textObject = mother == Hero.MainHero
                        ? new TextObject("{=oIA9lkpc}You have given birth to {DELIVERED_CHILDREN}.")
                        : new TextObject("{=CEEVENTS1092}Your captive {MOTHER.NAME} has given birth to {DELIVERED_CHILDREN}.");

                    switch (stillbornCount)
                    {
                    case 2:
                        textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=Sn9a1Aba}two stillborn babies"));
                        break;

                    case 1 when aliveOffsprings.Count == 0:
                        textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=qWLq2y84}a stillborn baby"));
                        break;

                    case 1 when aliveOffsprings.Count == 1:
                        textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1168}one healthy and one stillborn baby"));
                        break;

                    case 0 when aliveOffsprings.Count == 1:
                        textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1169}a healthy baby"));
                        break;

                    case 0 when aliveOffsprings.Count == 2:
                        textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1170}two healthy babies"));
                        break;
                    }
                    StringHelpers.SetCharacterProperties("MOTHER", mother.CharacterObject, textObject);
                    InformationManager.AddQuickInformation(textObject);
                }

                if (mother.IsHumanPlayerCharacter || pregnancy.Father == Hero.MainHero)
                {
                    for (int i = 0; i < stillbornCount; i++)
                    {
                        ChildbirthLogEntry childbirthLogEntry = new ChildbirthLogEntry(mother, null);
                        LogEntry.AddLogEntry(childbirthLogEntry);
                        Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new ChildBornMapNotification(null, childbirthLogEntry.GetEncyclopediaText()));
                    }
                    foreach (Hero newbornHero in aliveOffsprings)
                    {
                        ChildbirthLogEntry childbirthLogEntry2 = new ChildbirthLogEntry(mother, newbornHero);
                        LogEntry.AddLogEntry(childbirthLogEntry2);
                        Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new ChildBornMapNotification(newbornHero, childbirthLogEntry2.GetEncyclopediaText()));
                    }
                }

                mother.IsPregnant        = false;
                pregnancy.AlreadyOccured = true;

                ChangeWeight(pregnancy.Mother, 0, MBRandom.RandomFloatRanged(0.4025f, 0.6025f));
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Bad pregnancy");
                CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                TextObject textObject = new TextObject("{=CEEVENTS1008}Error: bad pregnancy in CE pregnancy list");
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black));
                pregnancy.AlreadyOccured = true;
            }
        }
Esempio n. 21
0
        public string CEWaitingList()
        {
            List <string> eventNames = new List <string>();

            if (CEPersistence.CEWaitingList != null && CEPersistence.CEWaitingList.Count > 0)
            {
                CECustomHandler.LogToFile("Having " + CEPersistence.CEWaitingList.Count + " of events to weight and check conditions on.");

                foreach (CEEvent listEvent in CEPersistence.CEWaitingList)
                {
                    string result = new CEEventChecker(listEvent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter, PlayerCaptivity.CaptorParty);

                    if (result == null)
                    {
                        int weightedChance = 10;

                        try
                        {
                            if (listEvent.WeightedChanceOfOccuring != null)
                            {
                                weightedChance = new CEVariablesLoader().GetIntFromXML(listEvent.WeightedChanceOfOccuring);
                            }
                        }
                        catch (Exception)
                        {
                            CECustomHandler.LogToFile("Missing WeightedChanceOfOccuring");
                        }

                        for (int a = weightedChance; a > 0; a--)
                        {
                            eventNames.Add(listEvent.Name);
                        }
                    }
                    else
                    {
                        CECustomHandler.LogToFile(result);
                    }
                }

                CECustomHandler.LogToFile("Number of Filtered events is " + eventNames.Count);

                try
                {
                    if (eventNames.Count > 0)
                    {
                        int    test = MBRandom.Random.Next(0, eventNames.Count);
                        string randomWeightedChoice = eventNames[test];
                        CECustomHandler.LogToFile("CEWaitingList Choice is " + randomWeightedChoice);
                        return(randomWeightedChoice);
                    }
                }
                catch (Exception)
                {
                    CECustomHandler.ForceLogToFile("Waiting Menu: Something is broken?");
                }
            }

            CECustomHandler.LogToFile("Number of Filtered events is " + eventNames.Count);

            return(null);
        }
Esempio n. 22
0
        public static CEEvent ReturnWeightedChoiceOfEventsPartyLeader(CharacterObject captive)
        {
            List <CEEvent> events = new List <CEEvent>();

            CECustomHandler.LogToFile("Number of Filitered events is " + events.Count);

            if (CEPersistence.CECallableEvents == null || CEPersistence.CECallableEvents.Count <= 0)
            {
                return(null);
            }
            CECustomHandler.LogToFile("Having " + CEPersistence.CECallableEvents.Count + " of events to weight and check conditions on.");

            foreach (CEEvent listEvent in CEPersistence.CECallableEvents)
            {
                if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captor))
                {
                    string result = new CEEventChecker(listEvent).FlagsDoMatchEventConditions(captive, PartyBase.MainParty);

                    if (result == null)
                    {
                        int weightedChance = 10;

                        if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.IgnoreAllOther))
                        {
                            CECustomHandler.LogToFile("IgnoreAllOther detected - autofire " + listEvent.Name);
                            return(listEvent);
                        }

                        try
                        {
                            weightedChance = new CEVariablesLoader().GetIntFromXML(listEvent.WeightedChanceOfOccuring);
                        }
                        catch (Exception)
                        {
                            CECustomHandler.LogToFile("Missing WeightedChanceOfOccuring");
                        }

                        for (int a = weightedChance; a > 0; a--)
                        {
                            events.Add(listEvent);
                        }
                    }
                    else
                    {
                        CECustomHandler.LogToFile(result);
                    }
                }
            }

            CECustomHandler.LogToFile("Number of Filtered events is " + events.Count);

            try
            {
                if (events.Count > 0)
                {
                    CEEvent randomEvent = events.GetRandomElement();
                    randomEvent.Captive = captive;
                    return(randomEvent);
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("eventNames.Count Broken : " + e);
                PrintDebugInGameTextMessage("eventNames.Count Broken");
            }

            return(null);
        }
Esempio n. 23
0
        internal void ChangeSpouse(Hero hero, Hero spouseHero)
        {
            try
            {
                if (hero == null)
                {
                    return;
                }
                Hero heroSpouse = hero.Spouse;

                if (!hero.IsHumanPlayerCharacter && hero.IsFactionLeader)
                {
                    RemoveFactionLeader(hero);
                }
                else if (!spouseHero.IsHumanPlayerCharacter && spouseHero.IsFactionLeader)
                {
                    RemoveFactionLeader(spouseHero);
                }

                if (heroSpouse != null)
                {
                    TextObject textObject = GameTexts.FindText("str_CE_spouse_leave");
                    textObject.SetTextVariable("HERO", hero.Name);
                    textObject.SetTextVariable("SPOUSE", heroSpouse.Name);
                    InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Magenta));

                    if (heroSpouse.Father != null)
                    {
                        heroSpouse.Clan = heroSpouse.Father.Clan;
                    }
                    else if (heroSpouse.Mother != null)
                    {
                        heroSpouse.Clan = heroSpouse.Mother.Clan;
                    }
                    hero.Spouse = null;
                }

                if (spouseHero == null)
                {
                    return;
                }

                if (hero.Clan == spouseHero.Clan)
                {
                    return;
                }

                Hero spouseHeroSpouse = spouseHero.Spouse;

                if (spouseHeroSpouse != null)
                {
                    TextObject textObject3 = GameTexts.FindText("str_CE_spouse_leave");
                    textObject3.SetTextVariable("HERO", hero.Name);
                    textObject3.SetTextVariable("SPOUSE", spouseHeroSpouse.Name);
                    InformationManager.DisplayMessage(new InformationMessage(textObject3.ToString(), Colors.Magenta));

                    if (spouseHeroSpouse.Father != null)
                    {
                        spouseHeroSpouse.Clan = spouseHeroSpouse.Father.Clan;
                    }
                    else if (spouseHeroSpouse.Mother != null)
                    {
                        spouseHeroSpouse.Clan = spouseHeroSpouse.Mother.Clan;
                    }
                    spouseHero.Spouse = null;
                }

                MarriageAction.Apply(hero, spouseHero);
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed ChangeSpouse " + e + " HERO1: " + hero + " HERO2: " + spouseHero);
            }
        }
Esempio n. 24
0
        internal void ConsequenceCompanions(CharacterObject hero, PartyBase party)
        {
            if (_option.Companions != null)
            {
                try
                {
                    foreach (Companion companion in _option.Companions)
                    {
                        Hero        referenceHero;
                        List <Hero> heroes = new List <Hero>();

                        if (companion.Ref != null)
                        {
                            switch (companion.Ref.ToLower())
                            {
                            case "hero":
                                if (!hero.IsHero)
                                {
                                    continue;
                                }
                                referenceHero = hero.HeroObject;
                                break;

                            case "captor":
                                if (!party.Leader.IsHero)
                                {
                                    continue;
                                }
                                referenceHero = party.Leader.HeroObject;
                                break;

                            default:
                                referenceHero = Hero.MainHero;
                                break;
                            }

                            if (companion.Type != null)
                            {
                                switch (companion.Type.ToLower())
                                {
                                case "spouse":
                                    if (referenceHero.Spouse == null)
                                    {
                                        continue;
                                    }
                                    heroes.Add(referenceHero.Spouse);
                                    break;

                                case "companion":
                                    if (referenceHero.Clan == null)
                                    {
                                        continue;
                                    }
                                    foreach (Hero companionHero in referenceHero.Clan.Companions)
                                    {
                                        heroes.Add(companionHero);
                                    }
                                    break;

                                default:
                                    if (referenceHero.Spouse != null)
                                    {
                                        heroes.Add(referenceHero.Spouse);
                                    }
                                    if (referenceHero.Clan != null)
                                    {
                                        foreach (Hero companionHero in referenceHero.Clan.Companions)
                                        {
                                            heroes.Add(companionHero);
                                        }
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                if (referenceHero.Spouse != null)
                                {
                                    heroes.Add(referenceHero.Spouse);
                                }
                                if (referenceHero.Clan != null)
                                {
                                    foreach (Hero companionHero in referenceHero.Clan.Companions)
                                    {
                                        heroes.Add(companionHero);
                                    }
                                }
                            }
                        }
                        else if (companion.Id != null)
                        {
                            Hero heroCompanion = _listedEvent.SavedCompanions.FirstOrDefault((item) => item.Key == companion.Id).Value;
                            if (hero != null)
                            {
                                heroes.Add(heroCompanion);
                            }
                        }

                        if (heroes.Count == 0)
                        {
                            continue;
                        }

                        if (companion.Location != null)
                        {
                            switch (companion.Location.ToLower())
                            {
                            case "prisoner":
                                heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedToAsPrisoner != party && companionHero.IsPrisoner); });
                                break;

                            case "party":
                                heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedTo?.Party != null && companionHero.PartyBelongedTo.Party != party && !companionHero.PartyBelongedTo.IsGarrison); });
                                break;

                            case "settlement":
                                heroes = heroes.FindAll((companionHero) => { return(companionHero?.CurrentSettlement != null); });
                                break;

                            case "current prisoner":
                                heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedToAsPrisoner == party); });
                                break;

                            case "current":
                                heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedTo?.Party == party); });
                                break;

                            default:
                                break;
                            }
                            if (heroes.Count == 0)
                            {
                                continue;
                            }
                        }

                        if (companion.UseOtherConditions != null && companion.UseOtherConditions.ToLower() != "false")
                        {
                            CEEvent triggeredEvent = CEPersistence.CEEventList.Find(item => item.Name == companion.UseOtherConditions);

                            if (triggeredEvent == null)
                            {
                                continue;
                            }

                            heroes = heroes.FindAll((companionHero) =>
                            {
                                string conditionals = new CEEventChecker(triggeredEvent).FlagsDoMatchEventConditions(companionHero.CharacterObject, party);
                                if (conditionals != null)
                                {
                                    CECustomHandler.LogToFile(conditionals);
                                    return(false);
                                }
                                else
                                {
                                    return(true);
                                }
                            });
                        }

                        if (heroes.Count == 0)
                        {
                            continue;
                        }

                        Hero heroSelected = heroes.GetRandomElement();

                        try
                        {
                            ConsequenceForceMarry(companion, heroSelected);
                            ConsequenceLeaveSpouse(companion, heroSelected);
                            ConsequenceGold(companion, heroSelected);
                            ConsequenceChangeGold(companion, heroSelected);
                            ConsequenceChangeCaptorGold(companion, heroSelected);
                            ConsequenceRenown(companion, heroSelected);
                            ConsequenceChangeCaptorRenown(companion, heroSelected);
                            ConsequenceChangeHealth(companion, heroSelected);
                            ConsequenceChangeTrait(companion, heroSelected);
                            ConsequenceChangeSkill(companion, heroSelected);
                            ConsequenceSlaveryFlags(companion, heroSelected);
                            ConsequenceProstitutionFlags(companion, heroSelected);
                            ConsequenceChangeMorale(companion, heroSelected);
                            ConsequenceSpecificCaptorRelations(companion, heroSelected);
                            ConsequenceImpregnation(companion, heroSelected);
                            ConsequenceImpregnationByLeader(companion, heroSelected);
                            ConsequenceImpregnationByPlayer(companion, heroSelected);
                            ConsequenceChangeClan(companion, heroSelected);
                            ConsequenceChangeKingdom(companion, heroSelected);
                            ConsequenceEscape(companion, heroSelected);
                            ConsequenceRelease(companion, heroSelected);
                            ConsequenceWoundPrisoner(companion, heroSelected);
                            ConsequenceKillPrisoner(companion, heroSelected);
                            ConsequenceStrip(companion, heroSelected);
                            ConsequenceGainRandomPrisoners(companion, heroSelected);
                        }
                        catch (Exception e)
                        {
                            CECustomHandler.ForceLogToFile("Incorrect ConsequenceCompanions heroSelected: " + e.ToString());
                        }
                    }
                }
                catch (Exception e)
                {
                    CECustomHandler.ForceLogToFile("Incorrect ConsequenceCompanions: " + e.ToString());
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Custom CheckCaptivityChange Function
        /// </summary>
        /// <param name="dt"></param>
        /// <returns>EventName</returns>
        public override string CheckCaptivityChange(float dt)
        {
            if (!PlayerCaptivity.IsCaptive)
            {
                return(DefaultOverridenCheckCaptivityChange(dt));
            }

            if (Hero.MainHero.Age < 18f)
            {
                EndCaptivityAction.ApplyByReleasing(Hero.MainHero);
                InformationManager.DisplayMessage(new InformationMessage(("Invalid Age: " + Hero.MainHero.Age), Colors.Gray));
                CECustomHandler.ForceLogToFile("Underaged Player Detected. Age: " + Hero.MainHero.Age);
                return("menu_captivity_end_by_party_removed");
            }

            if (CEHelper.delayedEvents.Count > 0)
            {
                string eventToFire = null;

                bool shouldFireEvent = CEHelper.delayedEvents.Any(item =>
                {
                    if (item.eventName != null && item.eventTime < Campaign.Current.CampaignStartTime.ElapsedHoursUntilNow)
                    {
                        CECustomHandler.LogToFile("Firing " + item.eventName);
                        if (item.conditions == true)
                        {
                            string result = CEEventManager.FireSpecificEvent(item.eventName);
                            switch (result)
                            {
                            case "$FAILEDTOFIND":
                                CECustomHandler.LogToFile("Failed to load event list.");
                                break;

                            case "$EVENTNOTFOUND":
                                CECustomHandler.LogToFile("Event not found.");
                                break;

                            case "$EVENTCONDITIONSNOTMET":
                                CECustomHandler.LogToFile("Event conditions are not met.");
                                break;

                            default:
                                if (result.StartsWith("$"))
                                {
                                    CECustomHandler.LogToFile(result.Substring(1));
                                }
                                else
                                {
                                    eventToFire       = item.eventName;
                                    item.hasBeenFired = true;
                                    return(true);
                                }
                                break;
                            }
                        }
                        else
                        {
                            eventToFire        = item.eventName.ToLower();
                            CEEvent foundevent = CEPersistence.CEEventList.FirstOrDefault(ceevent => ceevent.Name.ToLower() == eventToFire);
                            if (foundevent != null && !foundevent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captive))
                            {
                                eventToFire = null;
                                return(false);
                            }
                            item.hasBeenFired = true;
                            return(true);
                        }
                    }
                    return(false);
                });

                if (shouldFireEvent)
                {
                    CEHelper.delayedEvents.RemoveAll(item => item.hasBeenFired);
                    PlayerCaptivity.LastCheckTime = CampaignTime.Now;
                    return(eventToFire);
                }
            }

            if (PlayerCaptivity.CaptorParty != null && !PlayerCaptivity.CaptorParty.IsSettlement)
            {
                if (!CheckEvent())
                {
                    return(DefaultOverridenCheckCaptivityChange(dt));
                }
                PlayerCaptivity.LastCheckTime = CampaignTime.Now;

                CECustomHandler.LogToFile("About to choose a event!");
                CEEvent captiveEvent = CEEventManager.ReturnWeightedChoiceOfEvents();

                if (captiveEvent != null)
                {
                    return(captiveEvent.Name);
                }
            }
            else
            {
                if (!CheckEvent())
                {
                    return(DefaultOverridenCheckCaptivityChange(dt));
                }
                PlayerCaptivity.LastCheckTime = CampaignTime.Now;

                CECustomHandler.LogToFile("About to choose a settlement event!");
                CEEvent captiveEvent = CEEventManager.ReturnWeightedChoiceOfEvents();

                if (captiveEvent != null)
                {
                    return(captiveEvent.Name);
                }
            }

            return(DefaultOverridenCheckCaptivityChange(dt));
        }
Esempio n. 26
0
        internal void CECaptorContinue(MenuCallbackArgs args)
        {
            CEPersistence.animationPlayEvent = false;

            try
            {
                if (PlayerCaptivity.CaptorParty != null)
                {
                    string waitingList = new WaitingList().CEWaitingList();

                    if (waitingList != null)
                    {
                        GameMenu.ActivateGameMenu(waitingList);
                    }
                    else
                    {
                        new CESubModule().LoadTexture("default");

                        GameMenu.SwitchToMenu(PlayerCaptivity.CaptorParty.IsSettlement
                                                  ? "settlement_wait"
                                                  : "prisoner_wait");
                    }
                }
                else
                {
                    if (CECampaignBehavior.ExtraProps.menuToSwitchBackTo != null)
                    {
                        if (CECampaignBehavior.ExtraProps.menuToSwitchBackTo != "prisoner_wait")
                        {
                            GameMenu.SwitchToMenu(CECampaignBehavior.ExtraProps.menuToSwitchBackTo);
                        }
                        else
                        {
                            CECustomHandler.ForceLogToFile("General Error: CECaptorContinue : menuToSwitchBackTo : prisoner_wait");
                            if (Settlement.CurrentSettlement != null)
                            {
#if BETA
                                EncounterManager.StartSettlementEncounter(MobileParty.MainParty, Settlement.CurrentSettlement);
#else
                                Campaign.Current.HandleSettlementEncounter(MobileParty.MainParty, Settlement.CurrentSettlement);
#endif
                            }
                            else
                            {
                                GameMenu.ExitToLast();
                            }
                            Campaign.Current.TimeControlMode = Campaign.Current.LastTimeControlMode;
                            new CESubModule().LoadTexture("default");
                            return;
                        }
                        CECampaignBehavior.ExtraProps.menuToSwitchBackTo = null;

                        if (CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo != null)
                        {
                            args.MenuContext.SetBackgroundMeshName(CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo);
                            CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = null;
                        }
                    }
                    else
                    {
                        if (Settlement.CurrentSettlement != null)
                        {
#if BETA
                            EncounterManager.StartSettlementEncounter(MobileParty.MainParty, Settlement.CurrentSettlement);
#else
                            Campaign.Current.HandleSettlementEncounter(MobileParty.MainParty, Settlement.CurrentSettlement);
#endif
                        }
                        else
                        {
                            GameMenu.ExitToLast();
                        }
                    }

                    Campaign.Current.TimeControlMode = Campaign.Current.LastTimeControlMode;
                    new CESubModule().LoadTexture("default");
                }
            }
            catch (Exception e)
            {
                CECampaignBehavior.ExtraProps.menuToSwitchBackTo = null;
                CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = null;
                CECustomHandler.ForceLogToFile("Critical Error: CECaptorContinue : " + e);
            }
        }