Esempio n. 1
0
    private void OnSpellOver(SpellState state, Spell spell)
    {
        //Debug.Log (spell.Name + ": state is " + state);
        if (IsSpellOver(spell))
        {
            StopSpell(spell);

            if (OnSpellComplete != null)
            {
                OnSpellComplete(spell);
            }

            if (state == SpellState.Win)
            {
                winBox.GetComponent <Canvas>().enabled = true;
            }
            else if (state == SpellState.Lose)
            {
                loseBox.GetComponent <Canvas>().enabled = true;
            }

            // Ref: http://answers.unity3d.com/questions/350721/c-yield-waitforseconds.html
            StartCoroutine(WaitThenShowNextInstructions(spell));
        }
    }
    public void OnLoad()
    {
        IEnumerator enumerator = base.transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform  current   = (Transform)enumerator.Current;
                SpellState component = current.gameObject.GetComponent <SpellState>();
                if (component != null)
                {
                    component.OnLoad();
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable == null)
            {
            }
            disposable.Dispose();
        }
    }
Esempio n. 3
0
    public void ChangeState(SpellState state)
    {
        spellState[title]  = state;
        activeIcon.enabled = false;

        switch (state)
        {
        case SpellState.None:
            icon.sprite = spell.icon;
            castTime.Remove(title);
            break;

        case SpellState.Cast:
            SetCastTime(title);
            break;

        case SpellState.Active:
            activeIcon.enabled = true;
            break;

        case SpellState.Waiting:
            icon.sprite = spell.waitingIcon;
            break;
        }
    }
Esempio n. 4
0
        private void FiringUpdate()
        {
            // If SpellTarget is out of range - switch to abort state
            if (Spell.RangeBehaviour == Spell.TargetRangeBehaviour.AbortWhenOutOfRange &&
                !TargetUtility.IsInRange(Source, CastTarget, _minRange, _maxRange))
            {
                Abort();
                return;
            }

            var canStopFiring = true;

            for (var i = _children.Count - 1; i >= 0; i--)
            {
                var subProcessor = _children[i];
                subProcessor.Update();

                // Remove inactive SubSpells
                if (!subProcessor.IsActive)
                {
                    _children.RemoveAt(i);
                }
                else if (subProcessor.SubSpell.SpellShouldWaitUntilEnd)
                {
                    canStopFiring = false;
                }
            }

            if (canStopFiring)
            {
                _state = SpellState.Finilizing;
                Event?.Invoke(this, SpellEvent.FinishedFire, null);
            }
        }
Esempio n. 5
0
        /**
         * Called every diff milliseconds to update the spell
         */
        public virtual void update(long diff)
        {
            switch (state)
            {
            case SpellState.STATE_READY:
                return;

            case SpellState.STATE_CASTING:

                currentCastTime -= diff / 1000.0f;
                if (currentCastTime <= 0)
                {
                    finishCasting();
                }
                break;

            case SpellState.STATE_COOLDOWN:
                currentCooldown -= diff / 1000.0f;
                if (currentCooldown < 0)
                {
                    state = SpellState.STATE_READY;
                }
                break;
            }
        }
Esempio n. 6
0
        private void SequenceSpell()
        {
            m_State = SpellState.Sequencing;
            m_Caster.OnSpellCast(this);

            Caster.Delta(MobileDelta.Flags);

            if (m_Caster.Region != null)
            {
                m_Caster.Region.OnSpellCast(m_Caster, this);
            }

            m_Caster.NextSpellTime = Core.TickCount + (int)GetCastRecovery().TotalMilliseconds;

            Target originalTarget = m_Caster.Target;

            if (InstantTarget == null || !OnCastInstantTarget())
            {
                OnCast();
            }

            if (m_Caster.Player && m_Caster.Target != originalTarget && Caster.Target != null)
            {
                m_Caster.Target.BeginTimeout(m_Caster, TimeSpan.FromSeconds(30.0));
            }
        }
Esempio n. 7
0
 protected void Start()
 {
     SpellInfo[] spells = GameManager.instance.spells;
     SpellCount = spells.Length;
     for (int pi = 0; pi < PlayerCount; ++pi)
     {
         SpellState[] playerSpellState = new SpellState[SpellCount];
         if (pi == 0)
         {
             player1SpellState = playerSpellState;
         }
         else
         {
             player2SpellState = playerSpellState;
         }
         for (int si = 0; si < SpellCount; ++si)
         {
             SpellInfo  info  = spells[si];
             SpellState state = playerSpellState[si] = new SpellState();
             state.name = info.name;
             int copy_pi = pi; // required for lambda capture
             int copy_si = si; // required for lambda capture
             state.onSpellChange += (bool v) => notifySpellChange(copy_pi, copy_si, v);
         }
     }
 }
Esempio n. 8
0
        public void SendSpellStart()
        {
            this.State = SpellState.SPELL_STATE_PREPARING;
            this.SetCastTime();

            if (!Caster.IsTypeOf(ObjectTypes.TYPE_PLAYER))
            {
                return;
            }

            PacketWriter pkt = new PacketWriter(Opcodes.SMSG_SPELL_START);

            if (Targets.Target.IsTypeOf(ObjectTypes.TYPE_ITEM))
            {
                pkt.WriteUInt64(Targets.Target.Guid);
            }
            else
            {
                pkt.WriteUInt64(Caster.Guid);
            }

            pkt.WriteUInt64(Caster.Guid);
            pkt.WriteUInt32(Spell.Id);
            pkt.WriteUInt16(2);
            pkt.WriteUInt32(0);
            Targets.WriteTargets(ref pkt);
            ((Player)Caster).Client.Send(pkt);
        }
Esempio n. 9
0
 private void EndIfNoSubSpellsLeft()
 {
     if (_children.Count == 0)
     {
         _state = SpellState.Ended;
         Event?.Invoke(this, SpellEvent.Ended, null);
     }
 }
        public StateBuff AddStateBuff(FightActor target, bool dispelable, SpellState state)
        {
            int       id        = target.PopNextBuffId();
            StateBuff stateBuff = new StateBuff(id, target, this.Caster, this.Dice, this.Spell, dispelable, state);

            target.AddAndApplyBuff(stateBuff, true);
            return(stateBuff);
        }
Esempio n. 11
0
        public void Disturb(DisturbType type, bool firstCircle, bool resistable)
        {
            if (!CheckDisturb(type, firstCircle, resistable))
            {
                return;
            }

            if (m_State == SpellState.Casting)
            {
                if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
                {
                    return;
                }

                m_State        = SpellState.None;
                m_Caster.Spell = null;
                Caster.Delta(MobileDelta.Flags);

                OnDisturb(type, true);

                if (m_CastTimer != null)
                {
                    m_CastTimer.Stop();
                }

                if (m_AnimTimer != null)
                {
                    m_AnimTimer.Stop();
                }

                if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
                {
                    DoHurtFizzle();
                }

                m_Caster.NextSpellTime = Core.TickCount + (int)GetDisturbRecovery().TotalMilliseconds;
            }
            else if (m_State == SpellState.Sequencing)
            {
                if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
                {
                    return;
                }

                m_State        = SpellState.None;
                m_Caster.Spell = null;
                Caster.Delta(MobileDelta.Flags);

                OnDisturb(type, false);

                Target.Cancel(m_Caster);

                if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
                {
                    DoHurtFizzle();
                }
            }
        }
Esempio n. 12
0
        public virtual bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (canCast())
            {
                State        = SpellState.Casting;
                Caster.Spell = this;

                if (RevealOnCast)
                {
                    Caster.RevealingAction();
                }

                SayMantra();

                TimeSpan castTime = Info.castTime;

                double time = castTime.TotalSeconds;

                castTime = TimeSpan.FromSeconds(Vitesse.instance.CalculerVitesse(Caster, time));

                if (Caster.Body.IsHuman)
                {
                    int count = (int)Math.Ceiling(castTime.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (count != 0 && AnimateOnCast)
                    {
                        m_AnimTimer = new AnimTimer(this, count);
                        m_AnimTimer.Start();
                    }

                    if (m_Info.LeftHandEffect > 0)
                    {
                        Effects.SendTargetParticles(Caster, 0, 10, 5, Info.LeftHandEffect, EffectLayer.LeftHand);
                    }

                    if (m_Info.RightHandEffect > 0)
                    {
                        Effects.SendTargetParticles(Caster, 0, 10, 5, Info.RightHandEffect, EffectLayer.RightHand);
                    }
                }

                if (ClearHandsOnCast)
                {
                    Caster.ClearHands();
                }

                m_CastTimer = new CastTimer(this, castTime);
                m_CastTimer.Start();

                OnBeginCast();

                return(true);
            }

            return(false);
        }
Esempio n. 13
0
        protected Buff AddStateBuffDirectly(FightActor target, bool bypassMaxStack, SpellState state, FightActor triggerer = null)
        {
            var id   = target.PopNextBuffId();
            var buff = new StateBuff(id, target, Caster, this, Spell, DefaultDispellableStatus, state, triggerer: triggerer);

            target.AddBuff(buff, bypassMaxStack);

            return(buff);
        }
Esempio n. 14
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if (m_Caster.Spell == this)
            {
                m_Caster.Spell = null;
            }
        }
Esempio n. 15
0
        public void Disturb(DisturbType type, bool firstCircle, bool resistable)
        {
            if (!CheckDisturb(type, firstCircle, resistable))
            {
                return;
            }

            if (m_State == SpellState.Casting)
            {
                if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
                {
                    return;
                }

                m_State = SpellState.None;

                m_Caster.Spell = null;

                OnDisturb(type, true);

                if (m_CastTimer != null)
                {
                    m_CastTimer.Stop();
                }

                if (m_AnimTimer != null)
                {
                    m_AnimTimer.Stop();
                }

                if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
                {
                    DoHurtFizzle();
                }

                m_Caster.NextSpellTime = DateTime.Now + GetDisturbRecovery();
            }
            else if (m_State == SpellState.Sequencing)
            {
                if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
                {
                    return;
                }

                m_State        = SpellState.None;
                m_Caster.Spell = null;

                OnDisturb(type, false);

                Targeting.Target.Cancel(m_Caster);

                if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
                {
                    DoHurtFizzle();
                }
            }
        }
Esempio n. 16
0
 public SlimeBall(int cast, Vector2 pos, Ball b)
 {
     caster     = cast;
     frameCount = 0;
     Game1.activeSpells.Add(this);
     position   = new Vector2(pos.X, pos.Y);
     spellState = SpellState.Seeking;
     target     = b;
 }
Esempio n. 17
0
        public Buff AddStateBuff(FightActor target, bool bypassMaxStack, SpellState state)
        {
            if (IsTriggerBuff())
            {
                return(AddTriggerBuff(target, (buff, triggerrer, type, token) => AddStateBuffDirectly(target, bypassMaxStack, state, triggerrer)));
            }

            return(AddStateBuffDirectly(target, bypassMaxStack, state));
        }
        private void SpellReadyCheck()
        {
            bool Q_Ready = false;
            bool W_Ready = false;
            bool E_Ready = false;
            bool R_Ready = false;

            SpellState qstate = ObjectManager.Player.Spellbook.GetSpell(Q_Slot).State;
            SpellState wstate = ObjectManager.Player.Spellbook.GetSpell(W_Slot).State;
            SpellState estate = ObjectManager.Player.Spellbook.GetSpell(E_Slot).State;
            SpellState rstate = ObjectManager.Player.Spellbook.GetSpell(R_Slot).State;

            if (qstate == SpellState.Ready)
            {
                Q_Ready = true;
            }
            if (wstate == SpellState.Ready)
            {
                W_Ready = true;
            }
            if (estate == SpellState.Ready)
            {
                E_Ready = true;
            }
            if (rstate == SpellState.Ready)
            {
                R_Ready = true;
            }


            if (((Q_Effect == "Heal") && (Q_Ready)) || ((W_Effect == "Heal") && (W_Ready)) || ((E_Effect == "Heal") && (E_Ready)) || ((R_Effect == "Heal") && (R_Ready)))
            {
                HasHeal = true;
            }
            if (((Q_Effect == "Shield") && (Q_Ready)) || ((W_Effect == "Shield") && (W_Ready)) || ((E_Effect == "Shield") && (E_Ready)) || ((R_Effect == "Shield") && (R_Ready)))
            {
                HasShield = true;
            }
            if (((Q_Effect == "Wall") && (Q_Ready)) || ((W_Effect == "Wall") && (W_Ready)) || ((E_Effect == "Wall") && (E_Ready)) || ((R_Effect == "Wall") && (R_Ready)))
            {
                HasWall = true;
            }
            if (((Q_Effect == "Barrier") && (Q_Ready)) || ((W_Effect == "Barrier") && (W_Ready)) || ((E_Effect == "Barrier") && (E_Ready)) || ((R_Effect == "Barrier") && (R_Ready)))
            {
                HasBarrier = true;
            }
            if (((Q_Effect == "Block") && (Q_Ready)) || ((W_Effect == "Block") && (W_Ready)) || ((E_Effect == "Block") && (E_Ready)) || ((R_Effect == "Block") && (R_Ready)))
            {
                HasBlock = true;
            }
            if (((Q_Effect == "EscapeDeath") && (Q_Ready)) || ((W_Effect == "EscapeDeath") && (W_Ready)) || ((E_Effect == "EscapeDeath") && (E_Ready)) || ((R_Effect == "EscapeDeath") && (R_Ready)))
            {
                HasEscapeDeath = true;
            }
        }
Esempio n. 19
0
    //从技能书里激活此技能/元素;移除封印
    public void ChangeState(SpellState state)
    {
        if (curState == SpellState.LOCKED && state != SpellState.LOCKED)
        {
            GetComponent <Transform>().localPosition = ogPos;
            GetComponent <Transform>().localScale    = ogScale;
            GetComponent <Image>().sprite            = ogSprite;
        }

        curState = state;
    }
Esempio n. 20
0
        public bool CheckHSequence(Mobile target)
        {
            try
            {
                RegionControl regstone = null;
                CustomRegion  reg      = null;
                if (target != null)
                {
                    reg = CustomRegion.FindDRDTRegion(target);
                }
                if (reg != null)
                {
                    regstone = reg.GetRegionControler();
                }

                //if your in a region area spells will fail if disallowed, prevents the run outside of area precast
                //run back into region then release spell ability
                if (m_Caster != null && target != null && m_Caster.Spell != null && m_Caster.Region != target.Region && regstone != null && (regstone.IsRestrictedSpell(m_Caster.Spell, m_Caster) || regstone.IsMagicIsolated) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
                {
                    m_State = SpellState.None;
                    if (m_Caster.Spell == this)
                    {
                        m_Caster.Spell = null;
                    }
                    Targeting.Target.Cancel(m_Caster);
                    m_Caster.SendMessage("You cannot cast your spell into that area.");
                    return(false);
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0} Caught exception.", e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }

            if (!target.Alive)
            {
                m_Caster.SendLocalizedMessage(501857);                 // This spell won't work on that!
                return(false);
            }
            else if (Caster.CanBeHarmful(target) && CheckSequence())
            {
                Caster.DoHarmful(target);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 21
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if (m_Caster.Spell == this)
            {
                m_Caster.Spell = null;
            }

            Server.Gumps.MReagentGump.XReagentGump(m_Caster);
        }
Esempio n. 22
0
        public virtual void FinishSequence()
        {
            State = SpellState.None;

            if (Caster.Spell == this)
            {
                Caster.Spell = null;
            }

            CombatStrategy.GetStrategy(Caster).ResetAttackAfterCast(Caster);
        }
Esempio n. 23
0
    virtual protected void Start()
    {
        status        = GetComponent <CharacterStatus>();
        anim          = GetComponent <CharacterAnimation>();
        spellState    = SpellState.Ready;
        contactFilter = new ContactFilter2D();
        string parentLayer = LayerMask.LayerToName(gameObject.layer);

        enemyLayer = parentLayer == "Red side" ? "Blue Side" : "Red Side";
        contactFilter.SetLayerMask(LayerMask.GetMask(enemyLayer));
        contactFilter.useTriggers = true;
    }
Esempio n. 24
0
 virtual protected void Update()
 {
     if (spellState == SpellState.InCooldown)
     {
         cooldownTimer -= Time.deltaTime;
         if (cooldownTimer <= 0)
         {
             cooldownTimer = 0;
             spellState    = SpellState.Ready;
         }
     }
 }
Esempio n. 25
0
        private void FireMainSubSpells()
        {
            _state = SpellState.Firing;

            // Fire main sub spells
            foreach (var subSpell in Spell.MainSubSpells)
            {
                CastSubSpell(subSpell, Source, CastTarget);
            }

            Event?.Invoke(this, SpellEvent.StartedFiring, null);
        }
Esempio n. 26
0
        public virtual void FinishSequence()
        {
            if (m_Caster is BaseCreature)
            {
            }

            m_State = SpellState.None;

            if (m_Caster.Spell == this)
            {
                m_Caster.Spell = null;
            }
        }
Esempio n. 27
0
    // Update is called once per frame
    void Update()
    {
        print(currentSpellState);
        switch (currentSpellState)
        {
        case SpellState.Wind:
            windPresssed = true;
            lightPressed = false;
            grassPressed = false;

            if (Input.GetButton("Shortcut2"))
            {
                currentSpellState = SpellState.Grass;
            }
            if (Input.GetButton("Shortcut3"))
            {
                currentSpellState = SpellState.Light;
            }
            break;

        case SpellState.Grass:
            windPresssed = false;
            lightPressed = true;
            grassPressed = false;

            if (Input.GetButton("Shortcut1"))
            {
                currentSpellState = SpellState.Wind;
            }
            if (Input.GetButton("Shortcut3"))
            {
                currentSpellState = SpellState.Light;
            }
            break;

        case SpellState.Light:
            windPresssed = false;
            lightPressed = false;
            grassPressed = true;

            if (Input.GetButton("Shortcut1"))
            {
                currentSpellState = SpellState.Wind;
            }
            if (Input.GetButton("Shortcut2"))
            {
                currentSpellState = SpellState.Grass;
            }
            break;
        }
    }
Esempio n. 28
0
 public void Abort()
 {
     // If current state is not "aborted" or "Finilizing"
     // We need to switch to Finilizing state
     if (_state != SpellState.Finilizing && _state != SpellState.Ended)
     {
         _state = SpellState.Finilizing;
         foreach (var subSpellHandler in _children)
         {
             subSpellHandler.Abort();
         }
         Event?.Invoke(this, SpellEvent.Aborted, null);
     }
 }
Esempio n. 29
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if (m_Caster.Spell == this)
            {
                m_Caster.Spell = null;

                if (m_Caster.Player)
                {
                    EventDispatcher.InvokeSpellFinished(new SpellEventArgs((Player)m_Caster, this));
                }
            }
        }
Esempio n. 30
0
        private static void OnUpdate(EventArgs args)
        {
            if (ObjectManager.Player.IsDead)
            {
                return;
            }

            string     spellName  = ObjectManager.Player.Spellbook.GetSpell(SpellSlot.W).Name;
            SpellState spellState = ObjectManager.Player.Spellbook.CanUseSpell(SpellSlot.W);

            if (spellState == SpellState.Ready && spellName.Equals("PickACard", StringComparison.InvariantCultureIgnoreCase))
            {
                Status = SelectCardStatus.Ready;
            }
            else if (spellState == SpellState.Cooldown && spellName.Equals("PickACard", StringComparison.InvariantCultureIgnoreCase))
            {
                SelectedCard = Cards.None;
                Status       = SelectCardStatus.Cooldown;
            }
            else if (spellState == SpellState.Surpressed)
            {
                Status = SelectCardStatus.Selected;
            }

            switch (SelectedCard)
            {
            case Cards.Gold:
                if (spellName.Equals("GoldCardLock", StringComparison.InvariantCultureIgnoreCase))
                {
                    ObjectManager.Player.Spellbook.CastSpell(SpellSlot.W, false);
                }
                break;

            case Cards.Red:
                if (spellName.Equals("RedCardLock", StringComparison.InvariantCultureIgnoreCase))
                {
                    ObjectManager.Player.Spellbook.CastSpell(SpellSlot.W, false);
                }
                break;

            case Cards.Blue:
                if (spellName.Equals("BlueCardLock", StringComparison.InvariantCultureIgnoreCase))
                {
                    ObjectManager.Player.Spellbook.CastSpell(SpellSlot.W, false);
                }
                break;
            }
        }
Esempio n. 31
0
	public void StartSpell () {
		//Debug.Log (Name + " START");

		InitializeGround ();

		InitializeText ();

		CenterObjectInitialize ();

		ShowWinAnimation (false);

		// listening to events really "starts" the spell
		ListenToEvents ();

		state = SpellState.InProgress;
		NotifyStateChange ();
	}
Esempio n. 32
0
	private void OnSpellOver (SpellState state, Spell spell) {
		//Debug.Log (spell.Name + ": state is " + state);
		if (IsSpellOver (spell)) {
			StopSpell (spell);

			if (OnSpellComplete != null) {
				OnSpellComplete (spell);
			}

            if (state == SpellState.Win)
            {
                winBox.GetComponent<Canvas>().enabled = true;
            }
            else if (state == SpellState.Lose)
            {
                loseBox.GetComponent<Canvas>().enabled = true;
            }

			// Ref: http://answers.unity3d.com/questions/350721/c-yield-waitforseconds.html
			StartCoroutine (WaitThenShowNextInstructions (spell));
		}
	}
Esempio n. 33
0
		public bool Cast()
		{
			m_StartCastTime = Core.TickCount;

			if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
			{
				((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
			}

			if (!m_Caster.CheckAlive())
			{
				return false;
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
			else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
			}
			else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
					 (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
			{
				m_Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
			}
			else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
			{
				m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
				#region Dueling
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
					 !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
			{ }
				#endregion

			else if (m_Caster.Mana >= ScaleMana(GetMana()))
			{
				#region Stygian Abyss
				if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
				{
					var tiles = Caster.Map.Tiles.GetStaticTiles(Caster.X, Caster.Y, true);
					ItemData itemData;
					bool cancast = true;

					for (int i = 0; i < tiles.Length && cancast; ++i)
					{
						itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
						cancast = !(itemData.Name == "hover over");
					}

					if (!cancast)
					{
						if (m_Caster.IsPlayer())
						{
							m_Caster.SendLocalizedMessage(1113750); // You may not cast spells while flying over such precarious terrain.
							return false;
						}
						else
						{
							m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
						}
					}
				}
				#endregion

				if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
					m_Caster.Region.OnBeginSpellCast(m_Caster, this))
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if (!(m_Scroll is BaseWand) && RevealOnCast)
					{
						m_Caster.RevealingAction();
					}

					SayMantra();

					TimeSpan castDelay = GetCastDelay();

					if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
					{
						int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

						if (count != 0)
						{
							m_AnimTimer = new AnimTimer(this, count);
							m_AnimTimer.Start();
						}

						if (m_Info.LeftHandEffect > 0)
						{
							Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
						}

						if (m_Info.RightHandEffect > 0)
						{
							Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
						}
					}

					if (ClearHandsOnCast)
					{
						m_Caster.ClearHands();
					}

					if (Core.ML)
					{
						WeaponAbility.ClearCurrentAbility(m_Caster);
					}

					m_CastTimer = new CastTimer(this, castDelay);
					//m_CastTimer.Start();

					OnBeginCast();

					if (castDelay > TimeSpan.Zero)
					{
						m_CastTimer.Start();
					}
					else
					{
						m_CastTimer.Tick();
					}

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
			}

			return false;
		}
Esempio n. 34
0
      public bool Cast()
      {
         if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
            ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

         if ( !m_Caster.CheckAlive() )
         {
            return false;
         }
         else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
         {
            m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
         }
         else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
         {
            m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
         }
         else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
         {
            m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
         }
         else if ( !(m_Scroll is BaseWand) && DateTime.Now < m_Caster.NextSpellTime )
         {
            m_Caster.SendLocalizedMessage( 502642 ); // You must wait for that spell to have an effect.
         }
            //ADDED FOR STAFF ENDLESS MANA
         else if (m_Caster.Mana >= ScaleMana(GetMana()) || m_Caster.AccessLevel > AccessLevel.Player)
         {
            if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
            {
               m_State = SpellState.Casting;
               m_Caster.Spell = this;

               if ( RevealOnCast )
                  m_Caster.RevealingAction();

               SayMantra();

               TimeSpan castDelay = this.GetCastDelay();

               if ( m_Caster.Body.IsHuman )
               {
                  int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                  if ( count != 0 )
                  {
                     m_AnimTimer = new AnimTimer( this, count );
                     m_AnimTimer.Start();
                  }

                  if ( m_Info.LeftHandEffect > 0 )
                     Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                  if ( m_Info.RightHandEffect > 0 )
                     Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
               }

               if ( ClearHandsOnCast )
                  m_Caster.ClearHands();

               m_CastTimer = new CastTimer( this, castDelay );
               m_CastTimer.Start();

               m_CastStartTime = DateTime.Now;

               OnBeginCast();

               return true;
            }
            else
            {
               return false;
            }
         }
         else
         {
            m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
         }

         return false;
      }
Esempio n. 35
0
		public void Disturb(DisturbType type, bool firstCircle, bool resistable)
		{
			if (!CheckDisturb(type, firstCircle, resistable))
			{
				return;
			}

			if (m_State == SpellState.Casting)
			{
				if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
				{
					return;
				}

				m_State = SpellState.None;
				m_Caster.Spell = null;

				OnDisturb(type, true);

				if (m_CastTimer != null)
				{
					m_CastTimer.Stop();
				}

				if (m_AnimTimer != null)
				{
					m_AnimTimer.Stop();
				}

				if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
				{
					DoHurtFizzle();
				}

				m_Caster.NextSpellTime = Core.TickCount + (int)GetDisturbRecovery().TotalMilliseconds;
			}
			else if (m_State == SpellState.Sequencing)
			{
				if (!firstCircle && !Core.AOS && this is MagerySpell && ((MagerySpell)this).Circle == SpellCircle.First)
				{
					return;
				}

				m_State = SpellState.None;
				m_Caster.Spell = null;

				OnDisturb(type, false);

				Target.Cancel(m_Caster);

				if (Core.AOS && m_Caster.Player && type == DisturbType.Hurt)
				{
					DoHurtFizzle();
				}
			}
		}
Esempio n. 36
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.Now;

			if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
				((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

			if ( !m_Caster.CheckAlive() )
			{
				return false;
			}
			#region Mondain's Legacy
			else if ( m_Caster is PlayerMobile  && ((PlayerMobile) m_Caster).Peaced )
			{
				m_Caster.SendLocalizedMessage( 1072060 ); // You cannot cast a spell while calmed.
			}
			#endregion
			else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
			{
				m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
			}
			else if ( BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
			{
				m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
			}
			else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
			{
				m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
			}
			else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
			{
				m_Caster.SendLocalizedMessage( 502644 ); // You have not yet recovered from casting a spell.
			}
			else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
			{
				if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if ( RevealOnCast )
						m_Caster.RevealingAction();

					SayMantra();

					TimeSpan castDelay = this.GetCastDelay();

					if ( ShowHandMovement && m_Caster.Body.IsHuman )
					{
						int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

						if ( count != 0 )
						{
							m_AnimTimer = new AnimTimer( this, count );
							m_AnimTimer.Start();
						}

						if ( m_Info.LeftHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

						if ( m_Info.RightHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
					}

					if ( ClearHandsOnCast )
						m_Caster.ClearHands();

					m_CastTimer = new CastTimer( this, castDelay );
					m_CastTimer.Start();

					OnBeginCast();

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
			}

			return false;
		}
Esempio n. 37
0
        public void Disturb( DisturbType type, bool firstCircle, bool resistable )
        {
            if ( !CheckDisturb( type, firstCircle, resistable ) )
                return;

            if ( m_State == SpellState.Casting )
            {
                if( !firstCircle && !Core.AOS && this is MagerySpell &&  ((MagerySpell)this).Circle == SpellCircle.First )
                    return;

                m_State = SpellState.None;
                m_Caster.Spell = null;

                OnDisturb( type, true );

                if ( m_CastTimer != null )
                    m_CastTimer.Stop();

                if ( m_AnimTimer != null )
                    m_AnimTimer.Stop();

                if ( Core.AOS && m_Caster.Player && type == DisturbType.Hurt )
                    DoHurtFizzle();

                m_Caster.NextSpellTime = DateTime.Now + GetDisturbRecovery();
            }
            else if ( m_State == SpellState.Sequencing )
            {
                if( !firstCircle && !Core.AOS && this is MagerySpell &&  ((MagerySpell)this).Circle == SpellCircle.First )
                    return;

                m_State = SpellState.None;
                m_Caster.Spell = null;

                OnDisturb( type, false );

                Targeting.Target.Cancel( m_Caster );

                if ( Core.AOS && m_Caster.Player && type == DisturbType.Hurt )
                    DoHurtFizzle();
            }
        }
Esempio n. 38
0
        public bool SphereCast(Mobile from, object obj)
        {
            m_StartCastTime = DateTime.Now;

            if (m_PlayerCaster.Paralyzed && !m_PlayerCaster.HasFreeHand())
            {
                m_Caster.SendAsciiMessage(33, "You must have your hands free to cast while paralyzed!");
                return false;
            }

            if (IsCastPossible())
            {
                m_SphereSpellTarget = obj;

                if (m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    if (m_Caster is PlayerMobile && ClearHandsOnCast) //Mobiles don't need to disarm
                        m_Caster.ClearHands();

                    m_State = SpellState.Casting;

                    m_Caster.Spell = this;

                    m_PlayerCaster.WeaponTimerCheck();
                    m_PlayerCaster.BandageCheck();

                    m_PlayerCaster.AbortCurrentPlayerAction();

                    //Maka
                    if (RevealOnCast && !m_PlayerCaster.HiddenWithSpell)
                        m_Caster.RevealingAction();

                    SayMantra();

                    var castDelay = GetCastDelay();

                    var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                    if (count != 0)
                    {
                        m_AnimTimer = new AnimTimer(this, 1);
                        m_AnimTimer.Start();
                    }

                    if (m_Info.LeftHandEffect > 0)
                        Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                    if (m_Info.RightHandEffect > 0)
                        Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);

                    if (Core.ML)
                        WeaponAbility.ClearCurrentAbility(m_Caster);

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();
                    return true;
                }
                return false;
            }
            return false;
        }
Esempio n. 39
0
		public void Disturb( DisturbType type, bool firstCircle, bool resistable )
		{
			if ( !CheckDisturb( type, firstCircle, resistable ) )
				return;

			if ( m_State == SpellState.Casting )
			{
				if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
					return;

				m_State = SpellState.None;
				m_Caster.Spell = null;

				OnDisturb( type, true );

				if ( m_CastTimer != null )
					m_CastTimer.Stop();

				if ( m_AnimTimer != null )
					m_AnimTimer.Stop();

				// erl: removed next spell delay for "daggering" and [cancelspell
				// ..
				// line altered -
				// if ( type == DisturbType.EquipRequest || type == DisturbType.Hurt )
				// become -
				// if ( type == DisturbType.Hurt )
				// ..

				if ( type == DisturbType.Hurt )
					m_Caster.NextSpellTime = DateTime.Now + GetDisturbRecovery();
				else
					TimeSpan.FromSeconds( GetDisturbRecovery().TotalSeconds );

			}
			else if ( m_State == SpellState.Sequencing )
			{
				if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
					return;

				m_State = SpellState.None;
				m_Caster.Spell = null;

				OnDisturb( type, false );

				Targeting.Target.Cancel( m_Caster );

				if ( type == DisturbType.EquipRequest || type == DisturbType.Hurt )
					m_Caster.NextSpellTime = DateTime.Now + GetDisturbRecovery();
				else
					TimeSpan.FromSeconds( GetDisturbRecovery().TotalSeconds );
			}
		}
Esempio n. 40
0
        /**
         * Called when the spell is finished casting and we're supposed to do things
         * such as projectile spawning, etc.
         */
        public virtual void finishCasting()
        {
            doLua();

            state = SpellState.STATE_COOLDOWN;
            currentCooldown = getCooldown();

            var current = new Vector2(owner.getX(), owner.getY());
            var to = (new Vector2(x, y) - current);
            var trueCoords = current + (Vector2.Normalize(to) * 1150);

            var p = new Projectile(owner.getMap(), Game.GetNewNetID(), owner.getX(), owner.getY(), (int)lineWidth, owner, new Target(trueCoords.X, trueCoords.Y), this, projectileSpeed, (int)RAFHashManager.GetHash(spellName + "Missile"), projectileFlags > 0 ? (int)projectileFlags : flags);
            owner.getMap().addObject(p);
            PacketNotifier.notifyProjectileSpawn(p);
        }
Esempio n. 41
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( m_Caster.Spell is Spell && ( (Spell) m_Caster.Spell ).State == SpellState.Sequencing )
                ( (Spell) m_Caster.Spell ).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
            }
            else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
            {
                m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
            }
            else if ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) )
            {
                m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
            }
            else if ( !( m_Scroll is BaseWand ) && ( m_Caster.Paralyzed || m_Caster.Frozen ) )
            {
                m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage( 502644 ); // You have not yet recovered from casting a spell.
            }
            else if ( BaseBardCreature.IsCalmed( m_Caster ) )
            {
                m_Caster.SendLocalizedMessage( 1072060 ); // You cannot cast a spell while calmed.
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if ( RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    /*
                     * OSI cast delay is computed with a global timer based on ticks. There is
                     * one tick per 0.25 seconds, so every tick the timer computes all the
                     * spells ready to cast. This introduces a random additional delay of 0-0.25
                     * seconds due to fact that the first tick is always incomplete. We add this
                     * manually here to enhance the gameplay to get the real OSI feeling.
                     */
                    castDelay += TimeSpan.FromSeconds( 0.25 * Utility.RandomDouble() );

                    if ( ShowHandMovement && m_Caster.Body.IsHuman && !( m_Scroll is SpellStone ) )
                    {
                        int count = (int) Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                        if ( count != 0 )
                        {
                            m_AnimTimer = new AnimTimer( this, count );
                            m_AnimTimer.Start();
                        }

                        if ( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                        if ( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                    }

                    if ( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer( this, castDelay );
                    m_CastTimer.Start();

                    SpecialMove.ClearCurrentMove( m_Caster );
                    WeaponAbility.ClearCurrentAbility( m_Caster );

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Esempio n. 42
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
            }
            else if ( m_Caster.Paralyzed || m_Caster.Frozen )
            {
                m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage( 502644 ); // You must wait for that spell to have an effect.
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if ( RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if ( m_Caster.Body.IsHuman )
                    {
                        int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                        if ( count != 0 )
                        {
                            m_AnimTimer = new AnimTimer( this, count );
                            m_AnimTimer.Start();
                        }

                        if ( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                        if ( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                    }

                    if ( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer( this, castDelay );
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Esempio n. 43
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;
            Spellbook book = Caster.FindItemOnLayer( Layer.OneHanded ) as Spellbook;

            if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendAsciiMessage( "You are already casting a spell." );
            }
            else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
            {
                m_Caster.SendAsciiMessage( "You cannot cast that spell in this form." );
            }
            else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
            {
                m_Caster.SendAsciiMessage( "You can not cast a spell while frozen." );
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendAsciiMessage( "You must wait for that spell to have an effect." );
            }
            else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
            {
                if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
                {
                    if ( Caster.Player == true && book != null && CheckSpellbook == true || Caster.Player == false || CheckSpellbook == false || ( m_Scroll is BaseWand ) || ( m_Scroll is Items.IceStaff ) || ( m_Scroll is Runebook ) )
                    {
                        m_State = SpellState.Casting;
                        m_Caster.Spell = this;

                        if ( RevealOnCast )
                            m_Caster.RevealingAction();

                        SayMantra();

                        TimeSpan castDelay = this.GetCastDelay();

                        if ( m_Caster.Body.IsHuman )
                        {
                            int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

                            if ( count != 0 )
                            {
                                m_AnimTimer = new AnimTimer( this, count );
                                m_AnimTimer.Start();
                            }

                            if ( m_Info.LeftHandEffect > 0 )
                                Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

                            if ( m_Info.RightHandEffect > 0 )
                                Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
                        }

                        if ( ClearHandsOnCast )
                            m_Caster.ClearHands();

                        m_CastTimer = new CastTimer( this, castDelay );
                        m_CastTimer.Start();

                        OnBeginCast();

                        return true;
                    }
                    else if ( Caster.Player == true )
                    {
                          			Container backpack = Caster.Backpack;

                           			Spellbook spbook = (Spellbook) backpack.FindItemByType( typeof( Spellbook ) );
                        if ( spbook != null )
                        {
                            m_Caster.ClearHands();
                            Caster.EquipItem( spbook );
                            Cast();
                        }
                    }
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
            }

            return false;
        }
Esempio n. 44
0
 private static object Extract(SpellState state)
 {
     if (state == null) return null;
     return new
     {
         stateType = state.m_StateType.ToString(),
         name = state.name,
         tag = state.tag,
     };
 }
Esempio n. 45
0
      public void Disturb( DisturbType type, bool firstCircle, bool resistable )
      {
         if ( !CheckDisturb( type, firstCircle, resistable ) )
            return;

         if ( m_State == SpellState.Casting )
         {
            if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
               return;

            m_State = SpellState.None;
            //m_Caster.NextSpellTime = DateTime.Now + TimeSpan.FromSeconds(0.20 + (0.20 * (int)Circle) );
            try
            {
                TimeSpan NextSpellDelay = TimeSpan.FromSeconds((0.90 + (0.41 * (int)Circle)) * (1 - CastDelayFinishFactor));
                m_Caster.NextSpellTime = DateTime.Now + NextSpellDelay;
            }
            catch(Exception e)
            {
                //In case of an exception use old calculation.
                m_Caster.NextSpellTime = DateTime.Now + TimeSpan.FromSeconds(0.20 + (0.20 * (int)Circle) );
                //and log...
                GeneralLogging.WriteLine("CrashDebug", "Exception:\n{0}\n{1}\nCastDelayFinishFactor: {2}\nCircle: {3}", e.Message, e.StackTrace, CastDelayFinishFactor, (int)Circle);
            }
            //m_Caster.SendMessage("Debug: Disturb, FinishFactor: {0}, NextSpellTime: {1}", CastDelayFinishFactor, NextSpellDelay);

            m_Caster.Spell = null;

            OnDisturb( type, true );

            if ( m_CastTimer != null )
               m_CastTimer.Stop();

            if ( m_AnimTimer != null )
               m_AnimTimer.Stop();

            if ( Core.AOS && m_Caster.Player && type == DisturbType.Hurt )
               DoHurtFizzle();
         }
         else if ( m_State == SpellState.Sequencing )
         {
            if ( !firstCircle && Circle == SpellCircle.First && !Core.AOS )
               return;

            m_State = SpellState.None;
            m_Caster.Spell = null;

            OnDisturb( type, false );

            Targeting.Target.Cancel( m_Caster );

            if ( Core.AOS && m_Caster.Player && type == DisturbType.Hurt )
               DoHurtFizzle();
         }
      }
Esempio n. 46
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);

            if( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
            }
            else if( m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now )
            {
                m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
            }
            else if( m_Caster.Mana >= ScaleMana(GetMana()) )
            {
                if( m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this) )
                {
                    if( m_Caster.Player )
                    {
                        SpellCastEventArgs args = new SpellCastEventArgs((Player)Caster, this);
                        EventDispatcher.InvokeSpellCast(args);

                        if( args.Blocked )
                            return false;
                    }

                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if( !(m_Scroll is BaseWand) && RevealOnCast )
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if( ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)) )
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);
                        bool animate = true;

                        if (m_Caster is Player)
                        {
                            Arcanite arc = Perk.GetByType<Arcanite>((Player)m_Caster);

                            if (arc != null)
                            {
                                if (arc.EtherealKenetics())
                                    animate = false;
                            }
                        }

                        if( count != 0 && animate )
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if( m_Info.LeftHandEffect > 0 )
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if( m_Info.RightHandEffect > 0 )
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if( ClearHandsOnCast )
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if( castDelay > TimeSpan.Zero )
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
            }

            return false;
        }
Esempio n. 47
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if (Caster != null)
            {
                if (Caster is PlayerMobile)
                {
                    if (!((PlayerMobile) Caster).HiddenWithSpell) //Taran: Don't reveal when hidden with spell or pot
                        Caster.RevealingAction();
                }
                else
                    Caster.RevealingAction();
            }

            if (m_Caster.Spell == this)
                m_Caster.Spell = null;
        }
Esempio n. 48
0
		public bool CheckHSequence( Mobile target )
		{
			try
			{
				RegionControl regstone = null;
				CustomRegion reg = null;
				if(target !=null)
					reg = CustomRegion.FindDRDTRegion(target);
				if(reg !=null )
					regstone = reg.GetRegionControler();

				//if your in a region area spells will fail if disallowed, prevents the run outside of area precast
				//run back into region then release spell ability
				if(m_Caster != null && target != null && m_Caster.Spell != null && m_Caster.Region != target.Region && regstone != null && (regstone.IsRestrictedSpell( m_Caster.Spell, m_Caster ) || regstone.IsMagicIsolated) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
				{
					m_State = SpellState.None;
					if ( m_Caster.Spell == this )
						m_Caster.Spell = null;
					Targeting.Target.Cancel( m_Caster );
					m_Caster.SendMessage( "You cannot cast your spell into that area." );
					return false;
				}

			}
			catch(NullReferenceException e)
			{
				LogHelper.LogException(e);
				Console.WriteLine("{0} Caught exception.", e);
			}
			catch(Exception ex)
			{
                LogHelper.LogException(ex);
			}

			if ( !target.Alive )
			{
				m_Caster.SendLocalizedMessage( 501857 ); // This spell won't work on that!
				return false;
			}
			else if ( Caster.CanBeHarmful( target ) && CheckSequence() )
			{
				Caster.DoHarmful( target );
				return true;
			}
			else
			{
				return false;
			}
		}
Esempio n. 49
0
        public virtual void DoFizzle()
        {
            if (m_PlayerCaster != null) //Only consume mana on fizzle for players
            {
                CustomRegion cR = m_PlayerCaster.Region as CustomRegion;

                if (cR == null || !cR.Controller.FizzlePvP)
                {
                    int mana = ScaleMana(GetMana());
                    m_Caster.Mana -= (int) Math.Round((double) mana/2, 0);
                }
            }

            m_Caster.SendAsciiMessage("The spell fizzles.");

            m_Caster.FixedEffect(0x3735, 6, 30);
            m_Caster.PlaySound(0x5C);

            if (m_CastTimer != null)
                m_CastTimer.Stop();

            if (m_AnimTimer != null)
                m_AnimTimer.Stop();

            m_State = SpellState.None;
            m_Caster.Spell = null;
        }
Esempio n. 50
0
	private void lose() {
		Debug.Log (Name + ": YOU LOSE! (too many ticks) Elapsed: " + numTicksElapsed);
		if (LoseSound != null) {
			LoseSound.Play ();
		}

		ShowWinAnimation (false);

		ShowWetGround (false);

		//theme.SendMessage ("StopMusic");
		if (loseBox != null) {
			loseBox.SetActive (true);
		}

		CenterObjectLose ();

		state = SpellState.Lose;
		endSpell ();
	}
Esempio n. 51
0
        public bool DirectCast() //Mobile cast
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);

            if (!m_Caster.CheckAlive())
            {
                return false;
            }
            if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form.
            }
            else if (m_Caster.Frozen)
            {
                m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now)
            {
                m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
            }
            //Taran: Tacky fix for checking range and LoS for NPC's, I don't know where the NPC spell targeting method is so I'm using Combatant instead.
            else if (m_Caster is BaseCreature && m_Caster.Combatant != null && (!m_Caster.InLOS(m_Caster.Combatant) || !m_Caster.InRange(m_Caster.Combatant, 12) || !m_Caster.CanSee(m_Caster.Combatant)))
            {
                m_Caster.SendAsciiMessage("You cannot see your target");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        if (m_Caster is PlayerMobile)
                        {
                            if (!((PlayerMobile)m_Caster).HiddenWithSpell)
                                m_Caster.RevealingAction();
                        }
                        else
                            m_Caster.RevealingAction();
                    }

                    SayMantra();

                    var castDelay = GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, 1);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if (m_Info.RightHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if (m_Caster is PlayerMobile && ClearHandsOnCast) //Mobiles don't need to disarm
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                return false;
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
            }

            return false;
        }
Esempio n. 52
0
		public virtual bool CheckSequence()
		{

			try
			{
				RegionControl regstone = null;
				CustomRegion reg = null;
				if(m_Caster !=null)
					reg = CustomRegion.FindDRDTRegion(m_Caster);
				if(reg !=null )
					regstone = reg.GetRegionControler();

				//if your in a region area spells will fail if disallowed, prevents the run outside of area precast
    				//run back into region then release spell ability
				if(m_Caster != null && m_Caster.Spell != null && regstone != null && regstone.IsRestrictedSpell( m_Caster.Spell , m_Caster) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
				{
					m_State = SpellState.None;
					if ( m_Caster.Spell == this )
						m_Caster.Spell = null;
					Targeting.Target.Cancel( m_Caster );
					if(regstone.MagicMsgFailure == null)
						m_Caster.SendMessage( "You cannot cast that spell here." );
					else
						m_Caster.SendMessage(regstone.MagicMsgFailure);

				}

			}
			catch(NullReferenceException e)
			{
				LogHelper.LogException(e);
			    Console.WriteLine("{0} Caught exception.", e);
			}
			catch(Exception ex)
			{
                LogHelper.LogException(ex);
			}


			int mana = ScaleMana( GetMana() );

			if ( m_Caster.Deleted || !m_Caster.Alive || m_Caster.Spell != this || m_State != SpellState.Sequencing )
			{
				DoFizzle();
			}
			else if ( m_Scroll != null && !(m_Scroll is Runebook) && (m_Scroll.Amount <= 0 || m_Scroll.Deleted || m_Scroll.RootParent != m_Caster || (m_Scroll is BaseWand && (((BaseWand)m_Scroll).Charges <= 0 || m_Scroll.Parent != m_Caster))) )
			{
				DoFizzle();
			}
			else if ( !ConsumeReagents() )
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502630 ); // More reagents are needed for this spell.
			}
			else if ( m_Caster.Mana < mana )
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana for this spell.
			}
			else if ( Core.AOS && (m_Caster.Frozen || m_Caster.Paralyzed) )
			{
				m_Caster.SendLocalizedMessage( 502646 ); // You cannot cast a spell while frozen.
				DoFizzle();
			}
			else if ( CheckFizzle() )
			{
				m_Caster.Mana -= mana;

				if ( m_Scroll is SpellScroll )
					m_Scroll.Consume();
				else if ( m_Scroll is BaseWand )
					((BaseWand)m_Scroll).ConsumeCharge( m_Caster );

				if ( m_Scroll is BaseWand )
				{
					bool m = m_Scroll.Movable;

					m_Scroll.Movable = false;

					if ( ClearHandsOnCast )
						m_Caster.ClearHands();

					m_Scroll.Movable = m;
				}
				else
				{
					if ( ClearHandsOnCast )
						m_Caster.ClearHands();
				}

				int karma = ComputeKarmaAward();

				if ( karma != 0 )
					Misc.Titles.AwardKarma( Caster, karma, true );

				/*
				if ( TransformationSpell.UnderTransformation( m_Caster, typeof( VampiricEmbraceSpell ) ) )
				{
					bool garlic = false;

					for ( int i = 0; !garlic && i < m_Info.Reagents.Length; ++i )
						garlic = ( m_Info.Reagents[i] == Reagent.Garlic );

					if ( garlic )
					{
						m_Caster.SendLocalizedMessage( 1061651 ); // The garlic burns you!
						AOS.Damage( m_Caster, Utility.RandomMinMax( 17, 23 ), 100, 0, 0, 0, 0 );
					}
				}
				*/

				return true;
			}
			else
			{
				DoFizzle();
			}

			return false;
		}
Esempio n. 53
0
        /**
         * Called when the character casts the spell
         */
        public virtual bool cast(float x, float y, Unit u = null, int futureProjNetId = 0, int spellNetId = 0)
        {
            this.x = x;
            this.y = y;
            this.target = u;
            this.futureProjNetId = futureProjNetId;
            this.spellNetId = spellNetId;

            if (castTime > 0 && flags != (int)SpellFlag.SPELL_FLAG_InstantCast)
            {
                owner.setPosition(owner.getX(), owner.getY());//stop moving serverside too. TODO: check for each spell if they stop movement or not
                state = SpellState.STATE_CASTING;
                currentCastTime = castTime;
            }
            else
            {
                finishCasting();
            }
            return true;
        }
Esempio n. 54
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.Now;

			if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
				((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

			if ( !m_Caster.CheckAlive() )
			{
				return false;
			}
			else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
			{
				m_Caster.SendLocalizedMessage( 502642 ); // You are already casting a spell.
			}
			//else if ( BlockedByHorrificBeast && TransformationSpell.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) )
			//{
			//	m_Caster.SendLocalizedMessage( 1061091 ); // You cannot cast that spell in this form.
			//}
			else if ( !(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen) )
			{
				m_Caster.SendLocalizedMessage( 502643 ); // You can not cast a spell while frozen.
			}
			//else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
			else if ( DateTime.Now < m_Caster.NextSpellTime )
			{
				m_Caster.SendLocalizedMessage( 502644 ); // You must wait for that spell to have an effect.
			}
			else if ( m_Caster.Mana >= ScaleMana( GetMana() ) )
			{
				if ( m_Caster.Spell == null && m_Caster.CheckSpellCast( this ) && CheckCast() && m_Caster.Region.OnBeginSpellCast( m_Caster, this ) )
				{
					m_State = SpellState.Casting;
					m_Caster.Spell = this;

					if ( RevealOnCast )
						m_Caster.RevealingAction();

					SayMantra();

					TimeSpan castDelay = this.GetCastDelay();

// ---- Individual spell timing alterations ----

// For FC ----
					if ( m_Info.Name == "Mind Blast" )
						castDelay = this.GetCastDelay() + TimeSpan.FromSeconds( 0.45 );
					else if ( m_Info.Name == "Cure" )
						castDelay = this.GetCastDelay() + TimeSpan.FromSeconds( 0.02 );

// For FCR ----
					if ( m_Info.Name == "Heal" )
						NextSpellDelay = TimeSpan.FromSeconds( 0.95 );
					else
						NextSpellDelay = TimeSpan.FromSeconds( 0.80 );
// ----

					if ( m_Caster.Body.IsHuman )
					{
						int count = (int)Math.Ceiling( castDelay.TotalSeconds / AnimateDelay.TotalSeconds );

						if ( count != 0 )
						{
							m_AnimTimer = new AnimTimer( this, count );
							m_AnimTimer.Start();
						}

						if ( m_Info.LeftHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand );

						if ( m_Info.RightHandEffect > 0 )
							Caster.FixedParticles( 0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand );
					}

					if ( ClearHandsOnCast )
						m_Caster.ClearHands();

					m_CastTimer = new CastTimer( this, castDelay );
					m_CastTimer.Start();

					OnBeginCast();

					// If the caster is a staffmember, log the spellcasting.
					if ( m_Caster.AccessLevel > AccessLevel.Player )
						Server.Scripts.Commands.CommandLogging.LogCastSpell( m_Caster, this.Name );

					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				m_Caster.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana
			}

			return false;
		}
Esempio n. 55
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if ( Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing )
                ((Spell)m_Caster.Spell).Disturb( DisturbType.NewCast );

            if ( !m_Caster.CheckAlive() )
            {
                return false;
            }
            else if ( m_Caster.Spell != null && m_Caster.Spell.IsCasting )
            {
                m_Caster.SendAsciiMessage( "You are already casting a spell." ); // You are already casting a spell.
            }
            else if ( BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation( m_Caster, typeof( HorrificBeastSpell ) ) || ( BlockedByAnimalForm && AnimalForm.UnderTransformation( m_Caster ) ))
            {
                m_Caster.SendAsciiMessage( "You cannot cast that spell in this form." ); // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff || m_Scroll is BaseJewel || m_Scroll is BaseStationary) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendAsciiMessage( "You can not cast a spell while frozen." ); // You can not cast a spell while frozen.
            }
            else if ( CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime )
            {
                m_Caster.SendAsciiMessage( "You have not yet recovered from casting a spell." ); // You have not yet recovered from casting a spell.
            }
            else if (!(m_Scroll is BaseJewel) && (m_Caster.FindItemOnLayer(Layer.OneHanded) != null && !(m_Caster.FindItemOnLayer(Layer.OneHanded) is Spellbook) && !(m_Scroll is BaseWand)) || (m_Caster.FindItemOnLayer(Layer.TwoHanded) != null && (!(m_Caster.FindItemOnLayer(Layer.TwoHanded) is OrderShield) && !(m_Scroll is GnarledStaff) && !(m_Caster.FindItemOnLayer(Layer.TwoHanded) is ChaosShield))))
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Your hands must be free to cast spells.");
                //m_Caster.SendAsciiMessage("Your hands must be free to cast spells.");
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                        m_Caster.RevealingAction();

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling( castDelay.TotalSeconds );//(int)Math.Ceiling( castDelay.TotalSeconds / ( AnimateDelay.TotalSeconds ) );

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);

                        if (m_Info.RightHandEffect > 0)
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                    }

                    if (ClearHandsOnCast)
                        m_Caster.ClearHands();

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, true, "Insufficient mana for this spell."); // Insufficient mana
            }

            return false;
        }
Esempio n. 56
0
	private void win() {
		Debug.Log (Name + ": YOU WIN!" + "Elapsed: " + numTicksElapsed);
		if (WinSound != null) {
			WinSound.Play ();
		}

		ShowWinAnimation (true);

		ShowWetGround (true);

		CenterObjectWin ();

		//winBox.SetActive (true);
		//winBox.GetComponent<Renderer>().enabled = true;

		state = SpellState.Win;
		endSpell ();
	}
Esempio n. 57
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if ( m_Caster.Spell == this )
                m_Caster.Spell = null;
        }
Esempio n. 58
0
		public bool Cast()
		{
			m_StartCastTime = DateTime.UtcNow;

			if (!m_Caster.CheckAlive())
			{
				return false;
			}
			else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
			{
				m_Caster.SendLocalizedMessage(502642); // You are already casting a spell.
			}
			else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && (m_Caster.Paralyzed || m_Caster.Frozen))
			{
				m_Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen.
			}
			else if (CheckNextSpellTime && DateTime.UtcNow < m_Caster.NextSpellTime)
			{
				m_Caster.SendLocalizedMessage(502644); // You have not yet recovered from casting a spell.
			}
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
			{
				m_Caster.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed.
			}
				#region Dueling
			else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
					 !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
			{ }
				#endregion

			else if (m_Caster.Mana >= ScaleMana(GetMana()))
			{
				if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast())
				{
					if (XmlScript.HasTrigger(m_Caster, TriggerName.onBeginCast) &&
						UberScriptTriggers.Trigger(m_Caster, m_Caster, TriggerName.onBeginCast, null, null, this))
					{
						return false;
					}
					else if (m_Caster.Region.OnBeginSpellCast(m_Caster, this))
					{
						m_State = SpellState.Casting;
						m_Caster.Spell = this;

						if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && RevealOnCast)
						{
							m_Caster.RevealingAction();
						}

						SayMantra();

						TimeSpan castDelay = GetCastDelay();
						var count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);
						if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
						{
							if (count != 0)
							{
								m_AnimTimer = new AnimTimer(this, count);
								m_AnimTimer.Start();
							}

							if (m_Info.LeftHandEffect > 0)
							{
								Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
							}

							if (m_Info.RightHandEffect > 0)
							{
								Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
							}
						}
							//BaseCreature Animations For Casting
						else if (m_Caster is BaseCreature)
						{
							if (count != 0 && Utility.Random(3) == 0 || (!m_Caster.Deleted && m_Caster.NetState != null))
								// 1 in 3 chance that they do the animation
							{
								m_AnimTimer = new AnimTimer(this, count);
								m_AnimTimer.Start();
							}
						}

						if (ClearHandsOnCast)
						{
							m_Caster.ClearHands();
						}

						if (m_Caster.EraML)
						{
							WeaponAbility.ClearCurrentAbility(m_Caster);
						}

						m_CastTimer = new CastTimer(this, castDelay);
						m_CastTimer.Start();

						OnBeginCast();

						return true;
					}
				}
				return false;
			}
			else
			{
				m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625); // Insufficient mana
			}

			return false;
		}
Esempio n. 59
0
        public virtual void FinishSequence()
        {
            m_State = SpellState.None;

            if( m_Caster.Spell == this )
            {
                m_Caster.Spell = null;

                if( m_Caster.Player )
                {
                    EventDispatcher.InvokeSpellFinished(new SpellEventArgs((Player)m_Caster, this));
                }
            }
        }
Esempio n. 60
0
        /**
         * Called every diff milliseconds to update the spell
         */
        public virtual void update(long diff)
        {
            switch (state)
            {
                case SpellState.STATE_READY:
                    return;
                case SpellState.STATE_CASTING:

                    currentCastTime -= diff / 1000.0f;
                    if (currentCastTime <= 0)
                    {
                        finishCasting();
                    }
                    break;
                case SpellState.STATE_COOLDOWN:
                    currentCooldown -= diff / 1000.0f;
                    if (currentCooldown < 0)
                    {
                        state = SpellState.STATE_READY;
                    }
                    break;
            }
        }