本文整理汇总了C++中Creature::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::AddItem方法的具体用法?C++ Creature::AddItem怎么用?C++ Creature::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::AddItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateCreature
Creature* Factory::GenerateCreature(int iMaxLevel)
{
vector<Creature*> vProperCreatures;
for( auto it = vCreatures.begin();
it != vCreatures.end();
it++)
{
if((*it)->getLevel() <= iMaxLevel)
{
vProperCreatures.push_back(*it);
}
}
if(vProperCreatures.size() != 0)
{
int iIndex = (mtRandom() % vProperCreatures.size());
Creature* c_Creature = vProperCreatures[iIndex];
//use copy constructor to return a copy that is a seperate object
Creature* pReturnValue = new Creature(*c_Creature);
//arming creature
pReturnValue->AddItem(GenerateWeapon());
return pReturnValue;
}
return NULL;
}
示例2: HandleAddVendorItemCommand
bool ChatHandler::HandleAddVendorItemCommand(const char* args)
{
if (!*args)
return false;
Creature* vendor = getSelectedCreature();
if (!vendor || !vendor->isVendor())
{
SendSysMessage("You must select vendor");
return true;
}
char* pitem = strtok((char*)args, " ");
uint32 itemId = atol(pitem);
if (!pitem)
{
SendSysMessage("You must send id for item");
return true;
}
char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0
uint32 maxcount = 0;
if (fmaxcount)
maxcount = atol(fmaxcount);
char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0
uint32 incrtime = 0;
if (fincrtime)
incrtime = atol(fincrtime);
ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId);
if(!pProto)
{
PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId);
return true;
}
if(vendor->FindItem(itemId))
{
PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,itemId);
return true;
}
if (vendor->GetItemCount() >= MAX_CREATURE_ITEMS)
{
SendSysMessage("Vendor has too many items (max 128)");
return true;
}
// add to DB and to current ingame vendor
sDatabase.PExecuteLog("INSERT INTO `npc_vendor` (`entry`,`item`,`maxcount`,`incrtime`) VALUES('%u','%u','%u','%u')",vendor->GetEntry(), itemId, maxcount,incrtime);
vendor->AddItem(itemId,maxcount,incrtime);
PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime);
return false;
}