CatShaman.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class CatShaman : MonsterObject
  6. {
  7. protected virtual byte AttackRange
  8. {
  9. get
  10. {
  11. return 6;
  12. }
  13. }
  14. protected internal CatShaman(MonsterInfo info)
  15. : base(info)
  16. {
  17. }
  18. protected override bool InAttackRange()
  19. {
  20. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  21. }
  22. protected override void Attack()
  23. {
  24. if (!Target.IsAttackTarget(this))
  25. {
  26. Target = null;
  27. return;
  28. }
  29. ShockTime = 0;
  30. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  31. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  32. ActionTime = Envir.Time + 300;
  33. AttackTime = Envir.Time + AttackSpeed;
  34. if (!ranged)
  35. {
  36. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  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. if (Envir.Random.Next(5) > 0)
  45. {
  46. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  47. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  48. if (damage == 0) return;
  49. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MACAgility, false);
  50. ActionList.Add(action);
  51. }
  52. else
  53. {
  54. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  55. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  56. if (damage == 0) return;
  57. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MACAgility, true);
  58. ActionList.Add(action);
  59. }
  60. }
  61. }
  62. protected override void CompleteRangeAttack(IList<object> data)
  63. {
  64. MapObject target = (MapObject)data[0];
  65. int damage = (int)data[1];
  66. DefenceType defence = (DefenceType)data[2];
  67. bool poison = (bool)data[3];
  68. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  69. var finalDamage = target.Attacked(this, damage, defence);
  70. if (poison && finalDamage > 0)
  71. {
  72. PoisonTarget(target, 5, 5, PoisonType.Red, 1000);
  73. }
  74. }
  75. protected override void ProcessTarget()
  76. {
  77. if (Target == null) return;
  78. if (InAttackRange() && CanAttack)
  79. {
  80. Attack();
  81. return;
  82. }
  83. if (Envir.Time < ShockTime)
  84. {
  85. Target = null;
  86. return;
  87. }
  88. MoveTo(Target.CurrentLocation);
  89. }
  90. }
  91. }