Пример #1
0
        public static void PlayResurrectAnimation(Sim target, bool bPlayVTResurrectAnim, bool fadeSim)
        {
            string effectName = null;

            if (bPlayVTResurrectAnim)
            {
                effectName = "ep3VampireResurrect_test";
                VisualEffect visualEffect = VisualEffect.Create(effectName);
                visualEffect.SetPosAndOrient(target.Position, target.ForwardVector, target.UpVector);
                visualEffect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);
                if (target.SimDescription.AdultOrAbove)
                {
                    target.PlaySoloAnimation("a_floatingSimInResurrect_x", false);
                }
                if (fadeSim)
                {
                    target.FadeOut(true, false);
                }
            }
        }
Пример #2
0
        public static bool AttemptToPutInSafeLocation(Sim ths, Vector3 destination, bool allowHibernate)
        {
            if ((ths == null) || (ths.HasBeenDestroyed)) return false;

            if ((ths.LotHome == null) || (destination != Vector3.Invalid))
            {
                Lot lot = ths.LotHome;
                if (lot == null)
                {
                    lot = ths.VirtualLotHome;
                }

                Vector3 pos = destination;

                if (pos == Vector3.Invalid)
                {
                    pos = AttemptToFindSafeLocation(lot, ths.IsHorse);
                }

                if (pos != Vector3.Invalid)
                {
                    try
                    {
                        Vector3 fwd;
                        ths.SetPosition(FindRoutableLocation(ths, pos, out fwd));
                        ths.SetForward(fwd);
                        ths.RemoveFromWorld();
                        ths.AddToWorld();
                        ths.SetHiddenFlags(HiddenFlags.Nothing);
                        ths.SetOpacity(1f, 0f);
                        ths.SimRoutingComponent.ForceUpdateDynamicFootprint();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths, e);
                    }

                    return true;
                }
                else
                {
                    if (allowHibernate)
                    {
                        ths.FadeOut(false, true);
                    }
                    return false;
                }
            }

            Vector3 originalPos = ths.Position;

            try
            {
                if (!ths.AttemptToPutInSafeLocation(true)) return false;
            }
            catch (Exception e)
            {
                Common.DebugException(ths, e);
                return false;
            }

            return (ths.Position != originalPos);
        }
Пример #3
0
        public static bool AttemptToPutInSafeLocation(Sim ths, Vector3 destination, bool allowHibernate)
        {
            if ((ths == null) || (ths.HasBeenDestroyed))
            {
                return(false);
            }

            if ((ths.LotHome == null) || (destination != Vector3.Invalid))
            {
                Lot lot = ths.LotHome;
                if (lot == null)
                {
                    lot = ths.VirtualLotHome;
                }

                Vector3 pos = destination;

                if (pos == Vector3.Invalid)
                {
                    pos = AttemptToFindSafeLocation(lot, ths.IsHorse);
                }

                if (pos != Vector3.Invalid)
                {
                    try
                    {
                        Vector3 fwd;
                        ths.SetPosition(FindRoutableLocation(ths, pos, out fwd));
                        ths.SetForward(fwd);
                        ths.RemoveFromWorld();
                        ths.AddToWorld();
                        ths.SetHiddenFlags(HiddenFlags.Nothing);
                        ths.SetOpacity(1f, 0f);
                        ths.SimRoutingComponent.ForceUpdateDynamicFootprint();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths, e);
                    }

                    return(true);
                }
                else
                {
                    if (allowHibernate)
                    {
                        ths.FadeOut(false, true);
                    }
                    return(false);
                }
            }

            Vector3 originalPos = ths.Position;

            try
            {
                if (!ths.AttemptToPutInSafeLocation(true))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(ths, e);
                return(false);
            }

            return(ths.Position != originalPos);
        }
Пример #4
0
        public override bool Run()
        {
            string msg = "Run";

            checked
            {
                try
                {
                    if (AcceptCancelDialog.Show("Force Select Actor?"))
                    {
                        msg = "Accept";
                        var         definition   = base.InteractionDefinition as Definition;
                        LotLocation lotLocation  = default(LotLocation);
                        ulong       lotLocation2 = World.GetLotLocation(this.Hit.mPoint, ref lotLocation);
                        Lot         lot          = LotManager.GetLot(lotLocation2);
                        if ((definition.Age & (CASAgeGenderFlags.Baby | CASAgeGenderFlags.Toddler | CASAgeGenderFlags.Child)) != CASAgeGenderFlags.None)
                        {
                            bool flag = false;
                            if (lot != null && lot.Household != null)
                            {
                                foreach (SimDescription simDescription in lot.Household.SimDescriptions)
                                {
                                    if (simDescription.TeenOrAbove)
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                            if (!flag)
                            {
                                if (AssemblyCheckByNiec.IsInstalled("DGSCore") && TwoButtonDialog.Show("DGSCore" + NiecMod.Nra.NiecException.NewLine + "Found Childern Sims in Household Without Adult" + NiecMod.Nra.NiecException.NewLine + "Note: Social Worker Catch Remove Sims" + NiecMod.Nra.NiecException.NewLine + "Are you sure?!", "Yea It Create " + definition.Age, "No Create YoungAdult"))
                                {
                                    msg = "Accept if not flag";
                                    Sim simnocheck = DGSMakeRandomSimNoCheck(Hit.mPoint, definition.Age, definition.Gender, definition.WorldName);
                                    if (simnocheck != null)
                                    {
                                        if (simnocheck.IsSelectable)
                                        {
                                            PlumbBob.SelectActor(simnocheck);
                                        }
                                        else
                                        {
                                            simnocheck.SimDescription.IsNeverSelectable = false;
                                            PlumbBob.ForceSelectActor(simnocheck);
                                        }
                                        try
                                        {
                                            GlobalFunctions.PlaceAtGoodLocation(simnocheck, new World.FindGoodLocationParams(Hit.mPoint), false);
                                            if (simnocheck.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                            {
                                                simnocheck.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                                simnocheck.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                            }
                                        }
                                        catch
                                        { }

                                        try
                                        {
                                            if (simnocheck.SimDescription.Household.mName == null)
                                            {
                                                simnocheck.SimDescription.Household.SetName(simnocheck.SimDescription.LastName);
                                            }
                                        }
                                        catch (Exception ex2)
                                        {
                                            NiecMod.Nra.NiecException.WriteLog(msg + " SetName: " + NiecMod.Nra.NiecException.NewLine + NiecMod.Nra.NiecException.LogException(ex2), true, true);
                                        }
                                    }
                                    else
                                    {
                                        //return false;
                                        msg = "MakeSim Failed! if flag";
                                        goto backif;
                                    }
                                    return(true);
                                }
backif:
                                Sim sim = DGSMakeRandomSim(this.Hit.mPoint, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Male, definition.WorldName);
                                msg     = "Terraininstance";
                                if (sim != null)
                                {
                                    Sitoat    = true;
                                    mSima     = sim;
                                    mSimaStat = sim.SimDescription;
                                    sim.FadeOut();
                                    var terraininstance = new Terrain.TeleportMeHere.Definition(false).CreateInstance(Terrain.Singleton, sim, new InteractionPriority((InteractionPriorityLevel)8195), base.Autonomous, base.CancellableByPlayer) as TerrainInteraction;

                                    try
                                    {
                                        if (sim.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                        {
                                            sim.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                            sim.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                        }
                                    }
                                    catch
                                    { }

                                    if (terraininstance != null)
                                    {
                                        terraininstance.Hidden  = true;
                                        terraininstance.MustRun = true;
                                        //Vector3 vector2;
                                        Lot loty = sim.SimDescription.LotHome;
                                        if (loty == null)
                                        {
                                            loty = sim.SimDescription.VirtualLotHome;
                                        }
                                        //World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Helper.Create.GetPositionInRandomLot(loty));

                                        /*
                                         * fglParams.BooleanConstraints |= FindGoodLocationBooleans.StayInRoom;
                                         * fglParams.InitialSearchDirection = RandomUtil.GetInt(0x0, 0x7);
                                         */
                                        //lot.Household.Add(sim.SimDescription);
                                        terraininstance.Destination = Helpers.Create.GetPositionInRandomLot(loty);
                                        sim.InteractionQueue.Add(terraininstance);
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                                try
                                {
                                    //sim.SimDescription.Household.SetName(/* "E3Lesa is Good" */ "Good Household");
                                    sim.SimDescription.Household.SetName(sim.SimDescription.LastName);
                                }
                                catch (Exception ex2)
                                {
                                    NiecMod.Nra.NiecException.WriteLog(msg + " SetName: " + NiecMod.Nra.NiecException.NewLine + NiecMod.Nra.NiecException.LogException(ex2), true, true);
                                }
                            }
                        }

                        //lot.MoveIn(lot.Household);
                        //FixFoxNonStaticDGSMakeRandomSim = true;
                        Sim sim2 = DGSMakeRandomSim(this.Hit.mPoint, definition.Age, definition.Gender, definition.WorldName);
                        if (sim2 != null)
                        {
                            PlumbBob.ForceSelectActor(sim2);
                            if (mSima != null && Sitoat)
                            {
                                var followchildsim = Sims3.Gameplay.Actors.Sim.FollowParent.Singleton.CreateInstance(sim2, mSima, new InteractionPriority((InteractionPriorityLevel)8195), base.Autonomous, base.CancellableByPlayer) as Sims3.Gameplay.Actors.Sim.FollowParent;
                                followchildsim.Hidden  = true;
                                followchildsim.MustRun = true;
                                if (mSima.InteractionQueue.AddNextIfPossibleAfterCheckingForDuplicates(followchildsim))
                                {
                                    Sim.ForceSocial(mSima, sim2, "Chat", (InteractionPriorityLevel)8195, true);
                                }

                                //sim2.SimDescription.TraitManager.RemoveAllElements();
                                try
                                {
                                    if (sim2.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                    {
                                        sim2.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                        sim2.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                    }
                                }
                                catch
                                { }
                            }
                        }
                    }



                    else
                    {
                        msg = "Cancel";
                        var definition = base.InteractionDefinition as Definition;
                        Sim sim3       = DGSMakeRandomSim(this.Hit.mPoint, definition.Age, definition.Gender, definition.WorldName);
                        if (sim3 == null)
                        {
                            msg = "Sim3 is Null";
                            Sim sim4 = DGSMakeRandomSim(this.Hit.mPoint, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Male, definition.WorldName);
                            if (sim4 != null)
                            {
                                msg = "Sim4 is Keep";


                                if (!sim4.IsInActiveHousehold)
                                {
                                    try
                                    {
                                        if (sim4.SimDescription.Household.NameUnlocalized == "Good Household")
                                        {
                                            sim4.SimDescription.Household.SetName("Evil Household");
                                        }
                                        else
                                        {
                                            sim4.SimDescription.Household.SetName(sim4.LastName);
                                        }
                                        sim4.SimDescription.TraitManager.RemoveAllElements();
                                        sim4.SimDescription.TraitManager.AddElement(TraitNames.Daredevil);
                                        sim4.SimDescription.TraitManager.AddElement(TraitNames.Evil);
                                        sim4.SimDescription.TraitManager.AddElement(TraitNames.MeanSpirited);
                                        sim4.SimDescription.TraitManager.AddElement(TraitNames.Loser);
                                        sim4.SimDescription.TraitManager.AddElement(TraitNames.Adventurous);
                                    }
                                    catch
                                    { }
                                }
                                else
                                {
                                    try
                                    {
                                        if (sim4.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                        {
                                            sim4.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                            sim4.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                        }
                                    }
                                    catch
                                    { }

                                    if (sim4.SimDescription.Household.NameUnlocalized == "Evil Household")
                                    {
                                        sim4.SimDescription.Household.SetName("Good Household");
                                    }
                                    else
                                    {
                                        sim4.SimDescription.Household.SetName(sim4.LastName);
                                    }
                                }



                                Sim sim5 = DGSMakeRandomSim(this.Hit.mPoint, definition.Age, definition.Gender, definition.WorldName);
                                if (sim5 != null)
                                {
                                    msg = "Sim5 is Keep";
                                    GlobalFunctions.PlaceAtGoodLocation(sim5, new World.FindGoodLocationParams(Hit.mPoint), false);

                                    if (!sim5.IsInActiveHousehold)
                                    {
                                        try
                                        {
                                            if (sim5.SimDescription.Household.NameUnlocalized == "Good Household")
                                            {
                                                sim5.SimDescription.Household.SetName("Evil Household");
                                            }
                                            else
                                            {
                                                sim5.SimDescription.Household.SetName(sim5.LastName);
                                            }
                                            if (definition.Gender == CASAgeGenderFlags.Child)
                                            {
                                                sim5.SimDescription.TraitManager.RemoveAllElements();
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Evil);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.MeanSpirited);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Loser);
                                            }
                                            else
                                            {
                                                sim5.SimDescription.TraitManager.RemoveAllElements();
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Daredevil);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Evil);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.MeanSpirited);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Loser);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Adventurous);
                                            }
                                        }
                                        catch
                                        { }
                                    }
                                    else
                                    {
                                        try
                                        {
                                            if (sim5.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                            {
                                                sim5.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                                sim5.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                            }
                                        }
                                        catch
                                        { }


                                        if (sim5.SimDescription.Household.NameUnlocalized == "Evil Household")
                                        {
                                            sim5.SimDescription.Household.SetName("Good Household");
                                        }
                                        else
                                        {
                                            sim5.SimDescription.Household.SetName(sim5.LastName);
                                        }
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!sim3.IsInActiveHousehold)
                            {
                                try
                                {
                                    if (sim3.SimDescription.Household.NameUnlocalized == "Good Household")
                                    {
                                        sim3.SimDescription.Household.SetName("Evil Household");
                                    }

                                    else
                                    {
                                        sim3.SimDescription.Household.SetName(sim3.LastName);
                                    }

                                    if (definition.Gender == CASAgeGenderFlags.Child)
                                    {
                                        sim3.SimDescription.TraitManager.RemoveAllElements();
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Evil);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.MeanSpirited);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Loser);
                                    }
                                    else
                                    {
                                        sim3.SimDescription.TraitManager.RemoveAllElements();
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Daredevil);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Evil);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.MeanSpirited);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Loser);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Adventurous);
                                    }
                                }
                                catch
                                { }
                            }
                            else
                            {
                                try
                                {
                                    if (sim3.SimDescription.TraitManager.HasElement(TraitNames.Evil))
                                    {
                                        sim3.SimDescription.TraitManager.RemoveElement(TraitNames.Evil);
                                        sim3.SimDescription.TraitManager.AddElement(TraitNames.Good);
                                    }
                                }
                                catch
                                { }


                                if (sim3.SimDescription.Household.NameUnlocalized == "Evil Household")
                                {
                                    sim3.SimDescription.Household.SetName("Good Household");
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    NiecMod.Nra.NiecException.WriteLog(msg + " DGSMakeSim: " + NiecMod.Nra.NiecException.NewLine + NiecMod.Nra.NiecException.LogException(ex), true, true);
                    return(false);
                }
            }

            return(true);
        }
Пример #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);
            }
        }