当前位置: 首页>>代码示例>>C++>>正文


C++ Item::GetItemLevel方法代码示例

本文整理汇总了C++中Item::GetItemLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetItemLevel方法的具体用法?C++ Item::GetItemLevel怎么用?C++ Item::GetItemLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item::GetItemLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Execute

uint CGShopSellHandler::Execute( CGShopSell* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

    GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
    Assert( pGamePlayer ) ;

    Obj_Human* pHuman = pGamePlayer->GetHuman() ;
    Assert( pHuman ) ;

    Scene* pScene = pHuman->getScene() ;
    if( pScene==NULL )
    {
        Assert(FALSE) ;
        return PACKET_EXE_ERROR ;
    }
    //检查线程执行资源是否正确
    Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

    BYTE	m_nBagIndex	=	pPacket->GetBagIndex();		//包中的位置
    UINT	UniqueID	=	pPacket->GetUniqueID();

    SceneID_t	SceneID =	UniqueID>>16;
    ObjID_t		NpcObjID=	UniqueID&0x00ff;

    if(SceneID != pScene->SceneID())
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSellHandler Illegal scene ObjName = %s", pHuman->GetName()) ;
        return PACKET_EXE_CONTINUE ;
    }

    //距离判定
    Obj* pNpcObj = (Obj*) (pScene->GetObjManager()->GetObj(NpcObjID));
    if(pNpcObj == NULL)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSellHandler Illegal Obj ObjName = %s", pHuman->GetName()) ;
        return PACKET_EXE_CONTINUE ;
    }

    FLOAT fDist = MySqrt(pNpcObj->getWorldPos(), pHuman->getWorldPos());

    if(fDist>MAX_NPC_DISTANCE)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSellHandler Out Of Range ObjName = %s", pHuman->GetName()) ;
        return PACKET_EXE_CONTINUE ;
    }

    Item*		 pCurrentItem = HumanItemLogic::GetItem(pHuman,m_nBagIndex);

    if(!pCurrentItem||ConvertSerial2ItemType(pCurrentItem->GetItemTableIndex()).isNull())
    {
        //背包索引不存在
        g_pLog->FastSaveLog( LOG_FILE_1, "ERROR:CGShopSellHandler m_nBagIndex=%d PlayerName=s%",
                             m_nBagIndex,  pHuman->GetName()) ;
        return PACKET_EXE_CONTINUE;
    }

    //判定这个商人是不是收购这个物品
    _SHOP*		pShop	=	pHuman->Shop( )	;

    //商店不存在
    if(!pShop)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "ERROR:CGShopSellHandler Npc Shop Lose");
        return PACKET_EXE_CONTINUE;
    }

    //查询收购等级限制
    if( pCurrentItem->GetItemClass() == ICLASS_EQUIP )
    {
        if( pCurrentItem->GetRequireLevel() > pShop->m_nBuyLevel )
        {
            return PACKET_EXE_CONTINUE;
        }
    }
    else
    {
        if( pCurrentItem->GetItemLevel() > pShop->m_nBuyLevel )
        {
            return PACKET_EXE_CONTINUE;
        }
    }

    BOOL bCanBuy = TRUE;
    if(pShop->m_nBuyType != SHOP_All)
    {
        switch(pShop->m_nBuyType)
        {
        case SHOP_All:
        {
        }
        break;
        case SHOP_DEFENCE:		//防具
        {
            if( ICLASS_EQUIP == pCurrentItem->GetItemClass())
            {
                if( pCurrentItem->GetEquipPoint() != HEQUIP_CAP &&
                        pCurrentItem->GetEquipPoint() != HEQUIP_ARMOR &&
                        pCurrentItem->GetEquipPoint() != HEQUIP_CUFF &&
                        pCurrentItem->GetEquipPoint() != HEQUIP_BOOT )
//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGShopSellHandler.cpp

示例2: Execute

uint CGUseItemHandler::Execute(CGUseItem* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION
	USEITEM_RESULT	Result ;
	
	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}
	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID );
	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//检查是否可以使用物品
	ID_t	BagIndex = pPacket->GetBagIndex();

	//检查物品是否合法
	Item*	pBagItem = HumanItemLogic::GetBagItem(pHuman,BagIndex);
	if (pBagItem == NULL)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseItemHandler ERROR BagIndex=%d", BagIndex) ;
		return PACKET_EXE_ERROR ;
	}
	if(pBagItem->IsEmpty())
	{
		//Assert(FALSE) ; //物品得不到
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseItemHandler Can't GetItem	BagIndex=%d", BagIndex) ;
		return PACKET_EXE_CONTINUE ;
	}
	ObjID_t	Target = pHuman->GetID();
	//1.0 当前版本使用物品只处理吃药  
	//1.1 版本使用物品处理药品,藏宝图,配方  
	if(!pBagItem->IsRuler(IRL_CANUSE))
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseItemHandler Can't use item BagIndex=%d", BagIndex);
		return PACKET_EXE_CONTINUE ;
	}
	if(pHuman->GetLevel()>=pBagItem->GetItemLevel()) //级别检查
	{
		switch(pBagItem->GetItemClass()) 
		{
			case ICLASS_TASKITEM: //任务物品类
			case ICLASS_COMITEM: //药品的使用
				{
					ScriptID_t nScript = pBagItem->GetScriptID();
					SkillID_t nSkill = pBagItem->GetSkillID();
					if(INVALID_ID!= nScript)
					{
						if(FALSE == g_ScriptLogic.Item_IsSkillLikeScript(*pHuman, nScript))
						{
							g_ScriptLogic.Item_CallDefaultEvent(*pHuman, nScript, BagIndex);
							break;
						}
						else if(FALSE == g_ScriptLogic.Script_CancelImpacts(*pHuman, nScript))
						{
							//取消效果失败
							PET_GUID_t	PetGUID = pPacket->GetTargetPetGUID();

							Result = (USEITEM_RESULT)pHuman->GetHumanAI()->PushCommand_UseItem(
								pPacket->GetBagIndex(), 
								pPacket->GetTargetObjID(),
								*(pPacket->GetTargetPos()),
								PetGUID,
								pPacket->GetTargetItem() 
								);
						}
						else
						{
							Result = USEITEM_SUCCESS;
						}
					}
				}
				break;
			case ICLASS_IDENT:
				{
					Result = (USEITEM_RESULT)pHuman->UseIdentScroll(pPacket->GetBagIndex(),pPacket->GetTargetItem());
				}
				break;
			case ICLASS_STOREMAP://藏宝图
				{
					Result	=	(USEITEM_RESULT)pHuman->UseStoreMap(BagIndex);
				}
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGUseItemHandler.cpp

示例3: Execute

UINT CGUseItemHandler::Execute(CGUseItem* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION
	USEITEM_RESULT	Result ;
	
	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}
	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID );
	
	//检查是否可以使用物品
	ID_t	BagIndex = pPacket->GetBagIndex();
	Assert(BagIndex<MAX_BAG_SIZE);

	//检查物品是否合法
	Item*	pBagItem = HumanItemLogic::GetItem(pHuman,BagIndex);
	
	if(pBagItem->IsEmpty())
	{
		//Assert(FALSE) ; //物品得不到
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseItemHandler Can't GetItem	BagIndex=%d", BagIndex) ;
		return PACKET_EXE_CONTINUE ;
	}
	ObjID_t	Target = pHuman->GetID();
	//1.0 当前版本使用物品只处理吃药  
	//1.1 版本使用物品处理药品,藏宝图,配方  
	if(!pBagItem->IsRuler(IRL_CANUSE))
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseItemHandler Can't use item BagIndex=%d", BagIndex);
		return PACKET_EXE_CONTINUE ;
	}
	if(pHuman->GetLevel()>=pBagItem->GetItemLevel()) //级别检查
	{
		switch(pBagItem->GetItemClass()) 
		{
			case ICLASS_TASKITEM: //任务物品类
			case ICLASS_COMITEM: //药品的使用
				{
					if(CLASS_OF_IDENT(pBagItem))
					{
						Result = (USEITEM_RESULT)pHuman->UseIdentScroll(pPacket->GetBagIndex(),pPacket->GetTargetItem());
					}
					else
					{
						ScriptID_t nScript = pBagItem->GetScriptID();
						SkillID_t nSkill = pBagItem->GetSkillID();
						if(INVALID_ID!= nScript)
						{
							if(FALSE == g_ScriptLogic.Item_IsSkillLikeScript(*pHuman, nScript))
							{
								g_ScriptLogic.Item_CallDefaultEvent(*pHuman, nScript, BagIndex);
								break;
							}
							else if(FALSE == g_ScriptLogic.Script_CancelImpacts(*pHuman, nScript))
							{
								//取消效果失败
								PET_GUID_t	PetGUID = pPacket->GetTargetPetGUID();

								Result = (USEITEM_RESULT)pHuman->GetHumanAI()->PushCommand_UseItem(
									pPacket->GetBagIndex(), 
									pPacket->GetTargetObjID(),
									*(pPacket->GetTargetPos()),
									PetGUID,
									pPacket->GetTargetItem() 
									);
							}
							else
							{
								Result = USEITEM_SUCCESS;
							}
						}
					}
				}
				break;
			case ICLASS_STOREMAP://藏宝图
				{
					Result	=	(USEITEM_RESULT)pHuman->UseStoreMap(BagIndex);
				}
				break;
			default:
				{
					Result	=	USEITEM_INVALID;
				}
				break;
		}
	}
	else
	{
		Result = USEITEM_LEVEL_FAIL;
	}
//.........这里部分代码省略.........
开发者ID:brock7,项目名称:TianLong,代码行数:101,代码来源:CGUseItemHandler.cpp


注:本文中的Item::GetItemLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。