| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Server.MirDatabase;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class HarvestMonster : MonsterObject
- {
- protected short Quality;
- protected int RemainingSkinCount;
- private List<UserItem> _drops;
- protected internal HarvestMonster(MonsterInfo info)
- : base(info)
- {
- RemainingSkinCount = 2;
- }
- protected override void Drop() { }
- public override bool Harvest(PlayerObject player)
- {
- if (RemainingSkinCount == 0)
- {
- for (int i = _drops.Count - 1; i >= 0; i--)
- {
- if (player.CheckGroupQuestItem(_drops[i]))
- {
- _drops.RemoveAt(i);
- }
- else
- {
- if (player.CanGainItem(_drops[i]))
- {
- player.GainItem(_drops[i]);
- _drops.RemoveAt(i);
- }
- }
- }
- if (_drops.Count == 0)
- {
- Harvested = true;
- _drops = null;
- Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- }
- else player.ReceiveChat(GameLanguage.ServerTextMap.GetLocalization(ServerTextKeys.YouCannotCarryAnymore), ChatType.System);
- return true;
- }
- if (--RemainingSkinCount > 0) return true;
- _drops = new List<UserItem>();
- for (int i = 0; i < Info.Drops.Count; i++)
- {
- DropInfo drop = Info.Drops[i];
- var reward = drop.AttemptDrop(EXPOwner?.Stats[Stat.ItemDropRatePercent] ?? 0, EXPOwner?.Stats[Stat.GoldDropRatePercent] ?? 0);
- if (reward != null)
- {
- foreach (var dropItem in reward.Items)
- {
- UserItem item = Envir.CreateDropItem(dropItem);
- if (item == null) continue;
- if (drop.QuestRequired)
- {
- if (!player.CheckGroupQuestItem(item, false)) continue;
- }
- if (item.Info.Type == ItemType.Meat)
- {
- item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura + Quality);
- }
- _drops.Add(item);
- }
- }
- }
- if (_drops.Count == 0)
- {
- player.ReceiveChat(GameLanguage.ServerTextMap.GetLocalization(ServerTextKeys.NothingWasFound), ChatType.System);
- Harvested = true;
- _drops = null;
- Broadcast(new S.ObjectHarvested { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- }
- return true;
- }
- /*
- public override bool MagAttacked(MonsterObject A, int Damage)
- {
- bool B = base.MagAttacked(A, Damage);
- if (B)
- Quality = (short)Math.Max(short.MinValue, Quality - 2000);
- return true;
- }*/
- }
- }
|