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

            ProcessSkill(player, args, skill);
        }
Esempio n. 2
0
        public override void Process()
        {
            UseSkillArgs Args = new UseSkillArgs();
            Args.SkillId = SkillId;

            Global.Global.SkillEngine.UseSkill(Connection, Args);
        }
Esempio n. 3
0
        public Attack(Creature.Creature creature, UseSkillArgs args, Action onStageEnd, Action onFinish)
        {
            if (creature.Attack != null)
                creature.Attack.Release();

            Args = args;

            Creature = creature;
            OnStageEnd = onStageEnd;
            OnFinish = onFinish;
        }
Esempio n. 4
0
        private void ProcessAttack(Creature creature, UseSkillArgs args, int time)
        {
            try
            {
                Creature target = creature.Target;

                if (target == null || creature.LifeStats.IsDead())
                    return;

                if (!target.LifeStats.IsDead())
                {
                    creature.Attack = new Attack(creature,
                                             args,
                                             () => GlobalLogic.AttackStageEnd(creature),
                                             () => GlobalLogic.AttackFinished(creature));

                    int damage = SeUtils.CalculateDefaultAttackDamage(creature, target, creature.GameStats.Attack);

                    Player player = creature as Player;
                    if (player != null)
                        VisibleService.Send(player, new SpAttack(player, player.Attack));

                    Npc npc = creature as Npc;
                    if (npc != null)
                        VisibleService.Send(npc, new SpNpcAttack(npc, npc.Attack));

                    target.LifeStats.MinusHp(damage);

                    AiLogic.OnAttack(creature, target);
                    AiLogic.OnAttacked(target, creature, damage);

                    if (target is Player)
                        (target as Player).LifeStats.PlusSp(damage);

                    new DelayedAction(creature
                        .Attack
                        .NextStage, time);

                    return;
                }

                new DelayedAction(creature
                    .Attack
                    .Finish, time);
            }
            catch (Exception ex)
            {
                Log.ErrorException("ProcessAttack:", ex);
            }
        }
 public static void UseSkill(IConnection connection, UseSkillArgs args)
 {
     SkillEngine.UseSkill(connection, args);
 }
Esempio n. 6
0
        private void ProcessSkill(Creature creature, UseSkillArgs args, Skill skill, int time)
        {
            try
            {
                Player player = creature as Player;
                Creature target = creature.Target;

                if (target == null || creature.LifeStats.IsDead())
                    return;

                if (creature.LifeStats.Mp < skill.ManaCost)
                    if (player != null)
                        new SpPlayerSetSpell(args.SkillId, 2, 0).Send(player);

                if (!target.LifeStats.IsDead())
                {
                    creature.Attack = new Attack(creature,
                                             args,
                                             () => GlobalLogic.AttackStageEnd(creature),
                                             () => GlobalLogic.AttackFinished(creature));

                    int damage = SeUtils.CalculateSkillAttackDamage(creature, target, skill);

                    if (player != null)
                        VisibleService.Send(player, new SpAttack(player, player.Attack));

                    Npc npc = creature as Npc;
                    if (npc != null)
                        VisibleService.Send(npc, new SpNpcAttack(npc, npc.Attack));

                    switch (skill.Type)
                    {
                        case 2:

                            break;
                        case 3:

                            break;
                        default:
                            creature.LifeStats.MinusMp(skill.ManaCost);
                            break;
                    }

                    target.LifeStats.MinusHp(damage);

                    AiLogic.OnAttack(creature, target);
                    AiLogic.OnAttacked(target, creature, damage);

                    if (target is Player)
                        (target as Player).LifeStats.PlusSp(damage);

                    new DelayedAction(creature
                        .Attack
                        .NextStage, time);

                    return;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorException("ProcessSkill:", ex);
            }
        }
Esempio n. 7
0
        private void ProcessSkill(Creature creature, UseSkillArgs args, Skill skill)
        {
            Creature target = creature.Target;

            if (args.SkillId != 0 && skill == null)
            {
                Player p = creature as Player;

                if (args.SkillId == 1)
                    p.PlayerMode = PlayerMode.Relax;

                if (p != null)
                    VisibleService.Send(p, new SpPlayerSetSpell(args.SkillId, 1, 1));
            }
            else if (skill != null)
            {
                ProcessSkill(creature, args, skill, 0);
            }
            else
            {
                int time = (creature is Player) ? 1200 : 2000;
                ProcessAttack(creature, args, time);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        private void ProcessSkill(Creature creature, UseSkillArgs args, Skill skill, Projectile projectile = null)
        {
            bool isProjectileSkill = skill.Type == SkillType.Projectile || skill.Type == SkillType.Userslug;

            if (!isProjectileSkill)
            {
                if (skill.ChargingStageList == null || skill.ChargingStageList.ChargeStageList.Count == 0)
                {
                    if (skill.Precondition.Cost.Hp > 0)
                        CreatureLogic.HpChanged(creature, creature.LifeStats.MinusHp(skill.Precondition.Cost.Hp));

                    if (skill.Precondition.Cost.Mp > 0)
                        CreatureLogic.MpChanged(creature, creature.LifeStats.MinusMp(skill.Precondition.Cost.Mp));
                }

                if (!args.IsDelaySkill || args.IsDelayStart)
                {
                    if (args.TargetPosition.IsNull())
                    {
                        double angle = args.StartPosition.Heading*Math.PI/32768;

                        args.StartPosition.CopyTo(args.TargetPosition);

                        args.TargetPosition.X += 100*(float) Math.Cos(angle);
                        args.TargetPosition.Y += 100*(float) Math.Sin(angle);
                    }

                    // ReSharper disable ImplicitlyCapturedClosure
                    creature.Attack = new Attack(creature,
                                                 args,
                                                 () => GlobalLogic.AttackStageEnd(creature),
                                                 () => GlobalLogic.AttackFinished(creature));
                    // ReSharper restore ImplicitlyCapturedClosure

                    VisibleService.Send(creature, new SpAttack(creature, creature.Attack));

                    VisibleService.Send(creature, new SpAttackDestination(creature, creature.Attack));

                    if (!args.IsDelaySkill)
                        ProcessStages(creature, skill);
                    else
                    {
                        Player player = creature as Player;
                        if (player != null && skill.BaseId == 20100 &&
                            (player.PlayerData.Class == PlayerClass.Berserker
                            || player.PlayerData.Class == PlayerClass.Lancer))
                        {
                            player.EffectsImpact.ResetChanges(player); //Set IsBlockFrontAttacks
                        }
                    }

                    ProcessMove(creature, skill);
                }
            }
            else
            {
                creature.Attack.Args.IsTargetAttack = args.IsTargetAttack;
                creature.Attack.Args.Targets = args.Targets;

                ProcessProjectileTargets(creature, skill, projectile);
            }

            AiLogic.OnUseSkill(creature, skill);

            if (skill.ChargingStageList != null)
            {
                if (args.IsDelayStart)
                {
                    int uid = creature.Attack.UID;

                    ThreadPool.QueueUserWorkItem(
                        o =>
                            {
                                Thread.Sleep(750);

                                for (int i = 1; i < skill.ChargingStageList.ChargeStageList.Count; i++)
                                {
                                    if (creature.Attack.UID != uid)
                                        return;

                                    creature.Attack.NextStage();

                                    if (i != 3)
                                        Thread.Sleep(750);
                                }
                            });
                }
            }
            else
                ProcessTargets(creature, skill);
        }
Esempio n. 10
0
        public override void Release()
        {
            base.Release();

            if (Creature == null)
                return;

            if (Args != null)
                Args.Release();
            Args = null;

            Creature = null;
            OnStageEnd = null;
            OnFinish = null;
        }