public override void run() { L2Player player = Client.CurrentPlayer; if (player.EnchantState != ItemEnchantManager.STATE_ENCHANT_START) { player.sendSystemMessage(355);//Inappropriate enchant conditions. player.sendActionFailed(); return; } if (a_sTargetID != player.EnchantItem.ObjID) { player.sendSystemMessage(355);//Inappropriate enchant conditions. player.sendActionFailed(); return; } short rate = 50; if (player.EnchantStone != null) { EnchantScroll stone = ItemEnchantManager.getInstance().getSupport(player.EnchantStone.Template.ItemID); rate += stone.bonus; } if (player.EnchantItem.Enchant < 4) { rate = 100; } if (rate > 100) { rate = 100; } InventoryUpdate iu = null; bool equip = false; if (rate == 100 ? true : new Random().Next(100) < rate) { player.EnchantItem.Enchant += 1; player.EnchantItem.sql_update(); iu = new InventoryUpdate(); iu.addModItem(player.EnchantItem); player.sendPacket(new EnchantResult(EnchantResultVal.success)); equip = player.EnchantItem._isEquipped == 1; if (equip && player.EnchantItem.Enchant == 4 && player.EnchantItem.Template.item_skill_ench4 != null) { player.addSkill(player.EnchantItem.Template.item_skill_ench4, false, false); player.updateSkillList(); } //todo check +6 set } else { EnchantScroll scr = ItemEnchantManager.getInstance().getScroll(player.EnchantScroll.Template.ItemID); switch (scr.Type) { case EnchantType.blessed: player.EnchantItem.Enchant = 0; player.EnchantItem.sql_update(); iu = new InventoryUpdate(); iu.addModItem(player.EnchantItem); player.sendPacket(new EnchantResult(EnchantResultVal.breakToOne)); break; case EnchantType.ancient: player.sendPacket(new EnchantResult(EnchantResultVal.safeBreak)); break; default: { if (player.EnchantItem._isEquipped == 1) { int pdollId = player.Inventory.getPaperdollId(player.EnchantItem.Template); player.setPaperdoll(pdollId, null, false); equip = true; } player.Inventory.removeItem(player.EnchantItem); iu = new InventoryUpdate(); iu.addDelItem(player.EnchantItem); long cry = player.EnchantItem.Template._cryCount; if (cry == 0) { player.sendPacket(new EnchantResult(EnchantResultVal.breakToNothing)); } else { int id = player.EnchantItem.Template.getCrystallId(); player.sendPacket(new EnchantResult(EnchantResultVal.breakToCount, id, cry)); player.Inventory.addItem(id, cry, true, true); } } break; } } if (player.EnchantStone != null) { player.Inventory.destroyItem(player.EnchantStone, 1, true, true); } player.Inventory.destroyItem(player.EnchantScroll, 1, false, true); if (iu != null) { player.sendPacket(iu); } player.EnchantItem = null; player.EnchantScroll = null; player.EnchantStone = null; player.EnchantState = 0; if (equip) { player.broadcastUserInfo(); } }
public void transferHere(L2Player player, List <long[]> items, bool update) { InventoryUpdate iu = update ? new InventoryUpdate() : null; List <int> nulled = new List <int>(); foreach (L2Item item in player.Inventory.Items.Values) { foreach (long[] itemd in items) { if (item.ObjID == itemd[0]) { if (item.Template.isStackable()) { if (itemd[1] >= item.Count) { nulled.Add((int)itemd[0]); item.Location = L2Item.L2ItemLocation.refund; _items.Add(item); item.sql_update(); if (update) { iu.addDelItem(item); } } else { item.Count -= itemd[1]; L2Item ins = new L2Item(item.Template); ins.Count = itemd[1]; ins.Location = L2Item.L2ItemLocation.refund; _items.Add(ins); ins.sql_insert(_owner.ObjID); if (update) { iu.addModItem(item); } } } else { nulled.Add((int)itemd[0]); item.Location = L2Item.L2ItemLocation.refund; _items.Add(item); item.sql_update(); if (update) { iu.addModItem(item); } } } } } lock (player.Inventory.Items) { foreach (int itemd in nulled) { player.Inventory.Items.Remove(itemd); } } }
public void transferHere(L2Player player, List <long[]> items, bool update) { InventoryUpdate iu = update ? new InventoryUpdate() : null; List <int> nulled = new List <int>(); foreach (L2Item item in player.Inventory.Items.Values) { foreach (long[] itemd in items) { if (item.ObjID == itemd[0]) { bool ex = false; foreach (L2Item itp in Items.Values) { if (itp.Template.ItemID == item.Template.ItemID) { ex = true; break; } } if (item.Template.isStackable()) { if (itemd[1] >= item.Count) { nulled.Add((int)itemd[0]); if (ex) { foreach (L2Item itp in Items.Values) { if (itp.Template.ItemID == item.Template.ItemID) { itp.Count += item.Count; itp.sql_update(); break; } } item.sql_delete(); } else { item.Location = L2Item.L2ItemLocation.warehouse; Items.Add(item.ObjID, item); item.sql_update(); } if (update) { iu.addDelItem(item); } } else { item.Count -= itemd[1]; if (ex) { foreach (L2Item itp in Items.Values) { if (itp.Template.ItemID == item.Template.ItemID) { itp.Count += itemd[1]; itp.sql_update(); break; } } } else { L2Item ins = new L2Item(item.Template); ins.Count = itemd[1]; ins.Location = L2Item.L2ItemLocation.warehouse; Items.Add(ins.ObjID, ins); ins.sql_insert(_owner.ObjID); } if (update) { iu.addModItem(item); } } } else { nulled.Add((int)itemd[0]); item.Location = L2Item.L2ItemLocation.warehouse; Items.Add(item.ObjID, item); item.sql_update(); if (update) { iu.addModItem(item); } } } } } lock (player.Inventory.Items) { foreach (int itemd in nulled) { player.Inventory.Items.Remove(itemd); } } }