private void OnCaptorNotificationInspect() { CEHelper.notificationCaptorExists = false; ExecuteRemove(); if (MobileParty.MainParty.Party.PrisonRoster.Count > 0 && MobileParty.MainParty.Party.PrisonRoster.Contains(_captorEvent.Captive)) { // Declare Variables string returnString = new CEEventChecker(_captorEvent).FlagsDoMatchEventConditions(_captorEvent.Captive, PartyBase.MainParty); if (returnString == null) { if (!(Game.Current.GameStateManager.ActiveState is MapState mapState)) { TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met."); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray)); return; } Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode; if (!mapState.AtMenu) { if (CECampaignBehavior.ExtraProps != null) { CECampaignBehavior.ExtraProps.menuToSwitchBackTo = null; CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = null; } GameMenu.ActivateGameMenu(_captorEvent.Name); } else { if (CECampaignBehavior.ExtraProps != null) { CECampaignBehavior.ExtraProps.menuToSwitchBackTo = mapState.GameMenuId; CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName; } GameMenu.SwitchToMenu(_captorEvent.Name); } } else { TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met."); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray)); } } else { TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met."); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray)); } }
public static string FireSpecificEvent(string specificEvent, bool force = false) { List <string> eventNames = new List <string>(); string flag = "$FAILEDTOFIND"; if (CEPersistence.CEEventList == null || CEPersistence.CEEventList.Count <= 0) { return(flag); } specificEvent = specificEvent.ToLower(); CEEvent foundevent = CEPersistence.CEEventList.FirstOrDefault(ceevent => ceevent.Name.ToLower() == specificEvent); if (foundevent != null) { if (!force && foundevent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captive)) { string result = new CEEventChecker(foundevent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter, PlayerCaptivity.CaptorParty); if (result == null) { flag = foundevent.Name; } else { flag = "$" + result; } } else if (force) { flag = foundevent.Name; } else { flag = "$EVENTCONDITIONSNOTMET"; } } else { flag = "$EVENTNOTFOUND"; } return(flag); }
private void OnRandomNotificationInspect() { CEHelper.notificationEventExists = false; ExecuteRemove(); string result = new CEEventChecker(_randomEvent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter); if (result == null) { if (!(Game.Current.GameStateManager.ActiveState is MapState mapState)) { TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met."); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray)); return; } Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode; if (!mapState.AtMenu) { if (CECampaignBehavior.ExtraProps != null) { CECampaignBehavior.ExtraProps.menuToSwitchBackTo = null; CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = null; } GameMenu.ActivateGameMenu(_randomEvent.Name); } else { if (CECampaignBehavior.ExtraProps != null) { CECampaignBehavior.ExtraProps.menuToSwitchBackTo = mapState.GameMenuId; CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName; } GameMenu.SwitchToMenu(_randomEvent.Name); } } else { TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met."); InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray)); } }
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 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); }
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 string FireSpecificEventPartyLeader(string specificEvent, out CEEvent ceEvent, bool force = false, string heroname = null) { List <string> eventNames = new List <string>(); string flag = "$FAILEDTOFIND"; ceEvent = null; if (CEPersistence.CEEventList == null || CEPersistence.CEEventList.Count <= 0) { return(flag); } specificEvent = specificEvent.ToLower(); CEEvent foundevent = CEPersistence.CEEventList.FirstOrDefault(ceevent => ceevent.Name.ToLower() == specificEvent); if (foundevent != null) { if (heroname == null) { foreach (TroopRosterElement troopRosterElement in PartyBase.MainParty.PrisonRoster.GetTroopRoster()) { if (troopRosterElement.Character != null) { if (foundevent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captor)) { string result = new CEEventChecker(foundevent).FlagsDoMatchEventConditions(troopRosterElement.Character, PartyBase.MainParty); if (force || result == null) { foundevent.Captive = troopRosterElement.Character; ceEvent = foundevent; return(foundevent.Name); } flag = "$" + result; } } } } else { TroopRosterElement specificTroopRosterElement = PartyBase.MainParty.PrisonRoster.GetTroopRoster().FirstOrDefault(troopRosterElement => troopRosterElement.Character != null && troopRosterElement.Character.Name.ToString() == heroname); if (specificTroopRosterElement.Character == null) { return("$FAILTOFINDHERO"); } CharacterObject specificCaptive = specificTroopRosterElement.Character; if (!foundevent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captor)) { return(flag); } string result = new CEEventChecker(foundevent).FlagsDoMatchEventConditions(specificCaptive, PartyBase.MainParty); if (force || result == null) { foundevent.Captive = specificCaptive; return(foundevent.Name); } flag = "$" + result; } } else { flag = "$EVENTNOTFOUND"; } return(flag); }
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); }