public void Pickup() { DroppedItem itemForPickup = null; int minDistance = Range; foreach (var droppedItem in _data.DroppedItems) { if (_data.MainHero.RangeTo(droppedItem.Value) < minDistance && (!PickupMine || _data.MonstersToLoot.Contains(droppedItem.Value.SourceMobObjectId)) && (!_blockedDrop.ContainsKey(droppedItem.Key) || DateTime.Now.Subtract(_blockedDrop[droppedItem.Key]).TotalSeconds > 30) && (PickupAll || (PickupInclusive && RulesInUse.Any(rule => rule.Enable && rule.ItemId == droppedItem.Value.ItemId && rule.ConditionsAreMet(_data, droppedItem.Value))) || (PickupExclusive && !RulesInUse.Any(rule => rule.Enable && rule.ItemId == droppedItem.Value.ItemId && rule.ConditionsAreMet(_data, droppedItem.Value)))) ) { itemForPickup = droppedItem.Value; minDistance = (int)_data.MainHero.RangeTo(itemForPickup); } } if (itemForPickup == null) { return; } if (minDistance > 150) { if (DateTime.Now.Subtract(_moveToStamp).TotalMilliseconds > 500) { _actionsController.MoveToRaw(itemForPickup.X, itemForPickup.Y, itemForPickup.Z); _moveToStamp = DateTime.Now; } } else { _actionsController.Pickup(itemForPickup.ObjectId); int timeout = 0; while (timeout < 30 && _data.DroppedItems.ContainsKey(itemForPickup.ObjectId)) { Thread.Sleep(100); if (timeout % 10 == 0) { _actionsController.Pickup(itemForPickup.ObjectId); } } if (timeout == 30) { if (_blockedDrop.ContainsKey(itemForPickup.ObjectId)) { _blockedDrop[itemForPickup.ObjectId] = DateTime.Now; } else { _blockedDrop.Add(itemForPickup.ObjectId, DateTime.Now); } } } }
public bool ShouldPickup() { DroppedItem itemForPickup = null; int minDistance = Range; foreach (var droppedItem in _data.DroppedItems) { if (_data.MainHero.RangeTo(droppedItem.Value) < minDistance && (!PickupMine || _data.MonstersToLoot.Contains(droppedItem.Value.SourceMobObjectId)) && (!_blockedDrop.ContainsKey(droppedItem.Key) || DateTime.Now.Subtract(_blockedDrop[droppedItem.Key]).TotalSeconds > 30) && (PickupAll || (PickupInclusive && RulesInUse.Any(rule => rule.Enable && rule.ItemId == droppedItem.Value.ItemId && rule.ConditionsAreMet(_data, droppedItem.Value))) || (PickupExclusive && !RulesInUse.Any(rule => rule.Enable && rule.ItemId == droppedItem.Value.ItemId && rule.ConditionsAreMet(_data, droppedItem.Value)))) ) { //itemForPickup = droppedItem.Value; //minDistance = (int) _data.MainHero.RangeTo(itemForPickup); return(true); } } return(false); }