/// <summary>
        /// Action
        /// </summary>
        /// <param name="living"></param>
        public override void Execute(GameLiving living)
        {
            if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED))
            {
                return;
            }
            InventoryItem shield = living.Inventory.GetItem(eInventorySlot.LeftHandWeapon);

            if (shield == null)
            {
                return;
            }
            if (shield.Object_Type != (int)eObjectType.Shield)
            {
                return;
            }
            if (living.TargetObject == null)
            {
                return;
            }
            if (living.ActiveWeaponSlot == GameLiving.eActiveWeaponSlot.Distance)
            {
                return;
            }
            if (living.AttackWeapon == null)
            {
                return;
            }
            if (living.AttackWeapon.Hand == 1)
            {
                return;
            }
            GameLiving target = (GameLiving)living.TargetObject;

            if (target == null)
            {
                return;
            }
            if (!GameServer.ServerRules.IsAllowedToAttack(living, target, false))
            {
                return;
            }
            if (!living.IsWithinRadius(target, 1000))
            {
                return;
            }
            new ShieldTripRootEffect().Start(target);

            GamePlayer player = living as GamePlayer;

            if (player != null)
            {
                SendCasterSpellEffectAndCastMessage(player, 7046, true);
                ShieldTripDisarmEffect effect = new ShieldTripDisarmEffect();
                effect.Start(player);
            }
            DisableSkill(living);
        }
Exemple #2
0
		public override bool CheckBeginCast(GameLiving selectedTarget)
		{
			if (m_caster.ObjectState != GameLiving.eObjectState.Active)	return false;
			if (!m_caster.IsAlive)
			{
				MessageToCaster("You are dead and can't cast!", eChatType.CT_System);
				return false;
			}
			
			// Is PS ?
			GameSpellEffect Phaseshift = SpellHandler.FindEffectOnTarget(Caster, "Phaseshift");
			if (Phaseshift != null && (Spell.InstrumentRequirement == 0 || Spell.SpellType == "Mesmerize"))
			{
				MessageToCaster("You're phaseshifted and can't cast a spell", eChatType.CT_System);
				return false;
			}

			// Is Shield Disarm ?
			ShieldTripDisarmEffect shieldDisarm = Caster.EffectList.GetOfType<ShieldTripDisarmEffect>();
			if (shieldDisarm != null)
			{
				MessageToCaster("You're disarmed and can't cast a spell", eChatType.CT_System);
				return false;
			}

			// Is Mentalist RA5L ?
			SelectiveBlindnessEffect SelectiveBlindness = Caster.EffectList.GetOfType<SelectiveBlindnessEffect>();
			if (SelectiveBlindness != null)
			{
				GameLiving EffectOwner = SelectiveBlindness.EffectSource;
				if(EffectOwner==selectedTarget)
				{
					if (m_caster is GamePlayer)
						((GamePlayer)m_caster).Out.SendMessage(string.Format("{0} is invisible to you!", selectedTarget.GetName(0, true)), eChatType.CT_Missed, eChatLoc.CL_SystemWindow);
					
					return false;
				}
			}
			
			// Is immune ?
			if (selectedTarget!=null&&selectedTarget.HasAbility("DamageImmunity"))
			{
				MessageToCaster(selectedTarget.Name + " is immune to this effect!", eChatType.CT_SpellResisted);
				return false;
			}
			
			if (m_caster.IsSitting)
			{
				MessageToCaster("You can't cast while sitting!", eChatType.CT_SpellResisted);
				return false;
			}
			if (m_spell.RecastDelay > 0)
			{
				int left = m_caster.GetSkillDisabledDuration(m_spell);
				if (left > 0)
				{
					MessageToCaster("You must wait " + (left / 1000 + 1).ToString() + " seconds to use this spell!", eChatType.CT_System);
					return false;
				}
			}
			String targetType = m_spell.Target.ToLower();
			if (targetType == "area")
			{
				if (!m_caster.IsWithinRadius(m_caster.GroundTarget, CalculateSpellRange()))
				{
					MessageToCaster("Your area target is out of range.  Select a closer target.", eChatType.CT_SpellResisted);
					return false;
				}
			}

			if (targetType == "enemy")
			{
				if (m_caster.IsObjectInFront(selectedTarget, 180) == false)
				{
					MessageToCaster("Your target is not in view!", eChatType.CT_SpellResisted);
					Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView));
					return false;
				}

				if (m_caster.TargetInView == false)
				{
					MessageToCaster("Your target is not visible!", eChatType.CT_SpellResisted);
					Caster.Notify(GameLivingEvent.CastFailed, new CastFailedEventArgs(this, CastFailedEventArgs.Reasons.TargetNotInView));
					return false;
				}
			}
			
			if (Caster != null && Caster is GamePlayer && Caster.AttackWeapon != null && GlobalConstants.IsBowWeapon((eObjectType)Caster.AttackWeapon.Object_Type))
			{
				if (Spell.LifeDrainReturn == (int)eShotType.Critical && (!(Caster.IsStealthed)))
				{
					MessageToCaster("You must be stealthed and wielding a bow to use this ability!", eChatType.CT_SpellResisted);
					return false;
				}

				return true;
			}
			else
			{
				if (Spell.LifeDrainReturn == (int)eShotType.Critical)
				{
					MessageToCaster("You must be stealthed and wielding a bow to use this ability!", eChatType.CT_SpellResisted);
					return false;
				}

				MessageToCaster("You must be wielding a bow to use this ability!", eChatType.CT_SpellResisted);
				return false;
			}
		}