Jump to content

Lyricz

Member
  • Posts

    2
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Lyricz

  1. 40 minutes ago, Filiq said:

    post PickupItem function

    bool CHARACTER::PickupItem(DWORD dwVID)
    {
    	LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
    
    	if (!IsPC() || IsObserverMode())
    		return false;
    
    	if (!item || !item->GetSectree())
    		return false;
    
    	if (item->DistanceValid(this))
    	{
    		if (item->IsOwnership(this))
    		{
    			// ??????a AOA????A CI??A ????AIAUAI ????A???o??e
    			if (item->GetType() == ITEM_ELK)
    			{
    				GiveGold(item->GetCount());
    				item->RemoveFromGround();
    
    				M2_DESTROY_ITEM(item);
    
    				Save();
    			}
    			// ??o??uCN ????AIAUAI??o??e
    			else
    			{
    				if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
    				{
    					WORD bCount = item->GetCount();
    
    					for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
    					{
    						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;
    
    							WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
    							bCount -= bCount2;
    #if defined(__EXTENDED_BLEND_AFFECT__)
    							if (item2->IsBlendItem() && item->IsBlendItem())
    								item2->SetSocket(2, item2->GetSocket(2) + item->GetSocket(2));
    							else
    								item2->SetCount(item2->GetCount() + bCount2);
    #else
    							item2->SetCount(item2->GetCount() + bCount2);
    #endif
    
    							if (bCount == 0)
    							{
    #ifdef ENABLE_EXTENDED_BATTLE_PASS
    								if (item->IsOwnership(this))
    									UpdateExtBattlePassMissionProgress(BP_ITEM_COLLECT, bCount2, item->GetVnum());
    #endif
    								if (item->GetCount() > 1)
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), item2->GetName());	
    								}
    								M2_DESTROY_ITEM(item);
    								if (item2->GetType() == ITEM_QUEST)
    									quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
    								return true;
    							}
    						}
    					}
    					
    #ifdef ENABLE_SPECIAL_INVENTORY
    					for (int i = SPECIAL_INVENTORY_SLOT_START; i < SPECIAL_INVENTORY_SLOT_END; ++i)
    					{
    						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;
    							}
    
    							WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
    							bCount -= bCount2;
    
    							item2->SetCount(item2->GetCount() + bCount2);
    
    							if (bCount == 0)
    							{
    #ifdef ENABLE_EXTENDED_BATTLE_PASS
    								if (item->IsOwnership(this))
    									UpdateExtBattlePassMissionProgress(BP_ITEM_COLLECT, bCount2, item->GetVnum());
    #endif
    								if (item->GetCount() > 1)
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), item->GetName());
    								}
    								M2_DESTROY_ITEM(item);
    								if (item2->GetType() == ITEM_QUEST)
    									quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
    								return true;
    							}
    						}
    					}
    #endif
    
    					item->SetCount(bCount);
    #ifdef ENABLE_EXTENDED_BATTLE_PASS
    					if (item->IsOwnership(this))
    						UpdateExtBattlePassMissionProgress(BP_ITEM_COLLECT, bCount, item->GetVnum());
    #endif
    				}
    
    				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("You carry too many Items."));
    						return false;
    					}
    				}
    				else
    				{
    #ifdef ENABLE_SPECIAL_INVENTORY
    					if ((iEmptyCell = GetEmptyInventory(item)) == -1)
    #else
    					if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
    #endif
    					{
    						sys_log(0, "No empty inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
    						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You carry too many Items."));
    						return false;
    					}
    				}
    
    				item->RemoveFromGround();
    				
    				if (item->IsDragonSoul())
    					item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
    				else
    					item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
    				
    #ifndef DISABLE_LOGS
    				char szHint[32+1];
    				snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
    				LogManager::instance().ItemLog(this, item, "GET", szHint);
    #endif
    				if (item->GetCount() > 1)
    				{
    					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item->GetName());
    				}
    				else
    				{
    					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), 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);
    			GetParty()->ForEachOnMapMember(funcFindOwnership, GetMapIndex());
    
    			LPCHARACTER owner = funcFindOwnership.owner;
    			if (!owner)
    				return false;
    			
    			if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
    			{
    				WORD bCount = item->GetCount();
    				for (int i = SPECIAL_INVENTORY_SLOT_START; i < SPECIAL_INVENTORY_SLOT_END; ++i)
    				//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;
    						}
    
    						WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
    						bCount -= bCount2;
    
    						item2->SetCount(item2->GetCount() + bCount2);
    
    						if (bCount == 0)
    						{
    #ifdef ENABLE_EXTENDED_BATTLE_PASS
    							if (item->IsOwnership(this))
    								UpdateExtBattlePassMissionProgress(BP_ITEM_COLLECT, bCount2, item->GetVnum());
    #endif
    							if (owner == this)
    							{
    								if (item->GetCount() > 1)
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), item2->GetName());
    								}
    							}
    							else
    							{
    								if (item->GetCount() > 1)
    								{
    									owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %dx %s "), GetName(), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %s "), GetName(), item2->GetName());
    								}
    							}
    							M2_DESTROY_ITEM(item);
    							return true;
    						}
    					}
    				}
    				
    /*#ifdef ENABLE_SPECIAL_INVENTORY
    				for (int i = 0; i < INVENTORY_MAX_NUM; ++i) 
    				{
    					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;
    						}
    
    						WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
    						bCount -= bCount2;
    
    						item2->SetCount(item2->GetCount() + bCount2);
    						
    						if (bCount == 0)
    						{
    #ifdef ENABLE_EXTENDED_BATTLE_PASS
    							if (item->IsOwnership(this))
    								UpdateExtBattlePassMissionProgress(BP_ITEM_COLLECT, bCount2, item->GetVnum());
    #endif
    							if (owner == this)
    							{
    								if (item->GetCount() > 1)
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), item2->GetName());
    								}
    							}
    							else
    							{
    								if (item->GetCount() > 1)
    								{
    									owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %dx %s "), GetName(), item->GetCount(), item2->GetName());
    								}
    								else
    								{
    									owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %s "), GetName(), item2->GetName());
    								}
    							}
    							M2_DESTROY_ITEM(item);
    							return true;
    						}
    					}
    				}
    #endif*/
    
    				
    				item->SetCount(bCount);
    			}
    
    
    
    			int iEmptyCell;
    
    			if (item->IsDragonSoul())
    			{
    				if (!(owner && (iEmptyCell = owner->GetEmptyDragonSoulInventory(item)) != -1))
    				{
    					owner = this;
    
    					if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
    					{
    						owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You carry too many Items."));
    						return false;
    					}
    				}
    			}
    			else
    			{
    #ifdef ENABLE_SPECIAL_INVENTORY
    				if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item)) != -1))
    #else
    				if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item->GetSize())) != -1))
    #endif
    				{
    					owner = this;
    
    #ifdef ENABLE_SPECIAL_INVENTORY
    					if ((iEmptyCell = GetEmptyInventory(item)) == -1)
    #else
    					if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
    #endif
    					{
    						owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You carry too many Items."));
    						return false;
    					}
    				}
    			}
    
    			item->RemoveFromGround();
    
    			if (item->IsDragonSoul())
    				item->AddToCharacter(owner, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
    			else
    				item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
    #ifndef DISABLE_LOGS
    			char szHint[32+1];
    			snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
    			LogManager::instance().ItemLog(owner, item, "GET", szHint);
    #endif
    			if (owner == this)
    			{
    				if (item->GetCount() > 1)
    				{
    					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dx %s received"), item->GetCount(), item->GetName());
    				}
    				else
    				{
    					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s received"), item->GetName());
    				}
    			}
    			else
    			{
    				if (item->GetCount() > 1)
    				{
    					owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %dx %s "), GetName(), item->GetCount(), item->GetName());
    				}
    				else
    				{
    					owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Received Item: %s, %s "), GetName(), item->GetName());
    				}
    			}
    
    			if (item->GetType() == ITEM_QUEST)
    				quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
    
    			return true;
    		}
    	}
    
    	return false;
    }

    Here looked for multiple days now i cannot find anything 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.