示例#1
0
 public CEEventMapNotificationItemVM(InformationData data) : base(data)
 {
     NotificationIdentifier = CESettings.Instance != null && CESettings.Instance.EventCaptorCustomTextureNotifications
         ? "ceevent"
         : "vote";
     _randomEvent = ((CEEventMapNotification)data).RandomEvent;
     _onInspect   = OnRandomNotificationInspect;
 }
示例#2
0
 public CECaptorMapNotificationItemVM(InformationData data) : base(data)
 {
     NotificationIdentifier = CESettings.Instance != null && CESettings.Instance.EventCaptorCustomTextureNotifications
      ? "cecaptor"
      : "death";
     _captorEvent = ((CECaptorMapNotification)data).CaptorEvent;
     _onInspect   = OnCaptorNotificationInspect;
 }
示例#3
0
        public static void CELoadRandomEvent(CampaignGameStarter gameStarter, CEEvent listedEvent, List <CEEvent> eventList)
        {
            CEVariablesLoader          variablesLoader = new CEVariablesLoader();
            MenuCallBackDelegateRandom rcb             = new MenuCallBackDelegateRandom(listedEvent, eventList);

            if (listedEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.ProgressMenu))
            {
                gameStarter.AddWaitGameMenu(listedEvent.Name,
                                            listedEvent.Text,
                                            rcb.RandomProgressInitWaitGameMenu,
                                            rcb.RandomProgressConditionWaitGameMenu,
                                            rcb.RandomProgressConsequenceWaitGameMenu,
                                            rcb.RandomProgressTickWaitGameMenu,
                                            CEProgressMode(variablesLoader.GetIntFromXML(listedEvent.ProgressEvent.DisplayProgressMode)),
                                            TaleWorlds.CampaignSystem.Overlay.GameOverlays.MenuOverlayType.None,
                                            variablesLoader.GetFloatFromXML(listedEvent.ProgressEvent.TimeToTake),
                                            GameMenu.MenuFlags.none,
                                            "CEEVENTS");
            }
            else
            {
                gameStarter.AddGameMenu(
                    listedEvent.Name,
                    listedEvent.Text,
                    rcb.RandomEventGameMenu,
                    TaleWorlds.CampaignSystem.Overlay.GameOverlays.MenuOverlayType.None,
                    GameMenu.MenuFlags.none,
                    "CEEVENTS");
            }

            if (listedEvent.Options == null)
            {
                return;                                                                                                     // Leave if no Options
            }
            List <Option> sorted = listedEvent.Options.OrderBy(item => variablesLoader.GetIntFromXML(item.Order)).ToList(); // Sort Options

            foreach (Option op in sorted)
            {
                MenuCallBackDelegateRandom mcb = new MenuCallBackDelegateRandom(listedEvent, op, eventList);
                gameStarter.AddGameMenuOption(
                    listedEvent.Name,
                    listedEvent.Name + op.Order,
                    op.OptionText,
                    mcb.RandomEventConditionMenuOption,
                    mcb.RandomEventConsequenceMenuOption,
                    false, variablesLoader.GetIntFromXML(op.Order));
            }
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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));
        }
示例#6
0
        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());
                }
            }
        }
示例#7
0
 public CECompanionSystem(CEEvent listedEvent, Option option, List <CEEvent> eventList)
 {
     _listedEvent = listedEvent;
     _option      = option;
     _eventList   = eventList;
 }
示例#8
0
 public CECaptorMapNotification(CEEvent captorEvent, TextObject descriptionText) : base(descriptionText) => CaptorEvent = captorEvent;
        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);
                }
            }
        }
示例#10
0
        private bool LaunchCaptorEvent(CEEvent OverrideEvent = null)
        {
            if (CESettings.Instance.EventCaptorNotifications)
            {
                if (notificationCaptorExists || progressEventExists)
                {
                    return(false);
                }
            }

            CEEvent returnedEvent;

            if (OverrideEvent == null)
            {
                CharacterObject captive = MobileParty.MainParty.Party.PrisonRoster.GetTroopRoster().GetRandomElement().Character;
                returnedEvent = CEEventManager.ReturnWeightedChoiceOfEventsPartyLeader(captive);
            }
            else
            {
                returnedEvent = OverrideEvent;
            }

            if (returnedEvent == null)
            {
                return(false);
            }
            notificationCaptorExists = true;

            if (CESettings.Instance.EventCaptorNotifications)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(returnedEvent.NotificationName))
                    {
                        new CESubModule().LoadCampaignNotificationTexture(returnedEvent.NotificationName);
                    }
                    else if (returnedEvent.SexualContent)
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_sexual_notification");
                    }
                    else
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_castle_notification");
                    }
                }
                catch (Exception e)
                {
                    InformationManager.DisplayMessage(new InformationMessage("LoadCampaignNotificationTextureFailure", Colors.Red));

                    CECustomHandler.ForceLogToFile("LoadCampaignNotificationTexture");
                    CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                }

                Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new CECaptorMapNotification(returnedEvent, new TextObject("{=CEEVENTS1090}Captor event is ready")));
            }
            else
            {
                if (Game.Current.GameStateManager.ActiveState is MapState mapState)
                {
                    Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode;

                    if (!mapState.AtMenu)
                    {
                        _extraVariables.menuToSwitchBackTo = null;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = null;
                        GameMenu.ActivateGameMenu("prisoner_wait");
                    }
                    else
                    {
                        _extraVariables.menuToSwitchBackTo = mapState.GameMenuId;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName;
                    }

                    GameMenu.SwitchToMenu(returnedEvent.Name);
                }
            }

            return(true);
        }
示例#11
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
 public CEEventMapNotification(CEEvent randomEvent, TextObject descriptionText) : base(descriptionText) => RandomEvent = randomEvent;