DemonGuard.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class DemonGuard : ZumaMonster
  7. {
  8. public uint RevivalCount;
  9. public int LifeCount;
  10. public long RevivalTime, DieTime;
  11. public override uint Experience
  12. {
  13. get { return Info.Experience * (100 - (25 * RevivalCount)) / 100; }
  14. }
  15. protected internal DemonGuard(MonsterInfo info)
  16. : base(info)
  17. {
  18. RevivalCount = 0;
  19. LifeCount = Envir.Random.Next(3);
  20. }
  21. protected override void Attack()
  22. {
  23. if (!Target.IsAttackTarget(this))
  24. {
  25. Target = null;
  26. return;
  27. }
  28. ShockTime = 0;
  29. ActionTime = Envir.Time + 300;
  30. AttackTime = Envir.Time + AttackSpeed;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. if (Envir.Random.Next(3) > 0)
  33. {
  34. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  35. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  36. if (damage == 0) return;
  37. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  38. ActionList.Add(action);
  39. }
  40. else
  41. {
  42. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  43. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  44. if (damage == 0) return;
  45. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  46. ActionList.Add(action);
  47. }
  48. }
  49. public override void Die()
  50. {
  51. DieTime = Envir.Time;
  52. RevivalTime = (4 + Envir.Random.Next(20)) * 1000;
  53. base.Die();
  54. }
  55. protected override void ProcessAI()
  56. {
  57. if (Dead && Envir.Time > DieTime + RevivalTime && RevivalCount < LifeCount)
  58. {
  59. RevivalCount++;
  60. int newhp = (int)(Stats[Stat.HP] * (100 - (25 * RevivalCount)) / 100);
  61. Revive(newhp, false);
  62. }
  63. base.ProcessAI();
  64. }
  65. }
  66. }