bool CHARACTER::PickupItem(DWORD dwVID)
{
LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
if (IsObserverMode())
return false;
if (!item || !item->GetSectree())
return false;
if (item->DistanceValid(this))
{
if (item->IsOwnership(this))
{
// ¸¸¾à ÁÖÀ¸·Á ÇÏ´Â ¾ÆÀÌÅÛÀÌ ¿¤Å©¶ó¸é
if (item->GetType() == ITEM_ELK)
{
GiveGold(item->GetCount());
item->RemoveFromGround();
M2_DESTROY_ITEM(item);
Save();
}
// Æò¹üÇÑ ¾ÆÀÌÅÛÀ̶ó¸é
else
{
if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
{
BYTE bCount = item->GetCount();
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
#else
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
#endif
{
LPITEM item2 = GetInventoryItem(i);
if (!item2)
continue;
if (item2->GetVnum() == item->GetVnum())
{
int j;
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
if (item2->GetSocket(j) != item->GetSocket(j))
break;
if (j != ITEM_SOCKET_MAX_NUM)
continue;
BYTE bCount2 = MIN(g_bItemCountLimit - item2->GetCount(), bCount);
bCount -= bCount2;
item2->SetCount(item2->GetCount() + bCount2);
if (bCount == 0)
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kazandin %s"), item2->GetName());
M2_DESTROY_ITEM(item);
if (item2->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
return true;
}
}
}
item->SetCount(bCount);
}
int iEmptyCell;
if (item->IsDragonSoul())
{
if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
else if (item->IsSkillBook())
{
if ((iEmptyCell = GetEmptySkillBookInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
else if (item->IsUpgradeItem())
{
if ((iEmptyCell = GetEmptyUpgradeItemsInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
else if (item->IsStone())
{
if ((iEmptyCell = GetEmptyStoneInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
else if (item->IsBox())
{
if ((iEmptyCell = GetEmptyBoxInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
else if (item->IsEfsun())
{
if ((iEmptyCell = GetEmptyEfsunInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
else if (item->IsCicek())
{
if ((iEmptyCell = GetEmptyCicekInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
#endif
else
{
if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
{
sys_log(0, "No empty inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
item->RemoveFromGround();
if (item->IsDragonSoul())
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
else if (item->IsSkillBook())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsUpgradeItem())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsStone())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsBox())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsEfsun())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsCicek())
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
#endif
else
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
char szHint[32+1];
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
LogManager::instance().ItemLog(this, item, "GET", szHint);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kazandin %s"), item->GetName());
if (item->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
}
//Motion(MOTION_PICKUP);
return true;
}
else if (!IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_DROP) && GetParty())
{
// ´Ù¸¥ ÆÄƼ¿ø ¼ÒÀ¯±Ç ¾ÆÀÌÅÛÀ» ÁÖÀ¸·Á°í ÇÑ´Ù¸é
NPartyPickupDistribute::FFindOwnership funcFindOwnership(item);
GetParty()->ForEachOnlineMember(funcFindOwnership);
LPCHARACTER owner = funcFindOwnership.owner;
// @fixme115
if (!owner)
return false;
int iEmptyCell;
if (owner)
{
if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
{
BYTE bCount = item->GetCount();
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
LPITEM item2 = owner->GetInventoryItem(i);
if (!item2)
continue;
if (item2->GetVnum() == item->GetVnum())
{
int j;
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
if (item2->GetSocket(j) != item->GetSocket(j))
break;
if (j != ITEM_SOCKET_MAX_NUM)
continue;
BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
bCount -= bCount2;
item2->SetCount(item2->GetCount() + bCount2);
if (bCount == 0)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ??: %s ????? %s"), GetName(), item2->GetName());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ??: %s ??? %s"), owner->GetName(), item2->GetName());
M2_DESTROY_ITEM(item);
if (item2->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem(owner->GetPlayerID(), item2);
return true;
}
}
}
item->SetCount(bCount);
}
}
if (item->IsDragonSoul())
{
if (!(owner && (iEmptyCell = owner->GetEmptyDragonSoulInventory(item)) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
else if (item->IsSkillBook())
{
if (!(owner && (iEmptyCell = owner->GetEmptySkillBookInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptySkillBookInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
else if (item->IsUpgradeItem())
{
if (!(owner && (iEmptyCell = owner->GetEmptyUpgradeItemsInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyUpgradeItemsInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
else if (item->IsStone())
{
if (!(owner && (iEmptyCell = owner->GetEmptyStoneInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyStoneInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
else if (item->IsBox())
{
if (!(owner && (iEmptyCell = owner->GetEmptyBoxInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyBoxInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
else if (item->IsEfsun())
{
if (!(owner && (iEmptyCell = owner->GetEmptyEfsunInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyEfsunInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
else if (item->IsCicek())
{
if (!(owner && (iEmptyCell = owner->GetEmptyCicekInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyCicekInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
#endif
else
{
if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item->GetSize())) != -1))
{
owner = this;
if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("cokfazlaesyatasiyorsun"));
return false;
}
}
}
item->RemoveFromGround();
if (item->IsDragonSoul())
item->AddToCharacter(owner, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
else if (item->IsSkillBook())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsUpgradeItem())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsStone())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsBox())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsEfsun())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
else if (item->IsCicek())
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
#endif
else
item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
char szHint[32+1];
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
LogManager::instance().ItemLog(owner, item, "GET", szHint);
if (owner == this)
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kazandin %s"), item->GetName());
else
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s kazanilanesya %s"), GetName(), item->GetName());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("esyaticareti %s %s"), owner->GetName(), item->GetName());
}
if (item->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
return true;
}
}
return false;
}