public static void RefullLahve(Serial zdrojBagl, Serial cilBagl, params string[] options) { Game.PrintMessage("options.Length: " + options.Length); Dictionary <string, ReuqipItemInfo> requipInfo = new Dictionary <string, ReuqipItemInfo>(); try { foreach (string opt in options) { //if (opt.StartsWith("Potion:")) //{ ReuqipItemInfo optInfo = new ReuqipItemInfo(); foreach (FieldInfo fInfo in optInfo.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) { Match match = Regex.Match(opt, fInfo.Name + ":[ ]?(?<value>[^}{,]+),?"); if (match.Success) { string strValue = (match.Groups["value"].Value + String.Empty).Trim(); object converValue = null; if (fInfo.FieldType == typeof(PotionQuality)) { converValue = Enum.Parse(typeof(PotionQuality), strValue); } else { converValue = Convert.ChangeType(strValue, fInfo.FieldType); } fInfo.SetValue(optInfo, converValue); } } Potion potion = PotionCollection.Potions.GetItemByName(optInfo.Name); if (potion != null && !requipInfo.ContainsKey(optInfo.Name)) { optInfo.OriginalOpt = opt; optInfo.Type = new UOItemType() { Graphic = potion.Qualities[optInfo.Quality].Graphic, Color = potion.Qualities[optInfo.Quality].Color }; requipInfo.Add(optInfo.Name, optInfo); } else { Game.PrintMessage("Potion Failed OPT NAME: " + optInfo.Name + " " + (potion == null)); } //} //else // Game.PrintMessage("Not implemented OPT"); } } catch (Exception ex) { Game.PrintMessage(ex.Message); return; } UOItem zdrojKont = new UOItem(zdrojBagl); if (zdrojKont.Serial == Serial.Invalid && zdrojBagl > 0) { Game.PrintMessage("Vyber bednu s zdrojem (ESC = Ground):"); zdrojKont = new UOItem(UIManager.TargetObject()); } bool ground = !zdrojKont.ExistCust(); UOItem cilKont = new UOItem(cilBagl); if (cilKont.Serial == Serial.Invalid) { Game.PrintMessage("Vyber pytel kam:"); cilKont = new UOItem(UIManager.TargetObject()); } Game.PrintMessage("Nacitam Itemy ..."); List <UOItem> bagitems = new List <UOItem>(); bagitems.AddRange(ItemHelper.OpenContainerRecursive(cilKont)); Game.Wait(); foreach (UOItem item in bagitems) { foreach (KeyValuePair <string, ReuqipItemInfo> kvp in requipInfo) { ReuqipItemInfo info = kvp.Value; if (info.Type.Graphic == item.Graphic && item.Color == info.Type.Color) { info.Items.Add(item); info.Count++; } } } Game.Wait(); Game.PrintMessage("requipInfo.Count: " + requipInfo.Count); ushort startX = 15; ushort startY = 15; ushort currentX = startX; ushort currentY = startY; int counter = 0; foreach (KeyValuePair <String, ReuqipItemInfo> kvp in requipInfo) { ReuqipItemInfo info = kvp.Value; if (counter == 0) { if (info.PositionX > 0) { currentX = startX = info.PositionX; } if (info.PositionY > 0) { currentY = startY = info.PositionY; } } Potion potion = PotionCollection.Potions.GetItemByName(info.Name); UOItem kad = new UOItem(Serial.Invalid); if (ground) { kad = World.Ground.FindType(potion.Qualities[info.Quality].KadGraphic, potion.Qualities[info.Quality].KadColor); } else { kad = zdrojKont.Items.FindType(potion.Qualities[info.Quality].KadGraphic, potion.Qualities[info.Quality].KadColor); if (kad.ExistCust()) { kad.Move(1, World.Player.Backpack); Game.Wait(); } } Game.PrintMessage(info.Name + ": " + kad.Exist + " / " + kad.Distance + " / " + info.Count + " / " + info.MaxItem); if (kad.ExistCust() && (!ground || kad.Distance <= 6)) { while (info.Count < info.MaxItem) { UOItem empty = World.Ground.FindType(Potion.Empty); if (!empty.Exist) { if (zdrojBagl.IsValid) { Game.PrintMessage("Nacitam Itemy ..."); ItemsCollection items = new ItemsCollection(zdrojKont, true);// ItemHelper.OpenContainerRecursive(zdrojKont); empty = items.FindType(Potion.Empty); if (empty.Exist) { empty.Move(1, World.Player.Backpack); Game.Wait(); empty = World.Player.Backpack.AllItems.FindType(Potion.Empty); } } if (!empty.Exist) { empty = World.Player.Backpack.AllItems.FindType(Potion.Empty); } } if (empty.Exist) { kad.Use(); UO.WaitTargetObject(empty);// nebo jednoduse targettype ..? Game.Wait(); } info.Count++; } Game.Wait(); if (!ground) { kad.Move(1, zdrojKont.Serial); Game.Wait(); } bagitems.Clear(); bagitems.AddRange(ItemHelper.OpenContainerRecursive(World.Player.Backpack)); foreach (UOItem item in bagitems) { info = kvp.Value; if (info.Type.Graphic == item.Graphic && item.Color == info.Type.Color && !info.Items.Contains(item.Serial)) { info.Items.Add(item); } } } counter++; Game.Wait(); for (int i = 0; i < kvp.Value.Items.Count; i++) { UOItem item = new UOItem(kvp.Value.Items[i]); if (currentX > 95) { currentX = startX; currentY += 8; } if (item.X != currentX && item.Y != currentY || item.Container != cilKont.Serial) { item.Move(1, cilKont.Serial, currentX, currentY); Game.Wait(Game.SmallWait); } currentX += 4; } } Game.PrintMessage("Konec."); }
public static void RefullKade(Serial zdrojBagl, Serial cilBagl, params string[] options) { List <ItemRequipInfo> infos = ParseInfo <ItemRequipInfo>(options); UOItem zdrojKont = new UOItem(zdrojBagl); World.FindDistance = 20; if (zdrojKont.Serial == Serial.Invalid && zdrojKont.Serial > 0) { Game.PrintMessage("Vyber bednu s zdrojem (ESC = Ground):"); zdrojKont = new UOItem(UIManager.TargetObject()); } UOItem cilKont = new UOItem(cilBagl); if (cilKont.Serial == Serial.Invalid) { Game.PrintMessage("Vyber pytel kam:"); cilKont = new UOItem(UIManager.TargetObject()); } Game.PrintMessage("Nacitam Itemy ..."); List <UOItem> items = new List <UOItem>(); if (zdrojBagl == 0 || !zdrojBagl.IsValidCust() || !zdrojKont.ExistCust())// { World.FindDistance = 8; isGround = true; } { items.AddRange(World.Ground.ToArray()); } else { items = ItemHelper.OpenContainerRecursive(zdrojKont); } Game.PrintMessage("items ..." + items.Count); List <UOItem> bagitems = new List <UOItem>(); if (ItemHelper.IsInBackpack(cilKont)) { bagitems.AddRange(ItemHelper.OpenContainerRecursive(World.Player.Backpack)); } else { bagitems.AddRange(ItemHelper.OpenContainerRecursive(cilKont)); } ushort startX = 100; ushort startY = 16; //ushort currentX = startX; //ushort currentY = startY; for (int i = 0; i < infos.Count; i++) { Game.PrintMessage("infos ..." + i); ItemRequipInfo info = infos[i]; int minPerc = 80; if (info.Amount >= 200) { minPerc = 90; } Potion potion = PotionCollection.Potions.GetItemByName(info.Name); Graphic kadGra = potion.Qualities[info.Quality].KadGraphic; UOColor kadColor = potion.Qualities[info.Quality].KadColor; Game.PrintMessage("kad ..." + kadGra + " / " + kadColor); UOItem sourcekad = new UOItem(Serial.Invalid); foreach (UOItem item in bagitems) { if (item.Graphic == kadGra && item.Color == kadColor) { info.Items.Add(item); } } foreach (UOItem item in items) { if (item.Graphic == kadGra && item.Color == kadColor) { sourcekad = item; break; } } if (sourcekad.Exist) { Game.PrintMessage("info.Items ..." + info.Items.Count); foreach (Serial item in info.Items) { UOItem kad = new UOItem(item); if (String.IsNullOrEmpty(kad.Name)) { kad.Click(); Game.Wait(Game.SmallestWait); } Game.PrintMessage("Kad OK " + kad.Name); UOItemExtInfo extInfo = ItemHelper.GetItemExtInfo(kad, null); //UOItem from = new UOItem(Serial.Invalid); //UOItem to = new UOItem(Serial.Invalid); if (extInfo.Success) { if (extInfo.Charges < info.Amount)//TODO dodelat pokud je v kadi 90%-+ tak nedolevat? { if (((extInfo.Charges.GetValueOrDefault() / (decimal)info.Amount) * 100) < minPerc) { //Game.PrintMessage("V kadi je " + String.Format("{0:N1}", ((extInfo.Charges.GetValueOrDefault() / (decimal)info.Amount) * 100)) + "% / " + minPerc + "% - " + extInfo.Charges); int toFill = info.Amount - extInfo.Charges.GetValueOrDefault(); Serial orgiCont = kad.Container; if (!ItemHelper.IsInBackpack(kad)) { kad.Move(1, World.Player.Backpack); Game.Wait(); } for (int u = toFill; u > 0; u -= 50) { UO.WaitTargetObject(kad); sourcekad.Use(); Game.Wait(); } if (new UOItem(kad.Serial).Container != orgiCont) { kad.Move(1, orgiCont); Game.Wait(); } Game.PrintMessage(info.Name + " doplneno " + toFill); } else { Game.PrintMessage("V kadi je " + ((extInfo.Charges.GetValueOrDefault() / (decimal)info.Amount) * 100) + "% / " + minPerc + "% - " + extInfo.Charges); } } else if (extInfo.Charges > info.Amount + 50)//odlejvat ?? uvidime { } } else { Game.PrintMessage("Kad extInfo FAIL " + kad.Name); } } } else { Game.PrintMessage("Kad " + info.Name + " NENALEZENA."); } foreach (Serial s in info.Items) { UOItem item = new UOItem(s); ushort[] xy = FindEmptySlotCoordinates(cilKont, startX, startY, 165, 8, 16); //if (currentX > 165) //{ // currentX = startX; // currentY += 16; //} if (item.X != xy[0] && item.Y != xy[1] || item.Container != cilKont.Serial) { item.Move(1, cilKont.Serial, xy[0], xy[1]); Game.Wait(Game.SmallWait); } //currentX += 8; } } Game.PrintMessage("Konec"); }