DarkBeast.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. //Use Effect 1 if bleeding on secondary attack
  7. public class DarkBeast : MonsterObject
  8. {
  9. protected internal DarkBeast(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override void Attack()
  14. {
  15. if (!Target.IsAttackTarget(this))
  16. {
  17. Target = null;
  18. return;
  19. }
  20. ShockTime = 0;
  21. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  22. ActionTime = Envir.Time + 300;
  23. AttackTime = Envir.Time + AttackSpeed;
  24. if (Envir.Random.Next(5) > 0)
  25. {
  26. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  27. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  28. if (damage == 0) return;
  29. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, false);
  30. ActionList.Add(action);
  31. }
  32. else
  33. {
  34. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  35. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  36. if (damage == 0) return;
  37. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, true);
  38. ActionList.Add(action);
  39. }
  40. }
  41. protected override void CompleteAttack(IList<object> data)
  42. {
  43. MapObject target = (MapObject)data[0];
  44. int damage = (int)data[1];
  45. DefenceType defence = (DefenceType)data[2];
  46. bool poison = (bool)data[3];
  47. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  48. if (target.Attacked(this, damage, defence) <= 0) return;
  49. if (poison && Info.Effect == 1)
  50. {
  51. PoisonTarget(target, 5, 5, PoisonType.Bleeding);
  52. }
  53. }
  54. }
  55. }