Allow to sell item for: money, extendedCost or money+extendedCost.
The new method (money+extende) can be used by using negative values on npc_vendor.ExtendedCost. This one goes dedicated to ZxBiohazardZx. Tnx also to VladimirMangos. --HG-- branch : trunk
This commit is contained in:
@@ -19573,12 +19573,12 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
return false;
|
||||
}
|
||||
|
||||
if (crItem->ExtendedCost)
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId())
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
if (!iece)
|
||||
{
|
||||
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
|
||||
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, extendedCostId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19615,10 +19615,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
}
|
||||
}
|
||||
|
||||
int32 price = pProto->BuyPrice * count;
|
||||
int32 price = crItem->IsExcludeMoneyPrice() ? 0 : pProto->BuyPrice * count;
|
||||
|
||||
// reputation discount
|
||||
price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
|
||||
if (price)
|
||||
price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
|
||||
|
||||
if (GetMoney() < price)
|
||||
{
|
||||
@@ -19638,9 +19639,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
|
||||
ModifyMoney(-(int32)price);
|
||||
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
||||
|
||||
@@ -19666,11 +19667,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
GetSession()->SendPacket(&data);
|
||||
SendNewItem(it, pProto->BuyCount*count, true, false, false);
|
||||
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost)
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
|
||||
{
|
||||
it->SetRefundRecipient(GetGUIDLow());
|
||||
it->SetPaidMoney(price);
|
||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
||||
it->SetPaidExtendedCost(crItem->GetExtendedCostId());
|
||||
it->SaveRefundDataToDB();
|
||||
AddRefundReference(it->GetGUID());
|
||||
}
|
||||
@@ -19693,9 +19694,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
}
|
||||
|
||||
ModifyMoney(-(int32)price);
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
||||
|
||||
@@ -19724,11 +19725,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
|
||||
AutoUnequipOffhandIfNeed();
|
||||
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost)
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
|
||||
{
|
||||
it->SetRefundRecipient(GetGUIDLow());
|
||||
it->SetPaidMoney(price);
|
||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
||||
it->SetPaidExtendedCost(crItem->GetExtendedCostId());
|
||||
it->SaveRefundDataToDB();
|
||||
AddRefundReference(it->GetGUID());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user