示例#1
0
        public void UseSkill(IConnection connection, UseSkillArgs args)
        {
            Player player = connection.Player;
            Skill  skill  = args.GetSkill(player);

            ProcessSkill(player, args, skill);
        }
示例#2
0
        public void UseSkill(IConnection connection, UseSkillArgs args)
        {
            Player player = connection.Player;
            Skill  skill  = args.GetSkill(player);

            if (skill == null)
            {
                return;
            }

            if (skill.ChargingStageList != null)
            {
                args.IsChargeSkill = true;
            }

            if (skill.Type == SkillType.Mount)
            {
                MountService.ProcessMount(player, skill.Id);
                new SpSkillCooldown(skill.Id, skill.Precondition.CoolTime).Send(player.Connection);
                return;
            }

            if (player.Attack != null && !player.Attack.IsFinished)
            {
                if (player.Attack.Args.IsDelaySkill)
                {
                    int stage = player.Attack.Stage;

                    if (player.Attack.Args.IsChargeSkill)
                    {
                        skill = player.Attack.Args.GetSkill(player);

                        if (skill.ChargingStageList != null && skill.ChargingStageList.ChargeStageList.Count > stage)
                        {
                            int useHp = (int)(skill.ChargingStageList.CostTotalHp *
                                              skill.ChargingStageList.ChargeStageList[stage].CostHpRate);

                            int useMp = (int)(skill.ChargingStageList.CostTotalMp *
                                              skill.ChargingStageList.ChargeStageList[stage].CostMpRate);

                            if (player.LifeStats.Hp <= useHp)
                            {
                                SystemMessages.YouCannotUseThatSkillAtTheMoment.Send(player.Connection);
                                stage = -1;
                            }
                            else if (player.LifeStats.Mp < useMp)
                            {
                                SystemMessages.NotEnoughMp.Send(player.Connection);
                                stage = -1;
                            }
                            else
                            {
                                if (useHp > 0)
                                {
                                    CreatureLogic.HpChanged(player, player.LifeStats.MinusHp(useHp));
                                }

                                if (useMp > 0)
                                {
                                    CreatureLogic.MpChanged(player, player.LifeStats.MinusMp(useMp));
                                }

                                args = new UseSkillArgs
                                {
                                    SkillId        = player.Attack.Args.SkillId + 10 + stage,
                                    StartPosition  = player.Position.Clone(),
                                    TargetPosition = player.Attack.Args.TargetPosition,
                                };
                            }
                        }
                        else
                        {
                            stage = -1;
                        }
                    }

                    player.Attack.Finish();

                    if (skill.BaseId == 20100 &&
                        (player.PlayerData.Class == PlayerClass.Berserker ||
                         player.PlayerData.Class == PlayerClass.Lancer))
                    {
                        player.EffectsImpact.ResetChanges(player); //Set IsBlockFrontAttacks
                    }

                    if (player.Attack.Args.IsChargeSkill && stage != -1)
                    {
                        UseSkill(connection, args);
                    }

                    return;
                }

                if (args.SkillId / 10000 == player.Attack.Args.SkillId / 10000)
                {
                    player.Attack.Finish();

                    if (player.Attack.Args.Targets.Count == 0)
                    {
                        return;
                    }

                    args.Targets = new List <Creature>(player.Attack.Args.Targets);
                    ProcessSkill(player, args, skill);
                }

                return;
            }

            if (!CheckRequirements(player, skill))
            {
                return;
            }

            args.StartPosition.CopyTo(player.Position);

            ProcessSkill(player, args, skill);
        }