本文整理汇总了C++中CChar::GetPackItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CChar::GetPackItem方法的具体用法?C++ CChar::GetPackItem怎么用?C++ CChar::GetPackItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChar
的用法示例。
在下文中一共展示了CChar::GetPackItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearTradesFunctor
bool clearTradesFunctor( CBaseObject *a, UI32 &b, void *extraData )
{
bool retVal = true;
if( ValidateObject( a ) && a->CanBeObjType( OT_ITEM ) )
{
// Body of the functor goes here
CItem *i = static_cast< CItem * >(a);
if( ValidateObject( i ) )
{
if( i->GetType() == IT_TRADEWINDOW )
{
CChar *k = FindItemOwner( i );
if( ValidateObject( k ) )
{
CItem *p = k->GetPackItem();
if( ValidateObject( p ) )
{
CDataList< CItem * > *iCont = i->GetContainsList();
for( CItem *j = iCont->First(); !iCont->Finished(); j = iCont->Next() )
{
if( ValidateObject( j ) )
j->SetCont( p );
}
}
}
i->Delete();
++b; // let's track how many we cleared
}
}
}
return retVal;
}
示例2: Handle
//o---------------------------------------------------------------------------o
//| Function : void buyItem(CSocket *mSock)
//| Date : Unknown
//| Programmer : UOX3 DevTeam
//o---------------------------------------------------------------------------o
//| Purpose : Called when player buys an item from a vendor
//o---------------------------------------------------------------------------o
bool CPIBuyItem::Handle(void)
{
UI16 i;
UI32 playergoldtotal, goldtotal = 0;
bool soldout = false, clear = false;
CChar *mChar = tSock->CurrcharObj();
CItem *p = mChar->GetPackItem();
if (!ValidateObject(p))
return true;
ITEMLIST bitems;
std::vector<UI08> layer;
std::vector<UI16> amount;
// vector for storing all objects that actually end up in user backpack
std::vector< CItem * > boughtItems;
CChar *npc = calcCharObjFromSer(tSock->GetDWord(3));
UI16 itemtotal = static_cast<UI16>((tSock->GetWord(1) - 8) / 7);
if (itemtotal > 511)
return true;
boughtItems.reserve(itemtotal);
bitems.resize(itemtotal);
amount.resize(itemtotal);
layer.resize(itemtotal);
int baseOffset = 0;
for (i = 0; i < itemtotal; ++i)
{
baseOffset = 7 * i;
layer[i] = tSock->GetByte(8 + baseOffset);
bitems[i] = calcItemObjFromSer(tSock->GetDWord(9 + baseOffset));
amount[i] = tSock->GetWord(13 + baseOffset);
goldtotal += (amount[i] * (bitems[i]->GetBuyValue()));
}
bool useBank = (goldtotal >= static_cast<UI32>(cwmWorldState->ServerData()->BuyThreshold()));
if (useBank)
playergoldtotal = GetBankCount(mChar, 0x0EED);
else
playergoldtotal = GetItemAmount(mChar, 0x0EED);
if (playergoldtotal >= goldtotal || mChar->IsGM())
{
for (i = 0; i < itemtotal; ++i)
{
if (bitems[i]->GetAmount() < amount[i])
soldout = true;
// Check if onBuyFromVendor JS event is present for each item being purchased
// If true, and a return false has been returned from the script, halt the purchase
UI16 targTrig = bitems[i]->GetScriptTrigger();
cScript *toExecute = JSMapping->GetScript(targTrig);
if (toExecute != NULL)
if (toExecute->OnBuyFromVendor(tSock, npc, bitems[i]))
{
bitems.clear(); //needed???
return true;
}
}
if (soldout)
{
npc->TextMessage(tSock, 1336, TALK, false);
clear = true;
}
else
{
if (mChar->IsGM())
npc->TextMessage(NULL, 1337, TALK, false, mChar->GetName().c_str());
else
{
if (goldtotal == 1)
npc->TextMessage(NULL, 1338, TALK, false, mChar->GetName().c_str(), goldtotal);
else
npc->TextMessage(NULL, 1339, TALK, false, mChar->GetName().c_str(), goldtotal);
Effects->goldSound(tSock, goldtotal);
}
clear = true;
if (!mChar->IsGM())
if (useBank)
DeleteBankItem(mChar, goldtotal, 0x0EED);
else
DeleteItemAmount(mChar, goldtotal, 0x0EED);
CItem *biTemp;
CItem *iMade = NULL;
UI16 j;
for (i = 0; i < itemtotal; ++i)
{
//.........这里部分代码省略.........