DarkDevil.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class DarkDevil : MonsterObject
  7. {
  8. private long _areaTime;
  9. protected internal DarkDevil(MonsterInfo info) : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. if (Target.CurrentLocation == CurrentLocation) return false;
  16. return Functions.InRange(CurrentLocation, Target.CurrentLocation, Envir.Time > _areaTime ? 3 : 1);
  17. }
  18. protected override void Attack()
  19. {
  20. if (!Target.IsAttackTarget(this))
  21. {
  22. Target = null;
  23. return;
  24. }
  25. if (Envir.Time < _areaTime)
  26. {
  27. base.Attack();
  28. return;
  29. }
  30. _areaTime = Envir.Time + 2000 + Envir.Random.Next(3)*1000;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  33. ActionList.Add(new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500));
  34. ActionTime = Envir.Time + 300;
  35. AttackTime = Envir.Time + AttackSpeed;
  36. ShockTime = 0;
  37. }
  38. protected override void CompleteRangeAttack(IList<object> data)
  39. {
  40. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 3;
  41. if (damage == 0) return;
  42. List<MapObject> targets = FindAllTargets(1, Functions.PointMove(CurrentLocation, Direction, 2));
  43. if (targets.Count == 0) return;
  44. for (int i = 0; i < targets.Count; i++)
  45. {
  46. targets[i].Attacked(this, damage, DefenceType.MACAgility);
  47. }
  48. }
  49. }
  50. }