コード例 #1
0
        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);
        }
コード例 #2
0
 public void Update(long tick)
 {
     if (TCPManager.GetTimeStampMS() >= _channelStartTime + _channelInfo.CastTime)
     {
         SendChannelEnd();
         _parent.NotifyChannelEnded();
         _channelInfo = null;
         _channelBuff = null;
     }
     else if (TCPManager.GetTimeStampMS() >= _nextTickTime)
     {
         if (_channelInfo.ApCost > 0 && !_host.ConsumeActionPoints(_channelInfo.ApCost))
         {
             _parent.CancelCast((byte)GameData.AbilityResult.ABILITYRESULT_AP);
         }
         else if (_playerHost != null && _channelInfo.SpecialCost > 3 && !_playerHost.CrrInterface.ConsumeResource((byte)_channelInfo.SpecialCost, true))
         {
             _parent.CancelCast(1);
         }
         else if (_target != _host && !_host.IsInCastRange(_target, Math.Max((uint)25, _channelInfo.Range)))
         {
             _parent.CancelCast((byte)GameData.AbilityResult.ABILITYRESULT_OUTOFRANGE);
         }
         else if (_checkVisibility && !_host.LOSHit(_target))
         {
             _parent.CancelCast((byte)GameData.AbilityResult.ABILITYRESULT_NOT_VISIBLE);
         }
         else
         {
             _nextTickTime += 1000;
         }
     }
 }