Пример #1
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);
            }
        }
Пример #2
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.CalculateDefaultAttackDamage(creature, target, creature.GameStats.Attack);

                    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);
            }
        }