Example #1
0
            public override bool Test(Sim actor, Urnstone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(actor, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target == null)
                {
                    return(false);
                }
                if (target.DeadSimsDescription == null)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString("Gameplay/ActorSystems/OccultWitch:SimMovedOn", new object[0x0]));
                    return(false);
                }
                if (target.DeadSimsDescription.ChildOrBelow)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString("Gameplay/ActorSystems/OccultWitch:ReviveDead", new object[0x0]));
                    return(false);
                }
                if (target.DeadSimsDescription.IsPet)
                {
                    return(false);
                }
                if ((target.DeadSimsDescription.CreatedSim != null) && target.DeadSimsDescription.CreatedSim.IsDying())
                {
                    return(false);
                }
                return(true);
            }
Example #2
0
        public static bool TestMagicWandEquipped(Sim actor, Sim target, ActiveTopic topic, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            try
            {
                MagicControl controlActor = MagicControl.GetBestControl(actor, SpellcastingDuelEx.Singleton as IMagicalDefinition);
                if (controlActor == null)
                {
                    return(false);
                }

                MagicControl controlTarget = MagicControl.GetBestControl(target, SpellcastingDuelEx.Singleton as IMagicalDefinition);
                if (controlTarget == null)
                {
                    return(false);
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(actor, target, e);
                return(false);
            }
        }
Example #3
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (a == target)
                {
                    return(false);
                }

                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target.BuffManager.HasAnyElement(new BuffNames[] { BuffNames.Singed, BuffNames.SingedElectricity }))
                {
                    return(false);
                }

                /*
                 * if (target.SimDescription.IsPregnant)
                 * {
                 *  greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString(target.IsFemale, "Gameplay/Actors/Sim:PregnantFailure", new object[0x0]));
                 *  return false;
                 * }
                 */
                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Example #4
0
        public bool Run(T ths, IMagicalDefinition definition)
        {
            MagicControl control = MagicControl.GetBestControl(ths.Actor, definition);

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

            mWand = control.InitialPrep(ths.Actor, definition, out mWandCreated);
            if (mWand == null)
            {
                return(false);
            }

            mWand.PrepareForUse(ths.Actor);

            ths.Wand = mWand;

            bool twoPerson = (ths.Actor == ths.Target);

            if (!Hybrid.Settings.mEnforceTwoPersonAnimation)
            {
                twoPerson = false;
            }

            bool spellCastingEpiclyFailed;
            bool spellCastingSucceeded = !IsFailure(ths.Actor, control, definition, out spellCastingEpiclyFailed);

            if (!EpicFailureAllowed(ths))
            {
                spellCastingEpiclyFailed = false;
            }

            if (!InitialPrep(ths, twoPerson, definition, control, spellCastingSucceeded, spellCastingEpiclyFailed))
            {
                return(false);
            }

            ths.StandardEntry();
            ths.BeginCommodityUpdates();

            if (!SetupAnimation(ths, control, twoPerson))
            {
                return(false);
            }

            control.ConsumeMana(ths.Actor, this, definition);

            if (!PerformResults(ths, "EpicFail", definition, control, spellCastingSucceeded, spellCastingEpiclyFailed))
            {
                mSucceeded = false;
            }

            EventTracker.SendEvent(EventTypeId.kCastSpell, ths.Actor);
            ths.EndCommodityUpdates(mSucceeded);
            ths.StandardExit();
            return(mSucceeded);
        }
Example #5
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteToFireplace(Actor))
                {
                    return(false);
                }

                if (!Target.mLit)
                {
                    return(false);
                }

                if (!Target.WaitToPutOut(Actor))
                {
                    return(false);
                }

                StandardEntry();
                BeginCommodityUpdates();
                Target.EnableFootprintAndPushSims(Target.FootprintPathingHash, Actor);

                MagicControl control = MagicControl.GetBestControl(Actor, CastIceBlastEx.Singleton as IMagicalDefinition);
                if (control != null)
                {
                    mProxy.Run(this, CastIceBlastEx.Singleton as IMagicalDefinition);

                    mWand.FinishUsing(Actor);
                }
                else
                {
                    StateMachineClient stateMachine = Target.GetStateMachine(this, "Enter");
                    stateMachine.SetParameter("HaveRemote", Target.TuningFireplace.HasRemote);
                    stateMachine.SetParameter("CheapVersion", Target.UseCheapAnimations);
                    stateMachine.AddOneShotScriptEventHandler(0x65, StopFireCallback);
                    stateMachine.RequestState("x", "ExtinguishFire");
                    stateMachine.RequestState("x", "Exit");
                }

                TraitFunctions.CheckForNeuroticAnxiety(Actor, TraitFunctions.NeuroticTraitAnxietyType.Fireplace);
                EndCommodityUpdates(true);
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #6
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Example #7
0
            public override bool Test(Sim actor, Terrain target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(actor, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(true);
            }
            public override bool Test(Sim a, ISculptureFrozenSim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(CastSpellOnStatueProxy <CastSunlightCharmOnStatueEx> .CommonSpellOnTest(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Example #9
0
            public override bool Test(Sim a, Fire target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(!target.HasBeenDestroyed);
            }
Example #10
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (a == target)
                {
                    return(false);
                }

                if (!CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback))
                {
                    return(false);
                }

                if (target.BuffManager.HasElement(BuffNames.ToadSim))
                {
                    return(false);
                }

                if (((target.OccultManager != null) && target.OccultManager.HasAnyOccultType()) || target.SimDescription.IsGhost)
                {
                    greyedOutTooltipCallback = delegate
                    {
                        return(MagicWand.LocalizeString(a.IsFemale, "ImmuneToSpell", new object[0x0]));
                    };
                    return(false);
                }

                if (target.SimDescription.IsVisuallyPregnant)
                {
                    greyedOutTooltipCallback = delegate { return(MagicWand.LocalizeString(a.IsFemale, "ImmuneToSpell", new object[0x0])); };
                    return(false);
                }

                if (target.Service is GrimReaper)
                {
                    greyedOutTooltipCallback = delegate { return(MagicWand.LocalizeString(a.IsFemale, "ImmuneToSpell", new object[0x0])); };
                    return(false);
                }

                return(true);
            }
Example #11
0
            public override bool Test(Sim actor, GameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(actor, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target.GetContainedObject((Slot)(0xa820f8a6)) != null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("Slot Full");
                    return(false);
                }
                return(true);
            }
Example #12
0
            public override bool Test(Sim a, Plant target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (((target is OmniPlant) || (target is MoneyTree)) && (target.GrowthState >= PlantGrowthState.Mature))
                {
                    return(false);
                }

                return(target.mGrowthState != PlantGrowthState.Harvest);
            }
Example #13
0
            public override void AddInteractions(InteractionObjectPair iop, Sim actor, Sim target, List <InteractionObjectPair> results)
            {
                MagicControl control = MagicControl.GetBestControl(actor, HungerDefinition.sSingleton);

                if (control != null)
                {
                    if (target.SimDescription.IsVampire)
                    {
                        results.Add(new InteractionObjectPair(new Definition(CommodityKind.VampireThirst, HungerDefinition.sSingleton, control), target));
                    }
                    else
                    {
                        results.Add(new InteractionObjectPair(new Definition(CommodityKind.Hunger, HungerDefinition.sSingleton, control), target));
                    }
                }

                control = MagicControl.GetBestControl(actor, BladderDefinition.sSingleton);
                if (control != null)
                {
                    results.Add(new InteractionObjectPair(new Definition(CommodityKind.Bladder, BladderDefinition.sSingleton, control), target));
                }

                control = MagicControl.GetBestControl(actor, EnergyDefinition.sSingleton);
                if (control != null)
                {
                    results.Add(new InteractionObjectPair(new Definition(CommodityKind.Energy, EnergyDefinition.sSingleton, control), target));
                }

                control = MagicControl.GetBestControl(actor, SocialDefinition.sSingleton);
                if (control != null)
                {
                    results.Add(new InteractionObjectPair(new Definition(CommodityKind.Social, SocialDefinition.sSingleton, control), target));
                }

                control = MagicControl.GetBestControl(actor, HygieneDefinition.sSingleton);
                if (control != null)
                {
                    results.Add(new InteractionObjectPair(new Definition(CommodityKind.Hygiene, HygieneDefinition.sSingleton, control), target));
                }

                control = MagicControl.GetBestControl(actor, FunDefinition.sSingleton);
                if (control != null)
                {
                    results.Add(new InteractionObjectPair(new Definition(CommodityKind.Fun, FunDefinition.sSingleton, control), target));
                }
            }
Example #14
0
            public override bool Test(Sim actor, GameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(actor, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target.UpgradableComponent == null)
                {
                    return(false);
                }

                if ((target.Repairable != null) && (target.Repairable.Broken))
                {
                    return(false);
                }

                switch (SelectedUpgrade)
                {
                case Upgrade.Unbreakable:
                    if (!target.Repairable.HasChanceOfBreaking())
                    {
                        return(false);
                    }
                    break;

                case Upgrade.BoostedChannelsOnTV:
                {
                    ITelevision television = target as ITelevision;
                    if ((television != null) && television.HasAllChannels)
                    {
                        greyedOutTooltipCallback = delegate
                        {
                            return(Localization.LocalizeString("Gameplay/Objects/Electronics/TV/UpgradeBoostChannels:HasAllChannels", new object[0x0]));
                        };
                        return(false);
                    }
                    break;
                }
                }
                return(true);
            }
Example #15
0
            public override bool Test(Sim actor, GameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                MagicControl control = MagicControl.GetBestControl(actor, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target.UpgradableComponent.Unbreakable)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(MagicWand.LocalizeString(actor.IsFemale, "CantBreakWithIceBlast", new object[0x0]));
                    return(false);
                }

                return((target.Repairable != null) && !target.Repairable.Broken);
            }
Example #16
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if ((isAutonomous) && (a == target))
                {
                    if (OccultTypeHelper.HasType(a, OccultTypes.Vampire))
                    {
                        return(false);
                    }
                }

                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Example #17
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (a == target)
                {
                    return(false);
                }

                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                if (target.BuffManager.HasElement(BuffNames.SickAndTired))
                {
                    return(false);
                }

                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Example #18
0
            public override bool Test(Sim a, IGameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                IFairyRepairable repairable = target as IFairyRepairable;

                if (isAutonomous)
                {
                    return(false);
                }

                if ((target.Repairable == null) || (!target.Repairable.Broken))
                {
                    return(false);
                }

                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return((repairable != null) && repairable.repairCheck(a, target, ref greyedOutTooltipCallback));
            }
Example #19
0
        public override bool Run()
        {
            try
            {
                IMagicalDefinition definition = InteractionDefinition as IMagicalDefinition;

                bool succeeded = true;
                Actor.ClearExitReasons();
                if (mIsChallenger || (mChallengerSim == null))
                {
                    mIsChallenger  = true;
                    mChallengerSim = Actor;
                    mDefenderSim   = Target;
                    if (mDefenderSim == null)
                    {
                        return(false);
                    }

                    EventTracker.SendEvent(EventTypeId.kChallengeToSpellcasting, mChallengerSim, mDefenderSim);

                    mJig = GlobalFunctions.CreateObjectOutOfWorld("castSpellDuel_jig", ProductVersion.EP7) as SocialJigTwoPerson;
                    mJig.RegisterParticipants(mDefenderSim, mChallengerSim);
                    mJig.SetOpacity(0f, 0f);

                    Vector3 position      = mDefenderSim.Position;
                    Vector3 forwardVector = mDefenderSim.ForwardVector;
                    if (!GlobalFunctions.FindGoodLocationNearby(mJig, ref position, ref forwardVector))
                    {
                        return(false);
                    }

                    mJig.SetPosition(position);
                    mJig.SetForward(forwardVector);
                    mJig.AddToWorld();
                    if (!Actor.DoRoute(mJig.RouteToJigB(mChallengerSim)))
                    {
                        return(false);
                    }

                    mRouteComplete      = true;
                    mInteractionPersonB = SingletonPersonB.CreateInstance(mChallengerSim, mDefenderSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as MagicWand.SpellcastingDuel;
                    mInteractionPersonB.LinkedInteractionInstance = this;
                    mInteractionPersonB.mChallengerSim            = mChallengerSim;
                    mInteractionPersonB.Jig                 = mJig;
                    mInteractionPersonB.mDefenderSim        = mDefenderSim;
                    mInteractionPersonB.IsChallenger        = false;
                    mInteractionPersonB.CancellableByPlayer = false;
                    mDefenderSim.InteractionQueue.AddNext(mInteractionPersonB);
                    PresetDuelResults();
                }
                else
                {
                    if (!Actor.DoRoute(mJig.RouteToJigA(mDefenderSim)))
                    {
                        return(false);
                    }
                    mRouteComplete = true;
                }

                MagicControl controlX = MagicControl.GetBestControl(mChallengerSim, definition);
                if (controlX == null)
                {
                    return(false);
                }

                MagicControl controlY = MagicControl.GetBestControl(mDefenderSim, definition);
                if (controlY == null)
                {
                    return(false);
                }

                StandardEntry(true);
                BeginCommodityUpdates();
                if (mIsChallenger)
                {
                    while ((!mRouteComplete || !mInteractionPersonB.RouteComplete) && (mDefenderSim.InteractionQueue.HasInteraction(mInteractionPersonB) && !Actor.HasExitReason()))
                    {
                        SpeedTrap.Sleep(0x0);
                    }

                    if (mDefenderSim.HasExitReason() || mChallengerSim.HasExitReason())
                    {
                        mDefenderSim.AddExitReason(ExitReason.Canceled);
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }

                    AcquireStateMachine("spellcastingDuel");

                    SetActor("x", mChallengerSim);
                    SetActor("y", mDefenderSim);

                    mWandX = controlX.InitialPrep(mChallengerSim, definition, out mWandXCreated);
                    mWandY = controlY.InitialPrep(mDefenderSim, definition, out mWandYCreated);
                    if ((mWandX == null) || (mWandY == null))
                    {
                        return(false);
                    }

                    mWandX.PrepareForUse(mChallengerSim);
                    if (mWandX is MagicHands)
                    {
                        SetParameter("noWandX", true);
                    }
                    else
                    {
                        SetParameter("noWandX", false);
                    }

                    mWandY.PrepareForUse(mDefenderSim);
                    if (mWandY is MagicHands)
                    {
                        SetParameter("noWandY", true);
                    }
                    else
                    {
                        SetParameter("noWandY", false);
                    }

                    SetActor("wandX", mWandX);
                    SetActor("wandY", mWandY);

                    SetParameter("x:Age", Actor.SimDescription.Age);
                    SetParameter("y:Age", Actor.SimDescription.Age);

                    EnterState("x", "Enter");
                    EnterState("y", "Enter");

                    AddPersistentScriptEventHandler(0x65, CastingEffect);
                    AddPersistentScriptEventHandler(0x66, BlockingEffect);
                    AddPersistentScriptEventHandler(0x67, HitEffect);
                    AddPersistentScriptEventHandler(0x68, BlockingEffectTwo);
                    ReturnToIdle();

                    for (int i = 0x0; i < mTotalRounds; i++)
                    {
                        mCurrResult = mRoundResults[i];
                        mCastType   = (CastingType)RandomUtil.GetInt(0x4);

                        switch (mCurrResult)
                        {
                        case RoundResult.ChallengerHit:
                            AnimateJoinSims("XHit");
                            break;

                        case RoundResult.ChallengerDefend:
                            AnimateJoinSims("XDef");
                            break;

                        case RoundResult.DefenderHit:
                            AnimateJoinSims("YHit");
                            break;

                        case RoundResult.DefenderDefend:
                            AnimateJoinSims("YDef");
                            break;
                        }

                        ReturnToIdle();
                    }

                    switch (mDuelResult)
                    {
                    case DuelResult.ChallengerWin:
                        AnimateJoinSims("XWin");
                        mChallengerSim.BuffManager.AddElement(BuffNames.WonASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mDefenderSim.BuffManager.AddElement(BuffNames.LostASpellcastingDuel, Origin.FromSpellcastingDuel);
                        EventTracker.SendEvent(EventTypeId.kWonASpellcastingDuel, mChallengerSim);
                        break;

                    case DuelResult.DefenderWin:
                        AnimateJoinSims("YWin");
                        mDefenderSim.BuffManager.AddElement(BuffNames.WonASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mChallengerSim.BuffManager.AddElement(BuffNames.LostASpellcastingDuel, Origin.FromSpellcastingDuel);
                        EventTracker.SendEvent(EventTypeId.kWonASpellcastingDuel, mDefenderSim);
                        break;

                    default:
                        AnimateJoinSims("Tie");
                        mChallengerSim.BuffManager.AddElement(BuffNames.DrawnASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mDefenderSim.BuffManager.AddElement(BuffNames.DrawnASpellcastingDuel, Origin.FromSpellcastingDuel);
                        break;
                    }
                    mDefenderSim.AddExitReason(ExitReason.Finished);
                }
                else
                {
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }

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