public override void run() { L2Player player = getClient().CurrentPlayer; L2Citizen npc = player.FolkNpc; if (npc == null) { player.sendActionFailed(); return; } long fee = _count * 30; int slots = 0; long adenatransfer = 0; for (int i = 0; i < _count; i++) { int objectId = (int)_items[i * 2]; long count = _items[i * 2 + 1]; L2Item item = player.getItemByObjId(objectId); if (item == null) { Console.WriteLine("cant find item " + objectId + " in inventory " + player.Name); player.sendActionFailed(); return; } if (item.Template.isStackable()) { slots += 1; } else { slots += (int)count; } if (item.Template.ItemID == 57) { adenatransfer += count; } } if ((player.getAdena() - adenatransfer) < fee) { player.sendSystemMessage(281);//You do not have enough adena to pay the fee. player.sendActionFailed(); return; } InvPrivateWarehouse pw = player._warehouse; int itsize = 0; if (pw == null) { pw = new InvPrivateWarehouse(player); } else { itsize = pw.Items.Count; } if (player.ItemLimit_Warehouse < (itsize + slots)) { player.sendSystemMessage(130);//Your warehouse is full. player.sendActionFailed(); return; } player.reduceAdena(fee, true, false); List <long[]> transfer = new List <long[]>(); for (int i = 0; i < _count; i++) { int objectId = (int)_items[i * 2]; long count = _items[i * 2 + 1]; transfer.Add(new long[] { objectId, count }); } pw.transferHere(player, transfer, false); //if(npc.Template.fnBye != null) //{ // player.sendPacket(new NpcHtmlMessage(player, npc.Template.fnBye, npc.ObjID, 0)); //} player.sendItemList(true); }
public override void RunImpl() { L2Player player = _client.CurrentPlayer; L2Npc npc = player.FolkNpc; if (npc == null) { player.SendActionFailed(); return; } int fee = _count * 30; int slots = 0; int adenatransfer = 0; for (int i = 0; i < _count; i++) { int objectId = _items[i * 2]; int count = _items[(i * 2) + 1]; L2Item item = player.GetItemByObjId(objectId); if (item == null) { Log.Info($"cant find item {objectId} in inventory {player.Name}"); player.SendActionFailed(); return; } if (item.Template.Stackable) { slots += 1; } else { slots += count; } if (item.Template.ItemId == 57) { adenatransfer += count; } } if ((player.GetAdena() - adenatransfer) < fee) { player.SendSystemMessage(SystemMessage.SystemMessageId.YouNotEnoughAdenaPayFee); player.SendActionFailed(); return; } //InvPrivateWarehouse pw = player._warehouse; //int itsize = 0; //if (pw == null) // pw = new InvPrivateWarehouse(player); //else // itsize = pw.Items.Count; //if (player.ItemLimit_Warehouse < (itsize + slots)) //{ // player.sendSystemMessage(SystemMessage.SystemMessageId.WAREHOUSE_FULL); // player.sendActionFailed(); // return; //} player.ReduceAdena(fee); List <int[]> transfer = new List <int[]>(); for (int i = 0; i < _count; i++) { int objectId = _items[i * 2]; int count = _items[(i * 2) + 1]; transfer.Add(new[] { objectId, count }); } // pw.transferHere(player, transfer, false); //if(npc.Template.fnBye != null) //{ // player.sendPacket(new NpcHtmlMessage(player, npc.Template.fnBye, npc.ObjID, 0)); //} player.SendItemList(true); }
public Inventory(L2Character owner) { Owner = owner; Paperdoll = new L2Item[PaperdollTotalslots]; }
public TradeUpdate(L2Item item, long num, byte action) { this.item = item; this.num = num; this.action = action; }
public void AddDelItem(L2Item item) { Update.Add(new object[] { item, (short)3 }); }
public override void UsePlayer(L2Player player, L2Item item) { player.SendPacket(new Network.serverpackets.Calculator()); }
public override void RunImpl() { L2Player player = _client.CurrentPlayer; L2Item item = player.Inventory.GetItemByItemId(_itemId); }
protected bool RemoveItem(L2Item item) { return(Items.Remove(item)); }
public ExRpItemLink(L2Item item) { _item = item; }
public L2Item DestroyItem(L2Item item, int count, L2Player player) { return(null); //to be implemented }
public L2Item AddItem(L2Item item) { return(null); //to be implemented }
public TradeOtherAdd(L2Item item, long num) { this.item = item; this.num = num; }
public SpawnItem(L2Item item) { _item = item; }
public TradeUpdate(L2Item item, int num, byte action) { _item = item; _num = num; _action = action; }
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); } } }
public override void run() { L2Player player = getClient().CurrentPlayer; L2Citizen npc = player.FolkNpc; if (npc == null) { player.sendActionFailed(); return; } long totalCost = 0; int weight = 0; for (int i = 0; i < _count; i++) { int objectId = (int)_items[i * 3 + 0]; long count = _items[i * 3 + 2]; if (count < 0 || count > int.MaxValue) { player.sendSystemMessage(1801); //The attempt to sell has failed. player.sendActionFailed(); return; } L2Item item = (L2Item)player.Inventory.Items[objectId]; if (item.Template.isStackable()) { totalCost += (int)(item.Count * (item.Template.Price * .5)); } else { totalCost += (int)(item.Template.Price * .5); } weight += item.Template.Weight; } if (totalCost > long.MaxValue) { player.sendSystemMessage(1801); //The attempt to sell has failed. player.sendActionFailed(); return; } long added = 0, currentAdena = player.getAdena(); if (currentAdena + totalCost >= int.MaxValue) { added = int.MaxValue - currentAdena; } else { added = (int)totalCost; } List <long[]> transfer = new List <long[]>(); InventoryUpdate iu = new InventoryUpdate(); for (int i = 0; i < _count; i++) { int objectId = (int)_items[i * 3 + 0]; long count = _items[i * 3 + 2]; transfer.Add(new long[] { objectId, count }); } player.Refund.transferHere(player, transfer, false); player.Refund.validate(); player.addAdena(added, false, false); player.sendItemList(true); player.sendPacket(new ExBuySellList_Close()); if (weight != 0) { player.updateWeight(); } //if (npc.Template.fnSell != null) //{ // player.sendPacket(new NpcHtmlMessage(player, npc.Template.fnSell, npc.ObjID, 0)); //} }
public TradeOtherAdd(L2Item item, int num) { _item = item; _num = num; }
public override void RunImpl() { L2Player player = _client.CurrentPlayer; L2Npc npc = player.FolkNpc; if (npc == null) { player.SendActionFailed(); return; } int slots = 0; for (int i = 0; i < _count; i++) { int objectId = _items[i * 2]; int count = _items[(i * 2) + 1]; L2Item item = null; //player._warehouse.Items[objectId]; Log.Info($"cant find item {objectId} in warehouse {player.Name}"); player.SendActionFailed(); return; if (item.Template.Stackable) { slots += 1; } else { slots += count; } } //InvPrivateWarehouse pw = player._warehouse ?? new InvPrivateWarehouse(player); //int itsize = 0; //else // itsize = pw.Items.Count; if (player.ItemLimitInventory < (player.GetAllItems().Count + slots)) { player.SendSystemMessage(SystemMessage.SystemMessageId.SlotsFull); player.SendActionFailed(); return; } List <int[]> transfer = new List <int[]>(); for (int i = 0; i < _count; i++) { int objectId = _items[i * 2]; int count = _items[(i * 2) + 1]; transfer.Add(new[] { objectId, count }); } //pw.transferFrom(player, transfer, false); //if(npc.Template.fnBye != null) //{ // player.sendPacket(new NpcHtmlMessage(player, npc.Template.fnBye, npc.ObjID, 0)); //} player.SendItemList(true); }
public Inventory(IItemService itemService, IdFactory idFactory, ItemTable itemTable, L2Character owner) : base(itemService, idFactory, itemTable) { Owner = owner; Paperdoll = new L2Item[PaperdollTotalslots]; }
public override void run() { L2Player player = getClient().CurrentPlayer; if (_amount < 0) { _amount = 1; } if (player.LastRequestedMultiSellId != _listId) { player.sendMessage("You are not authorized to use this list now."); player.sendActionFailed(); return; } MultiSellList list = null; if (player.CustomMultiSellList != null) { list = player.CustomMultiSellList; if (list.id != _listId) { list = MultiSell.getInstance().getList(_listId); } } else { list = MultiSell.getInstance().getList(_listId); } if (list == null || list.container.Count < _entryId) { player.sendSystemMessage(1802);//The attempt to trade has failed. player.sendActionFailed(); return; } MultiSellEntry entry = list.container[_entryId]; bool ok = true; foreach (MultiSellItem i in entry.take) { if (i.id > 0) { if (!player.hasItem(i.id, i.count)) { ok = false; break; } } else { switch (i.id) { case -100: //pvppoint if (player.Fame < i.count * _amount) { ok = false; } break; } } } if (!ok) { player.sendSystemMessage(701);//You do not have enough required items. player.sendActionFailed(); return; } foreach (MultiSellItem i in entry.take) { if (i.l2item != null) { player.Inventory.destroyItem(i.l2item, 1, true, true); } else { if (i.id > 0) { player.Inventory.destroyItem(i.id, i.count, true, true); } else { switch (i.id) { case -100: //pvppoint break; } } } } foreach (MultiSellItem i in entry.give) { if (i.id > 0) { if (i.l2item != null) { L2Item item = new L2Item(i.template); item.Enchant = i.l2item.Enchant; player.Inventory.addItem(item, true, true); } else { if (i.template.isStackable()) { player.Inventory.addItem(i.id, i.count * _amount, i.enchant, true, true); } else { player.Inventory.addItem(i.id, 1, i.enchant, true, true); } } } else { switch (i.id) { case -100: //pvppoint break; } } } player.sendSystemMessage(1656);//You have successfully traded the item with the NPC. }
public override void UsePlayer(L2Player player, L2Item item) { player.sendPacket(new L2dotNET.Game.network.l2send.Calculator()); }
public DropItem(L2Item item) { _item = item; _id = item.Dropper; }
public void AddModItem(L2Item item) { Update.Add(new object[] { item, (short)2 }); }
public override void RunImpl() { L2Player player = _client.CurrentPlayer; if (player.TradeState < 3) // умник { player.SendActionFailed(); return; } if (player.EnchantState != 0) { player.SendActionFailed(); return; } if (player.Requester == null) { player.SendMessage("Your trade requestor has logged off."); player.SendActionFailed(); player.TradeState = 0; return; } if ((player.TradeState == 4) || (player.Requester.TradeState == 4)) // подтвердил уже { player.SendSystemMessage(SystemMessage.SystemMessageId.CannotAdjustItemsAfterTradeConfirmed); player.SendActionFailed(); return; } L2Item item = player.Inventory.GetItemByObjectId(_sId); if (item == null) { player.SendActionFailed(); return; } if (_num > item.Count) { _num = item.Count; } if (!item.Template.Stackable && (_num > 1)) { _num = 1; } int numInList = player.AddItemToTrade(item.ObjId, _num); int numCurrent = item.Count - numInList; player.SendPacket(new TradeOwnAdd(item, numInList)); player.Requester.SendPacket(new TradeOtherAdd(item, numInList)); byte action = 2; //mod, 2-del if (item.Template.Stackable) { action = (byte)(numCurrent < 1 ? 2 : 3); } player.SendPacket(new TradeUpdate(item, numCurrent, 0)); }
public void AddNewItem(L2Item item) { Update.Add(new object[] { item, (short)1 }); }
public void dbLoad(L2Item item) { Items.Add(item.ObjID, item); }
public void OnItemEquip(L2Player player, L2Item item) { }
public void transferFrom(L2Player player, List <int[]> transfer, bool update) { InventoryUpdate iu = update ? new InventoryUpdate() : null; List <int> nulled = new List <int>(); foreach (L2Item item in Items.Values) { foreach (int[] itemd in transfer) { if (item.ObjID == itemd[0]) { bool ex = false; foreach (L2Item itp in player.getAllItems()) { if (itp.Template.ItemID == item.Template.ItemID) { ex = true; break; } } if (item.Template.isStackable()) { if (itemd[1] >= item.Count) { nulled.Add(itemd[0]); if (ex) { foreach (L2Item itp in player.getAllItems()) { if (itp.Template.ItemID == item.Template.ItemID) { itp.Count += item.Count; itp.sql_update(); if (update) { iu.addModItem(itp); } break; } } item.sql_delete(); } else { item.Location = L2Item.L2ItemLocation.inventory; player.Inventory.Items.Add(item.ObjID, item); item.sql_update(); if (update) { iu.addNewItem(item); } } } else { item.Count -= itemd[1]; if (ex) { foreach (L2Item itp in player.getAllItems()) { if (itp.Template.ItemID == item.Template.ItemID) { itp.Count += itemd[1]; itp.sql_update(); if (update) { iu.addModItem(itp); } break; } } } else { L2Item ins = new L2Item(item.Template); ins.Count = itemd[1]; ins.Location = L2Item.L2ItemLocation.inventory; player.Inventory.Items.Add(ins.ObjID, ins); ins.sql_insert(_owner.ObjID); if (update) { iu.addNewItem(ins); } } } } else { nulled.Add(itemd[0]); item.Location = L2Item.L2ItemLocation.inventory; player.Inventory.Items.Add(item.ObjID, item); item.sql_update(); if (update) { iu.addNewItem(item); } } foreach (QuestInfo qi in _owner._quests) { if (!qi.completed) { qi._template.onEarnItem(_owner, qi.stage, item.Template.ItemID); } } } } } lock (Items) { foreach (int itemd in nulled) { Items.Remove(itemd); } } }
public virtual void OnEquipChest(L2Player player, L2Item item) { }
public void OnBypass(L2Player player, npcs.L2Citizen npc, string cmd) { if (cmd.Equals("_mrvhome")) { player.ShowHtm("mr_keeper.htm", npc); } else if (cmd.Equals("_mrvw01"))//View Odds { } else if (cmd.Equals("_mrvw20"))//View Monster Information { if (status == 1) { NpcHtmlMessage htm = new NpcHtmlMessage(player, "mr_vw20.htm", npc.ObjID); for (byte a = 0; a < 8; a++) { MonsterRunner mr = runners[a + rnd]; htm.replace("<?NAME" + (a + 1) + "?>", "&$" + mr.sys_string + ";"); htm.replace("<?COND" + (a + 1) + "?>", 0); htm.replace("<?WIN" + (a + 1) + "?>", (int)(mr.winCount / mr.runCount * 100)); } htm.replace("<?LINK_HOME?>", "bypass _mrvhome"); player.sendPacket(htm); } } else if (cmd.Equals("_mrbu01"))//Purchase Ticket { if (status == 1) { NpcHtmlMessage htm = new NpcHtmlMessage(player, "mr_buy1.htm", npc.ObjID); htm.replace("<?RACE_ID?>", currentRaceId); for (byte a = 0; a < 8; a++) { MonsterRunner mr = runners[a + rnd]; htm.replace("<?SEL" + (a + 1) + "?>", "bypass _mrbu2 " + a + " 1"); htm.replace("<?NAME" + (a + 1) + "?>", "&$" + mr.sys_string + ";"); htm.replace("<?COND" + (a + 1) + "?>", 0); htm.replace("<?WIN" + (a + 1) + "?>", (int)(mr.winCount / mr.runCount * 100)); } htm.replace("<?LINK_HOME?>", "bypass _mrvhome"); htm.replace("<?SEL_ID?>", ""); player.sendPacket(htm); } } else if (cmd.Equals("_mrsl01"))//Calculate Winnings { } else if (cmd.Equals("_mrvw31"))//View Past Results { } else if (cmd.StartsWith("_mrbu2")) { byte line = Convert.ToByte(cmd.Split(' ')[1]); byte cost = Convert.ToByte(cmd.Split(' ')[2]); int adena = 0; switch (cost) { case 1: adena = 100; break; case 2: adena = 500; break; case 3: adena = 1000; break; case 4: adena = 5000; break; case 5: adena = 10000; break; case 6: adena = 20000; break; case 7: adena = 50000; break; case 8: adena = 100000; break; } MonsterRunner mr = runners[line + rnd]; NpcHtmlMessage htm = new NpcHtmlMessage(player, "mr_buy2.htm", npc.ObjID); htm.replace("<?RACE_ID?>", currentRaceId); htm.replace("<?LANE?>", (line + 1)); htm.replace("<?NAME1?>", "&$" + mr.sys_string + ";"); htm.replace("<?COND1?>", 0); htm.replace("<?WIN1?>", (int)(mr.winCount / mr.runCount * 100)); for (byte a = 1; a <= 8; a++) { htm.replace("<?LINK_BUY_" + a + "?>", "bypass _mrbu2 " + line + " " + a); } htm.replace("<?SEL_ID?>", adena); htm.replace("<?LINK_NEXT?>", "bypass _mrbu3 " + line + " " + cost); player.sendPacket(htm); } else if (cmd.StartsWith("_mrbu3")) { byte line = Convert.ToByte(cmd.Split(' ')[1]); byte cost = Convert.ToByte(cmd.Split(' ')[2]); int adena = 0; switch (cost) { case 1: adena = 100; break; case 2: adena = 500; break; case 3: adena = 1000; break; case 4: adena = 5000; break; case 5: adena = 10000; break; case 6: adena = 20000; break; case 7: adena = 50000; break; case 8: adena = 100000; break; } MonsterRunner mr = runners[line + rnd]; NpcHtmlMessage htm = new NpcHtmlMessage(player, "mr_buy3.htm", npc.ObjID); htm.replace("<?RACE_ID?>", currentRaceId); htm.replace("<?LANE?>", (line + 1)); htm.replace("<?NAME1?>", "&$" + mr.sys_string + ";"); htm.replace("<?COND1?>", 0); htm.replace("<?WIN1?>", (int)(mr.winCount / mr.runCount * 100)); htm.replace("<?BUY_AMOUNT?>", adena); htm.replace("<?TAX_AMOUNT?>", 0); htm.replace("<?SUM_AMOUNT?>", adena); htm.replace("<?LINK_HOME?>", "bypass _mrvhome"); htm.replace("<?LINK_NEXT?>", "bypass _mrbu4 " + line + " " + cost); player.sendPacket(htm); } else if (cmd.StartsWith("_mrbu4")) { byte line = Convert.ToByte(cmd.Split(' ')[1]); byte cost = Convert.ToByte(cmd.Split(' ')[2]); int adena = 0; switch (cost) { case 1: adena = 100; break; case 2: adena = 500; break; case 3: adena = 1000; break; case 4: adena = 5000; break; case 5: adena = 10000; break; case 6: adena = 20000; break; case 7: adena = 50000; break; case 8: adena = 100000; break; } if (player.getAdena() < adena) { player.sendSystemMessage(279);//You do not have enough adena. return; } player.reduceAdena(adena, true, true); L2Item ticket = new L2Item(ItemTable.getInstance().getItem(TICKET)); ticket.Location = L2Item.L2ItemLocation.inventory; ticket.CustomType1 = line + 1; ticket.CustomType2 = adena / 100; ticket.Enchant = currentRaceId; player.Inventory.addItem(ticket, true, true); } }