public static void GetPregnancyForHero(Hero father, Hero mother) { MakePregnantAction.Apply(mother); PregnancyCampaignBehavior pregnancyCampaignBehavior = Campaign.Current.GetCampaignBehavior <PregnancyCampaignBehavior>(); CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = pregnancyCampaignBehavior.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(pregnancyCampaignBehavior); object[] parameters = new object[3] { mother, father, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } }
static bool Prefix(PregnancyCampaignBehavior __instance, Hero mother) { if (mother.IsFemale && mother.Age > 18 && (Hero.MainHero.ExSpouses.Contains(mother) || mother == Hero.MainHero.Spouse)) { CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = __instance.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(__instance); object[] parameters = new object[3] { mother, Hero.MainHero, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } return(false); } return(true); }
private void DoTellStories(ToldStoriesTo village) { if (village._battleStoriesTold < _notableBattlesWon) { float _renownToGive = CalculateRenownToGive(); GainRenownAction.Apply(Hero.MainHero, _renownToGive, true); InformationManager.DisplayMessage(new InformationMessage("You told the villagers a story about a notable battle, gained " + _renownToGive + " renown.")); village._daysToResetStories = CampaignTime.DaysFromNow(RandomizeDays()); village._hasToldStories = true; village._battleStoriesTold++; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(1, 3)); if (_renownToGive >= 0.9) { if (Settlement.CurrentSettlement.Notables.Count >= 1) { InformationManager.DisplayMessage(new InformationMessage("Notable people in village were impressed by your feats and like you more.")); foreach (Hero notablePerson in Settlement.CurrentSettlement.Notables) { ChangeRelationAction.ApplyPlayerRelation(notablePerson, +1, false, true); } } } } else { InformationManager.DisplayMessage(new InformationMessage("You do not have new stories to tell to these villagers.")); } }
private static void Postfix2(ref CampaignTime __result) { ISettingsProvider settings = new MASettings(); if (settings.RetryCourtship) { __result = CampaignTime.DaysFromNow(1f); } }
protected override QuestBase GenerateIssueQuest(string questId) { float stolenGearDuration = 3.0f; // Set default duration here if needed. if (CESettings.Instance != null) { stolenGearDuration = CESettings.Instance.StolenGearDuration; } return(new CEWhereAreMyThingsIssueQuest(questId, IssueOwner, CampaignTime.DaysFromNow(stolenGearDuration), RewardGold, new Equipment(Hero.MainHero.BattleEquipment), new Equipment(Hero.MainHero.CivilianEquipment))); }
private void CalculateBonus(Clan clan, CanvassSave save) { if (clan.IsKingdomFaction) { return; } var daysToNow = (int)CampaignTime.DaysFromNow(save.DayTime).ToDays; if (save.IsCurrent()) { save.Bonus = Math.Min(1, save.Bonus + daysToNow / 30f); } else { save.Bonus = Math.Max(0, save.Bonus - daysToNow / 30f); } }
private void DoTellStories(ToldStoriesTo village) { if (village._battleStoriesTold < _notableBattlesWon) { SkillObject skill; int num; skill = SkillObject.FindFirst((x) => { return(x.StringId == "Charm"); }); num = (int)Math.Ceiling(MobileParty.MainParty.LeaderHero.GetSkillValue(skill) * 0.03f); float _renownToGive = CalculateRenownToGive(num); GainRenownAction.Apply(Hero.MainHero, _renownToGive, true); if ((double)_renownToGive <= 0.2) { village._daysToResetStories = CampaignTime.DaysFromNow(this.RandomizeDays()); village._hasToldStories = true; ++village._battleStoriesTold; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, 1); InformationManager.DisplayMessage(new InformationMessage("Your story failed to inspire the villagers.")); return; } InformationManager.DisplayMessage(new InformationMessage("You told the villagers a story about a notable battle, gained " + _renownToGive + " renown.")); village._daysToResetStories = CampaignTime.DaysFromNow(RandomizeDays()); village._hasToldStories = true; village._battleStoriesTold++; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(1, 3)); if (_renownToGive >= 2.0) { if (Settlement.CurrentSettlement.Notables.Count >= 1) { InformationManager.DisplayMessage(new InformationMessage("Notable people in village were impressed by your feats and like you more.")); foreach (Hero notablePerson in Settlement.CurrentSettlement.Notables) { int _relationToGive = CalculateRelationToGive(_renownToGive); ChangeRelationAction.ApplyPlayerRelation(notablePerson, _relationToGive, false, true); } } } } else { InformationManager.DisplayMessage(new InformationMessage("You do not have new stories to tell to these villagers.")); } }
public void RecordPrePregnantInfo(Hero sexPartner1, Hero sexPartner2) { if ((double)MBRandom.RandomFloatRanged(0.0f, 1f) > (double)Config.Instance.PregnancyProbability || sexPartner1 == null || sexPartner2 == null || !Config.Instance.EnableLesbianPregnancy && sexPartner1.IsFemale && sexPartner2.IsFemale) { return; } Hero key = (Hero)null; Hero father = (Hero)null; if (sexPartner1.IsAlive && sexPartner1.IsFemale && (sexPartner1.IsPregnant == false && (double)sexPartner1.Age > (double)Config.Instance.MinAge)) { key = sexPartner1; father = sexPartner2; } if (sexPartner2.IsAlive && sexPartner2.IsFemale && (sexPartner2.IsPregnant == false && (double)sexPartner2.Age > (double)Config.Instance.MinAge) && (key == null || MBRandom.RandomInt(0, 1) == 0)) { key = sexPartner2; father = sexPartner1; } if (key == null || father == null) { return; } CampaignTime pregnantDate = CampaignTime.DaysFromNow((float)MBRandom.RandomInt(Config.Instance.MinPregnancyDelayDays, Config.Instance.MaxPregnancyDelayDays)); if (this.m_prePregnancyInfoMap.ContainsKey(key)) { if (this.m_prePregnancyInfoMap[key].m_pregnantDate > pregnantDate) { this.m_prePregnancyInfoMap[key].m_father = father; this.m_prePregnancyInfoMap[key].m_pregnantDate = pregnantDate; } } else { this.m_prePregnancyInfoMap.Add(key, new PregnancyControlBehavior.PrePregnancyInfo(father, pregnantDate)); } Utillty.DebugDisplayMessage("_recordPrePregnantInfo Success! Mother : " + ((object)key.Name).ToString() + " Father : " + ((object)father.Name).ToString() + " PregnantDate : " + pregnantDate.ToString()); }
private void OnChildConceived(Hero hero) { try { if (CEHelper.spouseOne == null && CEHelper.spouseTwo == null) { return; } Hero father = CEHelper.spouseOne == hero ? CEHelper.spouseTwo : CEHelper.spouseOne; CECustomHandler.ForceLogToFile("Added " + hero.Name + "'s Pregnancy"); if (CESettings.Instance != null) { _heroPregnancies.Add(new Pregnancy(hero, father, CampaignTime.DaysFromNow(CESettings.Instance.PregnancyDurationInDays))); } } catch (Exception e) { CECustomHandler.ForceLogToFile("Failed to handle OnChildConceivedEvent."); CECustomHandler.ForceLogToFile(e.Message + " : " + e); } }
private void WeeklyTick() { foreach (var item in _canvassSaves) { if (item.IsCurrent()) { var daysToNow = (int)CampaignTime.DaysFromNow(item.DayTime).ToDays; var hero = item.Hero; var clan = item.Clan; if (hero != null && clan != null && clan.Leader != null && daysToNow > 0) { ApplyAddRelation(hero, clan, daysToNow); CalculateBonus(clan, item); } else if (clan != null) { CalculateBonus(clan, item); } } } }
public void RecordSexInfo(Hero sexPartner1, Hero sexPartner2) { if (sexPartner1 == null || sexPartner1.IsDead || (sexPartner2 == null || sexPartner2.IsDead)) { return; } CampaignTime nextSexEnableDate = CampaignTime.DaysFromNow((float)MBRandom.RandomInt(Config.Instance.MinSexDelayDays, Config.Instance.MaxSexDelayDays)); if (this.m_dailySexTimeCountMap.ContainsKey(sexPartner1)) { ++this.m_dailySexTimeCountMap[sexPartner1]; } else { this.m_dailySexTimeCountMap.Add(sexPartner1, 1); } if (this.m_dailySexTimeCountMap.ContainsKey(sexPartner2)) { ++this.m_dailySexTimeCountMap[sexPartner2]; } else { this.m_dailySexTimeCountMap.Add(sexPartner2, 1); } int index = this.m_sexInformationList.FindIndex((Predicate <PregnancyControlBehavior.SexInfo>)(info => info.m_sexPartner1 == sexPartner1 && info.m_sexPartner2 == sexPartner2 || info.m_sexPartner2 == sexPartner1 && info.m_sexPartner1 == sexPartner2)); if (index >= 0) { this.m_sexInformationList[index].m_nextSexEnableDate = (this.m_sexInformationList[index].m_nextSexEnableDate >= nextSexEnableDate) ? this.m_sexInformationList[index].m_nextSexEnableDate : nextSexEnableDate; } else { this.m_sexInformationList.Add(new PregnancyControlBehavior.SexInfo(sexPartner1, sexPartner2, nextSexEnableDate)); } Utillty.DebugDisplayMessage("_recordSexInfo Success! Partner1 : " + ((object)sexPartner1.Name).ToString() + " Partner2 : " + ((object)sexPartner2.Name).ToString() + " NexSexEnableDate : " + nextSexEnableDate.ToString()); }
protected override void ApplyInternal(Kingdom proposingKingdom, Kingdom otherKingdom, float?customDurationInDays) { DiplomaticAgreementManager.Instance.RegisterAgreement(proposingKingdom, otherKingdom, new NonAggressionPactAgreement(CampaignTime.Now, CampaignTime.DaysFromNow(customDurationInDays.HasValue ? customDurationInDays.Value : Settings.Instance.NonAggressionPactDuration), proposingKingdom, otherKingdom)); TextObject textObject = new TextObject("{=vB3RrMNf}The {KINGDOM} has formed a non-aggression pact with the {OTHER_KINGDOM}."); textObject.SetTextVariable("KINGDOM", proposingKingdom.Name); textObject.SetTextVariable("OTHER_KINGDOM", otherKingdom.Name); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString())); }
public JawwalQuestLine(Hero questGiver) : base("actus.purus.jawwal_quest_line", questGiver, CampaignTime.DaysFromNow(30), 0) { SetDialogs(); }
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."); } } } } }
private void ArmorSmithDialogOnPay() { if (currentQuests.ContainsKey(Settlement.CurrentSettlement)) { currentQuests.Remove(Settlement.CurrentSettlement); } currentQuests.Add(Settlement.CurrentSettlement, new ArmorCraftingQuest($"armor_crafting_quest_id_{Settlement.CurrentSettlement.Name}_{CampaignTime.Now}", Hero.MainHero, Settlement.CurrentSettlement, CampaignTime.DaysFromNow(38f), selectedItem, goldPaidInAdvance)); }
public override CampaignTime GetMissiveDeliveryTime(Hero sender, Hero recipient) { return(CampaignTime.DaysFromNow(MissiveDeliveryRate)); // TODO: get arrival time based on distance }
public CEWhereAreMyThingsIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(25f)) { }