Example #1
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);
            }
        }
Example #2
0
        internal void CECaptorReleasePrisoners(MenuCallbackArgs args, int amount = 10, bool releaseHeroes = false)
        {
            try
            {
                int prisonerCount = MobileParty.MainParty.PrisonRoster.Count;
                if (prisonerCount < amount)
                {
                    amount = prisonerCount;
                }
                MobileParty.MainParty.PrisonRoster.KillNumberOfMenRandomly(amount, false);
                if (releaseHeroes)
                {
                    foreach (TroopRosterElement element in MobileParty.MainParty.PrisonRoster.GetTroopRoster())
                    {
                        if (element.Character.IsHero)
                        {
                            element.Character.HeroObject.ChangeState(Hero.CharacterStates.Active);
                        }
                    }
                    MobileParty.MainParty.PrisonRoster.Clear();
                }

                TextObject textObject = GameTexts.FindText("str_CE_release_prisoners");
                textObject.SetTextVariable("HERO", Hero.MainHero.Name);
                textObject.SetTextVariable("AMOUNT", amount);
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
            }
            catch (Exception)
            {
                CECustomHandler.LogToFile("Couldn't release any prisoners.");
            }
        }
Example #3
0
        internal void ConsequenceChangeCaptorGold(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeCaptorGold))
            {
                return;
            }

            if (hero.PartyBelongedToAsPrisoner.LeaderHero == null)
            {
                return;
            }

            try
            {
                int level = 0;

                if (!string.IsNullOrEmpty(companion.GoldTotal))
                {
                    level = new CEVariablesLoader().GetIntFromXML(companion.GoldTotal);
                }
                else
                {
                    CECustomHandler.LogToFile("Missing GoldTotal");
                }

                GiveGoldAction.ApplyBetweenCharacters(null, hero.PartyBelongedToAsPrisoner.LeaderHero, level);
            }
            catch (Exception) { CECustomHandler.LogToFile("Invalid GoldTotal"); }
        }
Example #4
0
        internal void ConsequenceChangeCaptorRenown(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeCaptorRenown))
            {
                return;
            }

            if (hero.PartyBelongedToAsPrisoner.LeaderHero == null)
            {
                return;
            }

            try
            {
                if (!string.IsNullOrEmpty(companion.RenownTotal))
                {
                    _dynamics.RenownModifier(new CEVariablesLoader().GetIntFromXML(companion.RenownTotal), hero.PartyBelongedToAsPrisoner.LeaderHero);
                }
                else
                {
                    CECustomHandler.LogToFile("Missing RenownTotal");
                    _dynamics.RenownModifier(MBRandom.RandomInt(-5, 5), hero.PartyBelongedToAsPrisoner.LeaderHero);
                }
            }
            catch (Exception) { CECustomHandler.LogToFile("Invalid RenownTotal"); }
        }
Example #5
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);
     }
 }
        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);
            }
        }
Example #7
0
        internal void ConsequenceChangeSkill(Companion companion, Hero hero)
        {
            try
            {
                int level = 0;
                int xp    = 0;

                if (companion.SkillsToLevel != null && companion.SkillsToLevel.Count(SkillToLevel => SkillToLevel.Ref.ToLower() == "hero") != 0)
                {
                    foreach (SkillToLevel skillToLevel in companion.SkillsToLevel)
                    {
                        if (skillToLevel.Ref.ToLower() == "captor" && hero.PartyBelongedToAsPrisoner.LeaderHero == null)
                        {
                            continue;
                        }
                        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(skillToLevel.Ref.ToLower() != "hero" ? hero.PartyBelongedToAsPrisoner.LeaderHero : hero, skillToLevel.Id, level, xp, !skillToLevel.HideNotification, skillToLevel.Color);
                    }
                }
            }
            catch (Exception) { CECustomHandler.LogToFile("Invalid Skill Flags"); }
        }
Example #8
0
        internal void ConsequenceChangeMorale(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeMorale))
            {
                return;
            }

            PartyBase party = hero.IsPrisoner
                ? hero.PartyBelongedToAsPrisoner //captive
                : hero.PartyBelongedTo?.Party;   //random, captor

            try
            {
                if (!string.IsNullOrEmpty(companion.MoraleTotal))
                {
                    _dynamics.MoraleChange(new CEVariablesLoader().GetIntFromXML(companion.MoraleTotal), party);
                }
                else
                {
                    CECustomHandler.LogToFile("Missing MoralTotal");
                    _dynamics.MoraleChange(MBRandom.RandomInt(-5, 5), party);
                }
            }
            catch (Exception) { CECustomHandler.LogToFile("Invalid MoralTotal"); }
        }
        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);
            }
        }
Example #10
0
        internal void GainSkills(SkillObject skillObject, int amount, int chance, Hero hero = null)
        {
            if (MBRandom.Random.Next(30) >= chance)
            {
                return;
            }
            if (hero == null)
            {
                hero = Hero.MainHero;
            }

            try
            {
                hero.HeroDeveloper.AddSkillXp(skillObject, amount);
            }
            catch (Exception)
            {
                CECustomHandler.LogToFile("Failed to add to skill");
            }

            //TextObject textObject = new TextObject("{HERO} has learned {SKILL_AMOUNT} {SKILL} XP.", null);
            //textObject.SetTextVariable("HERO", Hero.MainHero.Name);
            //Hero.MainHero.AddSkillXp(skilltoget, 1f);
            //textObject.SetTextVariable("SKILL", skilltoget.Name);
            //textObject.SetTextVariable("SKILL_AMOUNT", amount);
            //InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
        }
Example #11
0
 public static CESkillNode FindSkillNode(string skill)
 {
     try
     {
         return(_Skills.Find(skillNode => skillNode.Id == skill));
     }
     catch (Exception e)
     {
         CECustomHandler.ForceLogToFile(skill + " : " + e);
         return(null);
     }
 }
        public float GetFloatFromXML(string numpassed)
        {
            try
            {
                float number = 0f;

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

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

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

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

                        break;

                    case 2:
                        number = MBRandom.RandomFloatRanged(float.Parse(splitPass[1]));

                        break;

                    default:
                        number = MBRandom.RandomFloat;

                        break;
                    }
                }
                else
                {
                    number = float.Parse(numpassed);
                }

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

                return(0f);
            }
        }
Example #13
0
 internal void CECaptivityChange(ref MenuCallbackArgs args, PartyBase party)
 {
     try
     {
         PlayerCaptivity.CaptorParty = party;
         PlayerCaptivity.StartCaptivity(party);
         CEHelper.delayedEvents.Clear();
     }
     catch (Exception e)
     {
         CECustomHandler.LogToFile("Failed to exception: " + e.Message + " stacktrace: " + e.StackTrace);
     }
 }
        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);
            }
        }
Example #15
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());
            }
        }
Example #16
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);
            }
        }
        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);
            }
        }
Example #18
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);
        }
Example #19
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);
                }
            }
        }
Example #20
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);
                }
            }
        }
Example #21
0
        private void ConsequenceSpecificCaptorRelations(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeRelation))
            {
                return;
            }
            bool InformationMessage = !companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.NoInformationMessage);
            bool NoMessages         = companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.NoMessages);


            try
            {
                _dynamics.RelationsModifier(hero, new CEVariablesLoader().GetIntFromXML(companion.RelationTotal), null, InformationMessage && !NoMessages, !InformationMessage && !NoMessages);
            }
            catch (Exception)
            {
                CECustomHandler.LogToFile("Missing RelationTotal");
                _dynamics.RelationsModifier(hero, MBRandom.RandomInt(-5, 5), null, InformationMessage && !NoMessages, !InformationMessage && !NoMessages);
            }
        }
Example #22
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);
            }
        }
Example #23
0
 internal void CECaptorKillPrisoners(MenuCallbackArgs args, int amount = 10, bool killHeroes = false)
 {
     try
     {
         int prisonerCount = MobileParty.MainParty.PrisonRoster.Count;
         if (prisonerCount < amount)
         {
             amount = prisonerCount;
         }
         MobileParty.MainParty.PrisonRoster.KillNumberOfMenRandomly(amount, killHeroes);
         TextObject textObject = GameTexts.FindText("str_CE_kill_prisoners");
         textObject.SetTextVariable("HERO", Hero.MainHero.Name);
         textObject.SetTextVariable("AMOUNT", amount);
         InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
     }
     catch (Exception)
     {
         CECustomHandler.LogToFile("Couldn't kill any prisoners.");
     }
 }
Example #24
0
        private void ConsequenceImpregnationByPlayer(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ImpregnationByPlayer))
            {
                return;
            }

            try
            {
                if (!string.IsNullOrEmpty(companion.PregnancyRiskModifier))
                {
                    _impregnation.CaptivityImpregnationChance(hero, new CEVariablesLoader().GetIntFromXML(companion.PregnancyRiskModifier), false, false, Hero.MainHero);
                }
                else
                {
                    CECustomHandler.LogToFile("Missing PregnancyRiskModifier");
                    _impregnation.CaptivityImpregnationChance(hero, 30, false, false, Hero.MainHero);
                }
            }
            catch (Exception) { CECustomHandler.LogToFile("Invalid PregnancyRiskModifier"); }
        }
Example #25
0
        internal void ConsequenceChangeHealth(Companion companion, Hero hero)
        {
            if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeHealth))
            {
                return;
            }

            try
            {
                if (!string.IsNullOrEmpty(companion.HealthTotal))
                {
                    hero.HitPoints += new CEVariablesLoader().GetIntFromXML(companion.HealthTotal);
                }
                else
                {
                    CECustomHandler.LogToFile("Invalid HealthTotal");
                    hero.HitPoints += MBRandom.RandomInt(-20, 20);
                }
            }
            catch (Exception) { CECustomHandler.LogToFile("Missing HealthTotal"); }
        }
        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;
            }
        }
 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);
     }
 }
Example #28
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);
        }
Example #29
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));
        }
Example #30
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);
            }
        }