public void CopyKeys(int copiesNum) { Game.PrintMessage("Vyber kontejner s Blank klici a key ringy:"); UOItem blankBag = new UOItem(UIManager.TargetObject()); Game.PrintMessage("Pytlik nebo Key ring k okopirovani:"); UOItem toCopyBag = new UOItem(UIManager.TargetObject()); Game.PrintMessage("Pytlik kam davat klice:"); UOItem targetBag = new UOItem(UIManager.TargetObject()); ItemHelper.EnsureContainer(blankBag); int blankCount = blankBag.Items.Count(ItemLibrary.BlankMagicKey.Graphic); int keyRingCount = blankBag.Items.Count(ItemLibrary.KeyRing0.Graphic); UOItemExtInfo extInfo = ItemHelper.GetItemExtInfo(toCopyBag, null); int toCopyCount = extInfo.Success ? extInfo.Charges.GetValueOrDefault() : toCopyBag.Items.Count(ItemLibrary.BlankMagicKey.Graphic); bool sourceIsKeyRing = false; if (keyRingCount > 0 && keyRingCount < copiesNum) { Game.PrintMessage("Neni dostatek Key ringu."); return; } if (blankCount < (copiesNum * toCopyCount)) { Game.PrintMessage("Neni dostatek Blank Keys."); return; } List <UOItem> originals = new List <UOItem>(); List <Serial> keyRingItems = new List <Serial>(); if ( toCopyBag.Graphic == ItemLibrary.KeyRing1.Graphic || toCopyBag.Graphic == ItemLibrary.KeyRing2.Graphic || toCopyBag.Graphic == ItemLibrary.KeyRing3.Graphic) { sourceIsKeyRing = true; List <Serial> saveState = ItemHelper.ContainerState(World.Player.Backpack); UO.WaitTargetObject(toCopyBag); toCopyBag.Use(); Game.Wait(); keyRingItems = ItemHelper.ContainerStateDiff(saveState, ItemHelper.ContainerState(World.Player.Backpack)); foreach (var ser in keyRingItems) { UOItem itm = new UOItem(ser); if (itm.Graphic == ItemLibrary.BlankMagicKey.Graphic && itm.Color == ItemLibrary.BlankMagicKey.Color) { originals.Add(itm); } } } else { ItemHelper.EnsureContainer(toCopyBag); originals.AddRange(toCopyBag.Items.Where(itm => itm.Graphic == ItemLibrary.BlankMagicKey.Graphic && itm.Color == ItemLibrary.BlankMagicKey.Color).ToArray()); } toCopyCount = originals.Count; Game.PrintMessage(String.Format("Ke kopirovani: {0}, prazdnych: {1}/{2}", toCopyCount, blankCount, keyRingCount)); for (int i = 0; i < copiesNum; i++) { UOItem emptyKeyRing = blankBag.Items.FindType(ItemLibrary.KeyRing0.Graphic); if (keyRingCount == 0 || emptyKeyRing.Move(1, World.Player.Backpack)) { Game.Wait(); int counter = 0; foreach (var orig in originals) { string origName = ""; if (orig.Container != World.Player.Backpack) { orig.Move(1, World.Player.Backpack); Game.Wait(); ItemHelper.EnsureItem(orig); } origName = (orig.Name + String.Empty).Replace("Key to:", ""); if (String.IsNullOrEmpty(origName)) { origName = "Klicek " + (counter + 1); } UOItem empty = blankBag.Items.FindType(ItemLibrary.BlankMagicKey.Graphic); if (empty.Move(1, World.Player.Backpack)) { Game.Wait(); UO.WaitTargetObject(empty); orig.Use(); Game.Wait(); RenameKey(empty, origName); Game.Wait(); if (emptyKeyRing.Exist && empty.Move(1, emptyKeyRing)) { Game.Wait(); } else if (targetBag.Exist && empty.Move(1, targetBag)) { Game.Wait(); } } counter++; } } } // Serial: 0x4018E69C Name: "Key to:calebovo novy" Position: 62.119.0 Flags: 0x0000 Color: 0x0000 Graphic: 0x1012 Amount: 1 Layer: None Container: 0x4032F802 if (sourceIsKeyRing) { Game.PrintMessage("Vracim klice"); foreach (var ser in keyRingItems) { UOItem itm = new UOItem(ser); itm.Move(1, toCopyBag); Game.Wait(); } } else { foreach (var orig in originals) { if (orig.Container != toCopyBag.Serial) { orig.Move(1, toCopyBag.Serial); Game.Wait(); } } } Game.PrintMessage("KOnec."); }