private void ExtendDeadline()
 {
     if (Campaign.Current != null && Campaign.Current.QuestManager != null)
     {
         foreach (QuestBase questBase in Campaign.Current.QuestManager.Quests)
         {
             bool flag2 = questBase.GetName().ToString().StartsWith("stop_conspiracy_") && questBase.QuestDueTime < CampaignTime.DaysFromNow(5f);
             if (flag2)
             {
                 DebugHelpers.ColorGreenMessage("Extending Stop the Conspiracy quest by 1 year.");
                 questBase.ChangeQuestDueTime(CampaignTime.YearsFromNow(1f));
                 DebugHelpers.ColorGreenMessage("New quest deadline: " + questBase.QuestDueTime.ToString());
             }
             bool flag3 = questBase.StringId.StartsWith("conspiracy_quest_") && questBase.QuestDueTime < CampaignTime.DaysFromNow(7f);
             if (flag3)
             {
                 questBase.ChangeQuestDueTime(CampaignTime.WeeksFromNow(3f));
                 DebugHelpers.ColorGreenMessage("BT Extend Conspiracy Tweak: Extended conspiracy quest.");
                 float cStrngth = SecondPhase.Instance.ConspiracyStrength;
                 if (cStrngth > 1000 && cStrngth > 250)
                 {
                     SecondPhase.Instance.DecreaseConspiracyStrength(150);
                     DebugHelpers.ColorGreenMessage("BT Extend Conspiracy Tweak: Reduced conspiracy strength.");
                 }
             }
         }
     }
 }
示例#2
0
        public void GrowUp(Hero hero)
        {
            float age    = hero.Age;
            int   infant = Campaign.Current.Models.AgeModel.BecomeInfantAge;
            //int child = Campaign.Current.Models.AgeModel.BecomeChildAge;
            int teen  = Campaign.Current.Models.AgeModel.BecomeTeenagerAge;
            int adult = Campaign.Current.Models.AgeModel.HeroComesOfAge;

            if (age >= adult)
            {
                Helper.ColorRedMessage("This hero is already an adult.");
                return;
            }

            // Assure hero hits the right growth stages, depending on which stage they were grown from.--
            // Edit: Changed it to that each button press grows the hero by 1 stange.
            // To instantly grow a hero to 18, change the 'else if' functions to just 'if'

            if (age < infant)
            {
                SendHeroGrowsOutOfInfancyEvent(hero);
                Helper.DebugMessage("Out of infrancy event sent.");
                hero.SetBirthDay(CampaignTime.YearsFromNow((float)infant * -1));
            }

            //if (age < teen)
            else if (age < teen)
            {
                SendHeroReachesTeenAgeEvent(hero);
                Helper.DebugMessage("Out of teen event sent.");
                hero.SetBirthDay(CampaignTime.YearsFromNow((float)teen * -1));
            }


            //if (age < adult)
            else
            {
                SendHeroComesOfAgeEvent(hero);
                Helper.DebugMessage("Come of age event sent.");
                GrowUpForFixSkill(hero);
                hero.SetBirthDay(CampaignTime.YearsFromNow((float)adult * -1));
                var adulttextObject = new TextObject("{=tips_cr_HeroGrowAdult}Your child is now a qualified hero");
                StringHelpers.SetCharacterProperties("CR_HERO", hero.CharacterObject, null, adulttextObject);
            }


            //Helper.ColorGreenMessage("Grew "+hero.Name+" to Adulthood. Wait a day or two to assure they go through the Come-of-Age process and get stats.");
            Helper.ColorGreenMessage("Grew " + hero.Name + " Wait a day or two to assure they go through the growth process and get added stats/development.");
            Helper.DebugMessage("Hero: " + hero.Name + " | Old Age = " + age + " | New age = " + hero.Age);
        }
        private static void Postfix(Hero companion, EndCaptivityDetail detail)
        {
            if (companion.Clan != Hero.MainHero.Clan || companion.PartyBelongedTo != null && companion.PartyBelongedTo.Party.Owner == companion || ((companion != null ? companion.getOrder() : (PartyOrder)null) == null || !companion.IsAlive || companion.Clan.CommanderLimit <= companion.Clan.WarParties.Count <MobileParty>((Func <MobileParty, bool>)(p => !p.IsGarrison && !p.IsMilitia && !p.IsVillager && !p.IsCaravan))))
            {
                return;
            }
            companion.ChangeState(Hero.CharacterStates.Active);
            MobilePartyHelper.CreateNewClanMobileParty(companion, companion.Clan, out bool _);
            if (companion.PartyBelongedTo == null)
            {
                return;
            }
            PartyOrder order = companion.getOrder();

            if (order.Behavior == AiBehavior.EscortParty && (double)order.ScoreMinimum > 1.0)
            {
                companion.PartyBelongedTo.SetInititave(0.0f, 1f, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
            }
            else
            {
                companion.PartyBelongedTo.SetInititave(order.AttackInitiative, order.AvoidInitiative, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
            }
        }
示例#4
0
        private static bool Prefix(Hero prisoner, EndCaptivityDetail detail)
        {
            if (prisoner.Clan != Hero.MainHero.Clan || prisoner.PartyBelongedToAsPrisoner == null || (prisoner.IsActive || !prisoner.IsAlive) || prisoner.PartyBelongedTo != null && prisoner.PartyBelongedTo.Party.Owner == prisoner || detail != EndCaptivityDetail.ReleasedAfterBattle && detail != EndCaptivityDetail.ReleasedAfterPeace && detail != EndCaptivityDetail.RemovedParty || (prisoner.Clan.CommanderLimit <= prisoner.Clan.WarParties.Count <MobileParty>((Func <MobileParty, bool>)(p => !p.IsGarrison && !p.IsMilitia && !p.IsVillager && !p.IsCaravan)) || (double)prisoner.PartyBelongedToAsPrisoner.Position2D.DistanceSquared(MobileParty.MainParty.VisualPosition2DWithoutError) >= 25.0))
            {
                return(true);
            }
            StatisticsDataLogHelper.AddLog(StatisticsDataLogHelper.LogAction.EndCaptivityAction);
            PartyBase belongedToAsPrisoner = prisoner.PartyBelongedToAsPrisoner;
            IFaction  faction = belongedToAsPrisoner != null ? belongedToAsPrisoner.MapFaction : (IFaction)CampaignData.NeutralFaction;

            Traverse.Create((object)CampaignEventDispatcher.Instance).Method("OnHeroPrisonerReleased", new Type[4]
            {
                typeof(Hero),
                typeof(PartyBase),
                typeof(IFaction),
                typeof(EndCaptivityDetail)
            }, (object[])null).GetValue((object)prisoner, (object)belongedToAsPrisoner, (object)faction, (object)detail);
            EndCaptivityActionPatch.SpawnPartyAtPosition(prisoner, MobileParty.MainParty.VisualPosition2DWithoutError);
            if (prisoner.PartyBelongedTo != null && (prisoner != null ? prisoner.getOrder() : (PartyOrder)null) != null)
            {
                PartyOrder order = prisoner.getOrder();
                if (order.Behavior == AiBehavior.EscortParty && (double)order.ScoreMinimum > 1.0)
                {
                    if ((double)Campaign.Current.Models.MapDistanceModel.GetDistance(prisoner.PartyBelongedTo, MobileParty.MainParty) > 15.0)
                    {
                        prisoner.PartyBelongedTo.SetInititave(0.0f, 1f, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
                    }
                    else
                    {
                        prisoner.PartyBelongedTo.SetInititave(order.AttackInitiative, order.AvoidInitiative, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
                    }
                    prisoner.PartyBelongedTo.SetMoveEscortParty(order.TargetParty);
                }
            }
            return(false);
        }
        public void CampaignDescriptor_Test()
        {
            using var harmony = new HarmonyDisposable($"{nameof(DependencyInjectionTests)}.{nameof(CampaignDescriptor_Test)}");
            harmony.Patch(AccessTools.DeclaredPropertyGetter(typeof(CampaignTime), "CurrentTicks"),
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedCurrentTicks)));
            harmony.Patch(SymbolExtensions.GetMethodInfo(() => CharacterCode.CreateFrom((BasicCharacterObject)null !)),
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedCreateFrom)));


            var hero = (Hero)FormatterServices.GetUninitializedObject(typeof(Hero));

#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159
            AccessTools.Field(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#elif e1510 || e160
            AccessTools.Property(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
            AccessTools.Field(typeof(Hero), "_birthDay").SetValue(hero, CampaignTime.YearsFromNow(18));

            var campaignDescriptor = CampaignDescriptor.Create(hero);
            Assert.NotNull(campaignDescriptor);
            Assert.True(campaignDescriptor is CampaignDescriptorImplementation);
        }
 public static void RegisterOrder(Hero leader, PartyOrder order)
 {
     if (PartyAICommandsBehavior.Instance.order_map == null)
     {
         PartyAICommandsBehavior.Instance.order_map = new Dictionary <Hero, PartyOrder>();
     }
     PartyAICommandsBehavior.Instance.order_map[leader] = order;
     leader.PartyBelongedTo.SetInititave(order.AttackInitiative, order.AvoidInitiative, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
 }
示例#7
0
        public TestQuest(Hero questGiver, BasicCharacterObject target, int targetCount) : base("test_quest_1", questGiver, CampaignTime.YearsFromNow(2), 99999999)
        {
            KillQuestAction task1 = new KillQuestAction(target, targetCount);

            structure = new QuestActionStructure(task1, this);
            structure.AddQuestActionOnComplete(task1, new KillQuestAction(target, targetCount));
            structure.Completed().Where((x) => x).Subscribe((x) => CompleteQuestWithSuccess());
            structure.Failed().Where((x) => x).Subscribe((x) => CompleteQuestWithFail());
            SetDialogs();

            AddTrackedObject(questGiver);
        }
 // 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));
 }