HardenRhino.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class HardenRhino : MonsterObject
  7. {
  8. protected internal HardenRhino(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. return Target.CurrentLocation != CurrentLocation && Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  16. }
  17. protected override void ProcessSearch()
  18. {
  19. if (Envir.Time < SearchTime) return;
  20. if (Master != null && (Master.PMode == PetMode.MoveOnly || Master.PMode == PetMode.None || Master.PMode == PetMode.FocusMasterTarget)) return;
  21. SearchTime = Envir.Time + SearchDelay;
  22. if (Target == null || Envir.Random.Next(3) == 0)
  23. FindTarget();
  24. if (Target != null && !Functions.InRange(CurrentLocation, Target.CurrentLocation, 3) && Envir.Random.Next(3) == 0)
  25. {
  26. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  27. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  28. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 1500, Target);
  29. ActionList.Add(action);
  30. ActionTime = Envir.Time + 1500;
  31. MoveTime = Envir.Time + 1500;
  32. }
  33. }
  34. protected override void Attack()
  35. {
  36. if (!Target.IsAttackTarget(this))
  37. {
  38. Target = null;
  39. return;
  40. }
  41. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  42. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  43. ShockTime = 0;
  44. ActionTime = Envir.Time + 300;
  45. AttackTime = Envir.Time + AttackSpeed;
  46. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  47. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  48. if (damage == 0) return;
  49. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility);
  50. ActionList.Add(action);
  51. }
  52. protected override void CompleteRangeAttack(IList<object> data)
  53. {
  54. MapObject target = (MapObject)data[0];
  55. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  56. Dash(target);
  57. MoveTo(target.CurrentLocation);
  58. ActionTime = Envir.Time + 300;
  59. }
  60. private void Dash(MapObject target)
  61. {
  62. var dist = Functions.MaxDistance(CurrentLocation, target.CurrentLocation);
  63. var travelled = 0;
  64. if (dist > 2)
  65. {
  66. var location = CurrentLocation;
  67. for (int i = 0; i < dist; i += 2)
  68. {
  69. if (Functions.MaxDistance(CurrentLocation, target.CurrentLocation) <= 2) break;
  70. Direction = Functions.DirectionFromPoint(CurrentLocation, target.CurrentLocation);
  71. location = Functions.PointMove(location, Direction, 2);
  72. if (!CurrentMap.ValidPoint(location)) break;
  73. CurrentMap.GetCell(CurrentLocation).Remove(this);
  74. RemoveObjects(Direction, 1);
  75. CurrentLocation = location;
  76. travelled++;
  77. Broadcast(new S.ObjectRun { ObjectID = ObjectID, Direction = Direction, Location = location });
  78. CurrentMap.GetCell(CurrentLocation).Add(this);
  79. AddObjects(Direction, 1);
  80. }
  81. }
  82. }
  83. }
  84. }