Ejemplo n.º 1
0
 public static void AppearSimInResurrect(Sim target, bool fadeSim)
 {
     if (fadeSim)
     {
         target.PlaySoloAnimation("a_floatingSimInResurrect_x", false);
         target.FadeIn(true);
     }
 }
Ejemplo n.º 2
0
        public static bool GhostSpawn(Urnstone me, Lot lot)
        {
            if (me.DeadSimsDescription == null)
            {
                return(false);
            }

            if (!me.DeadSimsDescription.IsValidDescription)
            {
                me.DeadSimsDescription.Fixup();
            }

            Vector3 position;

            if (me.DeadSimsDescription.ToddlerOrBelow)
            {
                position = lot.EntryPoint();
            }
            else if (!me.InInventory)
            {
                position = me.Position;
            }
            else
            {
                position = Service.GetPositionInRandomLot(lot);
            }

            Household.NpcHousehold.Add(me.DeadSimsDescription);
            Sim sim = Instantiation.Perform(me.DeadSimsDescription, position, null, null);

            sim.SetOpacity(0f, 0f);

            ActiveTopic.AddToSim(sim, "Ghost");
            me.GhostSetup(sim, true);

            if (!me.InInventory)
            {
                sim.GreetSimOnLot(me.LotCurrent);
                Audio.StartObjectSound(me.ObjectId, "sting_ghost_appear", false);
            }

            sim.FadeIn();
            me.CreateAlarmReturnToGrave(false);
            return(true);
        }
Ejemplo n.º 3
0
        public static Sim CreateServicePerformer(ShowStage ths)
        {
            List <Service> services = new List <Service> {
                Magician.Instance, Singer.Instance, PerformanceArtist.Instance
            };
            int attempts  = 0;
            Sim performer = null;

            while (performer == null && attempts <= 5)
            {
                Service service = RandomUtil.GetRandomObjectFromList(services);
                if (service != null)
                {
                    foreach (SimDescription description in service.mPool)
                    {
                        if (!service.IsSimAssignedTask(description) && description.CreatedSim == null)
                        {
                            int lotAttempts = 0;
                            Lot lot         = null;
                            while (lot == null && lotAttempts <= 5)
                            {
                                lot = LotManager.SelectRandomLot(null);
                                lotAttempts++;
                            }

                            if (lot != null)
                            {
                                Sim createdSim = service.CreateSim(lot, description);
                                if (createdSim != null)
                                {
                                    createdSim.FadeIn();
                                    performer = createdSim;
                                    break;
                                }
                            }
                        }
                    }
                }
                attempts++;
            }

            return(performer);
        }
Ejemplo n.º 4
0
        public static void OnScriptError(ScriptCore.ScriptProxy proxy, Exception ex)
        {
            if (dontcall)
            {
                return;
            }

            if (proxy == null)
            {
                NFinalizeDeath.ThrowResetException("");
            }

            if (safeerrorbool && !ShouldInjectedMethodOnScriptError)
            {
                if (_SafeOnScriptError != null && ex != null)
                {
                    try
                    {
                        _SafeOnScriptError(proxy, ex);
                    }
                    catch (Exception)
                    {
                        // NRaas Failed
                    }
                }
                return;
            }
            if (!Simulator.CheckYieldingContext(false))
            {
                if (NiecHelperSituation.___bOpenDGSIsInstalled_)
                {
                    if (_SafeOnScriptError != null && ex != null)
                    {
                        try
                        {
                            _SafeOnScriptError(proxy, ex);
                        }
                        catch (Exception)
                        {
                            // NRaas Failed
                        }
                    }
                }
                return;
            }

            else if (NiecHelperSituation.___bOpenDGSIsInstalled_)
            {
                if (_SafeOnScriptError != null && ex != null)
                {
                    try
                    {
                        _SafeOnScriptError(proxy, ex);
                    }
                    catch (Exception)
                    {
                        // NRaas Failed
                    }
                }
                return;
            }

            var proxyTarget = proxy.Target;

            if (proxyTarget == null)
            {
                NFinalizeDeath.ThrowResetException("");
            }

            global::Sims3.SimIFace.Simulator.Sleep(110);

            Sim proxySim = proxyTarget as Sim;

            if (proxySim != null)
            {
                if (proxySim.SimDescription == null)
                {
                    proxySim.mSimDescription      = Create.NiecNullSimDescription();
                    proxySim.mSimDescription.mSim = proxySim;
                }

                if (NFinalizeDeath.SimIsGRReaper(proxySim.SimDescription))
                {
                    while (true)
                    {
                        if (!(proxySim.mPosture is NiecHelperSituationPosture))
                        {
                            NiecRunCommand.fcreap_Icommand(proxySim, false, true);
                        }

                        if (mGrimReaperSmoke != null && !mGrimReaperSmoke.ParentTo(proxySim, Sim.FXJoints.Pelvis))
                        {
                            var p = mGrimReaperSmoke;
                            mGrimReaperSmoke = null;
                            p.Stop();
                            p.Dispose();
                            p = null;
                        }

                        if (mGrimReaperSmoke == null)
                        {
                            mGrimReaperSmoke = VisualEffect.Create("reaperSmokeConstant");
                            if (mGrimReaperSmoke != null)
                            {
                                proxySim.FadeIn();
                                mGrimReaperSmoke.ParentTo(proxySim, Sim.FXJoints.Pelvis);
                                mGrimReaperSmoke.Start();
                            }
                        }

                        if (NiecHelperSituation.ExistsOrCreateAndAddToSituationList(proxySim) != null)
                        {
                            NiecHelperSituationPosture.r_internal(proxySim);
                        }

                        NFinalizeDeath.CheckYieldingContext();

                        if (NFinalizeDeath.GetCurrentExecuteType() == Sims3.SimIFace.ScriptExecuteType.Task)
                        {
                            global::Sims3.SimIFace.Simulator.Sleep(10);
                        }
                        else
                        {
                            global::Sims3.SimIFace.Simulator.Sleep(0);
                        }
                    }
                }
                else
                {
                    while (true)
                    {
                        try
                        {
                            //proxySim.DoInteraction();
                            if (!Bim.AOrGROnlyRunningSim || NFinalizeDeath.SimIsGRReaper(proxySim.SimDescription) || proxySim == (NPlumbBob.DoneInitClass ? NFinalizeDeath.GetSafeSelectActor() : PlumbBob.SelectedActor))
                            {
                                Bim.FoundInteraction(proxySim);
                                Simulator.Sleep(0);
                            }
                            else
                            {
                                proxySim.LoopIdle();
                                Simulator.Sleep(0);
                            }
                        }
                        catch (ResetException)
                        {
                            throw;
                        }
                        catch
                        {
                            NFinalizeDeath.CheckYieldingContext();
                            if (!proxySim.IsSelectable)
                            {
                                NiecHelperSituationPosture.r_internal(proxySim);
                            }
                            else
                            {
                                global::Sims3.SimIFace.Simulator.Sleep(100);
                            }
                        }

                        NFinalizeDeath.CheckYieldingContext();

                        if (NFinalizeDeath.GetCurrentExecuteType() == Sims3.SimIFace.ScriptExecuteType.Task)
                        {
                            global::Sims3.SimIFace.Simulator.Sleep(10);
                        }
                        else
                        {
                            global::Sims3.SimIFace.Simulator.Sleep(0);
                        }
                    }
                }
            }

            SimUpdate proxySimUpdate = proxyTarget as SimUpdate;

            if (proxySimUpdate != null)
            {
                var sim = proxySimUpdate.mSim;
                if (sim == null || !NFinalizeDeath.GameObjectIsValid(sim.ObjectId.mValue))
                {
                    var p = proxySimUpdate.Proxy;
                    if (p != null)
                    {
                        Simulator.DestroyObject(p.ObjectId);
                    }

                    NFinalizeDeath.CheckYieldingContext();
                    Simulator.Sleep(uint.MaxValue);
                    NFinalizeDeath.ThrowResetException("");
                    return;
                }
                Simulator.Sleep(500);
                if (NiecHelperSituation.__acorewIsnstalled__)
                {
                    return;
                }
            }

            var proxyLot = proxyTarget as Sims3.Gameplay.Core.Lot;

            if (proxyLot != null)
            {
                while (true)
                {
                    NFinalizeDeath.CheckYieldingContext();

                    if (NFinalizeDeath.GetCurrentExecuteType() == Sims3.SimIFace.ScriptExecuteType.Task)
                    {
                        global::Sims3.SimIFace.Simulator.Sleep(10);
                    }
                    else
                    {
                        global::Sims3.SimIFace.Simulator.Sleep(0);
                    }

                    try
                    {
                        Sims3.Gameplay.Utilities.AlarmManager alarmManger = proxyLot.mSavedData != null ? proxyLot.mSavedData.mAlarmManager : null;
                        if (alarmManger != null)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                NFinalizeDeath.SimulateAlarm(alarmManger, true, true, false);
                            }
                        }

                        if (proxyLot.mSavedData == null)
                        {
                            continue;
                        }

                        proxyLot.UpdateDoorPrivacy();
                        proxyLot.UpdateDetailPriority();

                        if (proxyLot.DisplayLevelChanged)
                        {
                            proxyLot.UpdateDisplayLevelInfo();
                            proxyLot.DisplayLevelChanged = false;
                        }

                        if (proxyLot.ShouldSimulate)
                        {
                            if (proxyLot.mLastTime == 0f)
                            {
                                proxyLot.mLastTime = SimClock.ElapsedTime(TimeUnit.Minutes);
                            }
                            else
                            {
                                float timePassed = SimClock.ElapsedTimeInMinutes(ref proxyLot.mLastTime);

                                proxyLot.UpdateReactions(timePassed, true);

                                if (GameUtils.IsInstalled(ProductVersion.EP7))
                                {
                                    for (int i = 0; i < 5; i++)
                                    {
                                        proxyLot.UpdateNumZombiesOnLot(timePassed + i);
                                    }
                                }
                            }
                        }
                        else if (proxyLot.mSavedData.mBroadcastersWithSims != null && proxyLot.mSavedData.mBroadcastersWithSims.Count > 0)
                        {
                            if (proxyLot.mLastTime == 0f)
                            {
                                proxyLot.mLastTime = SimClock.ElapsedTime(TimeUnit.Minutes);
                            }
                            else
                            {
                                proxyLot.UpdateReactions(SimClock.ElapsedTimeInMinutes(ref proxyLot.mLastTime), false);
                            }
                        }

                        try
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                proxyLot.UpdateReactions(3 + i, true);
                            }
                        }
                        catch (global::Sims3.SimIFace.ResetException)
                        { throw; }
                        catch { }
                    }
                    catch (global::Sims3.SimIFace.ResetException exT)
                    {
                        NiecTask.Perform(delegate
                        {
                            if (_SafeOnScriptError != null)
                            {
                                _SafeOnScriptError(proxy, exT);
                            }
                        });
                        throw;
                    }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();

                        for (int i = 0; i < 200; i++)
                        {
                            Simulator.Sleep(0);
                        }
                    }
                }
            }

            Sims3.Gameplay.Autonomy.AutonomyManager proxyAutonomyManager = proxyTarget as Sims3.Gameplay.Autonomy.AutonomyManager;
            if (proxyAutonomyManager != null)
            {
                proxy.mExecuteType = ScriptExecuteType.Threaded;
                Simulator.Sleep(150);
                if (NiecHelperSituation.__acorewIsnstalled__)
                {
                    return;
                }
            }

            Sims3.Gameplay.Services.Services proxyServices = proxyTarget as Sims3.Gameplay.Services.Services;
            if (proxyServices != null)
            {
                proxyServices.mServiceIndex = 0;
                proxy.mExecuteType          = ScriptExecuteType.Threaded;
                Simulator.Sleep(1000);
                if (NiecHelperSituation.__acorewIsnstalled__)
                {
                    return;
                }
            }

            var alarmOneShot = proxyTarget as Sims3.Gameplay.Utilities.AlarmManager.AlarmOneShot;

            if (alarmOneShot != null)
            {
                alarmOneShot.mStarted = true;
                var ofp = alarmOneShot.mFunction;
                if (ofp == null)
                {
                    try
                    {
                        Sims3.Gameplay.Abstracts.GameObject.RemoveOneShotFunctionOnFinish(Simulator.CurrentTask);
                    }
                    catch (Exception)
                    { }

                    Simulator.DestroyObject(Simulator.CurrentTask);
                    goto r;
                }

                try
                {
                    alarmOneShot.mFunction = null;
                    if (ofp != null)
                    {
                        ofp();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception exX)
                {
                    if (!NiecHelperSituation.__acorewIsnstalled__)
                    {
                        alarmOneShot.HandleException(exX);
                    }
                }

                r :;
                try
                {
                    Sims3.Gameplay.Abstracts.GameObject.RemoveOneShotFunctionOnFinish(Simulator.CurrentTask);
                }
                catch (Exception)
                { }

                Simulator.DestroyObject(Simulator.CurrentTask);

                if (alarmOneShot.mAlarmManager != null && alarmOneShot.mAlarmManager.mAlarmOneShotList != null)
                {
                    alarmOneShot.mAlarmManager.mAlarmOneShotList.Remove(alarmOneShot);
                }

                proxy.mTarget = null;
                return;
            }

            var oneShotFunc = proxyTarget as Sims3.Gameplay.OneShotFunction;

            if (oneShotFunc != null)
            {
                var ofp = oneShotFunc.mFunction;
                if (ofp == null)
                {
                    try
                    {
                        Sims3.Gameplay.Abstracts.GameObject.RemoveOneShotFunctionOnFinish(Simulator.CurrentTask);
                    }
                    catch (Exception)
                    { }

                    Simulator.DestroyObject(Simulator.CurrentTask);
                    return;
                }
                try
                {
                    oneShotFunc.mFunction = null;
                    if (ofp != null)
                    {
                        ofp();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception exX)
                {
                    if (!NiecHelperSituation.__acorewIsnstalled__)
                    {
                        oneShotFunc.HandleException(exX);
                    }
                }

                try
                {
                    Sims3.Gameplay.Abstracts.GameObject.RemoveOneShotFunctionOnFinish(Simulator.CurrentTask);
                }
                catch (Exception)
                { }

                Simulator.DestroyObject(Simulator.CurrentTask);
                proxy.mTarget = null;
                return;
            }



            //var roleMangerTask = proxyTarget as Sims3.Gameplay.Roles.RoleManagerTask;
            //if (NiecHelperSituation.__acorewIsnstalled__  && Instantiator.NACSDCInject && roleMangerTask != null && Simulator.CheckYieldingContext(false) && (ShouldInjectedMethodOnScriptError ? Type.GetType("NRaas.RegisterSpace.Tasks.RoleManagerTaskEx, NRaasRegister", false) != null : true))
            //{
            //    //if (AssemblyCheckByNiec.IsInstalled("NRaasRegister") &&
            //    //    Simulator.CheckYieldingContext(false))
            //    {
            //       //Simulator.Sleep(uint.MaxValue);
            //        while (true)
            //        {
            //            Simulator.Sleep(0);
            //            for (int i = 0; i < 3; i++)
            //            {
            //                NiecRunCommand.native_testcpu_debug(null, null);
            //            }
            //        }
            //    }
            //}

            if (_SafeOnScriptError != null && ex != null)
            {
                _SafeOnScriptError(proxy, ex);
            }
        }
Ejemplo n.º 5
0
        public override bool Run()
        {
            try
            {
                if (!Actor.Inventory.Contains(Target))
                {
                    if (!Actor.RouteToObjectRadiusAndCheckInUse(Target, 0.7f))
                    {
                        return(false);
                    }

                    StandardEntry();
                    BeginCommodityUpdates();
                    Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                    if (!Actor.Inventory.TryToAdd(Target))
                    {
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                }
                else
                {
                    StandardEntry();
                    BeginCommodityUpdates();
                }

                SocialJigTwoPerson person = GlobalFunctions.CreateObjectOutOfWorld(SocialJig.SocialJigMedatorNames.SocialJigTwoPerson.ToString()) as SocialJigTwoPerson;
                person.RegisterParticipants(Actor, null);
                Sim createdSim = null;
                try
                {
                    World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position);
                    fglParams.BooleanConstraints |= FindGoodLocationBooleans.Routable;
                    if (GlobalFunctions.PlaceAtGoodLocation(person, fglParams, true))
                    {
                        Route r = Actor.CreateRoute();
                        r.PlanToSlot(person, person.GetSlotForActor(Actor, true));
                        r.DoRouteFail = true;
                        if (Actor.DoRoute(r))
                        {
                            bool paramValue = false;
                            mSummonGenieBroadcast = new ReactionBroadcaster(Actor, kSummonGenieBroadcastParams, SummonGenieBroadcastCallback);
                            Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.Gameplay.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Gameplay);
                            if (Target.mGenieDescription == null)
                            {
                                Target.mGenieDescription = OccultGenie.CreateGenie(Actor, Target);
                                createdSim = Target.mGenieDescription.CreatedSim;
                                EventTracker.SendEvent(EventTypeId.kCleanLamp, Actor, Target);
                                paramValue = true;
                            }
                            else
                            {
                                createdSim = Target.mGenieDescription.Instantiate(Vector3.OutOfWorld, false);
                                OccultGenie occultType          = null;
                                DateAndTime previousDateAndTime = SimClock.CurrentTime();
                                do
                                {
                                    SpeedTrap.Sleep(0xa);
                                    occultType = createdSim.OccultManager.GetOccultType(OccultTypes.None | OccultTypes.Genie) as OccultGenie;
                                }while ((occultType == null) && (SimClock.ElapsedTime(TimeUnit.Minutes, previousDateAndTime) < 120f));

                                if (occultType != null)
                                {
                                    occultType.SetGenieLampRelations(Actor, createdSim, Target);
                                }
                                else
                                {
                                    createdSim.Destroy();
                                    createdSim = null;
                                }
                            }

                            if (createdSim != null)
                            {
                                createdSim.FadeOut(false, false, 0f);
                                createdSim.GreetSimOnLot(Actor.LotCurrent);
                                createdSim.AddToWorld();
                                Slot slotForActor = person.GetSlotForActor(createdSim, false);
                                createdSim.SetPosition(person.GetSlotPosition(slotForActor));
                                createdSim.SetForward(person.GetForwardOfSlot(slotForActor));
                                IGameObject actor = GlobalFunctions.CreateObject("GenieLamp", ProductVersion.EP6, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null);
                                if (!actor.IsActorUsingMe(Actor))
                                {
                                    actor.AddToUseList(Actor);
                                }
                                EnterStateMachine("GenieLampSummon", "Enter", "x");
                                SetActor("lamp", actor);
                                SetParameter("isFirstTime", paramValue);
                                AnimateSim("Exit");
                                actor.Destroy();
                                createdSim.FadeIn();
                                VisualEffect effect = VisualEffect.Create("ep6GenieAppearSmoke_main");
                                effect.SetPosAndOrient(createdSim.Position, Vector3.UnitX, Vector3.UnitZ);
                                effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);
                                OpportunityManager opportunityManager = Actor.OpportunityManager;
                                if ((opportunityManager != null) && opportunityManager.HasOpportunity(OpportunityNames.EP6_ReleaseGenie_SummonGenie))
                                {
                                    OccultGenie genie2 = createdSim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                                    if (genie2 == null)
                                    {
                                        createdSim.Destroy();
                                        createdSim = null;
                                    }
                                    else
                                    {
                                        OccultGenieEx.OnFreedFromLamp(genie2, Actor, createdSim, true);
                                        if (opportunityManager.GetLastOpportunity(OpportunityCategory.Special) == OpportunityNames.EP6_ReleaseGenie_SummonGenie)
                                        {
                                            opportunityManager.ClearLastOpportunity(OpportunityCategory.Special);
                                        }

                                        EventTracker.SendEvent(EventTypeId.kGrantedWishToFreeGenie, Actor, Target);
                                        if (Target.InInventory)
                                        {
                                            Actor.Inventory.RemoveByForce(Target);
                                            if (Target.IsOnHandTool)
                                            {
                                                Target.RemoveFromWorld();
                                            }
                                        }
                                        else
                                        {
                                            Target.RemoveFromWorld();
                                        }
                                        EnterStateMachine("FreeTheGenie", "Enter", "x");
                                        SetActor("x", createdSim);
                                        AnimateSim("Exit");
                                    }
                                }
                                else
                                {
                                    Target.mGenieSocializingEvent        = EventTracker.AddListener(EventTypeId.kSocialInteraction, OnSocialization);
                                    Target.CheckGenieReturnToLamp        = createdSim.AddAlarmRepeating(1f, TimeUnit.Minutes, Target.CheckGenieReturnToLampCallback, "Genie Check to return to lamp", AlarmType.AlwaysPersisted);
                                    Target.mTimeSinceLastSocialWithGenie = SimClock.CurrentTime();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    person.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit(createdSim == null, createdSim == null);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }