ManTree.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using Server.MirEnvir;
  4. using S = ServerPackets;
  5. namespace Server.MirObjects.Monsters
  6. {
  7. public class ManTree : ZumaMonster
  8. {
  9. protected internal ManTree(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override void Attack()
  14. {
  15. ShockTime = 0;
  16. if (!Target.IsAttackTarget(this))
  17. {
  18. Target = null;
  19. return;
  20. }
  21. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  22. AttackTime = Envir.Time + AttackSpeed;
  23. ActionTime = Envir.Time + 300;
  24. if (Envir.Random.Next(8) > 0)
  25. {
  26. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  27. if (Envir.Random.Next(4) > 0)
  28. {
  29. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  30. if (damage == 0) return;
  31. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage, DefenceType.ACAgility, false, false);
  32. ActionList.Add(action);
  33. }
  34. else
  35. {
  36. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  37. if (damage == 0) return;
  38. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage, DefenceType.ACAgility, true, false);
  39. ActionList.Add(action);
  40. }
  41. }
  42. else
  43. {
  44. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  45. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  46. if (damage == 0) return;
  47. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage, DefenceType.ACAgility, false, true);
  48. ActionList.Add(action);
  49. }
  50. }
  51. protected override void CompleteAttack(IList<object> data)
  52. {
  53. MapObject target = (MapObject)data[0];
  54. int damage = (int)data[1];
  55. DefenceType defence = (DefenceType)data[2];
  56. bool halfMoonAttack = (bool)data[3];
  57. bool boulderSmashAttack = (bool)data[4];
  58. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  59. if (halfMoonAttack)
  60. {
  61. MirDirection dir = Functions.PreviousDir(Direction);
  62. for (int i = 0; i < 4; i++)
  63. {
  64. Point halfMoontarget = Functions.PointMove(CurrentLocation, dir, 1);
  65. dir = Functions.NextDir(dir);
  66. if (!CurrentMap.ValidPoint(halfMoontarget)) continue;
  67. Cell cell = CurrentMap.GetCell(halfMoontarget);
  68. if (cell.Objects == null) continue;
  69. for (int o = 0; o < cell.Objects.Count; o++)
  70. {
  71. MapObject ob = cell.Objects[o];
  72. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue;
  73. if (!ob.IsAttackTarget(this)) continue;
  74. ob.Attacked(this, damage, defence);
  75. break;
  76. }
  77. }
  78. return;
  79. }
  80. if (boulderSmashAttack)
  81. {
  82. List<MapObject> targets = FindAllTargets(1, target.CurrentLocation);
  83. if (targets.Count == 0) return;
  84. for (int i = 0; i < targets.Count; i++)
  85. {
  86. if (targets[i].IsAttackTarget(this))
  87. {
  88. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  89. PoisonTarget(targets[Envir.Random.Next(targets.Count)], 5, 5, PoisonType.Stun);
  90. }
  91. }
  92. return;
  93. }
  94. target.Attacked(this, damage, defence);
  95. }
  96. }
  97. }