コード例 #1
0
        private SkillAttackResult CalcAttackResult(ActorExt sActor, ActorExt dActor, bool ignoreRange, int maxRange)
        {
            if (dActor.Status.Invincible)
            {
                return(SkillAttackResult.Miss);
            }

            if (sActor.DistanceToActor(dActor) > maxRange && !ignoreRange)
            {
                return(SkillAttackResult.Miss);
            }

            int angDif = Math.Abs(sActor.Dir - dActor.Dir);

            if (dActor.Status.Blocking && angDif >= 90)
            {
                return(SkillAttackResult.TotalParry);
            }

            if (dActor.Status.Counter && angDif >= 90)
            {
                return(SkillAttackResult.Counter);
            }

            if (dActor.Status.Dummy)
            {
                return(SkillAttackResult.Counter);
            }

            if (Global.Random.Next(0, 99) <= 95 || dActor.Status.Down)
            {
                int random = Global.Random.Next(0, 99);
                if (random <= 15)
                {
                    return(SkillAttackResult.Critical);
                }
                else if (random <= 18 && !dActor.Status.Down)
                {
                    return(SkillAttackResult.Avoid);
                }
                else if (random <= 20 && !dActor.Status.Down)
                {
                    return(SkillAttackResult.Parry);
                }
                else
                {
                    return(SkillAttackResult.Normal);
                }
            }
            else
            {
                return(SkillAttackResult.Miss);
            }
        }
コード例 #2
0
        public bool CheckSkillCast(ActorExt sActor, ActorExt dActor, ushort dir, Skill skill)
        {
            DateTime now = DateTime.Now;

            if (now < sActor.Status.SkillCooldownEnd || now < skill.CoolDownEndTime)
            {
                return(false);
            }

            if (skill.BaseData.PreviousSkills.Count > 0 && !skill.BaseData.PreviousSkills.Contains(sActor.Status.LastSkillID))
            {
                return(false);
            }
            switch (skill.BaseData.RequiredCasterStance)
            {
            case SkillCastStances.None:
                if (sActor.Status.Dead || sActor.Status.Down || sActor.Status.TakeDown)
                {
                    return(false);
                }

                break;

            case SkillCastStances.TakeDown:
                if (!sActor.Status.TakeDown)
                {
                    return(false);
                }

                break;

            default:
                return(false);
            }
            if (dActor != null)
            {
                if (NPC.FactionRelationFactory.Instance[sActor.Faction][dActor.Faction] == Relations.Friendly && sActor != dActor)
                {
                    return(false);
                }

                switch (skill.BaseData.RequiredTargetStance)
                {
                case SkillCastStances.Down:
                    if (!dActor.Status.Down || sActor.Status.TakeDown)
                    {
                        return(false);
                    }

                    break;

                case SkillCastStances.NoMove:
                    if (!dActor.Status.Down && !dActor.Status.Frosen && !dActor.Status.Stun)
                    {
                        return(false);
                    }

                    break;
                }
            }
            switch (skill.BaseData.SkillType)
            {
            case SkillType.Single:
            {
                int dist = sActor.DistanceToActor(dActor);
                if (dist >= skill.BaseData.CastRangeMin && dist <= skill.BaseData.CastRangeMax)
                {
                    return(CheckMana(sActor, skill));
                }
                else
                {
                    return(false);
                }
            }

            case SkillType.Self:
                if (sActor == dActor)
                {
                    return(CheckMana(sActor, skill));
                }
                else
                {
                    return(true);
                }

            case SkillType.Direction:
            case SkillType.NoTarget:
                return(CheckMana(sActor, skill));

            default:
                return(false);
            }
        }