IceCrystalSoldier.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class IceCrystalSoldier : MonsterObject
  7. {
  8. private long _areaTime;
  9. protected internal IceCrystalSoldier(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override void Attack()
  14. {
  15. if (!Target.IsAttackTarget(this))
  16. {
  17. Target = null;
  18. return;
  19. }
  20. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  21. if (damage == 0) return;
  22. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  23. if (Envir.Time < _areaTime)
  24. {
  25. if (Envir.Random.Next(4) == 0)
  26. {
  27. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  28. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage * 3 / 2, DefenceType.ACAgility);
  29. ActionList.Add(action);
  30. }
  31. else
  32. {
  33. base.Attack();
  34. }
  35. return;
  36. }
  37. _areaTime = Envir.Time + 2000 + Envir.Random.Next(5) * 1000;
  38. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  39. ActionList.Add(new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500));
  40. ActionTime = Envir.Time + 300;
  41. AttackTime = Envir.Time + AttackSpeed;
  42. ShockTime = 0;
  43. }
  44. protected override void CompleteRangeAttack(IList<object> data)
  45. {
  46. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 2;
  47. if (damage == 0) return;
  48. List<MapObject> targets = FindAllTargets(1, Functions.PointMove(CurrentLocation, Direction, 1));
  49. if (targets.Count == 0) return;
  50. for (int i = 0; i < targets.Count; i++)
  51. targets[i].Attacked(this, damage, DefenceType.MAC);
  52. }
  53. }
  54. }