private bool AllowCast()
        {
            AbilityResult myResult = AbilityResult.ABILITYRESULT_OK;

            if (AbInfo.Target != null)
            {
                if (AbInfo.Target.IsDead && !AbInfo.ConstantInfo.AffectsDead)
                {
                    myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_DEAD;
                }
                else if (!AbInfo.Target.IsDead && AbInfo.ConstantInfo.AffectsDead)
                {
                    myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_NOT_DEAD_ALLY;
                }

                else if (AbInfo.Target != _caster)
                {
                    if (AbInfo.ConstantInfo.CastAngle != 0 && _caster.IsMoving && !_caster.IsObjectInFront(AbInfo.Target, AbInfo.ConstantInfo.CastAngle))
                    {
                        myResult = AbilityResult.ABILITYRESULT_OUT_OF_ARC;
                    }

                    // Explicit LOS check for move-cast abilities
                    if (AbInfo.CastTime > 0 && AbInfo.CanCastWhileMoving && AbInfo.Target != null && !_caster.LOSHit(AbInfo.Target))
                    {
                        myResult = AbilityResult.ABILITYRESULT_NOT_VISIBLE;
                    }
                }
            }

            if (myResult != AbilityResult.ABILITYRESULT_OK)
            {
                CancelCast((ushort)myResult);
                return(false);
            }

            if (myResult == AbilityResult.ABILITYRESULT_OK && _caster.ItmInterface != null)
            {
                myResult = _caster.ItmInterface.WeaponCheck(AbInfo.ConstantInfo.WeaponNeeded);
            }

            if (AbInfo.ApCost > 0 && _caster is Player && !_caster.ConsumeActionPoints(AbInfo.ApCost))
            {
                myResult = AbilityResult.ABILITYRESULT_AP;
            }

            if (myResult != AbilityResult.ABILITYRESULT_OK)
            {
                CancelCast((ushort)myResult);
                return(false);
            }

            AbilityMgr.GetCommandsFor(_caster, AbInfo);

            return(true);
        }