Core/Player: Add new function AddItem. Useful in the scriptsystem for custom scripts.
--HG-- branch : trunk
This commit is contained in:
@@ -6853,25 +6853,10 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, int32 honor, bool pvpt
|
|||||||
|| (MapType == 3 && !InBattleground()))
|
|| (MapType == 3 && !InBattleground()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
uint32 noSpaceForCount = 0;
|
|
||||||
uint32 itemId = sWorld.getIntConfig(CONFIG_PVP_TOKEN_ID);
|
uint32 itemId = sWorld.getIntConfig(CONFIG_PVP_TOKEN_ID);
|
||||||
int32 count = sWorld.getIntConfig(CONFIG_PVP_TOKEN_COUNT);
|
int32 count = sWorld.getIntConfig(CONFIG_PVP_TOKEN_COUNT);
|
||||||
|
|
||||||
// check space and find places
|
if(AddItem(itemId, count))
|
||||||
ItemPosCountVec dest;
|
|
||||||
uint8 msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
|
|
||||||
if (msg != EQUIP_ERR_OK) // convert to possible store amount
|
|
||||||
count = noSpaceForCount;
|
|
||||||
|
|
||||||
if (count == 0 || dest.empty()) // can't add any
|
|
||||||
{
|
|
||||||
// -- TODO: Send to mailbox if no space
|
|
||||||
ChatHandler(this).PSendSysMessage("You don't have any space in your bags for a token.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
|
|
||||||
SendNewItem(item,count,true,false);
|
|
||||||
ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player.");
|
ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23997,6 +23982,29 @@ void Player::SendRefundInfo(Item *item)
|
|||||||
GetSession()->SendPacket(&data);
|
GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Player::AddItem(uint32 itemId, uint32 count)
|
||||||
|
{
|
||||||
|
uint32 noSpaceForCount = 0;
|
||||||
|
ItemPosCountVec dest;
|
||||||
|
uint8 msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
|
||||||
|
if (msg != EQUIP_ERR_OK)
|
||||||
|
count = noSpaceForCount;
|
||||||
|
|
||||||
|
if (count == 0 || dest.empty())
|
||||||
|
{
|
||||||
|
// -- TODO: Send to mailbox if no space
|
||||||
|
ChatHandler(this).PSendSysMessage("You don't have any space in your bags.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
|
||||||
|
if(item)
|
||||||
|
SendNewItem(item,count,true,false);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::RefundItem(Item *item)
|
void Player::RefundItem(Item *item)
|
||||||
{
|
{
|
||||||
if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
|
if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
|
||||||
|
|||||||
@@ -1272,6 +1272,8 @@ class Player : public Unit, public GridObject<Player>
|
|||||||
void LoadCorpse();
|
void LoadCorpse();
|
||||||
void LoadPet();
|
void LoadPet();
|
||||||
|
|
||||||
|
bool AddItem(uint32 itemId, uint32 count);
|
||||||
|
|
||||||
uint32 m_stableSlots;
|
uint32 m_stableSlots;
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user