Esempio n. 1
0
        /// <summary>
        /// Fire bolt
        /// </summary>
        /// <param name="target"></param>
        public override void FinishSpellCast(GameLiving target)
        {
            m_caster.Mana -= PowerCost(target);

            // endurance
            m_caster.Endurance -= 5;

            // messages
            GamePlayer caster = (GamePlayer)m_caster;

            if (Spell.InstrumentRequirement == 0)
            {
                if (SecondarySpell == null && PrimarySpell == null)
                {
                    MessageToCaster("No spells were loaded into " + m_spell.Name + ".", eChatType.CT_Spell);
                }
                else
                {
                    MessageToCaster("Your " + m_spell.Name + " is ready for use.", eChatType.CT_Spell);
                    //StartSpell(target); // and action
                    GameSpellEffect neweffect = CreateSpellEffect(target, 1);
                    neweffect.Start(m_caster);
                    SendEffectAnimation(m_caster, 0, false, 1);
                    ((GamePlayer)m_caster).Out.SendWarlockChamberEffect((GamePlayer)m_caster);
                }

                foreach (GamePlayer player in m_caster.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
                {
                    if (player != m_caster)
                    {
                        player.MessageFromArea(m_caster, m_caster.GetName(0, true) + " casts a spell!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
                    }
                }
            }

            //the quick cast is unallowed whenever you miss the spell
            //set the time when casting to can not quickcast during a minimum time
            if (m_caster is GamePlayer)
            {
                QuickCastEffect quickcast = m_caster.EffectList.GetOfType <QuickCastEffect>();
                if (quickcast != null && Spell.CastTime > 0)
                {
                    m_caster.TempProperties.setProperty(GamePlayer.QUICK_CAST_CHANGE_TICK, m_caster.CurrentRegion.Time);
                    m_caster.DisableSkill(SkillBase.GetAbility(Abilities.Quickcast), QuickCastAbilityHandler.DISABLE_DURATION);
                    quickcast.Cancel(false);
                }
            }
        }
        /// <summary>
        /// Executes the ability
        /// </summary>
        /// <param name="ab">The used ability</param>
        /// <param name="player">The player that used the ability</param>
        public void Execute(Ability ab, GamePlayer player)
        {
            // Cannot change QC state if already casting a spell (can't turn it off!)
            if (player.CurrentSpellHandler != null)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.QuickCast.CannotUseIsCasting"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            QuickCastEffect quickcast = player.EffectList.GetOfType <QuickCastEffect>();

            if (quickcast != null)
            {
                quickcast.Cancel(false);
                return;
            }

            // Dead can't quick cast
            if (!player.IsAlive)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.QuickCast.CannotUseDead"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            // Can't quick cast if in attack mode
            if (player.AttackState)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.QuickCast.CannotUseInMeleeCombat"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            long quickcastChangeTick = player.TempProperties.getProperty <long>(GamePlayer.QUICK_CAST_CHANGE_TICK);
            long changeTime          = player.CurrentRegion.Time - quickcastChangeTick;

            if (changeTime < DISABLE_DURATION)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Skill.Ability.QuickCast.CannotUseChangeTick", ((DISABLE_DURATION - changeTime) / 1000)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                //30 sec is time between 2 quick cast
                return;
            }

            //TODO: more checks in this order

            //player.DisableSkill(ab,DURATION / 10);

            new QuickCastEffect().Start(player);
        }