GuardianRock.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class GuardianRock : MonsterObject
  6. {
  7. public bool Active = true;
  8. protected override bool CanMove { get { return false; } }
  9. protected internal GuardianRock(MonsterInfo info)
  10. : base(info)
  11. {
  12. Direction = MirDirection.Up;
  13. }
  14. public override void Turn(MirDirection dir)
  15. {
  16. }
  17. public override bool Walk(MirDirection dir) { return false; }
  18. protected override void ProcessRoam() { }
  19. protected override bool InAttackRange()
  20. {
  21. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
  22. }
  23. protected override void CompleteAttack(IList<object> data)
  24. {
  25. if (Target == null) return;
  26. if (!Target.IsAttackTarget(this))
  27. {
  28. Target = null;
  29. return;
  30. }
  31. if (Target.CurrentMap != CurrentMap || Target.Node == null) return;
  32. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  33. PullAttack();
  34. ActionTime = Envir.Time + 300;
  35. AttackTime = Envir.Time + AttackSpeed;
  36. }
  37. private void PullAttack()
  38. {
  39. MirDirection pushdir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  40. if (Envir.Random.Next(Settings.MagicResistWeight) < Target.Stats[Stat.MagicResist]) return;
  41. int distance = Functions.MaxDistance(Target.CurrentLocation, CurrentLocation) -1;
  42. if (distance <= 0) return;
  43. if (distance > 4) distance = 4;
  44. Target.Pushed(this, pushdir, distance);
  45. }
  46. protected override void ProcessTarget()
  47. {
  48. if (Target == null) return;
  49. if (!Active) return;
  50. if (InAttackRange() && CanAttack)
  51. {
  52. ActionList.Add(new DelayedAction(DelayedType.Damage, Envir.Time + 500));
  53. return;
  54. }
  55. if (Envir.Time < ShockTime)
  56. {
  57. Target = null;
  58. return;
  59. }
  60. }
  61. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
  62. {
  63. return 0;
  64. }
  65. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
  66. {
  67. return 0;
  68. }
  69. public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
  70. {
  71. return 0;
  72. }
  73. public override void ChangeHP(int amount)
  74. {
  75. //make it immune to green poison
  76. }
  77. }
  78. }