internal void ConsequenceChangeMorale(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeMorale)) { return; } PartyBase party = hero.IsPrisoner ? hero.PartyBelongedToAsPrisoner //captive : hero.PartyBelongedTo?.Party; //random, captor try { if (!string.IsNullOrEmpty(companion.MoraleTotal)) { _dynamics.MoraleChange(new CEVariablesLoader().GetIntFromXML(companion.MoraleTotal), party); } else { CECustomHandler.LogToFile("Missing MoralTotal"); _dynamics.MoraleChange(MBRandom.RandomInt(-5, 5), party); } } catch (Exception) { CECustomHandler.LogToFile("Invalid MoralTotal"); } }
internal void ConsequenceChangeSkill(Companion companion, Hero hero) { try { int level = 0; int xp = 0; if (companion.SkillsToLevel != null && companion.SkillsToLevel.Count(SkillToLevel => SkillToLevel.Ref.ToLower() == "hero") != 0) { foreach (SkillToLevel skillToLevel in companion.SkillsToLevel) { if (skillToLevel.Ref.ToLower() == "captor" && hero.PartyBelongedToAsPrisoner.LeaderHero == null) { continue; } if (!string.IsNullOrWhiteSpace(skillToLevel.ByLevel)) { level = new CEVariablesLoader().GetIntFromXML(skillToLevel.ByLevel); } else if (!string.IsNullOrWhiteSpace(skillToLevel.ByXP)) { xp = new CEVariablesLoader().GetIntFromXML(skillToLevel.ByXP); } new Dynamics().SkillModifier(skillToLevel.Ref.ToLower() != "hero" ? hero.PartyBelongedToAsPrisoner.LeaderHero : hero, skillToLevel.Id, level, xp, !skillToLevel.HideNotification, skillToLevel.Color); } } } catch (Exception) { CECustomHandler.LogToFile("Invalid Skill Flags"); } }
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."); } }
internal void GainSkills(SkillObject skillObject, int amount, int chance, Hero hero = null) { if (MBRandom.Random.Next(30) >= chance) { return; } if (hero == null) { hero = Hero.MainHero; } try { hero.HeroDeveloper.AddSkillXp(skillObject, amount); } catch (Exception) { CECustomHandler.LogToFile("Failed to add to skill"); } //TextObject textObject = new TextObject("{HERO} has learned {SKILL_AMOUNT} {SKILL} XP.", null); //textObject.SetTextVariable("HERO", Hero.MainHero.Name); //Hero.MainHero.AddSkillXp(skilltoget, 1f); //textObject.SetTextVariable("SKILL", skilltoget.Name); //textObject.SetTextVariable("SKILL_AMOUNT", amount); //InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Green)); }
internal void ConsequenceChangeCaptorRenown(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeCaptorRenown)) { return; } if (hero.PartyBelongedToAsPrisoner.LeaderHero == null) { return; } try { if (!string.IsNullOrEmpty(companion.RenownTotal)) { _dynamics.RenownModifier(new CEVariablesLoader().GetIntFromXML(companion.RenownTotal), hero.PartyBelongedToAsPrisoner.LeaderHero); } else { CECustomHandler.LogToFile("Missing RenownTotal"); _dynamics.RenownModifier(MBRandom.RandomInt(-5, 5), hero.PartyBelongedToAsPrisoner.LeaderHero); } } catch (Exception) { CECustomHandler.LogToFile("Invalid RenownTotal"); } }
internal void ConsequenceChangeCaptorGold(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeCaptorGold)) { return; } if (hero.PartyBelongedToAsPrisoner.LeaderHero == null) { return; } try { int level = 0; if (!string.IsNullOrEmpty(companion.GoldTotal)) { level = new CEVariablesLoader().GetIntFromXML(companion.GoldTotal); } else { CECustomHandler.LogToFile("Missing GoldTotal"); } GiveGoldAction.ApplyBetweenCharacters(null, hero.PartyBelongedToAsPrisoner.LeaderHero, level); } catch (Exception) { CECustomHandler.LogToFile("Invalid GoldTotal"); } }
public float GetFloatFromXML(string numpassed) { try { float number = 0f; if (numpassed == null) { return(number); } if (numpassed.StartsWith("R")) { string[] splitPass = numpassed.Split(' '); switch (splitPass.Length) { case 3: float numberOne = float.Parse(splitPass[1]); float numberTwo = float.Parse(splitPass[2]); number = numberOne < numberTwo ? MBRandom.RandomFloatRanged(numberOne, numberTwo) : MBRandom.RandomFloatRanged(numberTwo, numberOne); break; case 2: number = MBRandom.RandomFloatRanged(float.Parse(splitPass[1])); break; default: number = MBRandom.RandomFloat; break; } } else { number = float.Parse(numpassed); } return(number); } catch (Exception) { CECustomHandler.LogToFile("Failed to parse float " + numpassed); return(0f); } }
internal void CECaptivityChange(ref MenuCallbackArgs args, PartyBase party) { try { PlayerCaptivity.CaptorParty = party; PlayerCaptivity.StartCaptivity(party); CEHelper.delayedEvents.Clear(); } catch (Exception e) { CECustomHandler.LogToFile("Failed to exception: " + e.Message + " stacktrace: " + e.StackTrace); } }
internal void CECaptorKillPrisoners(MenuCallbackArgs args, int amount = 10, bool killHeroes = false) { try { int prisonerCount = MobileParty.MainParty.PrisonRoster.Count; if (prisonerCount < amount) { amount = prisonerCount; } MobileParty.MainParty.PrisonRoster.KillNumberOfMenRandomly(amount, killHeroes); TextObject textObject = GameTexts.FindText("str_CE_kill_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 kill any prisoners."); } }
private void ConsequenceSpecificCaptorRelations(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeRelation)) { return; } bool InformationMessage = !companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.NoInformationMessage); bool NoMessages = companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.NoMessages); try { _dynamics.RelationsModifier(hero, new CEVariablesLoader().GetIntFromXML(companion.RelationTotal), null, InformationMessage && !NoMessages, !InformationMessage && !NoMessages); } catch (Exception) { CECustomHandler.LogToFile("Missing RelationTotal"); _dynamics.RelationsModifier(hero, MBRandom.RandomInt(-5, 5), null, InformationMessage && !NoMessages, !InformationMessage && !NoMessages); } }
private void ConsequenceImpregnationByPlayer(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ImpregnationByPlayer)) { return; } try { if (!string.IsNullOrEmpty(companion.PregnancyRiskModifier)) { _impregnation.CaptivityImpregnationChance(hero, new CEVariablesLoader().GetIntFromXML(companion.PregnancyRiskModifier), false, false, Hero.MainHero); } else { CECustomHandler.LogToFile("Missing PregnancyRiskModifier"); _impregnation.CaptivityImpregnationChance(hero, 30, false, false, Hero.MainHero); } } catch (Exception) { CECustomHandler.LogToFile("Invalid PregnancyRiskModifier"); } }
internal void ConsequenceChangeHealth(Companion companion, Hero hero) { if (!companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.ChangeHealth)) { return; } try { if (!string.IsNullOrEmpty(companion.HealthTotal)) { hero.HitPoints += new CEVariablesLoader().GetIntFromXML(companion.HealthTotal); } else { CECustomHandler.LogToFile("Invalid HealthTotal"); hero.HitPoints += MBRandom.RandomInt(-20, 20); } } catch (Exception) { CECustomHandler.LogToFile("Missing HealthTotal"); } }
/// <summary> /// Custom CheckCaptivityChange Function /// </summary> /// <param name="dt"></param> /// <returns>EventName</returns> public override string CheckCaptivityChange(float dt) { if (!PlayerCaptivity.IsCaptive) { return(DefaultOverridenCheckCaptivityChange(dt)); } if (Hero.MainHero.Age < 18f) { EndCaptivityAction.ApplyByReleasing(Hero.MainHero); InformationManager.DisplayMessage(new InformationMessage(("Invalid Age: " + Hero.MainHero.Age), Colors.Gray)); CECustomHandler.ForceLogToFile("Underaged Player Detected. Age: " + Hero.MainHero.Age); return("menu_captivity_end_by_party_removed"); } if (CEHelper.delayedEvents.Count > 0) { string eventToFire = null; bool shouldFireEvent = CEHelper.delayedEvents.Any(item => { if (item.eventName != null && item.eventTime < Campaign.Current.CampaignStartTime.ElapsedHoursUntilNow) { CECustomHandler.LogToFile("Firing " + item.eventName); if (item.conditions == true) { string result = CEEventManager.FireSpecificEvent(item.eventName); switch (result) { case "$FAILEDTOFIND": CECustomHandler.LogToFile("Failed to load event list."); break; case "$EVENTNOTFOUND": CECustomHandler.LogToFile("Event not found."); break; case "$EVENTCONDITIONSNOTMET": CECustomHandler.LogToFile("Event conditions are not met."); break; default: if (result.StartsWith("$")) { CECustomHandler.LogToFile(result.Substring(1)); } else { eventToFire = item.eventName; item.hasBeenFired = true; return(true); } break; } } else { eventToFire = item.eventName.ToLower(); CEEvent foundevent = CEPersistence.CEEventList.FirstOrDefault(ceevent => ceevent.Name.ToLower() == eventToFire); if (foundevent != null && !foundevent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captive)) { eventToFire = null; return(false); } item.hasBeenFired = true; return(true); } } return(false); }); if (shouldFireEvent) { CEHelper.delayedEvents.RemoveAll(item => item.hasBeenFired); PlayerCaptivity.LastCheckTime = CampaignTime.Now; return(eventToFire); } } if (PlayerCaptivity.CaptorParty != null && !PlayerCaptivity.CaptorParty.IsSettlement) { if (!CheckEvent()) { return(DefaultOverridenCheckCaptivityChange(dt)); } PlayerCaptivity.LastCheckTime = CampaignTime.Now; CECustomHandler.LogToFile("About to choose a event!"); CEEvent captiveEvent = CEEventManager.ReturnWeightedChoiceOfEvents(); if (captiveEvent != null) { return(captiveEvent.Name); } } else { if (!CheckEvent()) { return(DefaultOverridenCheckCaptivityChange(dt)); } PlayerCaptivity.LastCheckTime = CampaignTime.Now; CECustomHandler.LogToFile("About to choose a settlement event!"); CEEvent captiveEvent = CEEventManager.ReturnWeightedChoiceOfEvents(); if (captiveEvent != null) { return(captiveEvent.Name); } } return(DefaultOverridenCheckCaptivityChange(dt)); }
public static CEEvent ReturnWeightedChoiceOfEvents() { List <CEEvent> events = new List <CEEvent>(); if (CEPersistence.CECallableEvents != null && CEPersistence.CECallableEvents.Count > 0) { CECustomHandler.LogToFile("Having " + CEPersistence.CECallableEvents.Count + " of events to weight and check conditions on."); foreach (CEEvent listEvent in CEPersistence.CECallableEvents) { if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captive)) { string result = new CEEventChecker(listEvent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter, PlayerCaptivity.CaptorParty); if (result == null) { int weightedChance = 10; if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.IgnoreAllOther)) { CECustomHandler.LogToFile("IgnoreAllOther detected - autofire " + listEvent.Name); return(listEvent); } try { if (listEvent.WeightedChanceOfOccuring != null) { weightedChance = new CEVariablesLoader().GetIntFromXML(listEvent.WeightedChanceOfOccuring); } } catch (Exception) { CECustomHandler.LogToFile("Missing WeightedChanceOfOccuring"); } for (int a = weightedChance; a > 0; a--) { events.Add(listEvent); } } else { CECustomHandler.LogToFile(result); } } } CECustomHandler.LogToFile("Number of Filtered events is " + events.Count); try { if (events.Count > 0) { return(events.GetRandomElement()); } } catch (Exception) { CECustomHandler.LogToFile("Something is broken?"); PrintDebugInGameTextMessage("Something Broken...?"); } } CECustomHandler.LogToFile("Number of Filitered events is " + events.Count); return(null); }
public static CEEvent ReturnWeightedChoiceOfEventsPartyLeader(CharacterObject captive) { List <CEEvent> events = new List <CEEvent>(); CECustomHandler.LogToFile("Number of Filitered events is " + events.Count); if (CEPersistence.CECallableEvents == null || CEPersistence.CECallableEvents.Count <= 0) { return(null); } CECustomHandler.LogToFile("Having " + CEPersistence.CECallableEvents.Count + " of events to weight and check conditions on."); foreach (CEEvent listEvent in CEPersistence.CECallableEvents) { if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captor)) { string result = new CEEventChecker(listEvent).FlagsDoMatchEventConditions(captive, PartyBase.MainParty); if (result == null) { int weightedChance = 10; if (listEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.IgnoreAllOther)) { CECustomHandler.LogToFile("IgnoreAllOther detected - autofire " + listEvent.Name); return(listEvent); } try { weightedChance = new CEVariablesLoader().GetIntFromXML(listEvent.WeightedChanceOfOccuring); } catch (Exception) { CECustomHandler.LogToFile("Missing WeightedChanceOfOccuring"); } for (int a = weightedChance; a > 0; a--) { events.Add(listEvent); } } else { CECustomHandler.LogToFile(result); } } } CECustomHandler.LogToFile("Number of Filtered events is " + events.Count); try { if (events.Count > 0) { CEEvent randomEvent = events.GetRandomElement(); randomEvent.Captive = captive; return(randomEvent); } } catch (Exception e) { CECustomHandler.ForceLogToFile("eventNames.Count Broken : " + e); PrintDebugInGameTextMessage("eventNames.Count Broken"); } return(null); }
internal void CECaptorPrisonerRebel(MenuCallbackArgs args) { CEPersistence.animationPlayEvent = false; TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster(); try { foreach (TroopRosterElement element in MobileParty.MainParty.PrisonRoster.GetTroopRoster()) { if (element.Character.IsHero) { element.Character.HeroObject.ChangeState(Hero.CharacterStates.Active); } } releasedPrisoners.Add(MobileParty.MainParty.PrisonRoster.ToFlattenedRoster()); MobileParty.MainParty.PrisonRoster.Clear(); } catch (Exception) { CECustomHandler.LogToFile("Couldn't find anymore prisoners."); } if (!releasedPrisoners.GetTroopRoster().IsEmpty()) { try { TroopRosterElement leader = releasedPrisoners.GetTroopRoster().FirstOrDefault(hasHero => hasHero.Character.IsHero); Clan clan = null; Settlement nearest = null; MobileParty prisonerParty = null; if (leader.Character != null) { clan = leader.Character.HeroObject.Clan; nearest = SettlementHelper.FindNearestSettlement(settlement => settlement.OwnerClan == clan) ?? SettlementHelper.FindNearestSettlement(settlement => true); prisonerParty = LordPartyComponent.CreateLordParty("CustomPartyCE_" + MBRandom.RandomInt(int.MaxValue), leader.Character.HeroObject, MobileParty.MainParty.Position2D, 0.5f, nearest); } else { clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters"); clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual); nearest = SettlementHelper.FindNearestSettlement(settlement => true); prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_" + MBRandom.RandomInt(int.MaxValue), clan, nearest.Hideout, false); } PartyTemplateObject defaultPartyTemplate = clan.DefaultPartyTemplate; prisonerParty.InitializeMobileParty(defaultPartyTemplate, MobileParty.MainParty.Position2D, 0.5f, 0.1f, -1); prisonerParty.SetCustomName(new TextObject("{=CEEVENTS1107}Escaped Captives")); prisonerParty.MemberRoster.Clear(); prisonerParty.ActualClan = clan; prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster()); prisonerParty.IsActive = true; prisonerParty.HomeSettlement = nearest; prisonerParty.SetMovePatrolAroundPoint(nearest.IsTown ? nearest.GatePosition : nearest.Position2D); if (leader.Character != null) { prisonerParty.Party.Owner = leader.Character.HeroObject; #if BETA prisonerParty.ChangePartyLeader(leader.Character); #else prisonerParty.ChangePartyLeader(leader.Character, true); #endif } else { prisonerParty.Party.Owner = clan.Leader; } prisonerParty.RecentEventsMorale = -100; prisonerParty.Aggressiveness = 0.2f; prisonerParty.InitializePartyTrade(0); Hero.MainHero.HitPoints += 40; CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString()); PlayerEncounter.RestartPlayerEncounter(MobileParty.MainParty.Party, prisonerParty.Party); GameMenu.SwitchToMenu("encounter"); } catch (Exception) { CECaptorContinue(args); } } else { CECaptorContinue(args); } }
internal void CECaptorHuntPrisoners(MenuCallbackArgs args, int amount = 20) { CEPersistence.animationPlayEvent = false; TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster(); if (CESettings.Instance != null) { amount = CESettings.Instance.AmountOfTroopsForHunt; } try { for (int i = 0; i < amount; i++) { TroopRosterElement test = MobileParty.MainParty.PrisonRoster.GetTroopRoster().Where(troop => !troop.Character.IsHero).GetRandomElementInefficiently(); if (test.Character == null) { continue; } MobileParty.MainParty.PrisonRoster.RemoveTroop(test.Character); releasedPrisoners.AddToCounts(test.Character, 1, true); } } catch (Exception) { CECustomHandler.LogToFile("Couldn't find anymore prisoners."); } if (!releasedPrisoners.GetTroopRoster().IsEmpty()) { CECaptorContinue(args); try { Clan clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters"); clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual); Settlement nearest = SettlementHelper.FindNearestSettlement(settlement => { return(true); }); MobileParty prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_Hunt_" + MBRandom.RandomInt(int.MaxValue), clan, nearest.Hideout, false); PartyTemplateObject defaultPartyTemplate = clan.DefaultPartyTemplate; prisonerParty.InitializeMobileParty(defaultPartyTemplate, MobileParty.MainParty.Position2D, 0.5f, 0.1f, -1); prisonerParty.SetCustomName(new TextObject("{=CEEVENTS1107}Escaped Captives")); prisonerParty.MemberRoster.Clear(); prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster()); prisonerParty.RecentEventsMorale = -100; prisonerParty.IsActive = true; prisonerParty.ActualClan = clan; prisonerParty.Party.Owner = clan.Leader; prisonerParty.Party.Visuals.SetMapIconAsDirty(); prisonerParty.HomeSettlement = nearest; prisonerParty.InitializePartyTrade(0); Hero.MainHero.HitPoints += 40; CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString()); PlayerEncounter.RestartPlayerEncounter(prisonerParty.Party, MobileParty.MainParty.Party, true); StartBattleAction.Apply(MobileParty.MainParty.Party, prisonerParty.Party); PlayerEncounter.Update(); CEPersistence.huntState = CEPersistence.HuntState.StartHunt; CampaignMission.OpenBattleMission(PlayerEncounter.GetBattleSceneForMapPosition(MobileParty.MainParty.Position2D)); } catch (Exception) { CECaptorKillPrisoners(args, amount); } } else { CECaptorContinue(args); } }
internal void ConsequenceCompanions(CharacterObject hero, PartyBase party) { if (_option.Companions != null) { try { foreach (Companion companion in _option.Companions) { Hero referenceHero; List <Hero> heroes = new List <Hero>(); if (companion.Ref != null) { switch (companion.Ref.ToLower()) { case "hero": if (!hero.IsHero) { continue; } referenceHero = hero.HeroObject; break; case "captor": if (!party.Leader.IsHero) { continue; } referenceHero = party.Leader.HeroObject; break; default: referenceHero = Hero.MainHero; break; } if (companion.Type != null) { switch (companion.Type.ToLower()) { case "spouse": if (referenceHero.Spouse == null) { continue; } heroes.Add(referenceHero.Spouse); break; case "companion": if (referenceHero.Clan == null) { continue; } foreach (Hero companionHero in referenceHero.Clan.Companions) { heroes.Add(companionHero); } break; default: if (referenceHero.Spouse != null) { heroes.Add(referenceHero.Spouse); } if (referenceHero.Clan != null) { foreach (Hero companionHero in referenceHero.Clan.Companions) { heroes.Add(companionHero); } } break; } } else { if (referenceHero.Spouse != null) { heroes.Add(referenceHero.Spouse); } if (referenceHero.Clan != null) { foreach (Hero companionHero in referenceHero.Clan.Companions) { heroes.Add(companionHero); } } } } else if (companion.Id != null) { Hero heroCompanion = _listedEvent.SavedCompanions.FirstOrDefault((item) => item.Key == companion.Id).Value; if (hero != null) { heroes.Add(heroCompanion); } } if (heroes.Count == 0) { continue; } if (companion.Location != null) { switch (companion.Location.ToLower()) { case "prisoner": heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedToAsPrisoner != party && companionHero.IsPrisoner); }); break; case "party": heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedTo?.Party != null && companionHero.PartyBelongedTo.Party != party && !companionHero.PartyBelongedTo.IsGarrison); }); break; case "settlement": heroes = heroes.FindAll((companionHero) => { return(companionHero?.CurrentSettlement != null); }); break; case "current prisoner": heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedToAsPrisoner == party); }); break; case "current": heroes = heroes.FindAll((companionHero) => { return(companionHero?.PartyBelongedTo?.Party == party); }); break; default: break; } if (heroes.Count == 0) { continue; } } if (companion.UseOtherConditions != null && companion.UseOtherConditions.ToLower() != "false") { CEEvent triggeredEvent = CEPersistence.CEEventList.Find(item => item.Name == companion.UseOtherConditions); if (triggeredEvent == null) { continue; } heroes = heroes.FindAll((companionHero) => { string conditionals = new CEEventChecker(triggeredEvent).FlagsDoMatchEventConditions(companionHero.CharacterObject, party); if (conditionals != null) { CECustomHandler.LogToFile(conditionals); return(false); } else { return(true); } }); } if (heroes.Count == 0) { continue; } Hero heroSelected = heroes.GetRandomElement(); try { ConsequenceForceMarry(companion, heroSelected); ConsequenceLeaveSpouse(companion, heroSelected); ConsequenceGold(companion, heroSelected); ConsequenceChangeGold(companion, heroSelected); ConsequenceChangeCaptorGold(companion, heroSelected); ConsequenceRenown(companion, heroSelected); ConsequenceChangeCaptorRenown(companion, heroSelected); ConsequenceChangeHealth(companion, heroSelected); ConsequenceChangeTrait(companion, heroSelected); ConsequenceChangeSkill(companion, heroSelected); ConsequenceSlaveryFlags(companion, heroSelected); ConsequenceProstitutionFlags(companion, heroSelected); ConsequenceChangeMorale(companion, heroSelected); ConsequenceSpecificCaptorRelations(companion, heroSelected); ConsequenceImpregnation(companion, heroSelected); ConsequenceImpregnationByLeader(companion, heroSelected); ConsequenceImpregnationByPlayer(companion, heroSelected); ConsequenceChangeClan(companion, heroSelected); ConsequenceChangeKingdom(companion, heroSelected); ConsequenceEscape(companion, heroSelected); ConsequenceRelease(companion, heroSelected); ConsequenceWoundPrisoner(companion, heroSelected); ConsequenceKillPrisoner(companion, heroSelected); ConsequenceStrip(companion, heroSelected); ConsequenceGainRandomPrisoners(companion, heroSelected); } catch (Exception e) { CECustomHandler.ForceLogToFile("Incorrect ConsequenceCompanions heroSelected: " + e.ToString()); } } } catch (Exception e) { CECustomHandler.ForceLogToFile("Incorrect ConsequenceCompanions: " + e.ToString()); } } }
public string CEWaitingList() { List <string> eventNames = new List <string>(); if (CEPersistence.CEWaitingList != null && CEPersistence.CEWaitingList.Count > 0) { CECustomHandler.LogToFile("Having " + CEPersistence.CEWaitingList.Count + " of events to weight and check conditions on."); foreach (CEEvent listEvent in CEPersistence.CEWaitingList) { string result = new CEEventChecker(listEvent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter, PlayerCaptivity.CaptorParty); if (result == null) { int weightedChance = 10; try { if (listEvent.WeightedChanceOfOccuring != null) { weightedChance = new CEVariablesLoader().GetIntFromXML(listEvent.WeightedChanceOfOccuring); } } catch (Exception) { CECustomHandler.LogToFile("Missing WeightedChanceOfOccuring"); } for (int a = weightedChance; a > 0; a--) { eventNames.Add(listEvent.Name); } } else { CECustomHandler.LogToFile(result); } } CECustomHandler.LogToFile("Number of Filtered events is " + eventNames.Count); try { if (eventNames.Count > 0) { int test = MBRandom.Random.Next(0, eventNames.Count); string randomWeightedChoice = eventNames[test]; CECustomHandler.LogToFile("CEWaitingList Choice is " + randomWeightedChoice); return(randomWeightedChoice); } } catch (Exception) { CECustomHandler.ForceLogToFile("Waiting Menu: Something is broken?"); } } CECustomHandler.LogToFile("Number of Filtered events is " + eventNames.Count); return(null); }
private void OnHourlyTick() { if (CESettings.Instance.EventCaptorOn && Hero.MainHero.IsPartyLeader && CheckEventHourly()) { CECustomHandler.LogToFile("Checking Campaign Events"); try { bool shouldEventsFire = !progressEventExists; if (delayedEvents.Count > 0 && shouldEventsFire) { CEEvent captorEventCheck = CheckDelayedCaptorEvent(); CEEvent randomEventCheck = CheckDelayedRandomEvent(); if (captorEventCheck != null) { notificationCaptorExists = false; LaunchCaptorEvent(captorEventCheck); } else if (randomEventCheck != null) { notificationEventExists = false; LaunchCaptorEvent(randomEventCheck); } else { shouldEventsFire = true; } } if (shouldEventsFire) { if (MobileParty.MainParty.Party.PrisonRoster.Count > 0) { if (CESettings.Instance.EventRandomEnabled) { int randomNumber = MBRandom.RandomInt(100); if (randomNumber < CESettings.Instance.EventRandomFireChance && !LaunchRandomEvent()) { LaunchCaptorEvent(); } if (randomNumber > CESettings.Instance.EventRandomFireChance && !LaunchCaptorEvent()) { LaunchRandomEvent(); } } else { LaunchCaptorEvent(); } } else if (CESettings.Instance.EventRandomEnabled) { LaunchRandomEvent(); } } } catch (Exception e) { CECustomHandler.ForceLogToFile("CheckEventHourly Failure"); CECustomHandler.ForceLogToFile(e.Message + " : " + e); } } // Pregnancies try { _heroPregnancies.ForEach(item => { if (item.Mother != null) { item.Mother.IsPregnant = true; CheckOffspringsToDeliver(item); } else { item.AlreadyOccured = true; } }); _heroPregnancies.RemoveAll(item => item.AlreadyOccured); } catch (Exception e) { TextObject textObject = new TextObject("{=CEEVENTS1007}Error: resetting the CE pregnancy list"); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black)); _heroPregnancies = new List <Pregnancy>(); CECustomHandler.ForceLogToFile("Failed _heroPregnancies ForEach"); CECustomHandler.ForceLogToFile(e.Message + " : " + e); } // Gear if (CESettings.Instance.EventCaptorGearCaptives) { try { _returnEquipment.ForEach(CheckEquipmentToReturn); _returnEquipment.RemoveAll(item => item.AlreadyOccured); } catch (Exception e) { TextObject textObject = new TextObject("{=CEEVENTS1006}Error: resetting the return equipment list"); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Black)); _returnEquipment = new List <ReturnEquipment>(); CECustomHandler.ForceLogToFile("Failed _returnEquipment ForEach"); CECustomHandler.ForceLogToFile(e.Message + " : " + e); } } }
private CEEvent CheckDelayedRandomEvent() { CEEvent eventToFire = null; bool shouldFireEvent = delayedEvents.Any(item => { if (item.eventName != null && item.eventTime < Campaign.Current.CampaignStartTime.ElapsedHoursUntilNow) { CECustomHandler.LogToFile("Firing " + item.eventName); if (item.conditions == true) { string result = CEEventManager.FireSpecificEventRandom(item.eventName, out CEEvent ceEvent, true); switch (result) { case "$FAILEDTOFIND": CECustomHandler.LogToFile("Failed to load event list."); break; case "$EVENTNOTFOUND": CECustomHandler.LogToFile("Event not found."); break; case "$EVENTCONDITIONSNOTMET": CECustomHandler.LogToFile("Event conditions are not met."); break; default: if (result.StartsWith("$")) { CECustomHandler.LogToFile(result.Substring(1)); } else { eventToFire = ceEvent; item.hasBeenFired = true; return(true); } break; } } else { eventToFire = CEPersistence.CEEventList.FirstOrDefault(ceevent => ceevent.Name.ToLower() == item.eventName.ToLower()); if (!eventToFire.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Random)) { eventToFire = null; return(false); } item.hasBeenFired = true; return(true); } } return(false); }); if (shouldFireEvent) { delayedEvents.RemoveAll(item => item.hasBeenFired); return(eventToFire); } return(null); }