Esempio n. 1
0
        protected virtual bool SetupAnimation(T ths, MagicControl control, bool twoPerson)
        {
            if (mWand is MagicHands)
            {
                ths.SetParameter("noWand", true);
            }
            else
            {
                ths.SetParameter("noWand", false);
            }

            ths.SetActor("wand", mWand);
            ths.SetParameter("isSkilled", control.GetSkillLevel(ths.Actor.SimDescription) >= MagicWand.kExpertLevel);

            IMagicalInteraction interaction = ths as IMagicalInteraction;

            if (interaction != null)
            {
                ths.AddOneShotScriptEventHandler(0x65, interaction.ShowSuccessVfx);
                ths.AddOneShotScriptEventHandler(0x66, interaction.ShowFailVfx);
                ths.AddOneShotScriptEventHandler(0x67, interaction.ShowEpicFailVfx);
            }

            return(true);
        }
Esempio n. 2
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);
            }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
 public void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("RoammingPoint"))
     {
         _isSelectedAI = false;
     }
     if (other.CompareTag("Magic"))
     {
         GameObject   go   = GameObject.FindGameObjectWithTag("Magic");
         MagicControl Fire = go.GetComponent <MagicControl>();
         if (DamageMe(Fire.MagicDamage))
         {
             ChangedAction(PlayerController.eStateAction.DIE);
         }
         else
         {
             ChangedAction(PlayerController.eStateAction.HIT);
         }
     }
     if (other.CompareTag("Plasma"))
     {
         if (DamageMe(BulletControl._Instance.BulletDamage))
         {
             ChangedAction(PlayerController.eStateAction.DIE);
         }
         else
         {
             ChangedAction(PlayerController.eStateAction.HIT);
         }
     }
 }
Esempio n. 5
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));
            }
Esempio n. 6
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);
        }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     magicControl  = new MagicControl();
     movController = new MovController();
     magicControl.Init(maskPanel);
     movController.Init(movPanel);
     movController.SetPlayer(player);
 }
Esempio n. 8
0
    public void LuncherFireBall()
    {
        GameObject go = Instantiate(_preMagic);

        go.transform.position = _tfMagicPosition.position;
        go.transform.rotation = _tfMagicPosition.rotation;
        MagicControl fireball = go.GetComponent <MagicControl>();

        fireball.InitDamage(this);
    }
Esempio n. 9
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);
            }
        }
Esempio n. 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);
                }

                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
Esempio n. 11
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);
            }
Esempio n. 12
0
            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));
            }
Esempio n. 13
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);
            }
Esempio n. 14
0
        protected override bool SetupAnimation(T ths, MagicControl control, bool twoPerson)
        {
            if (twoPerson)
            {
                ths.EnterStateMachine("SpellcastingSolo", "Enter", "x");
            }
            else
            {
                ths.EnterStateMachine("SpellcastingSocial", "Enter", "x");
                ths.SetActor("y", ths.Target);
            }

            return(base.SetupAnimation(ths, control, twoPerson));
        }
Esempio n. 15
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);
            }
Esempio n. 16
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);
            }
Esempio n. 17
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));
                }
            }
Esempio n. 18
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);
            }
Esempio n. 19
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);
            }
Esempio n. 20
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);
            }
Esempio n. 21
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));
            }
Esempio n. 22
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));
            }
Esempio n. 23
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));
            }
Esempio n. 24
0
            protected override bool SetupAnimation(CastUpgradeEx ths, MagicControl control, bool twoPerson)
            {
                ths.EnterStateMachine("PracticeSpellcasting", "Enter", "x");

                return(base.SetupAnimation(ths, control, twoPerson));
            }
Esempio n. 25
0
            protected override bool InitialPrep(CastUpgradeEx ths, bool twoPerson, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
            {
                Route r = ths.Actor.CreateRoute();

                if (!r.PlanToPointRadialRange(ths.Target.Position, 0.5f, kRoutingDistance, RouteDistancePreference.PreferNearestToRouteDestination, RouteOrientationPreference.TowardsObject, ths.Target.LotCurrent.LotId, new int[] { ths.Target.RoomId }).Succeeded() || !ths.Actor.DoRoute(r))
                {
                    return(false);
                }

                return(true);
            }
Esempio n. 26
0
            protected override bool PerformResults(CastUpgradeEx ths, string epicJazzName, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
            {
                ths.mUpgradeEffect = VisualEffect.Create("ep7ObjectUpgrade_main");
                ths.mUpgradeEffect.SetPosAndOrient(ths.Target.PositionOnFloor, ths.Target.ForwardVector, Vector3.UnitY);
                ths.mUpgradeEffect.Start();
                ths.AnimateSim("Practice");
                bool succeeded = ths.DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                ths.mUpgradeEffect.Stop();
                ths.mUpgradeEffect.Dispose();
                ths.mUpgradeEffect = null;
                if (succeeded && !ths.Actor.HasExitReason(ExitReason.CancelExternal))
                {
                    ths.AddOneShotScriptEventHandler(0x65, ths.ShowSuccessVfx);
                    ths.AddOneShotScriptEventHandler(0x66, ths.ShowFailVfx);

                    if (spellCastingSucceeded)
                    {
                        succeeded = true;
                        ths.AnimateSim("CastSuccess");
                        ths.Target.Upgradable.CurrentUpgrade = (ths.InteractionDefinition as Definition).SelectedUpgrade;
                    }
                    else if ((ths.Target.Repairable != null) && (spellCastingEpiclyFailed))
                    {
                        succeeded = false;
                        ths.AnimateSim("CastFail");
                        ths.Target.Repairable.BreakObject(ths.Actor, true);
                    }
                    else
                    {
                        succeeded = false;
                        ths.AnimateSim("CastFail");
                    }
                }
                else
                {
                    ths.AnimateSim("Exit");
                }

                return(succeeded);
            }
Esempio n. 27
0
 protected override bool IsFailure(Sim actor, MagicControl control, IMagicalDefinition definition, out bool epicFailure)
 {
     epicFailure = false;
     return(false);
 }
Esempio n. 28
0
 protected override bool InitialPrep(LightFireEx ths, bool twoPerson, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
 {
     return(true);
 }
Esempio n. 29
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);
            }
        }
Esempio n. 30
0
        protected override bool InitialPrep(T ths, bool twoPerson, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
        {
            if (!ths.Actor.RouteToObjectRadius(ths.Target.GetFrozenSim(), MagicWand.CastSpellOnStatue.kRangeToCastSpellOn))
            {
                return(false);
            }

            return(true);
        }