private void OnSelectedCultureChanged(SelectorVM <SelectorItemVM> cultures)
        {
            var selectedCulture = SelectedCultureId(cultures);

            if (selectedCulture == null)
            {
                _groupsInSelection = _characterCollection.GroupsInCultures.Values.SelectMany(list => list)
                                     .DistinctBy(group => group.Info.FormationClass).ToList();
                var groups = _groupsInSelection.Select(g => g.Info.Name).Prepend(GameTexts.FindText("str_ebt_all"))
                             .ToList();
                var index = Groups.SelectedIndex;
                if (index >= groups.Count)
                {
                    index = 0;
                }
                RefreshSelector(Groups, groups, index, OnSelectedGroupChanged);
            }
            else
            {
                _groupsInSelection = _characterCollection.GroupsInCultures[selectedCulture];
                var groups = _groupsInSelection.Select(group => group.Info.Name)
                             .Prepend(GameTexts.FindText("str_ebt_all")).ToList();
                var index = Groups.SelectedIndex;
                if (index >= groups.Count)
                {
                    index = 0;
                }
                RefreshSelector(Groups, groups, index, OnSelectedGroupChanged);
            }
        }
 private static void Postfix(MobileParty party, ref ExplainedNumber result)
 {
     if (party.ItemRoster.FoodVariety > 10)
     {
         result.Add(party.ItemRoster.FoodVariety - 4f, GameTexts.FindText("str_food_bonus_morale", (string)null));
     }
 }
Exemplo n.º 3
0
        private void SetModifier(int amount, Hero hero, SkillObject skill, SkillObject flag, bool displayMessage = true, bool quickInformation = false)
        //Warning: SkillObject flag never used.
        {
            if (amount == 0)
            {
                if ((displayMessage || quickInformation) && hero.GetSkillValue(skill) > 0)
                {
                    TextObject textObject = GameTexts.FindText("str_CE_level_start");
                    textObject.SetTextVariable("SKILL", skill.Name);
                    textObject.SetTextVariable("HERO", hero.Name);

                    if (hero.GetSkillValue(skill) > 1)
                    {
                        if (displayMessage)
                        {
                            InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
                        }
                        if (quickInformation)
                        {
                            InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation");
                        }
                    }
                }

                hero.SetSkillValue(skill, 0);
            }
            else
            {
                int currentValue = hero.GetSkillValue(skill);
                int valueToSet   = currentValue + amount;
                if (valueToSet < 1)
                {
                    valueToSet = 1;
                }
                hero.SetSkillValue(skill, valueToSet);

                if (!displayMessage && !quickInformation)
                {
                    return;
                }
                TextObject textObject = GameTexts.FindText("str_CE_level_skill");
                textObject.SetTextVariable("HERO", hero.Name);
                textObject.SetTextVariable("SKILL", skill.Name);

                textObject.SetTextVariable("NEGATIVE", amount >= 0 ? 0 : 1);
                textObject.SetTextVariable("PLURAL", amount >= 2 ? 1 : 0);

                textObject.SetTextVariable("SKILL_AMOUNT", Math.Abs(amount));
                textObject.SetTextVariable("TOTAL_AMOUNT", valueToSet);
                if (displayMessage)
                {
                    InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
                }

                if (quickInformation)
                {
                    InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation");
                }
            }
        }
Exemplo n.º 4
0
        private void AllianceFormed(AllianceEvent allianceFormedEvent)
        {
            var txt = new TextObject("{=PdN5g5ub}{KINGDOM} has formed an alliance with {OTHER_KINGDOM}!");

            txt.SetTextVariable("KINGDOM", allianceFormedEvent.Kingdom.Name);
            txt.SetTextVariable("OTHER_KINGDOM", allianceFormedEvent.OtherKingdom.Name);
            var txtRendered = txt.ToString();

            if (allianceFormedEvent.Kingdom == Clan.PlayerClan.Kingdom ||
                allianceFormedEvent.OtherKingdom == Clan.PlayerClan.Kingdom)
            {
                InformationManager.ShowInquiry(
                    new InquiryData(new TextObject("{=qIa19an4}Alliance Formed").ToString(),
                                    txtRendered,
                                    true,
                                    false,
                                    GameTexts.FindText("str_ok", null).ToString(),
                                    null,
                                    null,
                                    null));
            }
            else
            {
                InformationManager.DisplayMessage(new InformationMessage(txtRendered, SubModule.StdTextColor));
            }
        }
Exemplo n.º 5
0
 public void UpdateProperties()
 {
     RelationToMainHeroText = "";
     GovernorOfText         = "";
     Skills.Clear();
     Traits.Clear();
     UpdateLearningSkillSelection();
     foreach (SkillObject item in SkillObject.All)
     {
         Skills.Add(new EncyclopediaSkillVM(item, _hero.GetSkillValue(item)));
     }
     foreach (TraitObject heroTrait in CampaignUIHelper.GetHeroTraits())
     {
         if (_hero.GetTraitLevel(heroTrait) != 0)
         {
             Traits.Add(new EncyclopediaTraitItemVM(heroTrait, _hero));
         }
     }
     IsChild = _hero.IsChild;
     if (_hero != Hero.MainHero)
     {
         RelationToMainHeroText = CampaignUIHelper.GetHeroRelationToHeroText(_hero, Hero.MainHero).ToString();
     }
     if (_hero.GovernorOf != null)
     {
         GameTexts.SetVariable("SETTLEMENT_NAME", _hero.GovernorOf.Owner.Settlement.EncyclopediaLinkWithName);
         GovernorOfText = GameTexts.FindText("str_governor_of_label").ToString();
     }
     HeroModel = new HeroViewModel();
     HeroModel.FillFrom(_hero);
     Banner_9 = new ImageIdentifierVM(BannerCode.CreateFrom(_hero.ClanBanner), nineGrid: true);
 }
Exemplo n.º 6
0
        public static void Apply(Kingdom kingdom, Kingdom otherKingdom)
        {
            Kingdom playerKingdom = Clan.PlayerClan?.Kingdom;

            if (otherKingdom == playerKingdom && playerKingdom.Leader == Hero.MainHero)
            {
                TextObject textObject = new TextObject("{=384jX28Q}{KINGDOM} is breaking the alliance with {PLAYER_KINGDOM}.");
                textObject.SetTextVariable("KINGDOM", kingdom.Name);
                textObject.SetTextVariable("PLAYER_KINGDOM", otherKingdom.Name);

                InformationManager.ShowInquiry(new InquiryData(
                                                   new TextObject("{=D1ZQKZr1}Alliance Broken").ToString(),
                                                   textObject.ToString(),
                                                   true,
                                                   false,
                                                   GameTexts.FindText("str_ok", null).ToString(),
                                                   null,
                                                   () => ApplyInternal(kingdom, otherKingdom),
                                                   null,
                                                   ""), true);
            }
            else
            {
                ApplyInternal(kingdom, otherKingdom);
            }
        }
Exemplo n.º 7
0
        private static bool WatchSiegeCondition(MenuCallbackArgs args)
        {
            try
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Mission;
                if (MobileParty.MainParty.BesiegedSettlement == null || !Hero.MainHero.IsWounded)
                {
                    args.IsEnabled = false;
                    return(false);
                }
                if (MobileParty.MainParty.BesiegedSettlement != null && MobileParty.MainParty.BesiegedSettlement.SiegeEvent != null && MobileParty.MainParty.BesiegedSettlement.SiegeEvent.BesiegerCamp != null && MobileParty.MainParty.BesiegedSettlement.SiegeEvent.BesiegerCamp.BesiegerParty == MobileParty.MainParty)
                {
                    Settlement settlement = PlayerEncounter.EncounteredParty != null ? PlayerEncounter.EncounteredParty.Settlement : PlayerSiege.PlayerSiegeEvent.BesiegedSettlement;
                    if (PlayerSiege.PlayerSide == BattleSideEnum.Attacker && !settlement.SiegeEvent.BesiegerCamp.IsPreparationComplete)
                    {
                        args.IsEnabled = false;
                        args.Tooltip   = new TextObject("{=bCuxzp1N}You need to wait for the siege equipment to be prepared.");
                        return(true);
                    }

                    args.IsEnabled = true;
                    args.Tooltip   = GameTexts.FindText("str_rts_camera_watch_mode_tool_tip");
                    return(true);
                }
            }
            catch (Exception e)
            {
                Utility.DisplayMessage(e.ToString());
            }

            return(false);
        }
Exemplo n.º 8
0
        // Returns display data from siege parameter, combines castle and town into one method determined by isCastle parameter.
        private string GetDisplayFromSiege(SiegeEvent e, bool isCastle)
        {
            if (isCastle)
            {
                TextObject text = GameTexts.FindText("str_sta_alarm_castle_attack_message", null);
                text.SetTextVariable("CASTLE", e.BesiegedSettlement.Name.ToString());
                TextObject attacker = new TextObject("", null);
                attacker.SetTextVariable("PARTY", e.BesiegedSettlement.LastAttackerParty.Name);
                attacker.SetTextVariable("NAME", e.BesiegedSettlement.LastAttackerParty.LeaderHero.Name);
                attacker.SetTextVariable("GENDER", e.BesiegedSettlement.LastAttackerParty.LeaderHero.IsFemale ? 1 : 0);
                attacker.SetTextVariable("FACTION", e.BesiegedSettlement.LastAttackerParty.LeaderHero.MapFaction.Name);
                text.SetTextVariable("ATTACKER", attacker);

                return(text.ToString());
            }
            else
            {
                TextObject text = GameTexts.FindText("str_sta_alarm_town_attack_message", null);
                text.SetTextVariable("TOWN", e.BesiegedSettlement.Name.ToString());
                TextObject attacker = new TextObject("", null);
                attacker.SetTextVariable("PARTY", e.BesiegedSettlement.LastAttackerParty.Name);
                attacker.SetTextVariable("NAME", e.BesiegedSettlement.LastAttackerParty.LeaderHero.Name);
                attacker.SetTextVariable("GENDER", e.BesiegedSettlement.LastAttackerParty.LeaderHero.IsFemale ? 1 : 0);
                attacker.SetTextVariable("FACTION", e.BesiegedSettlement.LastAttackerParty.LeaderHero.MapFaction.Name);
                text.SetTextVariable("ATTACKER", attacker);

                return(text.ToString());
            }
        }
Exemplo n.º 9
0
 public MPCombatant(BattleSideEnum side, int tacticLevel, BasicCultureObject culture,
                    Tuple <uint, uint> primaryColorPair, Tuple <uint, uint> alternativeColorPair, Banner banner)
     : base(GameTexts.FindText("str_ebt_side", side == BattleSideEnum.Attacker ? "Attacker" : "Defender"),
            side, culture, primaryColorPair, alternativeColorPair, banner)
 {
     _tacticLevel = tacticLevel;
 }
        public override string GetDescriptionText(GameEntity gameEntity = null)
        {
            TextObject textObject = new TextObject("{=5zGsfiMM}{TRAINING_TYPE}");

            textObject.SetTextVariable("TRAINING_TYPE", GameTexts.FindText("str_tutorial_" + this._descriptionTextOfIcon));
            return(textObject.ToString());
        }
Exemplo n.º 11
0
 // Initialization method, called from STAMain - > OnGameLoaded
 public void Initialize()
 {
     managedSettlements = new Dictionary <string, float>();
     GT_TRACK           = GameTexts.FindText("str_sta_ui_track", null).ToString();
     GT_OK    = GameTexts.FindText("str_sta_ui_ok", null).ToString();
     GT_CLOSE = GameTexts.FindText("str_sta_ui_close", null).ToString();
 }
Exemplo n.º 12
0
        public static void  Postfix(ref EncyclopediaHeroPageVM __instance)
        {
            if (null != ReflectUtils.ReflectField("_hero", __instance))
            {
                Hero   hero = (Hero)ReflectUtils.ReflectField("_hero", __instance);
                string heroOccupationName = CampaignUIHelper.GetHeroOccupationName(hero);
                if (string.IsNullOrEmpty(heroOccupationName))
                {
                    heroOccupationName = System.Enum.GetName(typeof(Occupation), hero.CharacterObject.Occupation);
                    string definition3 = GameTexts.FindText("str_enc_sf_occupation", null).ToString();
                    __instance.Stats.Add(new StringPairItemVM(definition3, heroOccupationName, null));
                }

                //模板
                FieldInfo fieldInfo = hero.CharacterObject.GetType().GetField("_originCharacter", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                if (null != fieldInfo)
                {
                    object obj = fieldInfo.GetValue(hero.CharacterObject);;
                    if (obj is CharacterObject)
                    {
                        CharacterObject originCharacter = (CharacterObject)obj;
                        __instance.Stats.Add(new StringPairItemVM("模板: ", originCharacter.StringId, null));
                    }
                }
            }
        }
Exemplo n.º 13
0
        public static IIdProvider <AOptionClass> CreateOptionClassProvider(IMenuClassCollection menuClassCollection)
        {
            return(IdProviderCreator.Create(() =>
            {
                var contourView = Mission.Current.GetMissionBehaviour <CommandSystemLogic>().FormationColorSubLogic;

                var optionClass = new OptionClass(CommandSystemSubModule.ModuleId,
                                                  GameTexts.FindText("str_rts_camera_command_system_option_class"), menuClassCollection);
                var commandOptionCategory = new OptionCategory("Command", GameTexts.FindText("str_rts_camera_command_system_command_system_options"));
                commandOptionCategory.AddOption(new BoolOptionViewModel(
                                                    GameTexts.FindText("str_rts_camera_command_system_click_to_select_formation"),
                                                    GameTexts.FindText("str_rts_camera_command_system_click_to_select_formation_hint"),
                                                    () => CommandSystemConfig.Get().ClickToSelectFormation, b =>
                {
                    CommandSystemConfig.Get().ClickToSelectFormation = b;
                    contourView?.SetEnableContourForSelectedFormation(b);
                }));
                commandOptionCategory.AddOption(new BoolOptionViewModel(
                                                    GameTexts.FindText("str_rts_camera_command_system_attack_specific_formation"),
                                                    GameTexts.FindText("str_rts_camera_command_system_attack_specific_formation_hint"),
                                                    () => CommandSystemConfig.Get().AttackSpecificFormation, b =>
                {
                    CommandSystemConfig.Get().AttackSpecificFormation = b;
                    if (b)
                    {
                        PatchChargeToFormation.Patch();
                    }
                }));
                optionClass.AddOptionCategory(0, commandOptionCategory);

                return optionClass;
            }, CommandSystemSubModule.ModuleId));
        }
 public override void RefreshValues()
 {
     base.RefreshValues();
     BattleTypeSelection = new SelectorVM <SelectorItemVM>(new List <TextObject>()
     {
         GameTexts.FindText("str_ebt_battle_type", "Field"),
         GameTexts.FindText("str_ebt_battle_type", "Siege"),
         GameTexts.FindText("str_ebt_battle_type", "Village"),
     }, (int)_config.BattleType, OnBattleTypeSelection);
     PlayerTypeSelection = new SelectorVM <SelectorItemVM>(new List <TextObject>()
     {
         GameTexts.FindText("str_ebt_player_type", "Commander"),
         GameTexts.FindText("str_ebt_player_type", "Sergeant"),
     }, (int)_config.PlayerType, OnPlayerTypeSelectionChange);
     PlayerSideSelection = new SelectorVM <SelectorItemVM>(new List <TextObject>()
     {
         GameTexts.FindText("str_ebt_side", "Attacker"),
         GameTexts.FindText("str_ebt_side", "Defender"),
     }, _config.PlayerSide == BattleSideEnum.Defender ? 1 : 0, OnPlayerSideChanged);
     EquipmentModifierTypeSelection = new SelectorVM <SelectorItemVM>(new List <TextObject>()
     {
         GameTexts.FindText("str_ebt_modifier_type", EquipmentModifierType.Random.ToString()),
         GameTexts.FindText("str_ebt_modifier_type", EquipmentModifierType.Average.ToString()),
         GameTexts.FindText("str_ebt_modifier_type", EquipmentModifierType.None.ToString()),
     }, (int)_config.EquipmentModifierType, OnEquipmentModifierType);
     BattleTypeText.RefreshValues();
     PlayerTypeText.RefreshValues();
     PlayerSideText.RefreshValues();
     EquipmentModifierTypeText.RefreshValues();
 }
        public static void wait_menu_settlement_wait_on_tick(MenuCallbackArgs args, CampaignTime dt)
        {
            int captiveTimeInDays = PlayerCaptivity.CaptiveTimeInDays;

            if (captiveTimeInDays == 0)
            {
                return;
            }

            TextObject variable = null;

            if (Hero.MainHero.IsPrisoner && Hero.MainHero.PartyBelongedToAsPrisoner.Settlement != null)
            {
                variable = Hero.MainHero.PartyBelongedToAsPrisoner.Settlement.Name;
            }

            if (variable == null)
            {
                variable = Settlement.CurrentSettlement.Name;
            }

            TextObject text       = args.MenuContext.GameMenu.GetText();
            TextObject textObject = GameTexts.FindText("str_prisoner_of_settlement_for_days_menu_text", null);

            textObject.SetTextVariable("NUMBER_OF_DAYS", captiveTimeInDays);
            textObject.SetTextVariable("PLURAL", (captiveTimeInDays > 1) ? 1 : 0);
            textObject.SetTextVariable("SETTLEMENT_NAME", variable);
            text.SetTextVariable("CAPTIVITY_TEXT", textObject);
        }
Exemplo n.º 16
0
        public bool ControlMainAgent(bool displayMessage = true)
        {
            try
            {
                if (Mission.MainAgent != null)
                {
                    if (Mission.MainAgent.Controller != Agent.ControllerType.Player)
                    {
                        if (displayMessage)
                        {
                            GameTexts.SetVariable("ControlledTroopName", Mission.MainAgent.Name);
                            Utility.DisplayLocalizedText("str_rts_camera_control_troop");
                        }
                        bool shouldSmoothMoveToAgent = Utility.BeforeSetMainAgent();
                        Utility.PlayerControlAgent(Mission.MainAgent);
                        Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen);

                        return(true);
                    }
                }
                else
                {
                    Utility.DisplayLocalizedText("str_rts_camera_no_troop_to_control");
                }
            }
            catch (Exception e)
            {
                Utility.DisplayMessage(e.ToString());
            }

            return(false);
        }
Exemplo n.º 17
0
        protected void RemoveOldConfig()
        {
            try
            {
                foreach (var oldName in OldNames)
                {
                    if (File.Exists(oldName))
                    {
                        Utility.DisplayMessage(GameTexts.FindText("str_rts_camera_found_old_config") + $" \"{oldName}\".");
                        Utility.DisplayLocalizedText("str_rts_camera_delete_old_config");
                        File.Delete(oldName);
                    }

                    if (Directory.Exists(OldSavePath) && Directory.GetFileSystemEntries(OldSavePath).Length == 0)
                    {
                        Directory.Delete(OldSavePath);
                    }
                }
            }
            catch (Exception e)
            {
                Utility.DisplayMessage(e.ToString());
                Console.WriteLine(e);
            }
        }
Exemplo n.º 18
0
        public bool SetToMainAgent(Agent agent)
        {
            if (agent != null)
            {
                if (Mission.MainAgent == agent || agent.Team != Mission.PlayerTeam)
                {
                    return(false);
                }
                if (!Utility.IsPlayerDead())
                {
                    MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent);
                    MissionLibrary.Event.MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent);
                    Utility.AIControlMainAgent(false);
                }
                GameTexts.SetVariable("ControlledTroopName", agent.Name);
                Utility.DisplayLocalizedText("str_rts_camera_control_troop");
                bool shouldSmoothMoveToAgent = Utility.BeforeSetMainAgent();
                if (_switchFreeCameraLogic.IsSpectatorCamera)
                {
                    Mission.MainAgent = agent;
                    Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen, false);
                }
                else
                {
                    Utility.PlayerControlAgent(agent);
                    Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen, true);
                }

                return(true);
            }

            Utility.DisplayLocalizedText("str_rts_camera_no_troop_to_control");
            return(false);
        }
Exemplo n.º 19
0
        public void InitializeValues()
        {
            if (this._SkillScreenVM.GetCharacterDeveloper() == null)
            {
                this.Level = 0;
            }
            else
            {
                this.Level     = this._SkillScreenVM.GetCharacterDeveloper().Hero.GetSkillValue(this.Skill);
                this.NextLevel = this.Level + 1;
                //this._isInSamePartyAsPlayer = (this._SkillScreenVM.hero.PartyBelongedTo != null && this._SkillScreenVM.hero.PartyBelongedTo == MobileParty.MainParty);
                this._SkillScreenVM.GetCharacterDeveloper().GetPropertyValue(this.Skill);
                this.CurrentSkillXP         = this._SkillScreenVM.GetCharacterDeveloper().GetSkillXpProgress(this.Skill);
                this.XpRequiredForNextLevel = Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(this.Level + 1) - Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(this.Level);
                this.ProgressPercentage     = 100.0 * (double)this._currentSkillXP / (double)this.XpRequiredForNextLevel;
                GameTexts.SetVariable("CURRENT_XP", this.CurrentSkillXP.ToString());
                GameTexts.SetVariable("LEVEL_MAX_XP", this.XpRequiredForNextLevel.ToString());
                this.ProgressHint = new HintViewModel(GameTexts.FindText("str_current_xp_over_max", null).ToString(), null);
                this.ProgressText = GameTexts.FindText("str_current_xp_over_max", null).ToString();
                GameTexts.SetVariable("REQUIRED_XP_FOR_NEXT_LEVEL", this.XpRequiredForNextLevel - this.CurrentSkillXP);
                this.SkillXPHint = new HintViewModel(GameTexts.FindText("str_skill_xp_hint", null).ToString(), null);

                this._orgFocusAmount   = this._SkillScreenVM.GetCharacterDeveloper().GetFocus(this.Skill);
                this.CurrentFocusLevel = this._orgFocusAmount;
                this.CreateLists();
            }
        }
Exemplo n.º 20
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.");
            }
        }
Exemplo n.º 21
0
 static bool Prefix(ClanVM __instance)
 {
     try
     {
         if (Clan.PlayerClan.IsUnderMercenaryService)
         {
             InformationManager.ShowInquiry(new InquiryData("Ending Mercenary Contract",
                                                            $"Your mercenary contract will end and you will no longer be affiliated with {Clan.PlayerClan.Kingdom.Name.ToString()}.",
                                                            true, true, new TextObject("{=5Unqsx3N}Confirm").ToString(),
                                                            GameTexts.FindText("str_cancel").ToString(),
                                                            () =>
             {
                 ChangeKingdomAction.ApplyByLeaveKingdomAsMercenaryForNoPayment(Clan.PlayerClan, Clan.PlayerClan.Kingdom);
                 __instance.ClanIsInAKingdom = (Clan.PlayerClan.Kingdom != null);
                 __instance.UpdateBannerVisuals();
             },
                                                            null));
             return(false);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"An error occurred in the leaving Kingdom as mercenary fix:\n\n{ex.ToStringFull()}");
     }
     return(true);
 }
        private static void RecruitMercenaries(int count)
        {
            try
            {
                var cost = GetMercenaryCost();
                MobileParty.MainParty.AddElementToMemberRoster(PlayerEncounter.Settlement.Town.MercenaryData.TroopType, count,
                                                               false);
                GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, count * cost, true);
                CampaignEventDispatcher.Instance.OnUnitRecruited(PlayerEncounter.Settlement.Town.MercenaryData.TroopType, count);
                PlayerEncounter.Settlement.Town.MercenaryData.ChangeMercenaryCount(-count);

                if (count == 1)
                {
                    InformationManager.DisplayMessage(new InformationMessage(
                                                          $"You recruited one {PlayerEncounter.Settlement.Town.MercenaryData.TroopType.Name}."));
                }
                else
                {
                    InformationManager.DisplayMessage(new InformationMessage(
                                                          $"You recruited {count} {PlayerEncounter.Settlement.Town.MercenaryData.TroopType.Name}s."));
                }

                MBTextManager.SetTextVariable("GOLD_AMOUNT", count * cost, false);
                InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("str_gold_removed_with_icon", null).ToString(), "event:/ui/notification/coins_negative"));
            }
            catch (Exception ex)
            {
                NativeMethods.MessageBox(IntPtr.Zero, ex.Message, "RecruitAllButton -- RecruitMercenaries", NativeMethods.MB_ICONERROR | NativeMethods.MB_OK);
            }
        }
Exemplo n.º 23
0
        private void WarnDayPerSeasonMismatch()
        {
            if (WasVanilla && Main.Settings !.DaysPerSeason != TimeParams.OldDayPerSeason)
            {
                var inquiryData = new InquiryData(
                    $"{Main.DisplayName}: {TimeParams.OldDayPerSeason} Days Per Season",
                    $"NOTE: Once a campaign has been started, its 'Days Per Season' setting cannot change thereafter. Since you are " +
                    $"loading a non-{Main.Name} save, your effective 'Days Per Season' setting for this campaign will be the " +
                    $"vanilla {TimeParams.OldDayPerSeason} days.\n    \nAll other settings can be changed freely mid-campaign, " +
                    $"and new games will of course use whatever 'Days Per Season' you've configured when you start them. Now " +
                    $"go on, and get playing!",
                    true,
                    false,
                    GameTexts.FindText("str_ok", null).ToString(),
                    null,
                    delegate() { },
                    null);

                InformationManager.ShowInquiry(inquiryData, false);
            }

            if (Main.Settings !.DaysPerSeason != Main.TimeParam.DayPerSeason)
            {
                InformationManager.DisplayMessage(new InformationMessage(
                                                      $"{Main.DisplayName}: Using {Main.TimeParam.DayPerSeason} Days Per Season (Instead of {Main.Settings.DaysPerSeason})",
                                                      Main.ImportantTextColor));
            }
        }
Exemplo n.º 24
0
        public override float CalculateLoyaltyChange(Town town, StatExplainer explanation = null)
        {
            ExplainedNumber explainedNumber = new ExplainedNumber(0.0f, explanation, (TextObject)null);
            SettlementInfo  info            = RevolutionBehaviour.GetSettlementInformation(town.Settlement);

            if (!town.IsTown)
            {
                return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation));
            }

            if (info.Settlement.MapFaction.Leader == Hero.MainHero)
            {
                explainedNumber.Add(_basePlayerLoyalty, GameTexts.FindText("str_loyalty_bannerlord"));

                if (ModOptions.OptionsData.PlayerAffectedByOverextension && ModOptions.OptionsData.OverextensionMechanics)
                {
                    Overextension(info, ref explainedNumber);
                }
            }
            else
            {
                BaseLoyalty(info, ref explainedNumber);

                if (ModOptions.OptionsData.OverextensionMechanics)
                {
                    Overextension(info, ref explainedNumber);
                }
            }

            return(explainedNumber.ResultNumber + base.CalculateLoyaltyChange(town, explanation));
        }
        public override void NotifyExpired()
        {
            TextObject textObject = new TextObject("{=uWY09LJb}The non-aggression pact between {KINGDOM} and {OTHER_KINGDOM} has expired.");

            textObject.SetTextVariable("KINGDOM", Factions.Faction1.MapFaction.Name);
            textObject.SetTextVariable("OTHER_KINGDOM", Factions.Faction2.MapFaction.Name);
            if (Factions.Faction1.MapFaction == Clan.PlayerClan.Kingdom || Factions.Faction2.MapFaction == Clan.PlayerClan.Kingdom)
            {
                InformationManager.ShowInquiry(
                    new InquiryData(
                        new TextObject("{=pdI7Tjtj}Non-Aggression Pact Expired").ToString(),
                        textObject.ToString(),
                        true,
                        false,
                        GameTexts.FindText("str_ok", null).ToString(),
                        null,
                        null,
                        null,
                        ""), true);
            }
            else
            {
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
            }
        }
        private static void DeclareWarBetweenHeros(Hero assassin, Hero victim, out string declareWarMessage)
        {
            declareWarMessage = string.Empty;

            if (victim.MapFaction.IsAtWarWith(assassin.MapFaction))
            {
                return;
            }

            if (assassin.Clan == victim.Clan)
            {
                throw new NotImplementedException("Assassinating members of the same clan is not supported.");
            }

            if (assassin.Clan.Kingdom != null && assassin.Clan.Kingdom == victim.Clan.Kingdom)
            {
                if (assassin.IsFactionLeader)
                {
                    throw new NotImplementedException("Assassinating members of the kingdom you own is not supported.");
                }

                ChangeKingdomAction.ApplyByLeaveKingdom(assassin.Clan);
            }

            DeclareWarAction.ApplyDeclareWarOverProvocation(victim.MapFaction, assassin.MapFaction);

            GameTexts.SetVariable("FACTION1_NAME", victim.MapFaction.Name);
            GameTexts.SetVariable("FACTION2_NAME", assassin.MapFaction.Name);

            declareWarMessage = $"\n{GameTexts.FindText("str_factions_declare_war_news", null)}.";
        }
Exemplo n.º 27
0
        private void TraitObjectModifier(TraitObject traitObject, Color color, Hero hero, string trait, int amount, int xp, bool display)
        {
            if (xp == 0)
            {
                int currentTraitLevel = hero.GetTraitLevel(traitObject);
                int newNumber         = currentTraitLevel + amount;
                if (newNumber < 0)
                {
                    newNumber = 0;
                }


                hero.SetTraitLevel(traitObject, newNumber);

                if (!display)
                {
                    return;
                }
                TextObject textObject = GameTexts.FindText("str_CE_trait_level");
                textObject.SetTextVariable("HERO", hero.Name);
                textObject.SetTextVariable("POSITIVE", newNumber >= 0 ? 1 : 0);
                textObject.SetTextVariable("TRAIT", CEStrings.FetchTraitString(trait));
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), color));
            }
            else if (hero == Hero.MainHero)
            {
                Campaign.Current.PlayerTraitDeveloper.AddTraitXp(traitObject, xp);
            }
        }
        private static void settlement_wait_on_init(MenuCallbackArgs args)
        {
            args.MenuContext.GameMenu.SetMenuAsWaitMenuAndInitiateWaiting();
            TextObject text = args.MenuContext.GameMenu.GetText();

            TextObject variable = null;

            if (Hero.MainHero.IsPrisoner && Hero.MainHero.PartyBelongedToAsPrisoner.Settlement != null)
            {
                variable = Hero.MainHero.PartyBelongedToAsPrisoner.Settlement.Name;
            }

            if (variable == null)
            {
                variable = Settlement.CurrentSettlement.Name;
            }

            int        captiveTimeInDays = PlayerCaptivity.CaptiveTimeInDays;
            TextObject textObject;

            if (captiveTimeInDays == 0)
            {
                textObject = GameTexts.FindText("str_prisoner_of_settlement_menu_text", null);
            }
            else
            {
                textObject = GameTexts.FindText("str_prisoner_of_settlement_for_days_menu_text", null);
                textObject.SetTextVariable("NUMBER_OF_DAYS", captiveTimeInDays);
                textObject.SetTextVariable("PLURAL", (captiveTimeInDays > 1) ? 1 : 0);
            }
            textObject.SetTextVariable("SETTLEMENT_NAME", variable);
            text.SetTextVariable("CAPTIVITY_TEXT", textObject);
        }
 static bool Prefix(KingdomManagementVM __instance)
 {
     try
     {
         if (Clan.PlayerClan.IsUnderMercenaryService)
         {
             InformationManager.ShowInquiry(new InquiryData("Ending Mercenary Contract",
                                                            $"Your mercenary contract will end and you will no longer be affiliated with {Clan.PlayerClan.Kingdom.Name.ToString()}.",
                                                            true, true, new TextObject("{=5Unqsx3N}Confirm").ToString(),
                                                            GameTexts.FindText("str_cancel").ToString(),
                                                            () =>
             {
                 ChangeKingdomAction.ApplyByLeaveKingdomAsMercenaryForNoPayment(Clan.PlayerClan, Clan.PlayerClan.Kingdom);
                 typeof(KingdomManagementVM).GetMethod("ExecuteClose", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
                 .Invoke(__instance, null);
             },
                                                            null));
             return(false);
         }
     }
     catch (Exception ex)
     {
         FileLog.Log($"An error occurred in the leaving Kingdom as mercenary fix:\n\n{ex.ToStringFull()}");
     }
     return(true);
 }
Exemplo n.º 30
0
        public static IIdProvider <AOptionClass> CreateOptionClassProvider(IMenuClassCollection menuClassCollection)
        {
            return(IdProviderCreator.Create(() =>
            {
                var optionClass = new OptionClass(ImprovedCombatAISubModule.ModuleId,
                                                  GameTexts.FindText("str_improved_combat_ai_option_class"), menuClassCollection);

                var optionCategory = new OptionCategory("CombatAI", GameTexts.FindText("str_improved_combat_ai_ai_options"));
                optionCategory.AddOption(new BoolOptionViewModel(
                                             GameTexts.FindText("str_improved_combat_ai_use_realistic_blocking"), null,
                                             () => ImprovedCombatAIConfig.Get().UseRealisticBlocking,
                                             b => ImprovedCombatAIConfig.Get().UseRealisticBlocking = b));
                optionCategory.AddOption(new NumericOptionViewModel(
                                             GameTexts.FindText("str_improved_combat_ai_melee_ai_difficulty"), null,
                                             () => ImprovedCombatAIConfig.Get().MeleeAIDifficulty,
                                             f => ImprovedCombatAIConfig.Get().MeleeAIDifficulty = (int)f, 0, 100, true, true));
                optionCategory.AddOption(new BoolOptionViewModel(
                                             GameTexts.FindText("str_improved_combat_ai_directly_set_melee_ai"), GameTexts.FindText("str_improved_combat_ai_directly_set_melee_ai_description"),
                                             () => ImprovedCombatAIConfig.Get().DirectlySetMeleeAI,
                                             b => ImprovedCombatAIConfig.Get().DirectlySetMeleeAI = b));
                optionCategory.AddOption(new NumericOptionViewModel(
                                             GameTexts.FindText("str_improved_combat_ai_ranged_ai_difficulty"), null,
                                             () => ImprovedCombatAIConfig.Get().RangedAIDifficulty,
                                             f => ImprovedCombatAIConfig.Get().RangedAIDifficulty = (int)f, 0, 100, true, true));
                optionCategory.AddOption(new BoolOptionViewModel(
                                             GameTexts.FindText("str_improved_combat_ai_directly_set_ranged_ai"), GameTexts.FindText("str_improved_combat_ai_directly_set_ranged_ai_description"),
                                             () => ImprovedCombatAIConfig.Get().DirectlySetRangedAI,
                                             b => ImprovedCombatAIConfig.Get().DirectlySetRangedAI = b));
                optionClass.AddOptionCategory(0, optionCategory);
                return optionClass;
            }, ImprovedCombatAISubModule.ModuleId));
        }