コード例 #1
0
        public override bool Run()
        {
            List <SimDescription> aliens = AlienUtilsEx.GetAliens();

            if (aliens == null)
            {
                Logger.Append("Debug - Trigger Alien Visit: No Aliens");
                return(false);
            }

            SimDescription alien = RandomUtil.GetRandomObjectFromList <SimDescription>(aliens);

            Lot farthestLot = LotManager.GetFarthestLot(Target);
            Sim visitor     = alien.InstantiateOffScreen(farthestLot);

            AlienSituation.Create(visitor, Target);

            return(true);
        }
コード例 #2
0
ファイル: AlienUtilsEx.cs プロジェクト: Duglarogg/Sims3
        static void ActivityCallback()
        {
            Logger.Append("Alien Activity Alarm Triggered");

            if (Household.AlienHousehold == null || Household.AlienHousehold.NumMembers == 0)
            {
                Logger.Append("Alien Activity: Alien Household Null or Empty");
                return;
            }

            float chance = GetActivityChance();

            if (RandomUtil.RandomChance(chance))
            {
                Logger.Append("Alien Activity: Chance Passed " + chance);

                List <SimDescription> aliens = GetAliens();

                if (aliens == null)
                {
                    Logger.Append("Alien Activity: No valid aliens.");
                    return;
                }

                SimDescription alien = RandomUtil.GetRandomObjectFromList <SimDescription>(aliens);

                chance = GetAbductionChance();

                if (RandomUtil.RandomChance(chance))
                {
                    Logger.Append("Alien Abduction: Chance Passed " + chance);

                    chance = GetAbductionChance(true);

                    Lot targetLot;
                    Sim abductee;

                    if (IsActiveTarget(chance))
                    {
                        Logger.Append("Alien Abduction (Active): Chance Passed " + chance);

                        List <Sim> abductees = GetAbductees(Household.ActiveHousehold);

                        if (abductees == null)
                        {
                            Logger.Append("Alien Abduction (Active): No Valid Abductees");
                            ResetAbductionHelper();
                            return;
                        }

                        abductee = RandomUtil.GetRandomObjectFromList <Sim>(abductees);

                        if (!CanSimBeAbducted(abductee))
                        {
                            Logger.Append("Alien Abduction (Active): Can't Abduct Target");
                            ResetAbductionHelper();
                            return;
                        }

                        targetLot = abductee.LotCurrent;
                    }
                    else
                    {
                        Logger.Append("Alien Abduction (Active): Chance Failed " + chance);

                        List <Lot> lots = GetLots();

                        if (lots == null)
                        {
                            Logger.Append("Alien Abduction (Non-Active): No Valid Lots");
                            ResetAbductionHelper();
                            return;
                        }

                        targetLot = RandomUtil.GetRandomObjectFromList <Lot>(lots);

                        List <Sim> abductees = GetAbductees(targetLot);

                        if (abductees == null)
                        {
                            Logger.Append("Alien Abduction (Non-Active): No Valid Abductees");
                            ResetAbductionHelper();
                            return;
                        }

                        abductee = RandomUtil.GetRandomObjectFromList <Sim>(abductees);

                        if (!CanSimBeAbducted(abductee))
                        {
                            Logger.Append("Alien Abduction (Non-Active): Can't Abduct Target");
                            ResetAbductionHelper();
                            return;
                        }
                    }

                    AlienAbductionSituationEx.Create(alien, abductee, targetLot);
                }
                else
                {
                    Logger.Append("Alien Abduction: Chance Failed " + chance);

                    chance = GetVisitChance();

                    if (RandomUtil.RandomChance(chance))
                    {
                        Logger.Append("Alien Visit: Chance Passed " + chance);

                        chance = GetVisitChance(true, alien);

                        Lot farthestLot, targetLot;
                        Sim visitor;

                        if (IsActiveTarget(chance))
                        {
                            Logger.Append("Alien Visit (Active): Chance Passed " + chance);

                            targetLot   = Household.ActiveHouseholdLot;
                            farthestLot = LotManager.GetFarthestLot(targetLot);
                            visitor     = alien.InstantiateOffScreen(farthestLot);
                        }
                        else
                        {
                            Logger.Append("Alien Visit (Active): Chance Failed " + chance);

                            List <Lot> lots = GetLots();

                            if (lots == null)
                            {
                                Logger.Append("Alien Visit (Non-Active): No Valid Lots");
                                ResetAbductionHelper();
                                return;
                            }

                            targetLot   = RandomUtil.GetRandomObjectFromList <Lot>(lots);
                            farthestLot = LotManager.GetFarthestLot(targetLot);
                            visitor     = alien.InstantiateOffScreen(farthestLot);
                        }

                        AlienSituation.Create(visitor, targetLot);
                    }
                    else
                    {
                        Logger.Append("Alien Visit: Chance Failed " + chance);
                    }
                }
            }
            else
            {
                Logger.Append("Alien Activity: Chance Failed " + chance);
            }

            ResetAbductionHelper();
        }
コード例 #3
0
        public static void AlienActivityCallback()
        {
            string msg = "Alien Activity Alarm" + Common.NewLine;

            if (cooldown > 0)
            {
                msg += " - On Cooldown: " + cooldown + " hours remaining";
                Common.DebugNotify(msg);

                cooldown -= 1;

                return;
            }

            if (SimClock.Hours24 >= Aliens.Settings.mEarliestHour ||
                SimClock.Hours24 <= (Aliens.Settings.mEarliestHour + Aliens.Settings.mActivityWindow) % 24)
            {
                if (Household.AlienHousehold == null || Household.AlienHousehold.NumMembers == 0)
                {
                    msg += " - Alien household null or empty";
                    Common.DebugNotify(msg);
                    return;
                }

                float chance = GetActivityChance();

                if (!RandomUtil.RandomChance(chance))
                {
                    msg += " - Activity Roll Fail (" + chance + "%)";
                    Common.DebugNotify(msg);
                    return;
                }

                msg += " - Activity Roll Pass (" + chance + "%)" + Common.NewLine;

                List <SimDescription> aliens = GetValidAliens();

                if (aliens == null)
                {
                    msg += " - No valid aliens";
                    Common.DebugNotify(msg);
                    return;
                }

                SimDescription alien = RandomUtil.GetRandomObjectFromList(aliens);
                chance = GetAbductionChance(true);

                if (RandomUtil.RandomChance(chance))
                {
                    msg += " - Active Abduction Roll Pass (" + chance + "%)" + Common.NewLine;

                    /* <WISHLIST>
                     *      For now, abductions will only target the active household.  This is due to how alien babies are treated
                     *      by NRaasStoryProgression.  If the abductee is married, then they are treated as though they had committed
                     *      adultery with the alien baby as proof of the deed.  This can result undesired break ups/divorces, etc.  I
                     *      will need to study StoryProgression to determine how to allow alien pregnancies in non-active households
                     *      without the adultery drama.
                     */

                    List <Sim> validAbductees = GetValidAbductees(Household.ActiveHousehold);

                    if (validAbductees == null)
                    {
                        msg += " -- No valid abductees";
                        Common.DebugNotify(msg);
                        return;
                    }

                    Sim abductee = RandomUtil.GetRandomObjectFromList(validAbductees);
                    Lot lot      = abductee.LotCurrent;

                    if (lot == null)
                    {
                        msg += " -- Abductee lot is null";
                        Common.DebugNotify(msg);
                        return;
                    }

                    msg += " -- Starting active abduction situation";
                    Common.DebugNotify(msg);

                    AlienAbductionSituationEx.Create(alien, abductee, lot);
                    cooldown = Aliens.Settings.mActivityCooldown;
                    ResetAbductionHelper();
                    return;
                }

                msg += " - Active Abduction Roll Fail (" + chance + "%)" + Common.NewLine;

                chance = GetAbductionChance();

                if (RandomUtil.RandomChance(chance))
                {
                    msg += " - NPC Abduction Roll Pass (" + chance + "%)" + Common.NewLine;

                    List <Lot> lots = GetValidLots(true);

                    if (lots == null)
                    {
                        msg += " - No valid lots";
                        Common.DebugNotify(msg);
                        return;
                    }

                    Lot lot = RandomUtil.GetRandomObjectFromList(lots);

                    if (lot == null)
                    {
                        msg += " - Lot is null";
                        Common.DebugNotify(msg);
                        return;
                    }

                    List <Sim> validAbductees = GetValidAbductees(lot);

                    if (validAbductees == null)
                    {
                        msg += " -- No valid abductees";
                        Common.DebugNotify(msg);
                        return;
                    }

                    msg += " -- Starting NPC abduction situation";
                    Common.DebugNotify(msg);

                    Sim abductee = RandomUtil.GetRandomObjectFromList(validAbductees);
                    AlienAbductionSituationEx.Create(alien, abductee, lot);
                    cooldown = Aliens.Settings.mActivityCooldown;
                    return;
                }

                msg += " - NPC Abduction Roll Fail (" + chance + "%)" + Common.NewLine;

                chance = GetVisitationChance(Household.ActiveHousehold, alien);

                if (RandomUtil.RandomChance(chance))
                {
                    msg += " - Visit Active Roll Pass (" + chance + "%)" + Common.NewLine +
                           " -- Starting active visit situation (" + Household.ActiveHousehold.LotHome.Name + ")";
                    Common.DebugNotify(msg);

                    Sim visitor = alien.InstantiateOffScreen(LotManager.GetFarthestLot(Household.ActiveHousehold.LotHome));
                    AlienSituation.Create(visitor, Household.ActiveHousehold.LotHome);
                    cooldown = Aliens.Settings.mActivityCooldown;
                    ResetAbductionHelper();
                }
                else
                {
                    msg += " - Visit Active Roll Fail (" + chance + "%)" + Common.NewLine;

                    List <Lot> lots = GetValidLots();

                    if (lots == null)
                    {
                        msg += " -- No valid lots";
                        Common.DebugNotify(msg);
                        return;
                    }

                    Lot lot = RandomUtil.GetRandomObjectFromList(lots);

                    msg += " -- Starting NPC visit situation (" + lot.Name + ")";
                    Common.DebugNotify(msg);

                    Sim visitor = alien.InstantiateOffScreen(LotManager.GetFarthestLot(lot));
                    AlienSituation.Create(visitor, lot);
                    cooldown = Aliens.Settings.mActivityCooldown;
                }
            }
            else
            {
                msg += " - Outside active hours";
                Common.DebugNotify(msg);
            }
        }
コード例 #4
0
        static void AlienActivityCallback()
        {
            if (Abductor.Settings.mDebugging)
            {
                StyledNotification.Format format = new StyledNotification.Format("Alien Visitation Alarm triggered!",
                                                                                 StyledNotification.NotificationStyle.kDebugAlert);
                StyledNotification.Show(format);
            }

            if (Household.AlienHousehold == null || Household.AlienHousehold.NumMembers == 0)
            {
                Logger.Append("Alien Activity Alarm: Alien Household Null or Empty");
                return;
            }

            float chance = GetActivityChance();

            if (!RandomUtil.RandomChance(chance))
            {
                Logger.Append("Alien Activity Alarm: Chance Fail " + chance);
                ResetAbductionHelper();
                return;
            }

            List <SimDescription> aliens = GetAliens();

            if (aliens == null)
            {
                Logger.Append("Alien Activity Alarm: No valid aliens");
                ResetAbductionHelper();
                return;
            }

            SimDescription alien = RandomUtil.GetRandomObjectFromList <SimDescription>(aliens);

            chance = GetAbductionChance();

            if (RandomUtil.RandomChance(chance))
            {
                chance = GetAbductionChance(true);

                Lot target;
                Sim abductee;

                if (IsActiveTarget(chance))
                {
                    List <Sim> abductees = GetAbductees(Household.ActiveHousehold);

                    if (abductees == null)
                    {
                        Logger.Append("Alien Abduction: No abductees");
                        ResetAbductionHelper();
                        return;
                    }

                    abductee = RandomUtil.GetRandomObjectFromList <Sim>(abductees);
                    target   = abductee.LotCurrent;
                }
                else
                {
                    List <Lot> lots = GetLots();

                    if (lots == null)
                    {
                        Logger.Append("Alien Abduction: No lots");
                        ResetAbductionHelper();
                        return;
                    }

                    target = RandomUtil.GetRandomObjectFromList <Lot>(lots);
                    List <Sim> abductees = GetAbductees(target);

                    if (abductees == null)
                    {
                        Logger.Append("Alien Abduction: No abductess");
                        ResetAbductionHelper();
                        return;
                    }

                    abductee = RandomUtil.GetRandomObjectFromList <Sim>(abductees);
                }

                AlienAbductionSituationEx.Create(alien, abductee, target);
            }
            else
            {
                Logger.Append("Alien Abduction: Chance Fail " + chance);

                chance = GetVisitChance();

                if (RandomUtil.RandomChance(chance))
                {
                    chance = GetVisitChance(true, alien);

                    Lot farthestLot, target;
                    Sim visitor;

                    if (IsActiveTarget(chance))
                    {
                        farthestLot = LotManager.GetFarthestLot(Household.ActiveHouseholdLot);
                        target      = Household.ActiveHouseholdLot;
                        visitor     = alien.InstantiateOffScreen(farthestLot);
                        //AlienSituation.Create(visitor, Household.ActiveHouseholdLot);
                    }
                    else
                    {
                        List <Lot> lots = GetLots();

                        if (lots == null)
                        {
                            Logger.Append("Alien Visit: No lots");
                            ResetAbductionHelper();
                            return;
                        }

                        target      = RandomUtil.GetRandomObjectFromList <Lot>(lots);
                        farthestLot = LotManager.GetFarthestLot(target);
                        visitor     = alien.InstantiateOffScreen(farthestLot);
                    }

                    AlienSituation.Create(visitor, target);
                }
                else
                {
                    Logger.Append("Alien Visit: Chance Fail " + chance);
                }
            }

            ResetAbductionHelper();
        }
コード例 #5
0
        public static void AlienVisitationCallback()
        {
            if (Abductor.Settings.Debugging)
            {
                StyledNotification.Format format = new StyledNotification.Format("Alien Visitation Alarm triggered!",
                                                                                 StyledNotification.NotificationStyle.kDebugAlert);
                StyledNotification.Show(format);
            }

            // Cache alien household
            Household alienHousehold = Household.AlienHousehold;

            // If alien household is null or empty, stop
            if (alienHousehold == null || alienHousehold.NumMembers == 0)
            {
                Common.DebugNotify("Alien Activity: Alien Household Null or Empty");
                return;
            }

            // Determine the chance of alien activity
            float chance = CalculateAlienActivityChance();

            // Check for alien activity
            if (!RandomUtil.RandomChance(chance))
            {
                // Activity chance failed; stop
                Common.DebugNotify("Alien Activity: Chance Fail " + chance);
                ResetAbductionHelper();
                return;
            }

            // Activity chance passed; get list of valid aliens
            List <SimDescription> aliens = GetValidAliens();

            // If no valid aliens, stop
            if (aliens == null)
            {
                Common.DebugNotify("Alien Visitation: No Valid Aliens");
                ResetAbductionHelper();
                return;
            }

            // Randomly select a valid alien
            SimDescription alien = RandomUtil.GetRandomObjectFromList <SimDescription>(aliens);

            // Determine chance for an abduction
            chance = CalculateAlienAbductionChance();

            // Check for alien abduction
            if (!RandomUtil.RandomChance(chance))
            {
                // Abduction chance failed; move on to alien visitation
                Common.DebugNotify("Alien Abduction: Chance Fail " + chance);
            }
            else
            {
                // Abduction chance passed; determine chance active household is the target
                chance = CalculateAlienAbductionChance(true);

                // Check if active household is abduction target
                if (IsActiveHouseholdTarget(chance) && CanASimBeAbducted(Household.ActiveHousehold))
                {
                    // Active househod is the target; get a list of valid abductees
                    List <Sim> validAbductees = GetValidAbductees(Household.ActiveHousehold);

                    // If abductee list is null, stop
                    if (validAbductees == null)
                    {
                        Common.DebugNotify("Alien Abduction: No Valid Abductees");
                        ResetAbductionHelper();
                        return;
                    }

                    // Randomly select an active household Sim for abduction
                    Sim abductee = RandomUtil.GetRandomObjectFromList <Sim>(validAbductees);

                    // Start an alien abduction situation on the abductee's current lot
                    Lot lot = abductee.LotCurrent;

                    // Attempt to abduct the selected Sim
                    if (lot != null)
                    {
                        // Start an alien abduction situation on the abductee's lot
                        AlienAbductionSituationEx.Create(alien, abductee, lot);
                    }
                    else
                    {
                        Common.DebugNotify("Alien Abduction: Abductee Lot is Null");
                    }
                }
                else
                {
                    // Active household is not target; get a list of valid lots
                    List <Lot> validLots = GetValidLots();

                    // If there are no valid lots, give up and return
                    if (validLots == null)
                    {
                        Common.DebugNotify("Alien Abduction: No Valid Lots");
                        ResetAbductionHelper();
                        return;
                    }

                    // Randomly select a lot
                    Lot lot = RandomUtil.GetRandomObjectFromList <Lot>(validLots);

                    // Get valid abductees on the selected lot
                    List <Sim> validAbductees = GetValidAbductees(lot);

                    // If there are no valid abductees, give up and return
                    if (validAbductees == null)
                    {
                        Common.DebugNotify("Alien Abduction: No Valid Abductees");
                        ResetAbductionHelper();
                        return;
                    }

                    // Randomly select an abductee
                    Sim abductee = RandomUtil.GetRandomObjectFromList <Sim>(validAbductees);

                    // Start an alien abduction situation on a random, valid lot
                    AlienAbductionSituationEx.Create(alien, abductee, lot);
                }

                ResetAbductionHelper();
                return;
            }

            // Abduction check failed; check for visitation
            chance = CalculateAlienVisitationChance();

            // Check for alien visitation
            if (!RandomUtil.RandomChance(chance))
            {
                // Visitation chance failed; stop
                Common.DebugNotify("Alien Visitation: Chance Fail " + chance);
                ResetAbductionHelper();
                return;
            }
            else
            {
                // Visitation check passed; determine chance active household is the target
                chance = CalculateAlienVisitationChance(true, alien);

                // Check if the active household is the visitation target
                if (IsActiveHouseholdTarget(chance))
                {
                    // Visitation chance passed

                    // Instantiate the visitor at the farthest lot from the active lot
                    Lot farthestLot = LotManager.GetFarthestLot(Household.ActiveHousehold.LotHome);
                    Sim visitor     = alien.InstantiateOffScreen(farthestLot);

                    // Start alien visitation situation on active lot
                    AlienSituation.Create(visitor, Household.ActiveHousehold.LotHome);
                }
                else
                {
                    // Visitation chance failed; get a list of valid lots
                    List <Lot> lots = GetValidLots();

                    // If no valid lots, stop
                    if (lots == null)
                    {
                        Common.DebugNotify("Alien Visitation: No Valid Lots");
                        ResetAbductionHelper();
                        return;
                    }

                    // Randomly select a lot
                    Lot lot = RandomUtil.GetRandomObjectFromList <Lot>(lots);

                    // Instantiate alien on farthest lot from target
                    Lot fartherLot = LotManager.GetFarthestLot(lot);
                    Sim visitor    = alien.InstantiateOffScreen(fartherLot);

                    // Start alien visitation situation on the selected lot
                    AlienSituation.Create(visitor, lot);
                }

                // Alien activity completed!
                ResetAbductionHelper();
                return;
            }
        }