GameServer/PC.cpp
/*
	Description
		create item and give it to pc

	Param
		IN		int			itemIndex		// item db index
		IN		int			plus			// item plus
		IN		int			flag			// item flag
		IN		LONGLONG	itemNum			// item count
		IN		bool		ndrop			// can drop field
		IN		bool		nOtion			// can plus option

	Return
		type bool
		if item create and give success, return true, otherwise return false
*/
Description
create item and give it to pc



Return
type bool
if item create and give success, return true, otherwise return false
Description create item and give it to pc Return type bool if item create and give success return true otherwise return false
bool CPC::GiveItem(int itemIndex, int plus, int flag, LONGLONG itemNum, bool bdrop, bool bOption)
{
	CItem* item = NULL;
	item = gserver->m_itemProtoList.CreateItem(itemIndex, -1, plus, flag, itemNum);
	if (!item)
	{
		return false;
	}
	bool bIsRare = false;
	if (item->IsRareItem())
	{
		bOption = false;
		bIsRare = true;
	}
	if (item->IsOriginItem())
	{
		bOption = false;
		bIsRare = false;
	}
	if( bOption )
	{
		const static int Option_table[5][4] =
		{
			{ 22, 12 ,13, 18 },		
			{ 23, 14, 15, 18 },		
			{ 7, 11, 18, 20 },		
			{ 20, 8, 11, 18 },		
			{ 0, 1, 2, 3}
		};		
		int Option_type = 0;
		switch( itemIndex )
		{
		case 1823:
			break;
		case 1824:
			Option_type = 1;
			break;
		case 1825:
			Option_type = 2;
			break;
		case 1826:
			Option_type = 3;
			break;
		case 1827:
			Option_type = 4;
			break;
		}
		for (int i=0; i < MAX_ITEM_OPTION - 1; i++)
		{
			if ( Option_table[Option_type][i] < 0 || Option_table[Option_type][i] >= MAX_NUM_OPTION )
				continue;
			item->m_option[i].m_proto = gserver->m_optionProtoList.FindProto(Option_table[Option_type][i]);
			if (!item->m_option[i].m_proto)
				continue;
			item->m_option[item->m_nOption].m_type = Option_table[Option_type][i];
			item->m_option[item->m_nOption].m_level = 4;
			item->m_option[item->m_nOption].m_value = item->m_option[i].m_proto->m_levelValue[item->m_option[i].m_level - 1];
			item->m_option[item->m_nOption].SetDBValue();
			++item->m_nOption;
		}
	}
	else if (!bIsRare)
	{
		if( item->IsAccessary()  && item->m_nOption < 1)
		{
			OptionSettingItem( this, item );
		}
	}
	if (this->m_inventory.addItem(item) == false)
	{
		if( !bdrop )
		{
			CNetMsg::SP rmsg(new CNetMsg);
			SysFullInventoryMsg(rmsg, 0);
			SEND_Q(rmsg, this->m_desc);
			delete item;
			return false;
		}
		item = this->m_pArea->DropItem(item, this);
		if (!item)
			return false;
		{
			CNetMsg::SP rmsg(new CNetMsg);
			SysMsg( rmsg, MSG_SYS_FULL_INVENTORY_AND_DROP );
			SEND_Q( rmsg, this->m_desc );
		}
		{
			CNetMsg::SP rmsg(new CNetMsg);
			item->m_preferenceIndex = this->m_index;
			ItemDropMsg(rmsg, this, item);
			this->m_pArea->SendToCell(rmsg, this, true);
		}
	}
	return true;
}
bool CPC :: GiveItem ( int itemIndex , int plus , int flag , LONGLONG itemNum , bool bdrop , bool bOption ) { CItem * item = NULL ; item = gserver -> m_itemProtoList . CreateItem ( itemIndex , -1 , plus , flag , itemNum ) ; if ( ! item ) { return false ; } bool bIsRare = false ; if ( item -> IsRareItem ( ) ) { bOption = false ; bIsRare = true ; } if ( item -> IsOriginItem ( ) ) { bOption = false ; bIsRare = false ; } if ( bOption ) { const static int Option_table [ 5 ] [ 4 ] = { { 22 , 12 , 13 , 18 } , { 23 , 14 , 15 , 18 } , { 7 , 11 , 18 , 20 } , { 20 , 8 , 11 , 18 } , { 0 , 1 , 2 , 3 } } ; int Option_type = 0 ; switch ( itemIndex ) { case 1823 : break ; case 1824 : Option_type = 1 ; break ; case 1825 : Option_type = 2 ; break ; case 1826 : Option_type = 3 ; break ; case 1827 : Option_type = 4 ; break ; } for ( int i = 0 ; i < MAX_ITEM_OPTION - 1 ; i ++ ) { if ( Option_table [ Option_type ] [ i ] < 0 || Option_table [ Option_type ] [ i ] >= MAX_NUM_OPTION ) continue ; item -> m_option [ i ] . m_proto = gserver -> m_optionProtoList . FindProto ( Option_table [ Option_type ] [ i ] ) ; if ( ! item -> m_option [ i ] . m_proto ) continue ; item -> m_option [ item -> m_nOption ] . m_type = Option_table [ Option_type ] [ i ] ; item -> m_option [ item -> m_nOption ] . m_level = 4 ; item -> m_option [ item -> m_nOption ] . m_value = item -> m_option [ i ] . m_proto -> m_levelValue [ item -> m_option [ i ] . m_level - 1 ] ; item -> m_option [ item -> m_nOption ] . SetDBValue ( ) ; ++ item -> m_nOption ; } } else if ( ! bIsRare ) { if ( item -> IsAccessary ( ) && item -> m_nOption < 1 ) { OptionSettingItem ( this , item ) ; } } if ( this -> m_inventory . addItem ( item ) == false ) { if ( ! bdrop ) { CNetMsg :: SP rmsg ( new CNetMsg ) ; SysFullInventoryMsg ( rmsg , 0 ) ; SEND_Q ( rmsg , this -> m_desc ) ; delete item ; return false ; } item = this -> m_pArea -> DropItem ( item , this ) ; if ( ! item ) return false ; { CNetMsg :: SP rmsg ( new CNetMsg ) ; SysMsg ( rmsg , MSG_SYS_FULL_INVENTORY_AND_DROP ) ; SEND_Q ( rmsg , this -> m_desc ) ; } { CNetMsg :: SP rmsg ( new CNetMsg ) ; item -> m_preferenceIndex = this -> m_index ; ItemDropMsg ( rmsg , this , item ) ; this -> m_pArea -> SendToCell ( rmsg , this , true ) ; } } return true ; }
Description
create item and give it to pc
Description create item and give it to pc
////////////////////////////// // item 생성 실패 //		GAMELOG << init("CREATE_AND_GIVE_ITEM_ERROR CANNOT CREATE", this) //					<< itemIndex << delim //					<< itemNum << delim //					<< end; // 근력의 반지 옵션 타입 a_type // 민첩의 목걸이 옵션 타입 a_type // 지혜의 귀걸이 옵션 타입 a_type // 생명의 목걸이 옵션 타입 a_type // 영혼의 반지 옵션 타입 a_type // 인벤토리 가득참