public void RemoveAll(int id, MapleClient cl) { var possessed = cl.Player.Inventorys[MapleItemInformationProvider.Instance.GetInventoryType(id).Value].CountById(id); if (possessed > 0) { MapleInventoryManipulator.RemoveById(cl, MapleItemInformationProvider.Instance.GetInventoryType(id), id, possessed, true, false); cl.Send(PacketCreator.GetShowItemGain(id, (short)-possessed, true)); } }
public void Sell(MapleClient c, MapleInventoryType type, byte slot, short quantity) { if (quantity == short.MinValue || quantity == 0) { quantity = 1; } MapleItemInformationProvider ii = MapleItemInformationProvider.Instance; IMapleItem item = c.Player.Inventorys[type.Value].Inventory[slot]; if (ii.IsThrowingStar(item.ItemId)) { quantity = item.Quantity; } if (quantity < 0) { AutobanManager.Instance.AddPoints(c, 1000, 0, "Selling " + quantity + " " + item.ItemId + " (" + type + "/" + slot + ")"); return; } short iQuant = item.Quantity; if (iQuant == short.MinValue) { iQuant = 1; } if (quantity <= iQuant && iQuant > 0) { MapleInventoryManipulator.RemoveFromSlot(c, type, slot, quantity, false); double price; if (ii.IsThrowingStar(item.ItemId)) { price = ii.GetWholePrice(item.ItemId) / (double)ii.GetSlotMax(c, item.ItemId); } else { price = ii.GetPrice(item.ItemId); } int recvMesos = (int)Math.Max(Math.Ceiling(price * quantity), 0); if (Math.Abs(price + 1) > 0.000001 && recvMesos > 0) { c.Player.GainMeso(recvMesos, true); } c.Send(PacketCreator.ConfirmShopTransaction(0x8)); } }
/** * remove all items of type from party; combination of haveItem and gainItem */ public void RemoveFromParty(int id, List <MapleCharacter> party) { foreach (var chr in party) { var cl = chr.Client; var type = MapleItemInformationProvider.Instance.GetInventoryType(id); var iv = cl.Player.Inventorys[type.Value]; var possesed = iv.CountById(id); if (possesed > 0) { MapleInventoryManipulator.RemoveById(Client, MapleItemInformationProvider.Instance.GetInventoryType(id), id, possesed, true, false); cl.Send(PacketCreator.GetShowItemGain(id, (short)-possesed, true)); } } }
public void Buy(MapleClient c, int itemId, short quantity) { if (quantity <= 0) { Console.WriteLine($"{c.Player.Name} is buying an invalid amount: { quantity } of itemid: { itemId}"); c.Close(); return; } MapleShopItem item = FindByItemId(itemId); MapleItemInformationProvider ii = MapleItemInformationProvider.Instance; if (item != null && item.Price > 0 && c.Player.Meso.Value >= item.Price * quantity) { if (MapleInventoryManipulator.CheckSpace(c, itemId, quantity, "")) { if (itemId >= 5000000 && itemId <= 5000100) { if (quantity > 1) { quantity = 1; } int petId = MaplePet.Create(itemId); MapleInventoryManipulator.AddById(c, itemId, quantity, "Pet was purchased.", null, petId); } else if (ii.IsRechargable(itemId)) { short rechquantity = ii.GetSlotMax(c, item.ItemId); MapleInventoryManipulator.AddById(c, itemId, rechquantity, "Rechargable item purchased.", null, -1); } else { MapleInventoryManipulator.AddById(c, itemId, quantity, c.Player.Name + " bought " + quantity + " for " + item.Price * quantity + " from shop " + ShopId); } c.Player.GainMeso(-(item.Price * quantity), false); c.Send(PacketCreator.ConfirmShopTransaction(0)); } else { c.Send(PacketCreator.ConfirmShopTransaction(3)); } } }
/** * PQ methods: give items/exp to all party members */ public void GivePartyItems(int id, short quantity, List <MapleCharacter> party) { foreach (var chr in party) { var cl = chr.Client; if (quantity >= 0) { string logInfo = $"{cl.Player.Name} received {quantity} from event {chr.EventInstanceManager.Name}"; MapleInventoryManipulator.AddById(cl, id, quantity, logInfo); } else { MapleInventoryManipulator.RemoveById(cl, MapleItemInformationProvider.Instance.GetInventoryType(id), id, -quantity, true, false); } cl.Send(PacketCreator.GetShowItemGain(id, quantity, true)); } }
public bool AddItem(int id, short quantity, bool randomStats) { if (quantity >= 0) { var ii = MapleItemInformationProvider.Instance; var item = ii.GetEquipById(id); var type = ii.GetInventoryType(id); string logInfo = $"{Player.Name} received {quantity} frome a scripted PlayerInteraction ({ToString()})"; if (!MapleInventoryManipulator.CheckSpace(Client, id, quantity, "")) { var invtype = ii.GetInventoryType(id); Client.Send(PacketCreator.ServerNotice(PacketCreator.ServerMessageType.Popup, "你的背包已满")); return(false); } if (type == MapleInventoryType.Equip && !ii.IsThrowingStar(item.ItemId) && !ii.IsBullet(item.ItemId)) { if (randomStats) { MapleInventoryManipulator.AddFromDrop(Client, ii.RandomizeStats((Equip)item), false, logInfo); } else { MapleInventoryManipulator.AddFromDrop(Client, (Equip)item, false, logInfo); } } else { MapleInventoryManipulator.AddById(Client, id, quantity, logInfo); } } else { MapleInventoryManipulator.RemoveById(Client, MapleItemInformationProvider.Instance.GetInventoryType(id), id, -quantity, true, false); } Client.Send(PacketCreator.GetShowItemGain(id, quantity, true)); return(true); }