PoisonHugger.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class PoisonHugger : MonsterObject
  7. {
  8. public byte AttackRange = 5;
  9. public long ExplosionTime;
  10. protected internal PoisonHugger(MonsterInfo info)
  11. : base(info)
  12. {
  13. ExplosionTime = Envir.Time + 1000 * 60 * 5;
  14. }
  15. protected override bool InAttackRange()
  16. {
  17. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  18. }
  19. protected override void ProcessTarget()
  20. {
  21. if (!CanAttack) return;
  22. if (Target == null || Envir.Time > ExplosionTime || !Target.IsAttackTarget(this))
  23. {
  24. Die(); return;
  25. }
  26. bool ranged = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  27. if(InAttackRange())
  28. {
  29. if (ranged)
  30. {
  31. if(Envir.Random.Next(5) == 0)
  32. {
  33. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  34. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  35. ActionTime = Envir.Time + 300;
  36. AttackTime = Envir.Time + AttackSpeed;
  37. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  38. if (damage == 0) return;
  39. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  40. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
  41. ActionList.Add(action);
  42. return;
  43. }
  44. else
  45. {
  46. MoveTo(Target.CurrentLocation);
  47. }
  48. }
  49. else
  50. {
  51. Die();
  52. }
  53. }
  54. if (Envir.Time < ShockTime)
  55. {
  56. Target = null;
  57. return;
  58. }
  59. MoveTo(Target.CurrentLocation);
  60. }
  61. public override void Die()
  62. {
  63. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  64. for (int i = 0; i < targets.Count; i++)
  65. {
  66. ActionList.Add(new DelayedAction(DelayedType.Die, Envir.Time + 500, targets[i], GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]), DefenceType.ACAgility));
  67. }
  68. base.Die();
  69. }
  70. protected override void CompleteDeath(IList<object> data)
  71. {
  72. MapObject target = (MapObject)data[0];
  73. int damage = (int)data[1];
  74. DefenceType defence = (DefenceType)data[2];
  75. if (target.Attacked(this, damage, defence) <= 0) return;
  76. PoisonTarget(target, 5, 5, PoisonType.Green, 2000);
  77. }
  78. }
  79. }