本文整理汇总了C++中Equipment::getQty方法的典型用法代码示例。如果您正苦于以下问题:C++ Equipment::getQty方法的具体用法?C++ Equipment::getQty怎么用?C++ Equipment::getQty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Equipment
的用法示例。
在下文中一共展示了Equipment::getQty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: upgrade
int script::upgrade(lua_State *L)
{
//charactersession, type(0=all), rate
//returns true on success
//TODO not sure how this one should work for final version
const int n = lua_gettop(L);
if (n != 3)
return 0;
Character *c = (Character *)lua_touserdata(L, 1);
int type = (int)lua_tonumber(L, 2);
int rate = (int)lua_tonumber(L, 3);
std::uniform_int_distribution<int> dist(0, 99);
if (rate < 100 && dist(generator()) >= rate) {
return 0;
}
//here im assuming this is the upgrader's function, but what if it should work
//for players too?
Item *itm = c->getInventory()[0];
if (!itm || itm->getType() != BaseItem::EQUIP)
return 0;
Equipment *eq = (Equipment*) itm;
if (!eq->canModify() || (eq->getSlot() != Equipment::WEAPON && eq->getSlot() != Equipment::ARMOR)
|| eq->getMod() > Equipment::GRAND) {
return 0;
}
if (c->countItems(eq->getId(), eq->getMod()) < 3) {
return 0;
}
//finally
Equipment *neweq = (Equipment*) new Equipment(eq->getId(), eq->getQty(), eq->getMaxDur());
neweq->setMod(eq->getMod() + 1);
Item *r = c->getInventory().take(eq->getId(), 3, eq->getMod(), c);
if (r) {
c->getItem(neweq);
delete r;
}
lua_pushboolean(L, true);
return 1;
}