Example #1
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            PregnancySimData other = data.Get <PregnancySimData>();

            if (sim.IsPregnant)
            {
                if ((other.mLastCheckPregnancy != 0) && (other.mLastCheckPregnancy < SimClock.ElapsedCalendarDays()))
                {
                    if (!AllowProgression(sim))
                    {
                        // Delay pregnancy indefinitely
                        sim.Pregnancy.mHourOfPregnancy = other.mPregnancyHour;

                        IncStat("Pregnancy Suspended");
                    }
                    else
                    {
                        if (other.mPregnancyHour == sim.Pregnancy.mHourOfPregnancy)
                        {
                            IncStat(sim.FirstName + " " + sim.LastName + ": Stuck Pregnancy", Common.DebugLevel.High);

                            if (!SimTypes.IsSelectable(sim))
                            {
                                Sims.Reset(sim);

                                if ((sim.CreatedSim != null) && (sim.LotHome != null))
                                {
                                    SimDescription dad = ManagerSim.Find(sim.Pregnancy.DadDescriptionId);
                                    if (dad != null)
                                    {
                                        Sims.Instantiate(dad, sim.LotHome, false);
                                    }

                                    if (sim.Pregnancy.PreggersAlarm != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(sim.Pregnancy.PreggersAlarm);
                                        sim.Pregnancy.PreggersAlarm = AlarmHandle.kInvalidHandle;
                                    }
                                    sim.Pregnancy.Continue(sim.CreatedSim, true);

                                    IncStat("Pregnancy Reset");
                                }
                            }
                        }
                    }
                }

                other.mPregnancyHour      = sim.Pregnancy.mHourOfPregnancy;
                other.mLastCheckPregnancy = SimClock.ElapsedCalendarDays();
            }
            else
            {
                other.mPregnancyHour      = 0;
                other.mLastCheckPregnancy = 0;
            }
        }
Example #2
0
        public override string GetUIValue(bool pure)
        {
            SimDescription sim = ManagerSim.Find(Value);

            if (sim == null)
            {
                return(null);
            }

            return(sim.FirstName);
        }
Example #3
0
        protected SimDescription FindNextOpponent(SimDescription sim)
        {
            MartialArts mySkill = sim.SkillManager.GetElement(SkillNames.MartialArts) as MartialArts;

            if (mySkill == null)
            {
                IncStat("No Skill");
                return(null);
            }

            SimDescription tournamentChallenger = ManagerSim.Find(mySkill.mTournamentChallenger);

            if ((tournamentChallenger == null) ||
                (SimTypes.IsDead(tournamentChallenger)) ||
                (tournamentChallenger.CreatedSim == null) ||
                (tournamentChallenger.CreatedSim.WorldBuilderDeath != null) ||
                (!tournamentChallenger.IsValidDescription) ||
                (SimTypes.IsSelectable(tournamentChallenger)))
            {
                List <Household> households = new List <Household>(Household.sHouseholdList);
                households.Remove(Household.ActiveHousehold);

                tournamentChallenger = TournamentManagement.FindSuitableOpponent(sim, households, tournamentChallenger, new TournamentManagement.GetAffinity(mySkill.GetAffinity));
            }

            if (tournamentChallenger == null)
            {
                IncStat("No Choice");
                return(null);
            }

            mySkill.mTournamentChallenger = tournamentChallenger.SimDescriptionId;

            if (!TestNextOpponent(this, mySkill))
            {
                return(null);
            }

            if (tournamentChallenger.SkillManager == null)
            {
                return(null);
            }

            MartialArts theirSkill = tournamentChallenger.SkillManager.GetElement(SkillNames.MartialArts) as MartialArts;

            if ((theirSkill != null) && (!TestNextOpponent(this, theirSkill)))
            {
                return(null);
            }

            return(tournamentChallenger);
        }
Example #4
0
                public ObjectGuid GetGuid()
                {
                    if (mSimID != 0)
                    {
                        SimDescription sim = ManagerSim.Find(mSimID);
                        if ((sim != null) && (sim.CreatedSim != null))
                        {
                            return(sim.CreatedSim.ObjectId);
                        }
                    }

                    return(mGuid);
                }
Example #5
0
        protected override string GetLocalizedValue(ulong value, ref bool matches, ref ThumbnailKey icon)
        {
            matches = (Value == value);

            SimDescription sim = ManagerSim.Find(value);

            if (sim == null)
            {
                return(null);
            }

            icon = sim.GetThumbnailKey(ThumbnailSize.Large, 0);

            return(sim.LastName + ", " + sim.FirstName);
        }
Example #6
0
        protected override bool PrivatePerform()
        {
            if (!base.PrivatePerform())
            {
                return(false);
            }

            ulong otherSim = Value;

            if (otherSim != 0)
            {
                SimDescription other = ManagerSim.Find(otherSim);

                StoryProgression.Main.SetValue <ArrangedMarriageOption, ulong>(other, Manager.SimDescription.SimDescriptionId);
            }

            return(true);
        }
Example #7
0
                public override PhoneCall.QueryResponse GetQueryResponse(Sim sim)
                {
                    if (mInvitationKeys == null)
                    {
                        HouseParty.PartyInvitationKeys kDefaultPartyKeys = HouseParty.kDefaultPartyKeys;
                    }
                    SimDescription description = ManagerSim.Find(mHostDescriptionId);
                    Sim            sim2        = (description != null) ? description.CreatedSim : null;

                    if (sim2 == null)
                    {
                        return(PhoneCall.QueryResponse.JustHangUp);
                    }
                    if (!TwoButtonDialog.Show(Common.LocalizeEAString(sim.IsFemale, mInvitationKeys.InvitationKey, new object[] { sim, sim2, mStartTime }), Common.LocalizeEAString(mInvitationKeys.AcceptKey), Common.LocalizeEAString(mInvitationKeys.RejectKey)))
                    {
                        return(PhoneCall.QueryResponse.RespondNegatively);
                    }
                    return(PhoneCall.QueryResponse.RespondPositively);
                }
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Pregnancy pregnancy = Sim.Pregnancy;

            if (pregnancy == null)
            {
                return(false);
            }

            SimDescription dad = ManagerSim.Find(pregnancy.DadDescriptionId);

            if (Sim.LotHome == null)
            {
                if (dad != null)
                {
                    Add(frame, new ForcedMoveScenario(Sim, dad), ScenarioResult.Start);
                    Add(frame, new NoHomeScenario(Sim, dad), ScenarioResult.Failure);
                }

                Add(frame, new GetOffStreetsScenario(Sim), ScenarioResult.Start);
            }

            if (dad != null)
            {
                if (dad.LotHome == null)
                {
                    Add(frame, new GetOffStreetsScenario(dad), ScenarioResult.Start);
                }

                if (dad.CreatedSim != null)
                {
                    if (pregnancy.mDad != dad.CreatedSim)
                    {
                        pregnancy.mDad = dad.CreatedSim;

                        IncStat("Attached");
                        return(true);
                    }
                }
            }

            return(false);
        }
        protected override ICollection <SimDescription> GetTargets(SimDescription sim)
        {
            ulong match = GetValue <ArrangedMarriageOption, ulong>(sim);

            if (match == 0)
            {
                IncStat("No Match");
                return(null);
            }

            SimDescription partner = ManagerSim.Find(match);

            if (partner == null)
            {
                SetValue <ArrangedMarriageOption, ulong>(sim, 0);

                IncStat("Missing Dropped");
                return(null);
            }
            else if (SimTypes.IsDead(partner))
            {
                SetValue <ArrangedMarriageOption, ulong>(sim, 0);

                IncStat("Target Dead");
                return(null);
            }
            else if (GetValue <ArrangedMarriageOption, ulong>(partner) != sim.SimDescriptionId)
            {
                SetValue <ArrangedMarriageOption, ulong>(sim, 0);

                IncStat("Mismatch Dropped");
                return(null);
            }

            List <SimDescription> results = new List <SimDescription>();

            results.Add(partner);

            return(results);
        }
Example #10
0
        protected static bool TestNextOpponent(Common.IStatGenerator stats, MartialArts mySkill)
        {
            SimDescription tournamentChallenger = ManagerSim.Find(mySkill.mTournamentChallenger);

            if (!TestNextOpponent(stats, mySkill, tournamentChallenger))
            {
                stats.IncStat("Next Opponent Fail");
                return(false);
            }

            int possibleWins = mySkill.mSparringTournamentMatchWins + 1;

            int newRank = 0;

            while ((newRank < MartialArts.kTournamentWinsToImproveSparringRank.Length) && (possibleWins >= MartialArts.kTournamentWinsToImproveSparringRank[newRank]))
            {
                newRank++;
            }

            if (newRank > mySkill.mTournamentRank)
            {
                int oldRank = mySkill.mTournamentRank;
                mySkill.mTournamentRank = newRank;
                try
                {
                    if (!TestNextOpponent(stats, mySkill, tournamentChallenger))
                    {
                        stats.IncStat("Next Rank Fail");
                        return(false);
                    }
                }
                finally
                {
                    mySkill.mTournamentRank = oldRank;
                }
            }

            return(true);
        }
Example #11
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription dad = ManagerSim.Find(Sim.Pregnancy.DadDescriptionId);

            if ((GetValue <SameSexSameGenderOption, bool>()) && (dad != null) && (dad.Gender == Sim.Gender))
            {
                IncStat("Same Sex");

                Sim.Pregnancy.mGender = Sim.Gender;
                return(true);
            }

            FirstBornGender firstBorn = GetValue <FirstBornGenderOption, FirstBornGender>();

            if (firstBorn == FirstBornGender.Male)
            {
                IncStat("First Born Male");

                Sim.Pregnancy.mGender = CASAgeGenderFlags.Male;
                return(true);
            }
            else if (firstBorn == FirstBornGender.Female)
            {
                IncStat("First Born Female");

                Sim.Pregnancy.mGender = CASAgeGenderFlags.Female;
                return(true);
            }
            else
            {
                if ((GetValue <OneOfEachGenderOption, bool>()) && (Sim.Genealogy != null))
                {
                    bool male = false, female = false;

                    foreach (SimDescription child in Relationships.GetChildren(Sim))
                    {
                        if (SimTypes.IsDead(child))
                        {
                            continue;
                        }

                        if (child.IsMale)
                        {
                            male = true;
                        }
                        else if (child.IsFemale)
                        {
                            female = true;
                        }
                    }

                    if (male)
                    {
                        if (!female)
                        {
                            Sim.Pregnancy.mGender = CASAgeGenderFlags.Female;
                            return(true);
                        }
                    }
                    else if (female)
                    {
                        Sim.Pregnancy.mGender = CASAgeGenderFlags.Male;
                        return(true);
                    }
                }

                if (firstBorn == FirstBornGender.Balanced)
                {
                    Sim.Pregnancy.mGender = CalculateGenderBalancer(Pregnancies, Sim.IsPet);
                    return(true);
                }
            }

            return(false);
        }
Example #12
0
            protected override void OnPerform()
            {
                try
                {
                    mScenario.IncStat("TriggerDisgraceTask");

                    CelebrityManager manager = mScenario.Sim.CelebrityManager;

                    if ((manager.mDisgracefulActionQueue == null) || (manager.mDisgracefulActionQueue.Count == 0x0))
                    {
                        mScenario.IncStat("DisgraceTask: No Task Event");
                        return;
                    }

                    CelebrityDisgracefulActionStaticData data;
                    DisgracefulActionEvent item = manager.mDisgracefulActionQueue[0x0];
                    manager.mDisgracefulActionQueue.Remove(item);

                    DisgracefulActionType disgracefulActionType = item.DisgracefulActionType;

                    if (manager.CantBeDisgraced())
                    {
                        mScenario.IncStat("DisgraceTask: Not Disgracable");
                        return;
                    }

                    if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out data))
                    {
                        mScenario.IncStat("DisgraceTask: No Task Data");
                        return;
                    }

                    BuffManager buffManager = null;

                    if (mScenario.Sim.CreatedSim != null)
                    {
                        buffManager = mScenario.Sim.CreatedSim.BuffManager;
                    }

                    if (buffManager != null)
                    {
                        buffManager.RemoveElement(BuffNames.PubliclyDisgraced);
                    }

                    SimDescription otherNaughty = ManagerSim.Find(item.TargetId);

                    bool flag = (disgracefulActionType == DisgracefulActionType.Cheating) && !mScenario.Sim.TraitManager.HasElement(TraitNames.NoJealousy);

                    int change = NRaas.StoryProgression.Main.GetValue <RelationshipChangeOption, int>();
                    if (change > 0)
                    {
                        change = 0;
                    }

                    foreach (Relationship relationship in Relationship.Get(mScenario.Sim))
                    {
                        SimDescription other = relationship.GetOtherSimDescription(mScenario.Sim);

                        if (other == otherNaughty)
                        {
                            continue;
                        }

                        if (other.ToddlerOrBelow)
                        {
                            continue;
                        }

                        bool testFriendship = true;
                        if (!mScenario.Cares(other, disgracefulActionType, mScenario.GetValue <RelationDropChanceOption, int>(), out testFriendship))
                        {
                            mScenario.IncStat("DisgraceTask: Sim Doesn't Care");
                            continue;
                        }

                        if (flag && relationship.AreRomantic())
                        {
                            Sim createdSim = other.CreatedSim;
                            if (createdSim != null)
                            {
                                SocialComponent.OnIWasCheatedOn(createdSim, mScenario.Sim, otherNaughty, JealousyLevel.Medium);
                            }
                        }

                        if (relationship.AreFriends())
                        {
                            mScenario.AddScoring("DisgraceTask: Relation Change", change);

                            relationship.LTR.UpdateLiking(change);
                        }
                    }

                    if (buffManager != null)
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, data.DisgracedOrigin);
                    }

                    if (data.DisgracedOrigin == Origin.FromFalselyAccused)
                    {
                        manager.IncrementFalselyAccused();
                    }
                    else
                    {
                        manager.IncrementPubliclyDisgraced();
                    }

                    Sim sim = mScenario.Sim.CreatedSim;
                    if (sim != null)
                    {
                        mScenario.IncStat("DisgraceTask: Display Message");

                        sim.ShowTNSAndPlayStingIfSelectable("sting_generic_tragic", data.TnsId, null, sim, null, null, new bool[] { mScenario.Sim.IsFemale }, mScenario.Sim.IsFemale, new object[] { sim });
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mScenario.Sim, e);
                }
            }
Example #13
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            CelebrityDisgracefulActionStaticData data;

            DisgracefulActionType disgracefulActionType = Event.DisgracefulActionType;

            if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out data))
            {
                IncStat("No Disgrace Data");
                return(false);
            }

            if (data.DisgracedOrigin != Origin.FromFalselyAccused)
            {
                if (HasValue <DisallowByTypeOption, DisgracefulActionType>(Event.DisgracefulActionType))
                {
                    IncStat("User Disallow");
                    return(false);
                }

                switch (Event.DisgracefulActionType)
                {
                case DisgracefulActionType.Cheating:
                case DisgracefulActionType.ChildOutOfMarriage:
                case DisgracefulActionType.Divorce:
                case DisgracefulActionType.WooHooInPublic:
                case DisgracefulActionType.WooHooWithOccult:
                    if (Sim.HasTrait(TraitNames.AboveReproach))
                    {
                        IncStat("Above Reproach");
                        return(false);
                    }
                    break;
                }
                ;

                switch (Event.DisgracefulActionType)
                {
                case DisgracefulActionType.Arrested:
                case DisgracefulActionType.CaughtSneakingIntoClub:
                case DisgracefulActionType.Divorce:
                case DisgracefulActionType.ChildTaken:
                case DisgracefulActionType.ChildOutOfMarriage:
                case DisgracefulActionType.JobSetback:
                    // No witness necessary
                    break;

                default:
                    if ((mWitnesses == null) || (mWitnesses.Count == 0))
                    {
                        IncStat("No Witnesses");
                        return(false);
                    }

                    SimDescription otherNaughty = ManagerSim.Find(Event.TargetId);

                    bool valid = false;
                    foreach (SimDescription witness in mWitnesses)
                    {
                        if (witness == Sim)
                        {
                            continue;
                        }

                        if (witness == otherNaughty)
                        {
                            continue;
                        }

                        bool testFriendship = true;
                        if (!Cares(witness, Event.DisgracefulActionType, GetValue <ReportChanceOption, int>(), out testFriendship))
                        {
                            continue;
                        }

                        if (testFriendship)
                        {
                            if (ManagerFriendship.AreFriends(Sim, witness))
                            {
                                continue;
                            }
                        }

                        valid = true;
                        break;
                    }

                    if (!valid)
                    {
                        IncStat("No One Cares");
                        return(false);
                    }
                    break;
                }
            }
            else
            {
                if (!GetValue <AllowFalseOption, bool>())
                {
                    IncStat("False Denied");
                    return(false);
                }
            }

            if (Sim.CelebrityManager.mDisgracefulActionQueue != null)
            {
                foreach (DisgracefulActionEvent e in Sim.CelebrityManager.mDisgracefulActionQueue)
                {
                    if ((e.TargetId == Event.TargetId) && (e.DisgracefulActionType == Event.DisgracefulActionType))
                    {
                        IncStat("Already Queued");
                        return(false);
                    }
                }
            }

            if (!RandomUtil.RandomChance01(data.Chance))
            {
                IncStat("Chance Fail");
                return(false);
            }

            if (Sim.CelebrityManager.mDisgracefulActionQueue == null)
            {
                Sim.CelebrityManager.mDisgracefulActionQueue = new List <DisgracefulActionEvent>();
            }

            Sim.CelebrityManager.mDisgracefulActionQueue.Add(Event);

            new TriggerDisgraceTask(this);
            return(true);
        }