Esempio n. 1
0
        protected bool Cares(SimDescription witness, DisgracefulActionType type, int reportChance, out bool testFriendship)
        {
            if (witness.AssignedRole is RolePaparazzi)
            {
                testFriendship = false;
                return(true);
            }

            testFriendship = true;
            switch (type)
            {
            case DisgracefulActionType.BiteSomeoneInPublic:
                if (witness.IsVampire)
                {
                    return(false);
                }
                break;

            case DisgracefulActionType.Cheating:
            case DisgracefulActionType.WooHooInPublic:
                if (ManagerFlirt.AreRomantic(Sim, witness))
                {
                    testFriendship = false;
                }
                break;

            case DisgracefulActionType.WooHooWithOccult:
                if (witness.IsPlayableGhost)
                {
                    return(false);
                }

                if (witness.OccultManager.HasAnyOccultType())
                {
                    return(false);
                }
                break;
            }

            if (testFriendship)
            {
                if (AddScoring("DisgraceWitness", reportChance, ScoringLookup.OptionType.Chance, witness) >= 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public static ListenerAction OnFindSimCommittedDisgracefulAction(Event e)
        {
            if (CelebrityUtil.sCelebrityDisgracefulActionData == null) // EA Fail if not EP Installed.
            {
                return(ListenerAction.Keep);
            }

            try
            {
                DisgracefulActionEvent disgracefulActionEvent = e as DisgracefulActionEvent;
                if (disgracefulActionEvent == null)
                {
                    return(ListenerAction.Keep);
                }

                Sim sim = disgracefulActionEvent.Actor as Sim;
                if (sim == null)
                {
                    return(ListenerAction.Keep);
                }

                SimDescription findsim = sim.SimDescription;

                if (findsim == null)
                {
                    return(ListenerAction.Keep);
                }

                if (findsim == null || !findsim.IsValid || !findsim.IsValidDescription || !findsim.IsCelebrity)
                {
                    return(ListenerAction.Keep);
                }

                Household household = findsim.Household;
                if (household != null && household == Household.ActiveHousehold)
                {
                    return(ListenerAction.Keep);
                }

                CelebrityManager celma = findsim.CelebrityManager;
                if (celma == null || CantBeDisgraced(celma))
                {
                    return(ListenerAction.Keep);
                }



                //SimDescription simDescription = sim.SimDescription;

                DisgracefulActionType disgracefulActionType = disgracefulActionEvent.DisgracefulActionType;
                CelebrityDisgracefulActionStaticData value;

                if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out value))
                {
                    return(ListenerAction.Keep);
                }

                if (celma.mDisgracefulActionQueue != null)
                {
                    foreach (DisgracefulActionEvent item in celma.mDisgracefulActionQueue)
                    {
                        if (item.TargetId == disgracefulActionEvent.TargetId && item.DisgracefulActionType == disgracefulActionEvent.DisgracefulActionType)
                        {
                            return(ListenerAction.Keep);
                        }
                    }
                }

                if (RandomUtil.RandomChance01(value.Chance) || RandomUtil.RandomChance01(65))
                {
                    if (celma.mDisgracefulActionQueue == null)
                    {
                        celma.mDisgracefulActionQueue = new List <DisgracefulActionEvent>();
                    }

                    celma.mDisgracefulActionQueue.Add(disgracefulActionEvent);

                    sim.AddAlarm(30, TimeUnit.Minutes, delegate
                    {
                        try
                        {
                            STriggerDisgrace(celma);
                        }
                        catch (ResetException)
                        { throw; }
                        catch { }
                    },
                                 null, AlarmType.NeverPersisted);
                }
            }
            //catch (ResetException){ throw; }
            catch { }
            return(ListenerAction.Keep);
        }
Esempio n. 3
0
        public void TriggerDisgrace()
        {
            // Test New 96?

            CelebrityManager This = CelebrityManager_;

            Sim         ownerSim    = This.OwnerSim;
            BuffManager buffManager = This.OwnerSim.BuffManager;

            if (This.mDisgracefulActionQueue != null && This.mDisgracefulActionQueue.Count != 0)
            {
                DisgracefulActionEvent disgracefulActionEvent = This.mDisgracefulActionQueue[0];
                DisgracefulActionType  disgracefulActionType  = disgracefulActionEvent.DisgracefulActionType;
                This.mDisgracefulActionQueue.Remove(disgracefulActionEvent);
                CelebrityDisgracefulActionStaticData value = null;
                if (!CantBeDisgraced(This) && CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out value) /* || !(Sims3.Gameplay.Moded.DGSHelperCommands.kNoDisgracedInIsPlayer && (ownerSim.IsInActiveHousehold || ownerSim.IsSafeInActiveHousehold)) */)
                {
                    buffManager.RemoveElement(BuffNames.PubliclyDisgraced);
                    SimDescription simDescription = SimDescription.Find(disgracefulActionEvent.TargetId);
                    bool           flag           = disgracefulActionType == DisgracefulActionType.Cheating && !ownerSim.HasTrait(TraitNames.NoJealousy);
                    foreach (Relationship relationship in ownerSim.SocialComponent.Relationships)
                    {
                        if (relationship.SimDescriptionB != simDescription)
                        {
                            if (flag && relationship.AreRomantic())
                            {
                                Sim createdSim = relationship.SimDescriptionB.CreatedSim;
                                if (createdSim != null)
                                {
                                    SocialComponent.OnIWasCheatedOn(createdSim, ownerSim.SimDescription, simDescription, JealousyLevel.Medium);
                                }
                            }
                            relationship.LTR.UpdateLiking(0f - CelebrityManager.kLTRLostFromDisgrace);
                        }
                    }
                    if (value != null)
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, value.DisgracedOrigin);
                    }
                    else
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, Origin.FromFalselyAccused);
                    }
                    if (value != null && value.DisgracedOrigin == Origin.FromFalselyAccused)
                    {
                        ownerSim.CelebrityManager.IncrementFalselyAccused();
                    }
                    else
                    {
                        ownerSim.CelebrityManager.IncrementPubliclyDisgraced();
                    }
                    if (value != null)
                    {
                        ownerSim.ShowTNSAndPlayStingIfSelectable("sting_generic_tragic", value.TnsId, null, ownerSim, null, null, new bool[1]
                        {
                            ownerSim.IsFemale
                        }, ownerSim.IsFemale, ownerSim);
                    }
                }
            }
        }
Esempio n. 4
0
        public ListenerAction OnSimCommittedDisgracefulAction(Event e)
        {
            if (CelebrityUtil.sCelebrityDisgracefulActionData == null) // EA Fail if not Installed.
            {
                return(ListenerAction.Remove);
            }

            if (CelebrityManager_ == null)
            {
                return(ListenerAction.Remove);
            }

            if (CantBeDisgraced(CelebrityManager_))
            {
                return(ListenerAction.Keep);
            }

            DisgracefulActionEvent disgracefulActionEvent = e as DisgracefulActionEvent;

            if (disgracefulActionEvent == null)
            {
                return(ListenerAction.Keep);
            }
            Sim sim = disgracefulActionEvent.Actor as Sim;

            if (sim == null)
            {
                return(ListenerAction.Keep);
            }
            SimDescription simDescription = sim.SimDescription;

            if (simDescription == null || !simDescription.IsValid || !simDescription.IsValidDescription)
            {
                return(ListenerAction.Keep);
            }
            DisgracefulActionType disgracefulActionType = disgracefulActionEvent.DisgracefulActionType;
            CelebrityDisgracefulActionStaticData value;

            if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out value))
            {
                return(ListenerAction.Keep);
            }
            if (CelebrityManager_.mDisgracefulActionQueue != null)
            {
                foreach (DisgracefulActionEvent item in CelebrityManager_.mDisgracefulActionQueue)
                {
                    if (item.TargetId == disgracefulActionEvent.TargetId && item.DisgracefulActionType == disgracefulActionEvent.DisgracefulActionType)
                    {
                        return(ListenerAction.Keep);
                    }
                }
            }

            if (RandomUtil.RandomChance01(value.Chance))
            {
                if (CelebrityManager_.mDisgracefulActionQueue == null)
                {
                    CelebrityManager_.mDisgracefulActionQueue = new List <DisgracefulActionEvent>();
                }
                CelebrityManager_.mDisgracefulActionQueue.Add(disgracefulActionEvent);
                sim.AddAlarm(CelebrityManager.kDelayBeforeDisgracefulActionIsKnown, TimeUnit.Minutes, TriggerDisgrace, "CelebrityManager: Disgrace delay alarm", AlarmType.AlwaysPersisted);
            }
            return(ListenerAction.Keep);
        }
Esempio n. 5
0
 protected abstract bool Handles(DisgracefulActionType type);
Esempio n. 6
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);
                }
            }
Esempio n. 7
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);
        }
Esempio n. 8
0
 protected override bool Handles(DisgracefulActionType type)
 {
     return(type == DisgracefulActionType.Arrested);
 }