SwampWarrior.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class SwampWarrior : MonsterObject
  6. {
  7. protected virtual byte AttackRange
  8. {
  9. get
  10. {
  11. return 6;
  12. }
  13. }
  14. protected internal SwampWarrior(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. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  45. AttackTime = Envir.Time + AttackSpeed + 500;
  46. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  47. if (damage == 0) return;
  48. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  49. ActionList.Add(action);
  50. }
  51. }
  52. protected override void CompleteRangeAttack(IList<object> data)
  53. {
  54. MapObject target = (MapObject)data[0];
  55. int damage = (int)data[1];
  56. DefenceType defence = (DefenceType)data[2];
  57. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  58. target.Attacked(this, damage, defence);
  59. if (Envir.Random.Next(1) > 0) // Random chance for poison to be either Green or Red (set to 50/50 chance)
  60. {
  61. PoisonTarget(target, 8, 5, PoisonType.Green, 2000);
  62. }
  63. else
  64. {
  65. PoisonTarget(target, 8, 5, PoisonType.Red, 2000);
  66. }
  67. }
  68. protected override void ProcessTarget()
  69. {
  70. if (Target == null) return;
  71. if (InAttackRange() && CanAttack)
  72. {
  73. Attack();
  74. return;
  75. }
  76. if (Envir.Time < ShockTime)
  77. {
  78. Target = null;
  79. return;
  80. }
  81. }
  82. }
  83. }