WingedTigerLord.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 WingedTigerLord : MonsterObject
  8. {
  9. enum AttackType
  10. {
  11. SingleSlash,
  12. Tornado,
  13. Stomp
  14. }
  15. private bool stomp, tornado;
  16. private int AttackRange = 5;
  17. protected internal WingedTigerLord(MonsterInfo info)
  18. : base(info)
  19. {
  20. }
  21. protected override bool InAttackRange()
  22. {
  23. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  24. }
  25. protected override void Attack()
  26. {
  27. if (!Target.IsAttackTarget(this))
  28. {
  29. Target = null;
  30. return;
  31. }
  32. DelayedAction action;
  33. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  34. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  35. ActionTime = Envir.Time + 500;
  36. AttackTime = Envir.Time + AttackSpeed;
  37. ShockTime = 0;
  38. int damage;
  39. if (ranged)
  40. {
  41. if (tornado)
  42. {
  43. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0, TargetID = Target.ObjectID });
  44. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  45. List<MapObject> targets = FindAllTargets(1, Target.CurrentLocation);
  46. for (int i = 0; i < targets.Count; i++)
  47. {
  48. action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 1000, targets[i], damage, DefenceType.ACAgility);
  49. ActionList.Add(action);
  50. }
  51. ActionTime = Envir.Time + 800;
  52. AttackTime = Envir.Time + AttackSpeed;
  53. tornado = false;
  54. return;
  55. }
  56. return;
  57. }
  58. else
  59. {
  60. if (stomp)
  61. {
  62. //Foot stomp
  63. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  64. MirDirection dir = Functions.PreviousDir(Direction);
  65. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  66. for (int i = 0; i < 8; i++)
  67. {
  68. Point tar = Functions.PointMove(CurrentLocation, dir, 1);
  69. dir = Functions.NextDir(dir);
  70. if (!CurrentMap.ValidPoint(tar)) continue;
  71. Cell cell = CurrentMap.GetCell(tar);
  72. if (cell.Objects == null) continue;
  73. for (int o = 0; o < cell.Objects.Count; o++)
  74. {
  75. MapObject ob = cell.Objects[o];
  76. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue;
  77. if (!ob.IsAttackTarget(this)) continue;
  78. action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.Stomp);
  79. ActionList.Add(action);
  80. break;
  81. }
  82. }
  83. ActionTime = Envir.Time + 800;
  84. AttackTime = Envir.Time + AttackSpeed;
  85. stomp = false;
  86. return;
  87. }
  88. switch (Envir.Random.Next(2))
  89. {
  90. case 0:
  91. //Slash
  92. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  93. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  94. action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
  95. ActionList.Add(action);
  96. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  97. action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
  98. ActionList.Add(action);
  99. break;
  100. case 1:
  101. //Two hand slash
  102. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  103. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  104. action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
  105. ActionList.Add(action);
  106. break;
  107. }
  108. if (Envir.Random.Next(5) == 0)
  109. stomp = true;
  110. if (Envir.Random.Next(2) == 0)
  111. tornado = true;
  112. }
  113. }
  114. protected override void CompleteRangeAttack(IList<object> data)
  115. {
  116. MapObject target = (MapObject)data[0];
  117. int damage = (int)data[1];
  118. DefenceType defence = (DefenceType)data[2];
  119. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  120. int poisonTime = GetAttackPower(Stats[Stat.MinSC], Stats[Stat.MaxSC]);
  121. if (target.Attacked(this, damage, defence) <= 0) return;
  122. PoisonTarget(target, 2, poisonTime, PoisonType.Dazed, 2000);
  123. }
  124. protected override void CompleteAttack(IList<object> data)
  125. {
  126. MapObject target = (MapObject)data[0];
  127. int damage = (int)data[1];
  128. DefenceType defence = (DefenceType)data[2];
  129. AttackType type = (AttackType)data[3];
  130. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  131. if (target.Attacked(this, damage, defence) <= 0) return;
  132. switch (type)
  133. {
  134. case AttackType.Stomp:
  135. {
  136. PoisonTarget(target, 2, 5, PoisonType.Paralysis, 2000);
  137. }
  138. break;
  139. }
  140. }
  141. protected override void ProcessTarget()
  142. {
  143. if (Target == null) return;
  144. if (InAttackRange() && CanAttack)
  145. {
  146. Attack();
  147. return;
  148. }
  149. if (Envir.Time < ShockTime)
  150. {
  151. Target = null;
  152. return;
  153. }
  154. MoveTo(Target.CurrentLocation);
  155. }
  156. }
  157. }