Guard.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class Guard : MonsterObject
  7. {
  8. public override bool Blocking
  9. {
  10. get { return true; }
  11. }
  12. protected override bool CanMove
  13. {
  14. get { return Route.Count > 0 && !Dead && Envir.Time > MoveTime && Envir.Time > ActionTime && Envir.Time > ShockTime; }
  15. }
  16. protected override bool CanRegen
  17. {
  18. get { return false; }
  19. }
  20. protected internal Guard(MonsterInfo info)
  21. : base(info)
  22. {
  23. NameColour = Color.SkyBlue;
  24. }
  25. public override void Spawned()
  26. {
  27. if (Respawn != null && Respawn.Info.Direction < 8)
  28. Direction = (MirDirection)Respawn.Info.Direction;
  29. base.Spawned();
  30. }
  31. protected override bool InAttackRange()
  32. {
  33. if (Target.CurrentMap != CurrentMap) return false;
  34. return Target.CurrentLocation != CurrentLocation && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
  35. }
  36. protected override void ProcessRegen() { }
  37. protected override void ProcessRoam()
  38. {
  39. if (CanMove)
  40. base.ProcessRoam();
  41. }
  42. public override bool IsAttackTarget(HumanObject attacker) { return false; }
  43. public override bool IsAttackTarget(MonsterObject attacker) { return false; }
  44. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true) { throw new NotSupportedException(); }
  45. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility) { throw new NotSupportedException(); }
  46. public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
  47. {
  48. return 0;
  49. }
  50. protected override bool DropItem(UserItem item) { throw new NotSupportedException(); }
  51. protected override bool DropGold(uint gold) { throw new NotSupportedException(); }
  52. public override void Die() { }
  53. protected override void Attack()
  54. {
  55. if (!Target.IsAttackTarget(this)) return;
  56. Point target = Target.Back;
  57. MirDirection dir = Functions.DirectionFromPoint(target, Target.CurrentLocation);
  58. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = dir, Location = target });
  59. Broadcast(new S.ObjectTurn { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  60. ActionTime = Envir.Time + 500;
  61. AttackTime = Envir.Time + AttackSpeed;
  62. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  63. if (Target.Race != ObjectType.Player) damage = int.MaxValue;
  64. if (damage == 0) return;
  65. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.AC);
  66. ActionList.Add(action);
  67. }
  68. }
  69. }