CreeperPlant.cs 3.0 KB

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