public static bool EquipWand(string wandName, int minimumCharges = -1) { try { WandTypes wandType = Utility.GetEnumValueByName <WandTypes>(wandName); int containerSerial = AliasCommands.ResolveSerial("backpack"); Item[] matches = FindWands(wandType, containerSerial, minimumCharges).Result; if (matches == null) { UOC.SystemMessage(Strings.Cannot_find_item___); return(false); } ActionCommands.EquipItem(matches.First().Serial, Layer.OneHanded); return(true); } catch (InvalidOperationException) { UOC.SystemMessage(string.Format(Strings.Invalid_skill_name___0__, wandName)); } return(false); }
private static async Task <Item[]> FindWands(WandTypes wandType, int containerSerial, int minimumCharges) { if (!Engine.TooltipsEnabled) { Item[] allWands = Engine.Items.SelectEntities(i => _wandIds.Contains(i.ID) && !ObjectCommands.InIgnoreList(i.Serial) && (containerSerial == -1 || i.IsDescendantOf(containerSerial))); if (allWands == null) { return(null); } foreach (Item wand in allWands) { Engine.SendPacketToServer(new LookRequest(wand.Serial)); await UOC.WaitForIncomingPacketFilterAsync( new PacketFilterInfo( 0xBF, new[] { PacketFilterConditions.ShortAtPositionCondition(0x10, 3), PacketFilterConditions.IntAtPositionCondition(wand.Serial, 5) } ), 2500); } } Item[] matches = Engine.Items.SelectEntities(i => _wandIds.Contains(i.ID) && !ObjectCommands.InIgnoreList(i.Serial) && (containerSerial == -1 || i.IsDescendantOf(containerSerial)) && i.Properties != null && i.Properties.Any(p => _wandClilocs[wandType].Contains(p.Cliloc) && (minimumCharges == -1 || int.Parse(p.Arguments[0]) >= minimumCharges))); return(matches); }
private static async Task <Item[]> FindWands(WandTypes wandType, int containerSerial, int minimumCharges) { // Hybrid has FeatureFlags.AOS, think of better solution if (!Engine.Features.HasFlag(FeatureFlags.AOS) || Engine.CurrentShard.Name.Equals("UOHybrid")) { Item[] allWands = Engine.Items.SelectEntities(i => _wandIds.Contains(i.ID) && (containerSerial == -1 || i.IsDescendantOf(containerSerial))); if (allWands == null) { return(null); } foreach (Item wand in allWands) { Engine.SendPacketToServer(new LookRequest(wand.Serial)); await UOC.WaitForIncomingPacketFilterAsync( new PacketFilterInfo( 0xBF, new[] { PacketFilterConditions.ShortAtPositionCondition(0x10, 3), PacketFilterConditions.IntAtPositionCondition(wand.Serial, 5) } ), 2500); } } Item[] matches = Engine.Items.SelectEntities(i => _wandIds.Contains(i.ID) && (containerSerial == -1 || i.IsDescendantOf(containerSerial)) && i.Properties != null && i.Properties.Any(p => _wandClilocs[wandType].Contains(p.Cliloc) && (minimumCharges == -1 || int.Parse(p.Arguments[0]) >= minimumCharges))); return(matches); }
public static bool FindWand(string wandName, object containerSource = null, int minimumCharges = -1) { try { WandTypes wandType = Utility.GetEnumValueByName <WandTypes>(wandName); int containerSerial = AliasCommands.ResolveSerial(containerSource); if (containerSource == null) { containerSerial = -1; } Item[] matches = FindWands(wandType, containerSerial, minimumCharges).Result; if (matches == null) { UOC.SystemMessage(Strings.Cannot_find_item___); return(false); } AliasCommands.SetMacroAlias("found", matches.First().Serial); UOC.SystemMessage(string.Format(Strings.Object___0___updated___, "found"), true); return(true); } catch (InvalidOperationException) { UOC.SystemMessage(string.Format(Strings.Invalid_skill_name___0__, wandName)); } return(false); }