HellCannibal.cs 2.4 KB

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