TreeGuardian.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class TreeGuardian : MonsterObject
  7. {
  8. protected virtual int AttackRange
  9. {
  10. get { return 6; }
  11. }
  12. protected internal TreeGuardian(MonsterInfo info)
  13. : base(info)
  14. {
  15. }
  16. protected override bool InAttackRange()
  17. {
  18. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  19. }
  20. protected override void Attack()
  21. {
  22. if (!Target.IsAttackTarget(this))
  23. {
  24. Target = null;
  25. return;
  26. }
  27. ShockTime = 0;
  28. ActionTime = Envir.Time + 300;
  29. AttackTime = Envir.Time + AttackSpeed;
  30. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  31. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  32. if (!ranged)
  33. {
  34. if (Envir.Random.Next(3) > 0)
  35. {
  36. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  37. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  38. if (damage == 0) return;
  39. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  40. ActionList.Add(action);
  41. }
  42. else
  43. {
  44. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  45. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  46. if (damage == 0) return;
  47. FullmoonAttack(damage);
  48. }
  49. }
  50. else
  51. {
  52. if (Envir.Random.Next(3) > 0)
  53. {
  54. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  55. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  56. if (damage == 0) return;
  57. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility);
  58. ActionList.Add(action);
  59. }
  60. else
  61. {
  62. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  63. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]) * 2;
  64. if (damage == 0) return;
  65. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility);
  66. ActionList.Add(action);
  67. }
  68. }
  69. }
  70. }
  71. }