HarvestMonster.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class HarvestMonster : MonsterObject
  6. {
  7. protected short Quality;
  8. protected int RemainingSkinCount;
  9. private List<UserItem> _drops;
  10. protected internal HarvestMonster(MonsterInfo info)
  11. : base(info)
  12. {
  13. RemainingSkinCount = 2;
  14. }
  15. protected override void Drop() { }
  16. public override bool Harvest(PlayerObject player)
  17. {
  18. if (RemainingSkinCount == 0)
  19. {
  20. for (int i = _drops.Count - 1; i >= 0; i--)
  21. {
  22. if (player.CheckGroupQuestItem(_drops[i]))
  23. {
  24. _drops.RemoveAt(i);
  25. }
  26. else
  27. {
  28. if (player.CanGainItem(_drops[i]))
  29. {
  30. player.GainItem(_drops[i]);
  31. _drops.RemoveAt(i);
  32. }
  33. }
  34. }
  35. if (_drops.Count == 0)
  36. {
  37. Harvested = true;
  38. _drops = null;
  39. Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  40. }
  41. else player.ReceiveChat(GameLanguage.ServerTextMap.GetLocalization(ServerTextKeys.YouCannotCarryAnymore), ChatType.System);
  42. return true;
  43. }
  44. if (--RemainingSkinCount > 0) return true;
  45. _drops = new List<UserItem>();
  46. for (int i = 0; i < Info.Drops.Count; i++)
  47. {
  48. DropInfo drop = Info.Drops[i];
  49. var reward = drop.AttemptDrop(EXPOwner?.Stats[Stat.ItemDropRatePercent] ?? 0, EXPOwner?.Stats[Stat.GoldDropRatePercent] ?? 0);
  50. if (reward != null)
  51. {
  52. foreach (var dropItem in reward.Items)
  53. {
  54. UserItem item = Envir.CreateDropItem(dropItem);
  55. if (item == null) continue;
  56. if (drop.QuestRequired)
  57. {
  58. if (!player.CheckGroupQuestItem(item, false)) continue;
  59. }
  60. if (item.Info.Type == ItemType.Meat)
  61. {
  62. item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura + Quality);
  63. }
  64. _drops.Add(item);
  65. }
  66. }
  67. }
  68. if (_drops.Count == 0)
  69. {
  70. player.ReceiveChat(GameLanguage.ServerTextMap.GetLocalization(ServerTextKeys.NothingWasFound), ChatType.System);
  71. Harvested = true;
  72. _drops = null;
  73. Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  74. }
  75. return true;
  76. }
  77. /*
  78. public override bool MagAttacked(MonsterObject A, int Damage)
  79. {
  80. bool B = base.MagAttacked(A, Damage);
  81. if (B)
  82. Quality = (short)Math.Max(short.MinValue, Quality - 2000);
  83. return true;
  84. }*/
  85. }
  86. }