public void DoAbortionNotificationAndLog(Hero mother, Hero causedHero) { TextObject textObject; if (mother == Hero.MainHero) { textObject = new TextObject(Utillty.ET("{=pcm_child_abortion_ntf_self}You just had an abortion."), null); } else if (mother == Hero.MainHero.Spouse) { textObject = new TextObject(Utillty.ET("{=pcm_child_abortion_ntf_spouse}Your spouse {MOTHER} just had an abortion."), null); textObject.SetTextVariable("MOTHER", (TextObject)mother.Name); } else if (mother.Clan == Clan.PlayerClan) { textObject = new TextObject(Utillty.ET("{=pcm_child_abortion_ntf_clan}Your clan member {MOTHER} just had an abortion."), null); textObject.SetTextVariable("MOTHER", (TextObject)mother.Name); } else { if (causedHero != Hero.MainHero) { return; } textObject = new TextObject(Utillty.ET("{=pcm_child_abortion_ntf_caused}{MOTHER} just had an abortion."), null); textObject.SetTextVariable("MOTHER", (TextObject)mother.Name); } InformationManager.AddQuickInformation(textObject, 0, (BasicCharacterObject)null, ""); LogEntry.AddLogEntry((LogEntry) new AbortionLogEntry(mother, causedHero), CampaignTime.Now); }
public static void RenewContract(Hero mercenary) { if (mercenary == Hero.MainHero) { InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("str_mercenary_contract_renewed", null).ToString())); } LogEntry.AddLogEntry(new MercenaryContractRenewedLogEntry(mercenary, mercenary.MapFaction)); }
private static void OnDailyTick() { foreach (var clan in Clan.All.Where(c => c.IsUnderMercenaryService)) { if (!MercenarySettings.Instance.ApplyRelationshipRulesToNPC && clan != Clan.PlayerClan) { continue; } if (MercenaryManager.DaysBeforeContractEnds(clan) < 1f) { var mercenaryContractExpired = new MercenaryContractExpiredLogEntry(Clan.PlayerClan.Leader); LogEntry.AddLogEntry(mercenaryContractExpired); Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new MercenaryContractMapNotification(Clan.PlayerClan.Leader, mercenaryContractExpired.GetEncyclopediaText())); } } }
public static void EndContract(Hero mercenary) { var mercenaryClan = mercenary.Clan; var mercenaryKingdom = mercenaryClan.Kingdom; var mercenaryFaction = mercenary.MapFaction; StatisticsDataLogHelper.AddLog(StatisticsDataLogHelper.LogAction.ChangeKingdomAction, new object[] { mercenaryClan, mercenaryKingdom, (Kingdom)null, true }); mercenaryClan.ClanLeaveKingdom(false); OnMercenaryClanChangedKingdomMethod.Invoke(CampaignEventDispatcher.Instance, new object[] { mercenaryClan, mercenaryKingdom, (Kingdom)null }); mercenaryClan.IsUnderMercenaryService = false; if (mercenary == Hero.MainHero) { mercenaryClan.ClanLeaveKingdom(true); } CheckIfPartyIconIsDirtyMethod.Invoke(null, new object[] { mercenaryClan, mercenaryKingdom }); if (mercenary == Hero.MainHero) { InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("str_mercenary_contract_ended", null).ToString())); } LogEntry.AddLogEntry(new MercenaryContractEndedLogEntry(mercenary, mercenaryFaction)); }
/// <summary> /// Behavior Duplicate found In PregnancyCampaignBehavior /// </summary> /// <param name="pregnancy"></param> private void CheckOffspringsToDeliver(Pregnancy pregnancy) { try { if (!pregnancy.Mother.IsAlive) { pregnancy.AlreadyOccured = true; return; } CalculatePregnancyWeight(pregnancy); if (pregnancy.DueDate.IsFuture) { return; } PregnancyModel pregnancyModel = Campaign.Current.Models.PregnancyModel; Hero mother = pregnancy.Mother; bool flag = MBRandom.RandomFloat <= pregnancyModel.DeliveringTwinsProbability; List <Hero> aliveOffsprings = new List <Hero>(); int num = flag ? 2 : 1; int stillbornCount = 0; for (int i = 0; i < 1; i++) { if (MBRandom.RandomFloat > pregnancyModel.StillbirthProbability) { bool isOffspringFemale = MBRandom.RandomFloat <= pregnancyModel.DeliveringFemaleOffspringProbability; try { Hero item = DeliverOffSpring(pregnancy.Mother, pregnancy.Father, isOffspringFemale, 0); aliveOffsprings.Add(item); } catch (Exception e) { CECustomHandler.ForceLogToFile("Bad pregnancy " + (isOffspringFemale ? "Female" : "Male")); CECustomHandler.ForceLogToFile(e.Message + " : " + e); Hero item = HeroCreator.DeliverOffSpring(pregnancy.Mother, pregnancy.Father, !isOffspringFemale, null, 0); aliveOffsprings.Add(item); } } else { if (mother == Hero.MainHero) { TextObject textObject = new TextObject("{=pw4cUPEn}{MOTHER.LINK} has delivered stillborn."); StringHelpers.SetCharacterProperties("MOTHER", mother.CharacterObject, textObject); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString())); } stillbornCount++; } } if (mother == Hero.MainHero || pregnancy.Father == Hero.MainHero) { TextObject textObject = mother == Hero.MainHero ? new TextObject("{=oIA9lkpc}You have given birth to {DELIVERED_CHILDREN}.") : new TextObject("{=CEEVENTS1092}Your captive {MOTHER.NAME} has given birth to {DELIVERED_CHILDREN}."); switch (stillbornCount) { case 2: textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=Sn9a1Aba}two stillborn babies")); break; case 1 when aliveOffsprings.Count == 0: textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=qWLq2y84}a stillborn baby")); break; case 1 when aliveOffsprings.Count == 1: textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1168}one healthy and one stillborn baby")); break; case 0 when aliveOffsprings.Count == 1: textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1169}a healthy baby")); break; case 0 when aliveOffsprings.Count == 2: textObject.SetTextVariable("DELIVERED_CHILDREN", new TextObject("{=CEEVENTS1170}two healthy babies")); break; } StringHelpers.SetCharacterProperties("MOTHER", mother.CharacterObject, textObject); InformationManager.AddQuickInformation(textObject); } if (mother.IsHumanPlayerCharacter || pregnancy.Father == Hero.MainHero) { for (int i = 0; i < stillbornCount; i++) { ChildbirthLogEntry childbirthLogEntry = new ChildbirthLogEntry(mother, null); LogEntry.AddLogEntry(childbirthLogEntry); Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new ChildBornMapNotification(null, childbirthLogEntry.GetEncyclopediaText())); } foreach (Hero newbornHero in aliveOffsprings) { ChildbirthLogEntry childbirthLogEntry2 = new ChildbirthLogEntry(mother, newbornHero); LogEntry.AddLogEntry(childbirthLogEntry2); Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new ChildBornMapNotification(newbornHero, childbirthLogEntry2.GetEncyclopediaText())); } } mother.IsPregnant = false; pregnancy.AlreadyOccured = true; ChangeWeight(pregnancy.Mother, 0, MBRandom.RandomFloatRanged(0.4025f, 0.6025f)); } catch (Exception e) { CECustomHandler.ForceLogToFile("Bad pregnancy"); CECustomHandler.ForceLogToFile(e.Message + " : " + e); TextObject textObject = new TextObject("{=CEEVENTS1008}Error: bad pregnancy in CE pregnancy list"); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black)); pregnancy.AlreadyOccured = true; } }
/* * Here it creates a bandit hero in the log */ private void AddHeroToLog(Hero hero) { LogEntry.AddLogEntry(new BanditHeroLogEntry(hero), CampaignTime.Now); }