本文整理汇总了C++中CGameItemPtr::standardHP方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameItemPtr::standardHP方法的具体用法?C++ CGameItemPtr::standardHP怎么用?C++ CGameItemPtr::standardHP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameItemPtr
的用法示例。
在下文中一共展示了CGameItemPtr::standardHP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSystemCraftedItem
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// create a system crafted item
static CGameItemPtr createSystemCraftedItem( uint16 quantity, const NLMISC::CSheetId& sheet )
{
if (quantity == 0) return NULL;
// if quantity > 1, check if item is stackable and check stack quantity
if (quantity > 1)
{
const CStaticItem* form = CSheets::getForm( sheet );
if( form )
{
if( form->Stackable < quantity )
{
quantity = (uint16) form->Stackable;
}
}
else
{
nlwarning("<CFaberActionCommon::createACraftedItem> can't found form for item %s", sheet.toString().c_str());
}
}
if (quantity > 1)
{
CSheetId idSheetStack("stack.sitem");
CGameItemPtr stackItem = GameItemManager.createItem( idSheetStack, (uint16)1, CEntityId::Unknown, (sint16)0, false, CEntityId::Unknown );
if( stackItem == NULL )
{
nlwarning("<CFaberActionCommon::createACraftedItem> Error while creating stack bag %s -> returned a NULL pointer", idSheetStack.toString().c_str() );
return NULL;
}
else
{
uint32 hp = 0;
uint32 hpmax = 0;
for( int q = 0; q < quantity; ++q )
{
CGameItemPtr itemTmp = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), 1, const_cast<NLMISC::CEntityId&>(stackItem->getId()), (sint16)-1, true, CEntityId::Unknown );
if (!hp && itemTmp != NULL)
{
hp = itemTmp->hp();
hpmax = itemTmp->standardHP();
}
}
return stackItem;
}
}
else // do not create a stack, as there is only one object
{
CGameItemPtr item = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), (uint16)1, CEntityId::Unknown, (sint16)0, true, CEntityId::Unknown );
if( item == NULL)
{
nlwarning("<CFaberActionCommon::createACraftedItem> Error while creating item %s -> returned a NULL pointer", sheet.toString().c_str() );
return NULL;
}
return item;
}
} // createSystemCraftedItem //