예제 #1
0
        public void WeeklyTick()
        {
            if (null != this._sneaker)
            {
                this._alertCoefficientReduceWeek++;
                if (this._alertCoefficientReduceWeek >= AlertReducWeekPeriod)
                {
                    AlertCoefficientReduce();
                    if (this._sneaker.CurrentSettlement != null &&
                        this._sneaker.IsAlive &&
                        !this._sneaker.IsPrisoner &&
                        null == this._sneaker.PartyBelongedTo
                        )
                    {
                        MoveSpecialCharacter(this._sneaker.CharacterObject, this._sneaker.CurrentSettlement);
                    }
                    this._alertCoefficientReduceWeek = 0;
                }

                if (this._sneaker.HeroState == Hero.CharacterStates.NotSpawned)
                {
                    this._sneaker.ChangeState(Hero.CharacterStates.Active);
                }

                if (this._sneaker.Age >= 50)
                {
                    this._sneaker.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((float)22));
                    InformationManager.DisplayMessage(new InformationMessage(this._sneaker.Name.ToString() + "变年轻了", Colors.Blue));
                }
            }
        }
        private static readonly FieldInfo IsBattleEncounteredField     = AccessTools.Field(HeroBehaviorsStructType, "IsBattleEncountered");     // type: bool

        //static bool Prefix(DynamicBodyCampaignBehavior __instance, ref Dictionary<Hero, object> ____heroBehaviorsDictionary)
        static bool Prefix(DynamicBodyCampaignBehavior __instance)
        {
            IDictionary dictionary = (IDictionary)AccessTools.Field(typeof(DynamicBodyCampaignBehavior), "_heroBehaviorsDictionary").GetValue(__instance);

            foreach (var hero in dictionary.Keys.Cast <Hero>())
            {
                //This is probably invalid because the bandit soldier is not a hero object
                if (hero.IsChild && hero.MapFaction.IsBanditFaction)
                {
                    float banditAge = 21;
                    hero.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((int)banditAge));
                    DynamicBodyProperties banditDynamicBodyProperties = new DynamicBodyProperties(hero.Age, hero.Weight, hero.Build);
                    BodyProperties        banditBodyProperties        = new BodyProperties(banditDynamicBodyProperties, hero.BodyProperties.StaticProperties);
                    hero.CharacterObject.UpdatePlayerCharacterBodyProperties(banditBodyProperties, hero.IsFemale);
                }

                if (!hero.IsChild && (hero.IsHumanPlayerCharacter || hero.IsPlayerCompanion))
                {
                    float heroAge = hero.Age + 0.0119047f;
                    DynamicBodyProperties dynamicBodyProperties = new DynamicBodyProperties(heroAge, hero.Weight, hero.Build);
                    BodyProperties        heroBodyProperties    = new BodyProperties(dynamicBodyProperties, hero.BodyProperties.StaticProperties);
                    hero.CharacterObject.UpdatePlayerCharacterBodyProperties(heroBodyProperties, hero.IsFemale);
                }
            }

            return(false);
        }
            static bool Prefix(CharacterObject __instance, BodyProperties properties, ref bool isFemale)
            {
                try
                {
                    var piSBP = typeof(Hero).GetProperty("StaticBodyProperties", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
                    //var piSBB = typeof(Hero).GetProperty("DynamicBodyProperties", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);

                    if (__instance.IsHero)
                    {
                        if (Settings.Instance.DebugMode == true)
                        {
                            InformationManager.DisplayMessage(new InformationMessage("Hero updated: " + __instance.HeroObject.Name, ColorManager.Purple));
                        }
                        //__instance.HeroObject.StaticBodyProperties = __properties.StaticProperties;
                        piSBP.SetValue(__instance.HeroObject, properties.StaticProperties);
                        __instance.HeroObject.DynamicBodyProperties = properties.DynamicProperties;
                        __instance.HeroObject.UpdatePlayerGender(isFemale);

                        if (Settings.Instance.OverrideAge == false)
                        {
                            float age = properties.DynamicProperties.Age;
                            __instance.HeroObject.BirthDay = HeroHelper.GetRandomBirthDayForAge(age);
                        }
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"An exception occurred whilst trying to apply the changes.\n\nException:\n{ex.Message}\n\n{ex.InnerException?.Message}");
                }
                return(true);
            }
        private static Hero DealNPC(CharacterObject target, CampaignGameStarter campaignGameStarter)
        {
            Hero hero = null;

            if (null != target)
            {
                CharacterObject character = CharacterObject.OneToOneConversationCharacter;
                hero = HeroCreator.CreateSpecialHero(character, null, Clan.PlayerClan, Clan.PlayerClan);
                // hero.StringId = "sms_npc_" + System.Enum.GetName(typeof(Occupation), character.Occupation) + hero.StringId;


                hero.ChangeState(Hero.CharacterStates.Active);
                hero.CacheLastSeenInformation(hero.HomeSettlement, true);
                hero.SyncLastSeenInformation();
                HeroInitPropertyUtils.InitHeroForNPC(hero);


                AddHeroToPartyAction.Apply(hero, MobileParty.MainParty, true);
                CampaignEventDispatcher.Instance.OnHeroCreated(hero, false);
                ConversationUtils.ChangeCurrentCharaObject(campaignGameStarter, hero);

                if (hero.Age > 30)
                {
                    hero.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((float)22));
                }
            }
            return(hero);
        }
 // Mercifully, this does something. Although there might be an issue with birthdays causing edited heroes to age up
 // more often than not, so this needs to be rewritten.
 // Needs to differentiate if the game is under setup or in progress, but that is something for another update.
 public static void ResetBirthDayForAge(CharacterObject characterObject, float targetAge, bool randomize = false)
 {
     if (!characterObject.IsHero)
     {
         return;
     }
     characterObject.HeroObject.SetBirthDay(randomize ? HeroHelper.GetRandomBirthDayForAge(targetAge) : CampaignTime.YearsFromNow(-targetAge));
 }
예제 #6
0
 static bool Prefix(BodyGenerator __instance)
 {
     __instance.Character.UpdatePlayerCharacterBodyProperties(__instance.CurrentBodyProperties, __instance.IsFemale);
     if (__instance.Character is CharacterObject characterObject)
     {
         float bodyAge = __instance.CurrentBodyProperties.DynamicProperties.Age;
         characterObject.HeroObject.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((int)bodyAge));
     }
     return(false);
 }
 public static void UpdateHeroCharacterBodyProperties(CharacterObject character, BodyProperties properties, bool isFemale)
 {
     if (character.IsHero)
     {
         Hero hero = character.HeroObject;
         ReflectUtils.ReflectPropertyAndSetValue("StaticBodyProperties", properties.StaticProperties, hero);
         hero.Weight = properties.Weight;
         hero.Build  = properties.Build;
         hero.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((int)properties.Age));
         hero.UpdatePlayerGender(isFemale);
     }
 }
예제 #8
0
        public static string Age(List <string> strings)
        {
            if (CampaignCheats.CheckParameters(strings, 0) || CampaignCheats.CheckHelp(strings))
            {
                return($"{FormatMsgHeader} \"dcc.age [{AgeText}]\".");
            }

            if (!int.TryParse(strings[0], out int num))
            {
                return(EnterAgeMsg.ToString());
            }
            Hero.MainHero.BirthDay = HeroHelper.GetRandomBirthDayForAge(num);
            return(SuccessMsg.ToString());
        }
예제 #9
0
        public static string Age(List <string> strings)
        {
            if (CampaignCheats.CheckParameters(strings, 0) || CampaignCheats.CheckHelp(strings))
            {
                return("Format is \"dcc.age [Age]\".");
            }
            int num = 1;

            if (!int.TryParse(strings[0], out num))
            {
                return("Please enter a age");
            }
            Hero.MainHero.BirthDay = HeroHelper.GetRandomBirthDayForAge((float)num);
            return("Success");
        }
예제 #10
0
            static void Postfix(CharacterObject __instance, BodyProperties properties, bool isFemale)
            {
                if (__instance.IsPlayerCharacter && __instance.IsHero)
                {
                    __instance.HeroObject.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((int)properties.Age));
                }

                if (!__instance.IsPlayerCharacter && __instance.IsHero)
                {
                    Hero hero = __instance.HeroObject;
                    ReflectUtils.ReflectPropertyAndSetValue("StaticBodyProperties", properties.StaticProperties, hero);
                    hero.Weight = properties.Weight;
                    hero.Build  = properties.Build;
                    hero.SetBirthDay(HeroHelper.GetRandomBirthDayForAge((int)properties.Age));
                    hero.UpdatePlayerGender(isFemale);
                }
            }
        // Mercifully, this does something. Although there might be an issue with birthdays causing edited heroes to age up
        // more often than not, so this needs to be rewritten.
        // Needs to differentiate if the game is under setup or in progress, but that is something for another update.
        public static void ResetBirthDayForAge(CharacterObject characterObject, float targetAge, bool randomize = false)
        {
            if (characterObject.IsHero == false)
            {
                return;
            }

            Hero hero = characterObject.HeroObject;

            if (DCCSettings.Instance == null || DCCSettings.Instance.OverrideAge)
            {
                return;
            }

            hero.BirthDay = randomize ?
                            HeroHelper.GetRandomBirthDayForAge(targetAge) :
                            CampaignTime.Years((float)(CampaignTime.Now.ToYears - targetAge));
        }
        public static int GrowTargetHeroWithoutSideEffect(Hero hero)
        {
            if (hero == null)
            {
                return(-1);
            }

            int currentAge = (int)hero.Age;

            if ((int)hero.Age < SettingClass.Instance.GrowthStopAge)
            {
                hero.BirthDay = HeroHelper.GetRandomBirthDayForAge((int)hero.Age + 1);
            }

            currentAge = (int)hero.Age;

            return(currentAge);
        }
예제 #13
0
        public static string AgeHero(List <string> strings)
        {
            if (!CampaignCheats.CheckParameters(strings, 2) || CampaignCheats.CheckHelp(strings))
            {
                return($"{FormatMsgHeader} \"dcc.age_hero [{HeroNameText}] [{AgeText}]\".");
            }
            Hero hero = CampaignCheats.GetHero(strings[0].Replace('_', ' '));

            if (hero == null)
            {
                return(HeroNotFoundMsg.ToString());
            }
            if (!int.TryParse(strings[1], out int num))
            {
                return(EnterAgeMsg.ToString());
            }
            hero.BirthDay = HeroHelper.GetRandomBirthDayForAge(num);
            return(SuccessMsg.ToString());
        }
예제 #14
0
        public static void Postfix(ref Hero __result)
        {
            //var faction = __result.MapFaction;
            // It appears that gang leaders, merchants, and preachers have some female representation. Will skip them in that case.
            if ((__result.IsArtisan || __result.IsRuralNotable || __result.IsHeadman) && !__result.IsFemale)
            {
                __result.UpdatePlayerGender(MBRandom.RandomFloat < D225MiscFixesSettingsUtil.Instance.WorkerGenderRatio);
                NameGenerator.Current.GenerateHeroNameAndHeroFullName(__result, out var firstName, out var fullName, false);
                __result.SetName(fullName, firstName);
            }

            AgeModel ageModel = Campaign.Current.Models.AgeModel;
            int      baseAge  = Math.Max(ageModel.HeroComesOfAge, LocationCharacterConstructorPatch.TweenAge);

            if (__result.IsNotable)
            {
                __result.SetBirthDay(HeroHelper.GetRandomBirthDayForAge(
                                         MathF.Lerp(baseAge, ageModel.MaxAge, (__result.Age - ageModel.HeroComesOfAge) / (ageModel.MaxAge - ageModel.HeroComesOfAge))));
            }
        }
예제 #15
0
        public static string AgeHero(List <string> strings)
        {
            if (!CampaignCheats.CheckParameters(strings, 2) || CampaignCheats.CheckHelp(strings))
            {
                return("Format is \"dcc.age_hero [HeroName] [Age]\".");
            }
            Hero hero = CampaignCheats.GetHero(strings[0].Replace('_', ' '));

            if (hero == null)
            {
                return("Hero is not found");
            }
            int num;

            if (!int.TryParse(strings[1], out num))
            {
                return("Please enter a age");
            }
            hero.BirthDay = HeroHelper.GetRandomBirthDayForAge((float)num);
            return("Success");
        }
예제 #16
0
        static void Postfix(CharacterObject __instance, BodyProperties properties, bool isFemale)
        {
            if (__instance.IsHero)
            {
                if (!__instance.IsPlayerCharacter)
                {
                    AccessTools.Property(typeof(Hero), "StaticBodyProperties").SetValue(__instance.HeroObject, properties.StaticProperties);
                    __instance.HeroObject.DynamicBodyProperties = properties.DynamicProperties;
                    __instance.HeroObject.UpdatePlayerGender(isFemale);
                }

                if (DCCSettings.Instance != null && DCCSettings.Instance.DebugMode)
                {
                    InformationManager.DisplayMessage(new InformationMessage(HeroUpdatedMsg.ToString() + __instance.HeroObject.Name, ColorManager.Purple));
                }

                if (DCCSettings.Instance != null && !DCCSettings.Instance.OverrideAge)
                {
                    __instance.HeroObject.BirthDay = HeroHelper.GetRandomBirthDayForAge(properties.DynamicProperties.Age);
                }
            }
        }
        public static int GrowSibling(Hero hero)
        {
            int currentAge = (int)hero.Age;

            hero.BirthDay = HeroHelper.GetRandomBirthDayForAge((int)hero.Age + 1);

            if ((SettingClass.Instance.NPCChildrenGrowthBoostEnabled || hero.Clan == Clan.PlayerClan) &&
                (int)hero.Age == SettingClass.Instance.BecomeHeroAge)
            {
                if (hero.Clan == Clan.PlayerClan)
                {
                    GrowthDebug.LogInfo(
                        $"Your child {hero.Name} has now become a hero and is ready to fight for his clan!",
                        "Grow Sibling");

                    InformationManager.AddQuickInformation(
                        SettingClass.CurrentLanguage == "zh"
                            ? new TextObject($"你的孩子{hero.Name}已经成年, 成为了一个可以为家族而战的英雄")
                            : new TextObject(
                            $"Your child {hero.Name} has become a hero and is ready to fight for his clan!"),
                        0, null, "event:/ui/notification/quest_finished");

                    InformationManager.AddQuickInformation(
                        SettingClass.CurrentLanguage == "zh"
                            ? new TextObject($"你的孩子{hero.Name}从父母那里继承了部分能力, 在许多方面都突出常人")
                            : new TextObject(
                            $"Your child{hero.Name} inherits from its parents and become capable in many fields"),
                        0, null, "event:/ui/notification/quest_finished");
                }

                InheritHelper.Inherit(hero);
            }

            currentAge = (int)hero.Age;
            return(currentAge);
        }
        public static int GrowTargetHero(Hero hero)
        {
            if (hero == null)
            {
                return(-1);
            }

            int  currentAge = (int)hero.Age;
            bool notified   = false;

            if ((int)hero.Age > SettingClass.Instance.BecomeHeroAge)
            {
                foreach (var heroSibling in hero.Siblings)
                {
                    if (heroSibling.Age >= currentAge)
                    {
                        GrowSibling(heroSibling);

                        GrowthDebug.LogInfo(
                            $"${hero.Name}'s older siblings are 1 year older due to the growth of {hero.Name}");

                        if (heroSibling.Clan == Clan.PlayerClan && !notified)
                        {
                            InformationManager.AddQuickInformation(
                                SettingClass.CurrentLanguage == "zh"
                                    ? new TextObject($"因为{hero.Name}的成长,他的哥哥姐姐都长大了一岁")
                                    : new TextObject(
                                    $"{hero.Name}'s older siblings are 1 year older due to the growth of {hero.Name}"),
                                0, null, "event:/ui/notification/quest_update");
                            notified = true;
                        }
                    }
                }
            }

            hero.BirthDay = HeroHelper.GetRandomBirthDayForAge((int)hero.Age + 1);

            if (hero.Father == Hero.MainHero || hero.Mother == Hero.MainHero)
            {
                InformationManager.AddQuickInformation(
                    SettingClass.CurrentLanguage == "zh"
                        ? new TextObject($"你的孩子:{hero.Name} 现在已经{(int) hero.Age}岁了")
                        : new TextObject($"Now your child: {hero.Name} is {(int) hero.Age} years old"), 0,
                    null, "event:/ui/notification/quest_update");


                if (hero.Age >= SettingClass.Instance.BecomeHeroAge && hero.Age <= SettingClass.Instance.GrowthStopAge)
                {
                    // Only Main Heros get the notification
                    InformationManager.AddQuickInformation(
                        SettingClass.CurrentLanguage == "zh"
                            ? new TextObject($"因为你的孩子的成长,你和你的配偶都老了一岁")
                            : new TextObject(
                            "You and your spouse are 1 year older due to the growth of your children"),
                        0, null, "event:/ui/notification/quest_update");
                }
            }

            if ((int)hero.Age >= SettingClass.Instance.BecomeHeroAge &&
                (int)hero.Age <= SettingClass.Instance.GrowthStopAge)
            {
                if (hero.Mother != null)
                {
                    GrowTargetHero(hero.Mother);
                }

                if (hero.Father != null)
                {
                    GrowTargetHero(hero.Father);
                }
            }

            if ((int)hero.Age == SettingClass.Instance.BecomeHeroAge)
            {
                InheritHelper.Inherit(hero);
                if (hero.Clan == Clan.PlayerClan)
                {
                    GrowthDebug.LogInfo(
                        $"Your child {hero.Name} has now become a hero and is ready to fight for his clan!",
                        "Grow Target");

                    InformationManager.AddQuickInformation(
                        SettingClass.CurrentLanguage == "zh"
                            ? new TextObject($"你的孩子{hero.Name}已经成年, 成为了一个可以为家族而战的英雄")
                            : new TextObject(
                            $"Your child {hero.Name} has become a hero and is ready to fight for his clan!"),
                        0, null, "event:/ui/notification/quest_finished");

                    InformationManager.AddQuickInformation(
                        SettingClass.CurrentLanguage == "zh"
                            ? new TextObject($"你的孩子{hero.Name}从父母那里继承了部分能力, 在许多方面都突出常人")
                            : new TextObject(
                            $"Your child {hero.Name} inherits from its parents and become capable in many fields"),
                        0, null, "event:/ui/notification/quest_finished");
                }
            }

            currentAge = (int)hero.Age;
            return(currentAge);
        }