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); } }
private void ProcessSkill(Creature creature, List <UseSkillArgs> argsList, Skill skill) { creature.Attack = new Attack(creature, argsList[0], () => GlobalLogic.AttackStageEnd(creature), () => GlobalLogic.AttackFinished(creature)); VisibleService.Send(creature, new SpAttack(creature, creature.Attack)); VisibleService.Send(creature, new SpAttackDestination(creature, creature.Attack)); ProcessStages(creature, skill); ProcessMove(creature, skill); AiLogic.OnUseSkill(creature, skill); ProcessTargets(creature, skill); }
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); } }
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); } }