本文整理汇总了C++中Item::GetItemClass方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetItemClass方法的具体用法?C++ Item::GetItemClass怎么用?C++ Item::GetItemClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::GetItemClass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
UINT CGUnEquipHandler::Execute( CGUnEquip* 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 ) ;
HUMAN_EQUIP EquipPoint = (HUMAN_EQUIP)pPacket->getEquipPoint();
//Assert( pHuman->GetDB()->GetEquipDB()->IsSet(EquipPoint) ) ;
Item* pEquipItem = HumanItemLogic::GetEquip(pHuman,EquipPoint);
if(!pEquipItem)
{
Assert(pEquipItem);
return PACKET_EXE_CONTINUE;
}
if(pEquipItem->IsEmpty())
{
return PACKET_EXE_CONTINUE;
}
UCHAR itemClass = pEquipItem->GetItemClass();
if(itemClass == ICLASS_EQUIP)
{
INT BagIndex;// = pHuman->GetFirstEmptyBagIndex();
ItemContainer* pEquipContainer = pHuman->GetEquipContain();
ItemContainer* pBaseContainer = pHuman->GetBaseContain();
if(!pEquipContainer)
{
Assert(pEquipItem);
return PACKET_EXE_CONTINUE;
}
BYTE DeliverBagIndex = pPacket->getBagIndex();
if(DeliverBagIndex<pBaseContainer->GetContainerSize())
{
BagIndex = g_ItemOperator.MoveItem(pEquipContainer,
EquipPoint,
pBaseContainer,DeliverBagIndex);
}
else
{
BagIndex = g_ItemOperator.MoveItem(pEquipContainer,
EquipPoint,
pBaseContainer);
}
GCUnEquipResult Msg;
if(BagIndex>=0
&& BagIndex<pBaseContainer->GetContainerSize())
{
Msg.setEquipPoint(EquipPoint);
Msg.setBagIndex(BagIndex);
Msg.setItemID(pEquipItem->GetGUID());
Msg.setItemTableIndex(pEquipItem->GetItemTableIndex());
Msg.setResult(UNEQUIP_SUCCESS);
pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
pHuman->ItemEffectFlush();
pGamePlayer->SendPacket( &Msg ) ;
//如果可见
if(pHuman->IsVisualPart(EquipPoint))
{
GCCharEquipment OtherMsg;
OtherMsg.setObjID(pHuman->GetID());
//if(EquipPoint == HEQUIP_WEAPON)
//{
// UINT uGemID = GetEquipmentMaxLevelGemID(pEquipItem);
// OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), uGemID);
//}
//else
//{
OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), -1);
//}
pScene->BroadCast(&OtherMsg,pHuman,TRUE);
}
}
else
//.........这里部分代码省略.........
示例2: Execute
uint CGEquipLevelupHandler::Execute(CGEquipLevelup* 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 );
//交易状态不可操作
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 ;
}
Item* pEquipItem = NULL;
UINT EquipPoint = INVALID_ITEM_POS;
UINT BagIndex = INVALID_ITEM_POS;
EQUIPLEVEUP_RESULT nResult = EQUIPLEVEUP_FAIL;
GCEquipLevelupResult Msg;
switch(pPacket->GetEquipPosType())
{
case ENUM_EQUIP_POINT:
{
EquipPoint = pPacket->GetPos();
if(EquipPoint>HEQUIP_ADORN2)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: EquipPoint error, EquipPoint=%d", EquipPoint) ;
return PACKET_EXE_ERROR;
}
ItemContainer* pEquipContainer = pHuman->GetEquipContain();
if(NULL==pEquipContainer)
{
AssertEx(FALSE,"[CGUseGem]: NULL EquipContainer pointer found!");
}
pEquipItem = pEquipContainer->GetItem((UINT)EquipPoint);
Assert(pEquipItem);
if(pEquipItem->IsEmpty())
{
nResult = EQUIPLEVEUP_EQUIP_FAIL;
Msg.SetResult(nResult);
pGamePlayer->SendPacket( &Msg ) ;
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler pEquipItem is Null at EquipPoint= %d", EquipPoint) ;
return PACKET_EXE_CONTINUE;
}
Assert (pEquipItem->GetItemClass() == ICLASS_EQUIP);
if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
{
nResult = EQUIPLEVEUP_EQUIP_FAIL;
Msg.SetResult(nResult);
pGamePlayer->SendPacket( &Msg ) ;
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler GUID is different ") ;
return PACKET_EXE_CONTINUE;
}
}
break;
case ENUM_BAG:
{
BagIndex = pPacket->GetPos();
ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman,BagIndex);
if( pItemContainer == NULL )
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: BagIndex error, BagIndex=%d", BagIndex) ;
return PACKET_EXE_ERROR;
}
if (!pItemContainer->IsCanUse())
{
nResult = EQUIPLEVEUP_BAG_INVALID;
Msg.SetResult(nResult);
pGamePlayer->SendPacket( &Msg ) ;
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d",
pItemContainer->GetContainerType(), BagIndex) ;
return PACKET_EXE_ERROR;
}
pEquipItem = pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex));
//.........这里部分代码省略.........
示例3: Execute
uint CGEquipSuitExchangeHandler::Execute(CGEquipSuitExchange* 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 ) ;
//交易状态不可操作
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 ;
}
//切场景时丢弃换装消息
if(pGamePlayer->GetPlayerStatus()!=PS_SERVER_NORMAL ||
!pHuman->IsActiveObj() )
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipSuitExchangeHandler: change scene") ;
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 ;
}
UINT nSuitNum = pPacket->getEquipSuitNum();
if( nSuitNum > MAX_EQUIP_SUIT_NUM )
{
return PACKET_EXE_ERROR ;
}
ItemContainer* pEquipContainer = pHuman->GetEquipContain();
Assert(pEquipContainer);
_SUIT_SETTING suitSetting = pHuman->GetEquipSuitSetting(nSuitNum);
GCEquipSuitExchangeResult Msg;
GCDetailEquipList SelfMsg;
GCCharEquipment OtherMsg;
SelfMsg.setObjID( pHuman->GetID() );
BOOL bChange = FALSE;
UINT RetPart = 0;
//遍历所有套装
for(INT i=0; i<HEQUIP_NUMBER; ++i)
{
//存在套装数据
if(!suitSetting.m_EquipData[i].isNull())
{
//检查装备栏
Item* pEquip = pEquipContainer->GetItem(i);
Assert(pEquip);
//装备有变化,装备栏数据与保存的对应位置套装信息不一致,需要到背包里找
if(!(pEquip->GetGUID() == suitSetting.m_EquipData[i]))
{
INT nPos = INVALID_INDEX;
ItemContainer* pBagContainer = HumanItemLogic::GetBagItemContain(pHuman, &suitSetting.m_EquipData[i], nPos);
//背包里也找不到,需记录下来(卖掉了?丢掉了?。。)
if(nPos == INVALID_INDEX)
{
EXCHANGE_EQUIP_INFO ExchangeInfo;
ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
ExchangeInfo.m_EquipPoint = INVALID_ITEM_POS;
Msg.setEquipInfo(ExchangeInfo, i);
continue;
}
//找到了
Item* pExchangeItem = HumanItemLogic::GetBagItem(pHuman, nPos);
Assert(pExchangeItem->GetItemClass() == ICLASS_EQUIP);
if(pExchangeItem->GetEquipPoint() != i)
{
if(pExchangeItem->GetEquipPoint() == HEQUIP_RING1)
{
Assert(i == HEQUIP_RING2);
//.........这里部分代码省略.........
示例4: Execute
//.........这里部分代码省略.........
GCExchangeSuccessIII::_SUCC_ITEM ItemListToOt[EXCHANGE_BOX_SIZE+EXCHANGE_PET_BOX_SIZE];
INT OtItemNum = 0;
BOOL bFlag = FALSE;
//用来记录可以交换的物品
struct ExItem_t
{
UCHAR uItemType;
INT nIndex;
INT nIndexInEx;
ExItem_t()
{
uItemType = 0;
nIndex = -1;
nIndexInEx = -1;
}
};
INT ExItemNumOt = 0;
ExItem_t ExItemIndexInOt[EXCHANGE_BOX_SIZE];
INT ExItemNumMy = 0;
ExItem_t ExItemIndexInMy[EXCHANGE_BOX_SIZE];
INT ExPetItemNumOt = 0;
ExItem_t ExPetItemIndexInOt[EXCHANGE_PET_BOX_SIZE];
INT ExPetItemNumMy = 0;
ExItem_t ExPetItemIndexInMy[EXCHANGE_PET_BOX_SIZE];
for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
{
if(pMyExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
{
Item* pItemRef = pMyExchangeContainer->GetItem(i);
ItemContainer* pMyBagContainer = HumanItemLogic::GetItemContain(pHuman, pItemRef->GetItemTableIndex());
ExItemIndexInMy[ExItemNumMy].uItemType = pItemRef->GetItemClass();
ExItemIndexInMy[ExItemNumMy].nIndex = pMyBagContainer->GetIndexByGUID(&pItemRef->GetGUID());
ExItemIndexInMy[ExItemNumMy].nIndexInEx = i;
ExItemNumMy++;
}
if(pOtExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
{
Item* pItemRef = pOtExchangeContainer->GetItem(i);
ItemContainer* pOtBagContainer = HumanItemLogic::GetItemContain(pDestHuman, pItemRef->GetItemTableIndex());
ExItemIndexInOt[ExItemNumOt].uItemType = pItemRef->GetItemClass();
ExItemIndexInOt[ExItemNumOt].nIndex = pOtBagContainer->GetIndexByGUID(&pItemRef->GetGUID());
ExItemIndexInOt[ExItemNumOt].nIndexInEx = i;
ExItemNumOt++;
}
}
for(INT i = 0; i<EXCHANGE_PET_BOX_SIZE; i++)
{
if(pMyExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
{
Item* pItemRef = pMyExchangePetContainer->GetItem(i);
ItemContainer* pMyPetContainer = pHuman->GetPetContain();
ExPetItemIndexInMy[ExPetItemNumMy].nIndex = pMyPetContainer->GetIndexByGUID(&pItemRef->GetPetGUID());
ExPetItemIndexInMy[ExPetItemNumMy].nIndexInEx = i;
ExPetItemNumMy++;
}
if(pOtExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
{
Item* pItemRef = pOtExchangePetContainer->GetItem(i);
ItemContainer* pOtPetContainer = pDestHuman->GetPetContain();
ExPetItemIndexInOt[ExPetItemNumOt].nIndex = pOtPetContainer->GetIndexByGUID(&pItemRef->GetPetGUID());
示例5: 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);
}
//.........这里部分代码省略.........
示例6: Execute
UINT CGEquipRefiningHandler::Execute( CGEquipRefining* 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 iEquipItemPos = pPacket->GetEquipItemPos();
Assert(iEquipItemPos >= 0 );
Assert(iEquipItemPos <= MAX_BAG_SIZE);
GCEquipRefining msg;
ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, iEquipItemPos);
if (pBagContainer == NULL)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler equipment BagIndex is invalid, BagIndex = %d", iEquipItemPos) ;
msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
Item* pEquipment = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(iEquipItemPos));
Assert(NULL != pEquipment);
//一些验证:星级,等级...
if( NULL == pEquipment || ICLASS_EQUIP != pEquipment->GetItemClass() || !(pEquipment->IsRuler(IRL_DISCARD) )
|| pEquipment->IsAdsorbMagic() || pEquipment->GetRequireLevel() < EQUIP_REFINING_MIN_LEVEL //已经附魔或者需求等级小于40
|| 0 == pEquipment->GetEquipGemCount()) //没有镶嵌宝石
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler equipment type is invalid, BagIndex = %d", iEquipItemPos) ;
msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
//获取炼化神器
BYTE iRefiningItemPos = pPacket->GetRefiningItemPos();
Assert(iRefiningItemPos >= 0 );
Assert(iRefiningItemPos <= MAX_BAG_SIZE);
pBagContainer = HumanItemLogic::GetBagContainer(pHuman, iRefiningItemPos);
if (pBagContainer == NULL)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler refining BagIndex is invalid, BagIndex = %d", iRefiningItemPos) ;
msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
Item* pRefiningItem = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(iRefiningItemPos));
Assert(NULL != pRefiningItem);
if(NULL == pRefiningItem || pRefiningItem->GetItemClass() != ICLASS_COMITEM || pRefiningItem->GetItemType() != COMITEM_EQUIP_REFINING)
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler refining type is invalid, BagIndex = %d", iRefiningItemPos) ;
msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
//逻辑处理
COMMITEM_INFO_TB* pGet = g_ItemTable.GetCommItemInfoTB(pRefiningItem->GetItemTableIndex());
Assert(NULL != pGet);
if ((pEquipment->GetRequireLevel()-1)/10+1 != pGet->m_nLevel)//验证等级
{
msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
if ( 0 == pEquipment->GetAttrCount())// && pEquipment->GetLevel()
{
msg.SetResult(EQUIPREFINING_NOT_HAVE_ATTR);
pGamePlayer->SendPacket(&msg);
return PACKET_EXE_CONTINUE;
}
//EQUIP_TB* pGet = g_ItemTable.GetEquipTB(pEquipment->GetItemTableIndex());
//Assert(NULL != pGet);
//删除装备和炼化神符道具
UINT iPrice = pEquipment->GetSellPrice();//保留将要删除的装备属性给后面用
BYTE iRequireLevel = pEquipment->GetRequireLevel();
BYTE curEquipPoint = pEquipment->GetEquipPoint();
BYTE attrCount = 0;
//.........这里部分代码省略.........
示例7: Execute
UINT CGUseEquipHandler::Execute(CGUseEquip* 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 ) ;
//切场景时丢弃换装消息
if(pGamePlayer->GetPlayerStatus()!=PS_SERVER_NORMAL ||
!pHuman->IsActiveObj() )
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGUseEquipmentHandler: change scene") ;
return PACKET_EXE_CONTINUE;
}
BYTE BagIndex = pPacket->getBagIndex();
if( BagIndex == INVALID_BAG_INDEX )
{
Assert(FALSE) ; //包发错了
return PACKET_EXE_CONTINUE ;
}
Item* pUseItem = HumanItemLogic::GetItem(pHuman,BagIndex);
GCUseEquipResult Msg;
//////////////////////////////////////////////////////////////////////////
//装配条件判断
UCHAR itemClass = pUseItem->GetItemClass();
if(itemClass == ICLASS_EQUIP)
{
//需求等级判断
if(pUseItem->GetRequireLevel()>pHuman->GetLevel())
{
Msg.setResult(USEEQUIP_IDENT_FAIL);
pGamePlayer->SendPacket( &Msg ) ;
}
//鉴定判断
else if(pUseItem->GetItemQual() == EQUALITY_BLUE && pUseItem->GetItemIdent() == FALSE)
{
Msg.setResult(USEEQUIP_LEVEL_FAIL);
pGamePlayer->SendPacket( &Msg ) ;
}
else
{
HUMAN_EQUIP Equip_Point =(HUMAN_EQUIP)pUseItem->GetEquipPoint();
//const _ITEM* pEquip = pHuman->GetEquip(Equip_Point);
ItemContainer* pEquipContainer = pHuman->GetEquipContain();
if(!pEquipContainer)
{
Assert(pEquipContainer);
return PACKET_EXE_CONTINUE;
}
Item* pEquipItem = pEquipContainer->GetItem((UINT)Equip_Point);
if(!pEquipItem)
{
Assert(pEquipItem);
return PACKET_EXE_CONTINUE;
}
BOOL bEquipStatus = (!pEquipItem->IsEmpty());
ItemContainer* pBagContainer =
HumanItemLogic::GetContainer(pHuman,BagIndex);
if(bEquipStatus)
{
//装备上物品,替换下来装备点数据
g_ItemOperator.ExchangeItem(pBagContainer,
pBagContainer->BagIndex2ConIndex(BagIndex),
pEquipContainer,
(UINT)Equip_Point);
}
else
{
//pHuman->GetDB()->OverWriteBag2Equip(BagIndex,Equip_Point);
g_ItemOperator.MoveItem(pBagContainer,
//.........这里部分代码省略.........
示例8: CanUseAbility
ORESULT AbilityMachining::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION
Assert( pHuman );
AbilityOpera* pAbilityOpera;
pAbilityOpera = pHuman->GetAbilityOpera();
Assert( pAbilityOpera );
switch( pAbilityOpera->m_SubType )
{
case NORMAL_TYPE:
return AbilityCompound::CanUseAbility(pHuman);
case GEM_COMPOUND:
{
ORESULT res;
res = Ability::CanUseAbility(pHuman);
if( res != OR_OK )
{
return res;
}
if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
|| (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
)
{
Assert(FALSE);
return OR_ERROR;
}
//const _ITEM* pGem1 = pHuman->GetItem(pAbilityOpera->m_BagPos[0]);
//const _ITEM* pGem2 = pHuman->GetItem(pAbilityOpera->m_BagPos[1]);
Item* pGem1Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]);
Item* pGem2Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]);
Assert( (pGem1Item != NULL) && (pGem2Item != NULL) );
if( (pGem1Item->GetItemClass() != ICLASS_GEM) || (pGem2Item->GetItemClass() != ICLASS_GEM) )
{
return OR_STUFF_LACK;
}
if((pGem1Item->GetItemIndex() != pGem2Item->GetItemIndex())// (pGem1Item->GetItemQual() != pGem2Item->GetItemQual())
)
{
return OR_STUFF_LACK;
}
//if( >= MAX_GEM_QUALITY ) // pGem1Item->GetItemQual()没法再升了
//{
// return OR_CANNOT_UPGRADE;
//}
return OR_OK;
}
break;
case GEM_EMBED:
{
ORESULT res;
res = Ability::CanUseAbility(pHuman);
if( res != OR_OK )
{
return res;
}
if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
|| (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
)
{
Assert(FALSE);
return OR_ERROR;
}
//const _ITEM* pGem = pHuman->GetItem(pAbilityOpera->m_BagPos[0]);
//const _ITEM* pEquip = pHuman->GetItem(pAbilityOpera->m_BagPos[1]);
Item* pGemItem = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]);
Item* pEquipItem = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]);
Assert( (pGemItem != NULL) && (pEquipItem != NULL) );
if( (pGemItem->GetItemClass() != ICLASS_GEM) || (pEquipItem->GetItemClass() != ICLASS_EQUIP) )
{
return OR_STUFF_LACK;
}
if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE )
{
return OR_GEM_CONFLICT;
}
LuaInterface* pLuaInterface;
pLuaInterface = pHuman->getScene()->GetLuaInterface();
if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount()
|| pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT,
"TooManyGems",
(INT)pHuman->getScene()->SceneID(),
//.........这里部分代码省略.........
示例9: CanUseAbility
ORESULT AbilityInlay::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION
Assert( pHuman );
AbilityOpera* pAbilityOpera;
pAbilityOpera = pHuman->GetAbilityOpera();
Assert( pAbilityOpera );
ORESULT res;
res = Ability::CanUseAbility(pHuman);
if( res != OR_OK )
{
return res;
}
CHAR MaterialBagIndex1 = (CHAR)pAbilityOpera->m_BagPos[2];
CHAR MaterialBagIndex2 = (CHAR)pAbilityOpera->m_BagPos[3];
if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
|| (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
|| (MaterialBagIndex1>= MAX_BAG_SIZE)|| (MaterialBagIndex2>= MAX_BAG_SIZE)
)
{
Assert(FALSE);
return OR_ERROR;
}
Item* pGemItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[0] );
Item* pEquipItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[1] );
Item* pMaterialItem1 = NULL;
Item* pMaterialItem2 = NULL;
if( MaterialBagIndex1 != -1 )
{
pMaterialItem1 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[2] );
Assert( pMaterialItem1 != NULL );
}
if( MaterialBagIndex2 != -1 )
{
pMaterialItem2 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[3] );
Assert( pMaterialItem2 != NULL );
}
Assert( (pGemItem != NULL) && (pEquipItem != NULL) );
if( (pGemItem->IsLock())
|| (pEquipItem->IsLock())
|| (pGemItem->IsPWLock())
|| (pEquipItem->IsPWLock())
|| (pGemItem->GetItemClass() != ICLASS_GEM)
|| (pEquipItem->GetItemClass() != ICLASS_EQUIP)
)
{
return OR_STUFF_LACK;
}
//if( pHuman->__GetAbilityLevel(pAbilityOpera->m_AbilityID) < pGemItem->GetItemQual() )
//{
// return OR_NO_LEVEL;
//}
if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE )
{
return OR_GEM_CONFLICT;
}
LuaInterface* pLuaInterface;
pLuaInterface = pHuman->getScene()->GetLuaInterface();
if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount()
|| pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, DEF_GEM_COUNT_CHECK,
(INT)pHuman->getScene()->SceneID(),
(INT)pHuman->GetID(),
(INT)pAbilityOpera->m_BagPos[1] )
)
{
return OR_GEM_SLOT_LACK;
}
if( pLuaInterface->ExeScript_DDDD( ABILITY_LOGIC_SCRIPT, DEF_IS_GEM_FIT_EQUIP,
(INT)pHuman->getScene()->SceneID(),
(INT)pHuman->GetID(),
pGemItem->GetItemTableIndex(),
pAbilityOpera->m_BagPos[1] ) == 0
)
{ // 判断宝石和装备是否匹配
return OR_GEM_NOT_FIT_EQUIP;
}
return OR_OK;
__LEAVE_FUNCTION
return OR_ERROR;
}
示例10: 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 )
//.........这里部分代码省略.........
示例11: Execute
uint CGExchangeSynchItemIIHandler::Execute( CGExchangeSynchItemII* 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 ) ;
//验证交易状态
EXCHANGE_CERTIFY_EACH_OTHER(pHuman) // 验证交易双方是否掉线合法
EXCHANGE_CERTIFY_ISLOCK(pHuman) // 验证当前人物的交易状态是否已经上锁
ObjID_t DestID = pHuman->m_ExchangBox.m_ObjID;
Obj_Human* pDestHuman = pScene->GetHumanManager()->GetHuman( DestID );
EXCHANGE_CERTIFY_STATUS(pHuman, EXCHANGE_SYNCH_DATA) // 验证当前人物的交易状态是否正确
EXCHANGE_CERTIFY_STATUS(pDestHuman, EXCHANGE_SYNCH_DATA)
//操作
BYTE Opt = pPacket->GetOpt();
BYTE FromType = pPacket->GetFromType();
BYTE ToType = pPacket->GetToType();
BYTE FromIndex = pPacket->GetFromIndex();
BYTE ToIndex = pPacket->GetToIndex();
PET_GUID_t PetGuid = pPacket->GetPetGuid();
_ITEM ItemTemp;
GCExchangeSynchII Msg;
GCExchangeError MsgError;
ItemContainer* pExchangeContainer = &(pHuman->m_ExchangBox.m_Container);
ItemContainer* pExchangePetContainer = &(pHuman->m_ExchangBox.m_PetContainer);
switch(Opt)
{
case OPT_ERROR:
{
}
break;
case OPT_ADDITEM:
{
switch(FromType)
{
case POS_BAG:
{
//验证位置里是否有东西
Item* pItem = HumanItemLogic::GetBagItem(pHuman, FromIndex);
if ( pItem != NULL && pItem->GetItemClass() == ICLASS_EQUIP)
{
if(pItem->GetEquipBindLevel()>0) // 装备绑定
{
MsgError.SetID(ERR_ITEM_LOCKED);
pGamePlayer->SendPacket(&MsgError);
g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 该物品[%d]已绑定,不可交易", pHuman->GetName(), FromIndex ) ;
return PACKET_EXE_CONTINUE;
}
}
if (pItem == NULL)
{
MsgError.SetID(ERR_ILLEGAL);
pGamePlayer->SendPacket(&MsgError);
g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 背包位置 [%d] 处不存在物品", pHuman->GetName(), FromIndex ) ;
return PACKET_EXE_CONTINUE;
}
if(pItem->IsEmpty() == FALSE)
{
ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, FromIndex);
if ( pBagContainer == NULL )
{
MsgError.SetID(ERR_ILLEGAL);
pGamePlayer->SendPacket(&MsgError);
g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 背包不存在", pHuman->GetName() ) ;
return PACKET_EXE_CONTINUE;
}
//先查一遍交易盒中是不是已经有该物品了
for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
{
_ITEM_GUID guid = (pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(FromIndex)))->GetGUID() ;
if(pExchangeContainer->GetItem(i)->GetGUID() == guid)
{//物品已经在交易盒中,丢弃该消息
return PACKET_EXE_CONTINUE ;
}
}
//自动找格
INT result =
//.........这里部分代码省略.........
示例12: 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;
}
//.........这里部分代码省略.........