public void SendListInventory(ObjectGuid vendorGuid) { Creature vendor = GetPlayer().GetNPCIfCanInteractWith(vendorGuid, NPCFlags.Vendor, NPCFlags2.None); if (vendor == null) { Log.outDebug(LogFilter.Network, "WORLD: SendListInventory - {0} not found or you can not interact with him.", vendorGuid.ToString()); GetPlayer().SendSellError(SellResult.CantFindVendor, null, ObjectGuid.Empty); return; } // remove fake death if (GetPlayer().HasUnitState(UnitState.Died)) { GetPlayer().RemoveAurasByType(AuraType.FeignDeath); } // Stop the npc if moving vendor.PauseMovement(WorldConfig.GetUIntValue(WorldCfg.CreatureStopForPlayer)); vendor.SetHomePosition(vendor.GetPosition()); VendorItemData vendorItems = vendor.GetVendorItems(); int rawItemCount = vendorItems != null?vendorItems.GetItemCount() : 0; VendorInventory packet = new(); packet.Vendor = vendor.GetGUID(); float discountMod = GetPlayer().GetReputationPriceDiscount(vendor); byte count = 0; for (uint slot = 0; slot < rawItemCount; ++slot) { VendorItem vendorItem = vendorItems.GetItem(slot); if (vendorItem == null) { continue; } VendorItemPkt item = new(); PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(vendorItem.PlayerConditionId); if (playerCondition != null) { if (!ConditionManager.IsPlayerMeetingCondition(_player, playerCondition)) { item.PlayerConditionFailed = (int)playerCondition.Id; } } if (vendorItem.Type == ItemVendorType.Item) { ItemTemplate itemTemplate = Global.ObjectMgr.GetItemTemplate(vendorItem.item); if (itemTemplate == null) { continue; } int leftInStock = vendorItem.maxcount == 0 ? -1 : (int)vendor.GetVendorItemCurrentCount(vendorItem); if (!GetPlayer().IsGameMaster()) { if (!Convert.ToBoolean(itemTemplate.GetAllowableClass() & GetPlayer().GetClassMask()) && itemTemplate.GetBonding() == ItemBondingType.OnAcquire) { continue; } if ((itemTemplate.HasFlag(ItemFlags2.FactionHorde) && GetPlayer().GetTeam() == Team.Alliance) || (itemTemplate.HasFlag(ItemFlags2.FactionAlliance) && GetPlayer().GetTeam() == Team.Horde)) { continue; } if (leftInStock == 0) { continue; } } if (!Global.ConditionMgr.IsObjectMeetingVendorItemConditions(vendor.GetEntry(), vendorItem.item, _player, vendor)) { Log.outDebug(LogFilter.Condition, "SendListInventory: conditions not met for creature entry {0} item {1}", vendor.GetEntry(), vendorItem.item); continue; } int price = (int)(vendorItem.IsGoldRequired(itemTemplate) ? Math.Floor(itemTemplate.GetBuyPrice() * discountMod) : 0); int priceMod = GetPlayer().GetTotalAuraModifier(AuraType.ModVendorItemsPrices); if (priceMod != 0) { price -= MathFunctions.CalculatePct(price, priceMod); } item.MuID = (int)slot + 1; item.Durability = (int)itemTemplate.MaxDurability; item.ExtendedCostID = (int)vendorItem.ExtendedCost; item.Type = (int)vendorItem.Type; item.Quantity = leftInStock; item.StackCount = (int)itemTemplate.GetBuyCount(); item.Price = (ulong)price; item.DoNotFilterOnVendor = vendorItem.IgnoreFiltering; item.Refundable = itemTemplate.HasFlag(ItemFlags.ItemPurchaseRecord) && vendorItem.ExtendedCost != 0 && itemTemplate.GetMaxStackSize() == 1; item.Item.ItemID = vendorItem.item; if (!vendorItem.BonusListIDs.Empty()) { item.Item.ItemBonus.Value = new(); item.Item.ItemBonus.Value.BonusListIDs = vendorItem.BonusListIDs; } packet.Items.Add(item); } else if (vendorItem.Type == ItemVendorType.Currency) { CurrencyTypesRecord currencyTemplate = CliDB.CurrencyTypesStorage.LookupByKey(vendorItem.item); if (currencyTemplate == null) { continue; } if (vendorItem.ExtendedCost == 0) { continue; // there's no price defined for currencies, only extendedcost is used } item.MuID = (int)slot + 1; // client expects counting to start at 1 item.ExtendedCostID = (int)vendorItem.ExtendedCost; item.Item.ItemID = vendorItem.item; item.Type = (int)vendorItem.Type; item.StackCount = (int)vendorItem.maxcount; item.DoNotFilterOnVendor = vendorItem.IgnoreFiltering; packet.Items.Add(item); } else { continue; } if (++count >= SharedConst.MaxVendorItems) { break; } } packet.Reason = (byte)(count != 0 ? VendorInventoryReason.None : VendorInventoryReason.Empty); SendPacket(packet); }