private static void Postfix(ref TextObject __result, Hero queriedHero, Hero baseHero)
        {
            _stringResult = __result.ToString();
            _isFemale     = queriedHero.IsFemale;
            // In case of polygamy setting
            if (queriedHero.IsAlive && baseHero.IsAlive)
            {
                if (ResultContains("str_ex_husband_motherinlaw") || ResultContains("str_ex_husband_fatherinlaw"))
                {
                    __result = ReplaceResult("str_ex_husband_motherinlaw", "str_ex_husband_fatherinlaw", "str_ma_husband_motherinlaw", "str_ma_husband_fatherinlaw");
                }
                if (ResultContains("str_ex_wife_motherinlaw") || ResultContains("str_ex_wife_fatherinlaw"))
                {
                    __result = ReplaceResult("str_ex_wife_motherinlaw", "str_ex_wife_fatherinlaw", "str_ma_wife_motherinlaw", "str_ma_wife_fatherinlaw");
                }
                if (ResultContains("str_ex_husband_sisterinlaw") || ResultContains("str_ex_husband_brotherinlaw"))
                {
                    __result = ReplaceResult("str_ex_husband_sisterinlaw", "str_ex_husband_brotherinlaw", "str_ma_husband_sisterinlaw", "str_ma_husband_brotherinlaw");
                }
                if (ResultContains("str_ex_wife_sisterinlaw") || ResultContains("str_ex_wife_brotherinlaw"))
                {
                    __result = ReplaceResult("str_ex_wife_sisterinlaw", "str_ex_wife_brotherinlaw", "str_ma_wife_sisterinlaw", "str_ma_wife_brotherinlaw");
                }
            }
            TextObject tempResult = __result;

            __result = GetHeroRelationToHeroTextShort(queriedHero, baseHero);
            if (__result == TextObject.Empty)
            {
                __result = tempResult;
            }
        }
Ejemplo n.º 2
0
        public static void Apply(Kingdom kingdom, Kingdom otherKingdom, bool forcePlayerCharacterCosts = false)
        {
            Kingdom playerKingdom = Clan.PlayerClan?.Kingdom;

            if (otherKingdom == playerKingdom && playerKingdom.Leader == Hero.MainHero)
            {
                TextObject textObject = new TextObject("{=QbOqatd7}{KINGDOM} is proposing an alliance with {PLAYER_KINGDOM}.");
                textObject.SetTextVariable("KINGDOM", kingdom.Name);
                textObject.SetTextVariable("PLAYER_KINGDOM", otherKingdom.Name);

                InformationManager.ShowInquiry(new InquiryData(
                                                   new TextObject("{=3pbwc8sh}Alliance Proposal").ToString(),
                                                   textObject.ToString(),
                                                   true,
                                                   true,
                                                   new TextObject("{=3fTqLwkC}Accept").ToString(),
                                                   new TextObject("{=dRoMejb0}Decline").ToString(),
                                                   () => ApplyInternal(kingdom, otherKingdom, forcePlayerCharacterCosts),
                                                   null,
                                                   ""), true);
            }
            else
            {
                ApplyInternal(kingdom, otherKingdom, forcePlayerCharacterCosts);
            }
        }
Ejemplo n.º 3
0
        public void PayPatrols()
        {
            int totalWages = 0;
            PatrolProperties patrolProperties;

            foreach (Settlement settlement in Settlement.All)
            {
                if ((settlement.IsVillage || settlement.IsCastle) && settlement.OwnerClan == Clan.PlayerClan)
                {
                    settlementPatrolProperties.TryGetValue(settlement.StringId, out patrolProperties);
                    foreach (MobileParty patrol in patrolProperties.patrols.ToList())
                    {
                        GiveGoldAction.ApplyForCharacterToParty(Hero.MainHero, patrol.Party, (int)(patrol.GetTotalWage() * DailyPatrolWageModifier), true);
                        totalWages += (int)(patrol.GetTotalWage() * DailyPatrolWageModifier);
                    }
                    settlementPatrolProperties[settlement.StringId] = patrolProperties;
                }
            }
            if (totalWages > 0)
            {
                TextObject text = new TextObject("Daily Patrol Wages: -{BASILPATROL_DAILY_WAGES}{GOLD_ICON}", null);
                text.SetTextVariable("GOLD_ICON", "<img src=\"Icons\\Coin@2x\">");
                text.SetTextVariable("BASILPATROL_DAILY_WAGES", totalWages);
                InformationManager.DisplayMessage(new InformationMessage(text.ToString()));
            }
        }
        public static bool Prefix(ref string __result, ref string baseSkinsXmlPath)
        {
            Debug.Print(DebugString.ToString());

            // Why do I have to clone and modify two separate methods? - Designer225
            List <string> usedPaths = new List <string>();
            List <Tuple <string, string> > toBeMerged = new List <Tuple <string, string> >();
            List <string> xsltList = new List <string>();

            List <MbObjectXmlInformation> mbprojXmlList = XmlResource.MbprojXmls.Where(x => x.Id == "soln_skins").ToList();

            mbprojXmlList.Reverse(); // restored for compatibility reason with mods that modify skin.xml that load later.

            foreach (MbObjectXmlInformation mbprojXml in mbprojXmlList)
            {
                if (File.Exists(ModuleHelper.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name)))
                {
                    usedPaths.Add(ModuleHelper.GetXmlPathForNativeWBase(mbprojXml.ModuleName, mbprojXml.Name));
                    toBeMerged.Add(Tuple.Create(ModuleHelper.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name), string.Empty));
                }
                string xsltPathForNative = ModuleHelper.GetXsltPathForNative(mbprojXml.ModuleName, mbprojXml.Name);

                xsltList.Add(File.Exists(xsltPathForNative) ? xsltPathForNative : string.Empty);
            }
            XmlDocument mergedXmlForNative = MBObjectManager.CreateMergedXmlFile(toBeMerged, xsltList, true);

            System.IO.StringWriter stringWriter  = new System.IO.StringWriter();
            XmlTextWriter          xmlTextWriter = new XmlTextWriter(stringWriter);

            mergedXmlForNative.WriteTo(xmlTextWriter);
            baseSkinsXmlPath = usedPaths.First();
            __result         = stringWriter.ToString();

            return(false);
        }
        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());
        }
Ejemplo n.º 6
0
        public override void NotifyExpired()
        {
            var txt = new TextObject("{=uWY09LJb}The non-aggression pact between {KINGDOM} and {OTHER_KINGDOM} has expired.");

            txt.SetTextVariable("KINGDOM", Factions.Faction1.MapFaction.Name);
            txt.SetTextVariable("OTHER_KINGDOM", Factions.Faction2.MapFaction.Name);
            var txtRendered = txt.ToString();

            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(),
                        txtRendered,
                        true,
                        false,
                        GameTexts.FindText("str_ok", null).ToString(),
                        null,
                        null,
                        null), true);
            }
            else
            {
                InformationManager.DisplayMessage(new InformationMessage(txtRendered));
            }
        }
        private void OnArmySizeValueChange(int value)
        {
            TextObject textObject = new TextObject("{=mxbq3InD}{ARMY_SIZE} men");

            textObject.SetTextVariable("ARMY_SIZE", value);
            this.ArmySizeText = textObject.ToString();
        }
Ejemplo n.º 8
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.");
            }
        }
Ejemplo n.º 9
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());
            }
        }
Ejemplo n.º 10
0
        public static List <CEEvent> DeserializeXMLFileToObject(string XmlFilename)
        {
            List <CEEvent> list = new List <CEEvent>();

            try
            {
                if (string.IsNullOrEmpty(XmlFilename))
                {
                    return(null);
                }
                StreamReader  textReader    = new StreamReader(XmlFilename);
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(CEEvents));
                CEEvents      xsefsevents   = (CEEvents)xmlSerializer.Deserialize(textReader);
                list.AddRange(xsefsevents.CEEvent);
            }
            catch (Exception innerException)
            {
                TextObject textObject = new TextObject("{=CEEVENTS1001}Failed to load {FILE} for more information refer to Mount & Blade II Bannerlord\\Modules\\zCaptivityEvents\\ModuleLogs\\LoadingFailedXML.txt");
                textObject.SetTextVariable("FILE", XmlFilename);
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Red));

                throw new Exception("ERROR DeserializeXMLFileToObject:  -- filename: " + XmlFilename, innerException);
            }

            return(list);
        }
        public static void GetLoyaltyTooltipInfo(Clan clan, out string text, out Color color)
        {
            if (clan.Kingdom is null)
            {
                GetBlankLoyaltyTooltip(out text, out color);
                return;
            }

            int DaysWithKingdom = (int)(CampaignTime.Now - clan.LastFactionChangeTime).ToDays;
            int RequiredDays    = clan.IsUnderMercenaryService ? Settings.Instance.MinorFactionServicePeriod : (clan.IsMinorFaction ? Settings.Instance.MinorFactionOathPeriod : Settings.Instance.FactionOathPeriod);

            if (clan.Kingdom != null && DaysWithKingdom <= RequiredDays)
            {
                TextObject ReasonPeriod = new TextObject(TooltipOathLoyal);
                StringHelper.SetEntitiyProperties(ReasonPeriod, "HERO_CLAN", clan);
                StringHelper.SetNumericVariable(ReasonPeriod, "REMAINING_DAYS", RequiredDays - DaysWithKingdom);
                text  = ReasonPeriod.ToString();
                color = Colors.Green;
                return;
            }
            if (!Settings.Instance.UseRelationForEnsuredLoyalty)
            {
                GetBlankLoyaltyTooltip(out text, out color);
                return;
            }
            GetAveragedLoyaltyStatus(clan, out text, out color);
        }
Ejemplo n.º 12
0
        static void Postfix()
        {
            if (Hero.MainHero.Gold < mainHeroGold_beforeTransaction)
            {
                // presume transaction occurred
                if (Hero.MainHero.IsHumanPlayerCharacter &&
                    Hero.MainHero.CharacterObject.GetFeatValue(DefaultFeats.Cultural.AseraiCheapCaravans))
                {
                    int creditAmount = mainHeroGold_beforeTransaction - Hero.MainHero.Gold;  // will modify later
                    if (DefaultFeats.Cultural.AseraiCheapCaravans.EffectBonus == 0f)
                    {
                        // Assume 30%
                        creditAmount = (int)(creditAmount * 0.30f);
                    }
                    else
                    {
                        creditAmount = (int)(creditAmount * (1.0f - DefaultFeats.Cultural.AseraiCheapCaravans.EffectBonus));
                    }

                    // Flavor text
                    TextObject textObject = new TextObject("An Aserai clerk nods to you and slips a coinpurse into your hands.");
                    // StringHelpers.SetCharacterProperties("HERO", Hero.MainHero.CharacterObject, null, textObject);
                    InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));

                    // Apply credit
                    GiveGoldAction.ApplyForSettlementToCharacter(Settlement.CurrentSettlement, Hero.MainHero, creditAmount, false);
                }
            }
        }
Ejemplo n.º 13
0
        public override void RefreshValues()
        {
            base.RefreshValues();

            if (this._hero.IsPregnant)
            {
                this.PregnancyStatus = new TextObject("{=suems_doctor_satus_pregnancy_get}Pregnant", null).ToString();
            }
            else
            {
                this.PregnancyStatus = "";
            }

            if (Hero.MainHero.Spouse == this._hero)
            {
                this.SpousePrimaryStatus = new TextObject("{=suems_doctor_satus_primary_spouse}Primary", null).ToString();
            }
            else
            {
                this.SpousePrimaryStatus = "";
            }

            this.Name = this._hero.Name.ToString();
            this.CurrentActionText = ((this._hero != Hero.MainHero) ? CampaignUIHelper.GetHeroBehaviorText(this._hero) : "");
            if (this._hero.PartyBelongedToAsPrisoner != null)
            {
                TextObject textObject = new TextObject("{=a8nRxITn}Prisoner of {PARTY_NAME}", null);
                textObject.SetTextVariable("PARTY_NAME", this._hero.PartyBelongedToAsPrisoner.Name);
                this.LocationText = textObject.ToString();
            }
            else
            {
                this.LocationText = ((this._hero != Hero.MainHero) ? StringHelpers.GetLastKnownLocation(this._hero).ToString() : " ");
            }
        }
Ejemplo n.º 14
0
        private void OnDailyTick()
        {
            if (!SeparatismConfig.Settings.NationalRebellionsEnabled)
            {
                return;
            }

            var readyClans = Clan.All.ReadyToGoAndNotEmpty()
                             .Where(c => c.Culture != c.Kingdom?.Culture && c.Settlements.Any(s => s.Culture == c.Culture))
                             .GroupBy(c => new { Kingdom = c.Kingdom, Culture = c.Culture })
                             .OrderByDescending(x => x.Count());

            foreach (var group in readyClans)
            {
                var rebelRightNow = SeparatismConfig.Settings.DailyNationalRebellionChance >= 1 ||
                                    (MBRandom.RandomFloat <= SeparatismConfig.Settings.DailyNationalRebellionChance);

                if (group.Count() >= SeparatismConfig.Settings.MinimalRequiredNumberOfNativeLords && rebelRightNow)
                {
                    var rebelKingdom = GoRebelKingdom(group.OrderByDescending(c => c.Tier).ThenByDescending(c => c.Renown));
                    if (rebelKingdom != null)
                    {
                        var textObject = new TextObject("{=Separatism_National_Rebel}{Culture} people of {Kingdom} leading by their native lords have rised a rebellion to fight for their independence and found the {RebelKingdom}.", null);
                        textObject.SetTextVariable("Culture", group.Key.Culture.Name);
                        textObject.SetTextVariable("Kingdom", group.Key.Kingdom.Name);
                        textObject.SetTextVariable("RebelKingdom", rebelKingdom.Name);
                        GameLog.Warn(textObject.ToString());
                        return;
                    }
                }
            }
        }
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
0
        private static string CreateMakePeaceInquiryText(Kingdom kingdomMakingPeace, Kingdom otherKingdom, int payment)
        {
            TextObject peaceText;

            if (Settings.Instance.EnableWarExhaustion && WarExhaustionManager.Instance.HasMaxWarExhaustion(kingdomMakingPeace, otherKingdom))
            {
                peaceText = new TextObject("{=HWiDa4R1}Exhausted from the war, the {KINGDOM} is proposing peace with the {PLAYER_KINGDOM}.");
                peaceText.SetTextVariable("KINGDOM", kingdomMakingPeace.Name.ToString());
                peaceText.SetTextVariable("PLAYER_KINGDOM", otherKingdom.Name.ToString());
            }
            else
            {
                peaceText = new TextObject("{=t0ZS9maD}{KINGDOM_LEADER} of the {KINGDOM} is proposing peace with the {PLAYER_KINGDOM}.");
                peaceText.SetTextVariable("KINGDOM_LEADER", kingdomMakingPeace.Leader.Name.ToString());
                peaceText.SetTextVariable("KINGDOM", kingdomMakingPeace.Name.ToString());
                peaceText.SetTextVariable("PLAYER_KINGDOM", otherKingdom.Name.ToString());
            }
            List <string> inquiryText = new List <string>();

            inquiryText.Add(peaceText.ToString());

            if (payment > 0)
            {
                TextObject warReparationText = new TextObject("{=ZrwszZww} They are willing to pay war reparations of {DENARS} denars.");
                warReparationText.SetTextVariable("DENARS", payment);
                inquiryText.Add(warReparationText.ToString());
            }
            return(string.Concat(inquiryText));
        }
Ejemplo n.º 17
0
 private void ShowPoll(TextObject pollQuestion)
 {
     if (this.OnShowPoll == null)
     {
         return;
     }
     this.OnShowPoll(pollQuestion.ToString());
 }
Ejemplo n.º 18
0
        // Returns title data from village parameter, also applies icon to text header.
        private string GetTitleFromVillage(Village v)
        {
            TextObject header = GameTexts.FindText("str_sta_alarm_village_attack_title", null);

            header.SetTextVariable("ICON", "{=!}<img src=\"Icons\\Food@2x\">");

            return(header.ToString());
        }
Ejemplo n.º 19
0
 public static void ShowComfirInformation(TextObject title, TextObject message, Action affirmativeAction = null, Action negativeAction = null)
 {
     if (null == negativeAction)
     {
         negativeAction = () => { };
     }
     InformationManager.ShowInquiry(new InquiryData(title.ToString(), message == null? string.Empty: message.ToString(), true, true, GameTexts.FindText("str_done", null).ToString(), GameTexts.FindText("str_cancel", null).ToString(), affirmativeAction, negativeAction), false);
 }
        private void OnArmySizePercentChange(float value)
        {
            this.ArmySize = (int)Math.Round((double)value / 100.0 * ((double)this._maxNumOfMen - (double)this._minNumOfMen) + (double)this._minNumOfMen);
            TextObject textObject = new TextObject("{=mxbq3InD}{ARMY_SIZE} men", (Dictionary <string, TextObject>)null);

            textObject.SetTextVariable("ARMY_SIZE", this.ArmySize);
            this.ArmySizeText = textObject.ToString();
        }
Ejemplo n.º 21
0
        public SettingsPropertyDefinitionWrapper(object @object) : base()
        {
            var type = @object.GetType();

            SettingsIdProperty       = AccessTools.Property(type, nameof(SettingsId));
            SettingTypeProperty      = AccessTools.Property(type, nameof(SettingType));
            PropertyProperty         = AccessTools.Property(type, nameof(PropertyReference));
            DisplayNameProperty      = AccessTools.Property(type, nameof(DisplayName));
            HintTextProperty         = AccessTools.Property(type, nameof(HintText));
            OrderProperty            = AccessTools.Property(type, nameof(Order));
            RequireRestartProperty   = AccessTools.Property(type, nameof(RequireRestart));
            GroupNameProperty        = AccessTools.Property(type, nameof(GroupName));
            IsMainToggleProperty     = AccessTools.Property(type, nameof(IsMainToggle));
            MinValueProperty         = AccessTools.Property(type, nameof(MinValue));
            MaxValueProperty         = AccessTools.Property(type, nameof(MaxValue));
            EditableMinValueProperty = AccessTools.Property(type, nameof(EditableMinValue));
            EditableMaxValueProperty = AccessTools.Property(type, nameof(EditableMaxValue));
            SelectedIndexProperty    = AccessTools.Property(type, nameof(SelectedIndex));


            SettingsId  = SettingsIdProperty?.GetValue(@object) as string ?? "ERROR";
            SettingType = SettingTypeProperty?.GetValue(@object) is { } settingTypeObject
                ? Enum.TryParse <SettingType>(settingTypeObject.ToString(), out var resultEnum)
                    ? resultEnum
                    : SettingType.NONE
                : SettingType.NONE;

            PropertyReference = PropertyProperty?.GetValue(@object) is { } value
                ? value is IRef @ref ? @ref : new RefWrapper(value)
                : null;

            DisplayName = DisplayNameProperty?.GetValue(@object) switch
            {
                string str => str,
                TextObject to => to.ToString(),
                       _ => DisplayName
            };
            HintText = HintTextProperty?.GetValue(@object) switch
            {
                string str => str,
                TextObject to => to.ToString(),
                       _ => HintText
            };
            Order          = OrderProperty?.GetValue(@object) as int? ?? -1;
            RequireRestart = RequireRestartProperty?.GetValue(@object) as bool? ?? true;

            GroupName    = GroupNameProperty?.GetValue(@object) as string ?? "";
            IsMainToggle = IsMainToggleProperty?.GetValue(@object) as bool? ?? false;

            MinValue         = MinValueProperty?.GetValue(@object) is { } minVal?minVal as decimal? ?? 0 : 0;
            MaxValue         = MaxValueProperty?.GetValue(@object) is { } maxVal?maxVal as decimal? ?? 0 : 0;
            EditableMinValue = EditableMinValueProperty?.GetValue(@object) is { } eMinVal?  eMinVal as decimal? ?? 0 : 0;
            EditableMaxValue = EditableMaxValueProperty?.GetValue(@object) is { } eMaxValue?eMaxValue as decimal? ?? 0 : 0;

            SelectedIndex = SelectedIndexProperty?.GetValue(@object) as int? ?? 0;
        }
    }
}
Ejemplo n.º 22
0
        private void DailyTickEvent()
        {
            foreach (var info in Managers.Settlement.Infos)
            {
                if (info.Settlement.Parties.Any(party => party.IsLordParty && party.Party.Owner.Clan == info.Settlement.OwnerClan))
                {
                    info.Settlement.Town.Loyalty += RevolutionsSettings.Instance.RevoltsGeneralOwnerInTownLoyaltyIncrease;

                    if (info.Settlement.OwnerClan.StringId == Hero.MainHero.Clan.StringId)
                    {
                        var textObject = new TextObject(GameTexts.RevoltsLoyaltyIncrease);
                        textObject.SetTextVariable("SETTLEMENT", info.Settlement.Name);
                        InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
                    }
                }

                if (!info.Settlement.IsFortification)
                {
                    continue;
                }

                if (info.LoyalFaction.StringId == info.CurrentFactionId)
                {
                    continue;
                }

                if (info.CurrentFactionInfo?.CanRevolt == false || info.HasRebellionEvent)
                {
                    info.RevoltProgress = 0;
                    continue;
                }

                info.RevoltProgress -= info.Settlement.Town.LoyaltyChange;

                if (info.RevoltProgress >= 100 && !info.Settlement.IsUnderSiege)
                {
                    StartRevolt(info.Settlement);
                    continue;
                }

                if (info.RevoltProgress < 0)
                {
                    info.RevoltProgress = 0;
                }

                info.DaysOwnedByOwner++;
            }

            foreach (var factionInfo in Managers.Faction.Infos)
            {
                factionInfo.DaysSinceLastRevolt++;

                if (factionInfo.DaysSinceLastRevolt > RevolutionsSettings.Instance.RevoltsGeneralCooldownTime)
                {
                    factionInfo.CanRevolt = true;
                }
            }
        }
        private void OnHourlyTickEvent(MobileParty mobileParty)
        {
            Hero companion = mobileParty.LeaderHero;

            if (mobileParty == MobileParty.MainParty ||
                companion == null ||
                !mobileParty.IsLordParty ||
                companion.Clan != Clan.PlayerClan)
            {
                return;
            }

            Settlement target = mobileParty.TargetSettlement;

            if (mobileParty.DefaultBehavior != AiBehavior.PatrolAroundPoint ||
                target.OwnerClan != Clan.PlayerClan)
            {
                return;
            }

            if (mobileParty.Position2D.DistanceSquared(target.Position2D) > MinPatrolDistance)
            {
                //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " too far away from " + target.Name));
                mobileParty.SetMoveGoToSettlement(target);
                return;
            }
            //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " patrolling around " + target.Name));

            int companion_relation;

            foreach (Hero notable in target.Notables)
            {
                companion_relation = CharacterRelationManager.GetHeroRelation(companion, notable) + 1;
                if (companion_relation % HoursRequirement == 0)
                {
                    // reset companion personal relation
                    companion_relation = 0;

                    // increase player relation
                    int oldRelation = notable.GetRelation(Hero.MainHero);
                    ChangeRelationAction.ApplyPlayerRelation(notable, 1, false, false);
                    int newRelation     = notable.GetRelation(Hero.MainHero);
                    int relation_change = newRelation - oldRelation;

                    if (relation_change > 0)
                    {
                        TextObject textObject = GameTexts.FindText("str_your_relation_increased_with_notable", null);
                        TextObject heroText   = new TextObject();
                        ZenDzeeCompatibilityHelper.SetTextVariable(heroText, "NAME", notable.Name);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "HERO", heroText);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "VALUE", newRelation);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "MAGNITUDE", relation_change);
                        InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
                    }
                }
                CharacterRelationManager.SetHeroRelation(companion, notable, companion_relation);
            }
        }
Ejemplo n.º 24
0
        internal void VictimProstitutionModifier(int amount, Hero hero, bool updateFlag = false, bool displayMessage = true, bool quickInformation = false)
        {
            if (hero == null)
            {
                return;
            }
            SkillObject prostitutionSkill = CESkills.Prostitution;
            SkillObject prostitutionFlag  = CESkills.IsProstitute;

            if (updateFlag)
            {
                int currentLevel = hero.GetSkillValue(prostitutionFlag);

                if (amount == 0)
                {
                    if ((displayMessage || quickInformation) && currentLevel != 0)
                    {
                        TextObject textObject = GameTexts.FindText("str_CE_level_leave");
                        textObject.SetTextVariable("HERO", hero.Name);
                        textObject.SetTextVariable("OCCUPATION", prostitutionFlag.Name);
                        if (displayMessage)
                        {
                            InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
                        }

                        if (quickInformation)
                        {
                            InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation");
                        }
                    }
                }
                else
                {
                    if ((displayMessage || quickInformation) && currentLevel != 1)
                    {
                        TextObject textObject = GameTexts.FindText("str_CE_level_enter");
                        textObject.SetTextVariable("HERO", hero.Name);
                        textObject.SetTextVariable("OCCUPATION", prostitutionFlag.Name);
                        if (displayMessage)
                        {
                            InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green));
                        }

                        if (quickInformation)
                        {
                            InformationManager.AddQuickInformation(textObject, 0, hero.CharacterObject, "event:/ui/notification/relation");
                        }
                    }
                }

                hero.SetSkillValue(prostitutionFlag, amount);
            }
            else
            {
                SetModifier(amount, hero, prostitutionSkill, prostitutionFlag, displayMessage, quickInformation);
            }
        }
Ejemplo n.º 25
0
 private void OnDailyTick()
 {
     Campaign.Current.RemoveEmptyKingdoms(kingdom =>
     {
         var textObject = new TextObject("{=Separatism_Kingdom_Destroyed}The {Kingdom} has been destroyed and the stories about it will be lost in time.", null);
         textObject.SetTextVariable("Kingdom", kingdom.Name);
         GameLog.Warn(textObject.ToString());
     });
 }
Ejemplo n.º 26
0
        public void CallToTalk()
        {
            TelepathyBehaviour.CallToTalk(hero);
            var textObject = new TextObject("{=Telepathy_Hero_Will_Talk}{HeroName} will talk to you soon...", null);

            textObject.SetTextVariable("HeroName", hero.Name);
            GameLog.Info(textObject.ToString());
            base.OnPropertyChanged(nameof(WillNotTalk));
        }
        internal override string EvaluateString(TextProcessingContext context, TextObject parent)
        {
            TextObject paramWithoutEvaluate = context.GetFunctionParamWithoutEvaluate(this._parameter);

            (TextObject value, bool doesValueExist)qualifiedVariableValue = context.GetQualifiedVariableValue(paramWithoutEvaluate.ToString() + this._attribute, parent);
            TextObject textObject = qualifiedVariableValue.value;

            return(qualifiedVariableValue.doesValueExist ? textObject.ToString() : "");
        }
Ejemplo n.º 28
0
        private static string CreateMakePeaceDueToWarExhaustionInquiryText(Kingdom kingdom, IFaction faction)
        {
            TextObject peaceText = new TextObject("{=HWiDa4R1}Exhausted from the war, the {KINGDOM} is proposing peace with the {PLAYER_KINGDOM}.");

            peaceText.SetTextVariable("KINGDOM", kingdom.Name.ToString());
            peaceText.SetTextVariable("PLAYER_KINGDOM", faction.Name.ToString());

            return(peaceText.ToString());
        }
 public CustomBattleMenuSideVM(TextObject sideName, bool isPlayerSide)
 {
     this._sideName               = sideName;
     this._isPlayerSide           = isPlayerSide;
     this.CompositionGroup        = new ArmyCompositionGroup(sideName.ToString() + "_COMPOSITION", this._isPlayerSide);
     this.FactionSelectionGroup   = new SelectorVM <SelectorItemVM>((IEnumerable <string>) new List <string>(), 0, (Action <SelectorVM <SelectorItemVM> >)null);
     this.CharacterSelectionGroup = new SelectorVM <SelectorItemVM>((IEnumerable <string>) new List <string>(), 0, (Action <SelectorVM <SelectorItemVM> >)null);
     this.RefreshValues();
 }
Ejemplo n.º 30
0
 private static bool DisableFollowMeOrderWhenPlayerIsDead(Agent agent)
 {
     if (agent == null)
     {
         TextObject textObject = new TextObject("Cannot issue the order because the target is dead.");
         InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
         return(false);
     }
     return(true);
 }