Behemoth.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 Behemoth : MonsterObject
  8. {
  9. public byte AttackRange = 10;
  10. protected internal Behemoth(MonsterInfo info)
  11. : base(info)
  12. {
  13. }
  14. protected override bool InAttackRange()
  15. {
  16. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  17. }
  18. protected override void Attack()
  19. {
  20. if (!Target.IsAttackTarget(this))
  21. {
  22. Target = null;
  23. return;
  24. }
  25. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  26. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  27. if (!ranged)
  28. {
  29. switch (Envir.Random.Next(5))
  30. {
  31. case 0:
  32. case 1:
  33. case 2:
  34. base.Attack(); //swipe
  35. break;
  36. case 3:
  37. {
  38. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  39. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  40. if (damage == 0) return;
  41. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, true);
  42. ActionList.Add(action);
  43. }
  44. break;
  45. case 4:
  46. {
  47. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  48. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, 0, DefenceType.ACAgility, false);
  49. ActionList.Add(action);
  50. }
  51. break;
  52. }
  53. PoisonTarget(Target, 15, 5, PoisonType.Bleeding);
  54. }
  55. else
  56. {
  57. if (Envir.Random.Next(2) == 0)
  58. {
  59. MoveTo(Target.CurrentLocation);
  60. }
  61. else
  62. {
  63. switch (Envir.Random.Next(2))
  64. {
  65. case 0:
  66. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  67. SpawnSlaves(); //spawn huggers
  68. break;
  69. case 1:
  70. {
  71. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  72. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 3;
  73. if (damage == 0) return;
  74. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.ACAgility);
  75. ActionList.Add(action);
  76. }
  77. break;
  78. }
  79. }
  80. ShockTime = 0;
  81. ActionTime = Envir.Time + 300;
  82. AttackTime = Envir.Time + AttackSpeed;
  83. }
  84. }
  85. protected override void CompleteRangeAttack(IList<object> data)
  86. {
  87. MapObject target = (MapObject)data[0];
  88. int damage = (int)data[1];
  89. DefenceType defence = (DefenceType)data[2];
  90. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  91. List<MapObject> targets = FindAllTargets(AttackRange, CurrentLocation);
  92. if (targets.Count == 0) return;
  93. for (int i = 0; i < targets.Count; i++)
  94. {
  95. Broadcast(new S.ObjectEffect { ObjectID = targets[i].ObjectID, Effect = SpellEffect.Behemoth });
  96. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  97. PoisonTarget(targets[i], 15, 5, PoisonType.Paralysis, 1000);
  98. }
  99. }
  100. protected override void CompleteAttack(IList<object> data)
  101. {
  102. MapObject target = (MapObject)data[0];
  103. int damage = (int)data[1];
  104. DefenceType defence = (DefenceType)data[2];
  105. bool fireCircle = data.Count >= 4 ? (bool)data[3] : false;
  106. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  107. if (fireCircle) //Firecircle
  108. {
  109. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  110. if (targets.Count == 0) return;
  111. for (int i = 0; i < targets.Count; i++)
  112. {
  113. targets[i].Attacked(this, damage, defence);
  114. }
  115. }
  116. else //Push back
  117. {
  118. Point point = Functions.PointMove(CurrentLocation, Direction, 1);
  119. Cell cell = CurrentMap.GetCell(point);
  120. if (cell.Objects != null)
  121. {
  122. for (int o = 0; o < cell.Objects.Count; o++)
  123. {
  124. MapObject t = cell.Objects[o];
  125. if (t == null || t.Race != ObjectType.Player) continue;
  126. if (t.IsAttackTarget(this))
  127. {
  128. t.Pushed(this, Direction, 4);
  129. PoisonTarget(t, 3, 15, PoisonType.Dazed, 1000);
  130. }
  131. break;
  132. }
  133. }
  134. }
  135. }
  136. private void SpawnSlaves()
  137. {
  138. List<MapObject> targets = FindAllTargets(10, CurrentLocation);
  139. int count = Math.Min(8, (targets.Count * 5) - SlaveList.Count);
  140. ActionTime = Envir.Time + 300;
  141. AttackTime = Envir.Time + AttackSpeed;
  142. for (int i = 0; i < count; i++)
  143. {
  144. MonsterObject mob = null;
  145. switch (Envir.Random.Next(4))
  146. {
  147. case 0:
  148. mob = GetMonster(Envir.GetMonsterInfo(Settings.BehemothMonster1));
  149. break;
  150. case 1:
  151. mob = GetMonster(Envir.GetMonsterInfo(Settings.BehemothMonster2));
  152. break;
  153. case 2:
  154. mob = GetMonster(Envir.GetMonsterInfo(Settings.BehemothMonster3));
  155. break;
  156. }
  157. if (mob == null) continue;
  158. if (!mob.Spawn(CurrentMap, Front))
  159. mob.Spawn(CurrentMap, CurrentLocation);
  160. mob.Target = targets[Envir.Random.Next(targets.Count)];
  161. mob.ActionTime = Envir.Time + 2000;
  162. SlaveList.Add(mob);
  163. }
  164. }
  165. public override void Die()
  166. {
  167. foreach (var slave in SlaveList)
  168. {
  169. slave.Die();
  170. }
  171. base.Die();
  172. }
  173. }
  174. }