Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System;
  3. using System.Drawing;
  4. using Server.MirDatabase;
  5. using Server.MirEnvir;
  6. using S = ServerPackets;
  7.  
  8. namespace Server.MirObjects.Monsters
  9. {
  10. public class MutantCatLord : MonsterObject
  11. {
  12. public long FearTime, ChargeTime;
  13. public byte AttackRange = 6;
  14.  
  15.  
  16. protected internal MutantCatLord(MonsterInfo info)
  17. : base(info)
  18. {
  19. }
  20.  
  21. protected override bool InAttackRange()
  22. {
  23. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  24. }
  25.  
  26. protected override void Attack()
  27. {
  28. if (!Target.IsAttackTarget(this))
  29. {
  30. Target = null;
  31. return;
  32. }
  33.  
  34. if (ChargeTime > 0 && Envir.Time > ChargeTime)
  35. {
  36. ChargeTime = 0;
  37. RefreshAll();
  38. }
  39.  
  40. ShockTime = 0;
  41.  
  42. int damage = GetAttackPower(MinDC, MaxDC);
  43. if (damage == 0) return;
  44.  
  45. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  46.  
  47. ActionTime = Envir.Time + 300;
  48. AttackTime = Envir.Time + AttackSpeed;
  49.  
  50. if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 1) && Envir.Random.Next(2) == 0)
  51. {
  52. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  53.  
  54. Target.Attacked(this, damage, DefenceType.MagicArmour, Info.element);
  55.  
  56. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  57.  
  58. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MagicArmour, Info.element);
  59. ActionList.Add(action);
  60.  
  61. // Two actions as its a double attack
  62. }
  63.  
  64.  
  65.  
  66. else if (Envir.Random.Next(8) != 0)
  67. {
  68. Point offset = new Point(CurrentLocation.X, CurrentLocation.Y);
  69.  
  70. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  71.  
  72. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  73.  
  74. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MagicArmour, Info.element);
  75. ActionList.Add(action);
  76. }
  77. else
  78. {
  79.  
  80. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  81.  
  82. int levelgap = 50 - Target.Level;
  83. if (Envir.Random.Next(20) < 4 + levelgap)
  84. Target.ApplyPoison(new Poison
  85. {
  86. Owner = this,
  87. Duration = 5,
  88. PType = PoisonType.Bleed,
  89. TickSpeed = 1000,
  90. }, this);
  91. }
  92.  
  93.  
  94. if (Target.Dead)
  95. FindTarget();
  96.  
  97. }
  98.  
  99. protected override void ProcessTarget()
  100. {
  101.  
  102. bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  103.  
  104. MapObject LowHPTarget = Target;
  105.  
  106. List<MapObject> targets = FindAllTargets(range ? AttackRange : 4, CurrentLocation);
  107.  
  108. if (Target == null || !CanAttack) return;
  109.  
  110. if (InAttackRange() && (Envir.Time < FearTime))
  111. {
  112. if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 2) && Envir.Time > ChargeTime && Envir.Random.Next(5) == 0)
  113. {
  114. ChargeTime = Envir.Time + 8000;
  115. Broadcast(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.CatLordCharge });
  116. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  117. FireResistance = 75;
  118. IceResistance = 75;
  119. WindResistance = 75;
  120. LightningResistance = 75;
  121. ChaosResistance = 75;
  122. DivineResistance = 75;
  123. return;
  124. }
  125. if (targets.Count >= 2)
  126. {
  127. for (int i = 0; i < targets.Count; i++)
  128. {
  129. Target = targets[i];
  130. if (Target.Health > LowHPTarget.Health)
  131. {
  132. Target = LowHPTarget;
  133. Attack();
  134. }
  135. }
  136. }
  137. else
  138. {
  139. Attack();
  140. return;
  141. }
  142. }
  143.  
  144. FearTime = Envir.Time + 5000;
  145.  
  146. if (Envir.Time < ShockTime)
  147. {
  148. Target = null;
  149. return;
  150. }
  151.  
  152. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  153.  
  154. if (dist >= AttackRange)
  155. MoveTo(Target.CurrentLocation);
  156. else
  157. {
  158. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  159.  
  160. if (Walk(dir)) return;
  161.  
  162. switch (Envir.Random.Next(2)) //No favour
  163. {
  164. case 0:
  165. for (int i = 0; i < 7; i++)
  166. {
  167. dir = Functions.NextDir(dir);
  168.  
  169. if (Walk(dir))
  170. return;
  171. }
  172. break;
  173. default:
  174. for (int i = 0; i < 7; i++)
  175. {
  176. dir = Functions.PreviousDir(dir);
  177.  
  178. if (Walk(dir))
  179. return;
  180. }
  181. break;
  182. }
  183.  
  184. }
  185. }
  186.  
  187. }
  188.  
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement