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


C++ Obj_Human::GetAIObj方法代码示例

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


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

示例1: Execute

uint CGManipulatePetHandler::Execute( CGManipulatePet* 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 ) ;

	Item *pPetItem = pHuman->GetPetItem(pPacket->GetGUID());
	if(pPetItem == NULL)
		return PACKET_EXE_CONTINUE;

	if(pPetItem->IsLock())
	{
		return PACKET_EXE_CONTINUE;
	}

	INT nType = pPacket->GetManipulateType();
	switch(nType)
	{
	case MANIPULATE_CREATEPET:
		{// 召唤宠物
			ORESULT oResult = pHuman->TestCallUpPet(pPacket->GetGUID() );
			if( OR_SUCCEEDED(oResult) )
			{
				AI_Human* pHumanAI = (AI_Human*)(pHuman->GetAIObj());
				if (pHumanAI)
				{
					ObjID_t idSkill = CALL_UP_PET;
					oResult = pHumanAI->PushCommand_UseSkill(idSkill, 1, -1, -1.f, -1.f, 0.f, INVALID_GUID);
				}
			}
			if( OR_FAILED(oResult) )
			{
				GCManipulatePetRet msg;
				msg.SetManipulateRet(GCManipulatePetRet::MANIPULATEPET_RET_CALLUPFALID);
				pGamePlayer->SendPacket(&msg);

				pHuman->SendOperateResultMsg(oResult);
				return PACKET_EXE_CONTINUE;
			}

			pHuman->ReCallPet();
			pHuman->SetGUIDOfCallUpPet(pPacket->GetGUID());
		}
		break;
	case MANIPULATE_DELETEPET:
		{// 收回宠物
			ORESULT oResult = pHuman->ReCallPet();
			GCManipulatePetRet msg;
			if (OR_FAILED(oResult))
			{
				msg.SetManipulateRet(GCManipulatePetRet::MANIPULATEPET_RET_RECALLFALID);
			}
			else if (OR_SUCCEEDED(oResult))
			{
				msg.SetManipulateRet(GCManipulatePetRet::MANIPULATEPET_RET_RECALLSUCC);
			}
			pGamePlayer->SendPacket(&msg);
		}
		break;
	case MANIPULATE_FREEPET:
		{// 放生宠物
			PET_LOG_PARAM	PetLogParam;
			ORESULT oResult = pHuman->FreePetToNature(&PetLogParam,pPacket->GetGUID());
			GCManipulatePetRet msg;
			if (OR_FAILED(oResult))
			{
				msg.SetManipulateRet(GCManipulatePetRet::MANIPULATEPET_RET_FREEFALID);
			}
			else if (OR_SUCCEEDED(oResult))
			{
				msg.SetManipulateRet(GCManipulatePetRet::MANIPULATEPET_RET_FREESUCC);
			}
			pGamePlayer->SendPacket(&msg);
		}
		break;
	case MANIPULATE_ASKOTHERPETINFO:
		{// 察看其他玩家的宠物信息
			ObjID_t objID = pPacket->GetObjID();
			Obj* pObj = pScene->GetObjManager()->GetObj(objID);
			if (pObj && pObj->GetObjType() == Obj::OBJ_TYPE_PET)
			{
				Obj_Human* pCreator = ((Obj_Pet*)pObj)->GetCreator();
				if (pCreator)
				{
					PET_GUID_t guidpet = ((Obj_Pet*)pObj)->GetPetGUID();
					if(guidpet.IsNull())
//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGManipulatePetHandler.cpp

示例2: Execute

uint CGStallEstablishHandler::Execute( CGStallEstablish* 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 ) ;

	// 通过AI判断当前状态下能否摆摊
	AI_Human* pAIHuman = (AI_Human*)(pHuman->GetAIObj());
	if (!pAIHuman) {
		return PACKET_EXE_ERROR;
	}

	ORESULT oResult = pAIHuman->PushCommand_Stall();
	if (OR_OK != oResult) {
		pHuman->SendOperateResultMsg(oResult);
		return PACKET_EXE_ERROR;
	}
	//验证是否有资格摆摊
	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_READY)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pHuman->m_StallBox.CleanUp();
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallEstablishHandler::ObjID=%d, ERR_ILLEGAL:!= ServerStallBox::STALL_READY"
			,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	
	UINT	PosTax		= 0;
	BYTE	TradeTax	= 0;
	StallInfoManager* pStallInfoMgr = pScene->GetStallInfoManager();
	if(pStallInfoMgr)
	{
		UINT PosX = (UINT)pHuman->getWorldPos()->m_fX;
		UINT PosZ = (UINT)pHuman->getWorldPos()->m_fZ;
		PosTax	  = pStallInfoMgr->StallPosPayment(PosX, PosZ);
		TradeTax  = pStallInfoMgr->StallExchangeTax(PosX, PosZ);

		if(pHuman->GetMoney() < PosTax)
		{
			GCStallError	Msg;
			Msg.SetID(STALL_MSG::ERR_NOT_ENOUGH_MONEY_TO_OPEN);
			pHuman->m_StallBox.CleanUp();
			pGamePlayer->SendPacket(&Msg);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallEstablishHandler::ObjID=%d, ERR_NOT_ENOUGH_MONEY_TO_OPEN"
				,pHuman->GetID()) ;
			return PACKET_EXE_CONTINUE ;
		}
		else
		{
			pHuman->SetMoney(pHuman->GetMoney() - PosTax);
			MONEY_LOG_PARAM	MoneyLogParam;
			MoneyLogParam.CharGUID	=	pHuman->GetGUID();
			MoneyLogParam.OPType	=	MONEY_EXCHANGE_STALL_TAX;	
			MoneyLogParam.Count		=	PosTax;
			MoneyLogParam.SceneID	=	pHuman->getScene()->SceneID();
			MoneyLogParam.XPos		=	pHuman->getWorldPos()->m_fX;
			MoneyLogParam.ZPos		=	pHuman->getWorldPos()->m_fZ;
			SaveMoneyLog(&MoneyLogParam);

		}

		//验证完毕,设置摊位盒
		pHuman->m_StallBox.SetStallStatus(ServerStallBox::STALL_OPEN);
		pHuman->m_StallBox.SetStallIsOpen(TRUE);//这个语句会引起客户端的显示更新
		pHuman->m_StallBox.SetPosTax(PosTax);
		pHuman->m_StallBox.SetTradeTax(TradeTax);
		//pHuman->m_StallBox.SetFirstPage(0);

		//占了这格,不准别人再摆摊了
		pStallInfoMgr->SetCanStall(PosX, PosZ, FALSE);
		pHuman->m_StallBox.SetStallPos(PosX, PosZ);

		//通知自己初始化自己的摊位盒
		GCStallEstablish Msg;
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "CGStallEstablishHandler::ObjID=%d"
			,pHuman->GetID()) ;
	}
	else
	{
		Assert(0);
	}

		return PACKET_EXE_CONTINUE ;

//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallEstablishHandler.cpp


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