本文整理汇总了C++中CChar::GetItemAtLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ CChar::GetItemAtLayer方法的具体用法?C++ CChar::GetItemAtLayer怎么用?C++ CChar::GetItemAtLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChar
的用法示例。
在下文中一共展示了CChar::GetItemAtLayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restockNPC
//o---------------------------------------------------------------------------o
//| Function : void restockNPC(CChar *i, bool stockAll)
//| Date : Unknown
//| Programmer : UOX3 DevTeam
//o---------------------------------------------------------------------------o
//| Purpose : Restock NPC Vendors
//o---------------------------------------------------------------------------o
void restockNPC(CChar& i, bool stockAll)
{
if (!i.IsShop())
return; // if we aren't a shopkeeper, why bother?
CItem *ci = i.GetItemAtLayer(IL_SELLCONTAINER);
if (ValidateObject(ci))
{
CDataList< CItem * > *ciCont = ci->GetContainsList();
for (CItem *c = ciCont->First(); !ciCont->Finished(); c = ciCont->Next())
if (ValidateObject(c))
{
if (stockAll)
{
c->IncAmount(c->GetRestock());
c->SetRestock(0);
}
else if (c->GetRestock())
{
UI16 stockAmt = UOX_MIN(c->GetRestock(), static_cast<UI16>((c->GetRestock() / 2) + 1));
c->IncAmount(stockAmt);
c->SetRestock(c->GetRestock() - stockAmt);
}
if (cwmWorldState->ServerData()->TradeSystemStatus())
{
CTownRegion *tReg = calcRegionFromXY(i.GetX(), i.GetY(), i.WorldNumber());
Items->StoreItemRandomValue(c, tReg);
}
}
}
}
示例2: Handle
//o---------------------------------------------------------------------------o
//| Function : void sellItem(CSocket *mSock)
//| Date : Unknown
//| Programmer : UOX3 DevTeam
//o---------------------------------------------------------------------------o
//| Purpose : Player sells an item to the vendor
//o---------------------------------------------------------------------------o
bool CPISellItem::Handle(void)
{
if (tSock->GetByte(8) != 0)
{
CChar *mChar = tSock->CurrcharObj();
CChar *n = calcCharObjFromSer(tSock->GetDWord(3));
if (!ValidateObject(n) || !ValidateObject(mChar))
return true;
CItem *buyPack = n->GetItemAtLayer(IL_BUYCONTAINER);
CItem *boughtPack = n->GetItemAtLayer(IL_BOUGHTCONTAINER);
CItem *sellPack = n->GetItemAtLayer(IL_SELLCONTAINER);
if (!ValidateObject(buyPack) || !ValidateObject(sellPack) || !ValidateObject(boughtPack))
return true;
CItem *j = NULL, *k = NULL, *l = NULL;
UI16 amt = 0, maxsell = 0;
UI08 i = 0;
UI32 totgold = 0, value = 0;
for (i = 0; i < tSock->GetByte(8); ++i)
{
j = calcItemObjFromSer(tSock->GetDWord(9 + (6*i)));
amt = tSock->GetWord(13 + (6*i));
maxsell += amt;
}
if (maxsell > cwmWorldState->ServerData()->SellMaxItemsStatus())
{
n->TextMessage(NULL, 1342, TALK, false, mChar->GetName().c_str(), cwmWorldState->ServerData()->SellMaxItemsStatus());
return true;
}
for (i = 0; i < tSock->GetByte(8); ++i)
{
j = calcItemObjFromSer(tSock->GetDWord(9 + (6*i)));
amt = tSock->GetWord(13 + (6*i));
if (ValidateObject(j))
{
if (j->GetAmount() < amt || FindItemOwner(j) != mChar)
{
n->TextMessage(NULL, 1343, TALK, false);
return true;
}
// Check if onSellToVendor JS event is present for each item being sold
// If true, and a value of "false" has been returned from the script, halt the sale
UI16 targTrig = j->GetScriptTrigger();
cScript *toExecute = JSMapping->GetScript(targTrig);
if (toExecute != NULL)
if (toExecute->OnSellToVendor(tSock, n, j))
return true;
CItem *join = NULL;
CDataList<CItem *> *pCont = boughtPack->GetContainsList();
for (k = pCont->First(); !pCont->Finished(); k = pCont->Next())
if (ValidateObject(k))
if (k->GetID() == j->GetID() && j->GetType() == k->GetType())
join = k;
pCont = buyPack->GetContainsList();
for (k = pCont->First(); !pCont->Finished(); k = pCont->Next())
if (ValidateObject(k))
if (k->GetID() == j->GetID() && j->GetType() == k->GetType())
value = calcValue(j, k->GetSellValue());
// If an object already exist in the boughtPack that this one can be joined to...
if (ValidateObject(join))
{
join->IncAmount(amt);
join->SetRestock(join->GetRestock() - amt);
l = join;
totgold += (amt * value);
if (j->GetAmount() == amt)
j->Delete();
else
j->IncAmount(-amt);
}
else
{
//Otherwise, move this item to the vendor's boughtPack
totgold += (amt * value);
if (j->GetAmount() != amt)
{
l = Items->DupeItem(tSock, j, amt);
j->SetAmount(j->GetAmount() - amt);
}
else
l = j;
if (ValidateObject(l))
l->SetCont(boughtPack);
//.........这里部分代码省略.........