本文整理汇总了C++中CItem::GetWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetWeight方法的具体用法?C++ CItem::GetWeight怎么用?C++ CItem::GetWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetWeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calcCharWeight
//o--------------------------------------------------------------------------o
//| Function - SI32 CWeight::calcCharWeight( CChar *mChar )
//| Date - 2/23/2003
//| Developers - Zane
//| Organization - UOX3 DevTeam
//o--------------------------------------------------------------------------o
//| Description - Calculate the total weight of a character based upon all items he owns,
//| This function should never need to be called but is available for
//| bruteforce weight updating
//o--------------------------------------------------------------------------o
SI32 CWeight::calcCharWeight( CChar *mChar )
{
SI32 totalWeight = 0;
SI32 contWeight = 0;
for( CItem *i = mChar->FirstItem(); !mChar->FinishedItems(); i = mChar->NextItem() )
{
if( !ValidateObject( i ) )
continue;
if( IsWeightedContainer( i ) )
{
if( i->GetLayer() == IL_PACKITEM )
{
CTile& tile = Map->SeekTile( i->GetID() );
contWeight = static_cast<SI32>( tile.Weight() * 100); // Add the weight of the container
contWeight += calcWeight( i ); // Find and add the weight of the items in the container
i->SetWeight( contWeight, false ); // Also update the weight property of the container
totalWeight += contWeight;
}
else
totalWeight += i->GetWeight(); // Normal item, just add its weight
}
if( totalWeight >= MAX_WEIGHT )
return MAX_WEIGHT;
}
return totalWeight;
}
示例2: OnRemoveOb
void CContainer::OnRemoveOb( CGObListRec* pObRec ) // Override this = called when removed from list.
{
ADDTOCALLSTACK("CContainer::OnRemoveOb");
// remove this object from the container list.
// Overload the RemoveAt for general lists to come here.
CItem * pItem = STATIC_CAST <CItem*>(pObRec);
ASSERT(pItem);
CGObList::OnRemoveOb( pItem );
ASSERT( pItem->GetParent() == NULL );
pItem->SetContainerFlags(UID_O_DISCONNECT); // It is no place for the moment.
OnWeightChange( -pItem->GetWeight());
}
示例3: SetPropertyNum
void CCPropsItemChar::SetPropertyNum(int iPropIndex, PropertyValNum_t iVal, CObjBase* pLinkedObj, RESDISPLAY_VERSION iLimitToExpansion, bool fDeleteZero)
{
ADDTOCALLSTACK("CCPropsItemChar::SetPropertyNum");
ASSERT(!IsPropertyStr(iPropIndex));
ASSERT((iLimitToExpansion >= RDS_PRET2A) && (iLimitToExpansion < RDS_QTY));
if ((fDeleteZero && (iVal == 0)) || (_iPropertyExpansion[iPropIndex] > iLimitToExpansion))
{
if (0 == _mPropsNum.erase(iPropIndex))
return; // I didn't have this property, so avoid further processing.
}
else
_mPropsNum[iPropIndex] = iVal;
if (!pLinkedObj)
return;
// Do stuff to the pLinkedObj
switch (iPropIndex)
{
case PROPITCH_WEIGHTREDUCTION:
{
CItem *pItemLink = static_cast<CItem*>(pLinkedObj);
int oldweight = pItemLink->GetWeight();
CContainer * pCont = dynamic_cast <CContainer*> (pItemLink->GetParent());
if (pCont)
{
ASSERT(pItemLink->IsItemEquipped() || pItemLink->IsItemInContainer());
pCont->OnWeightChange(pItemLink->GetWeight() - oldweight);
pLinkedObj->UpdatePropertyFlag();
}
break;
}
//default:
// pLinkedObj->UpdatePropertyFlag();
// break;
}
}
示例4: GetWeight
int GetWeight( ItemAttr item )
{
int type, num;
getItemIndex( item.item_no, type, num );
CItem *t = ItemUnit( type, num );
if( !t ) return 0;
int weight = t->GetWeight();
if( t->GetRbutton() == DIVIDE_ITEM )
{
int dur = t->GetItemDuration();
if( dur > 0 )
weight *= item.attr[IATTR_MUCH] / dur;
else weight *= item.attr[IATTR_MUCH];
}
return weight;
}