本文整理汇总了C++中Inventory::getArmory方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getArmory方法的具体用法?C++ Inventory::getArmory怎么用?C++ Inventory::getArmory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getArmory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getArmory
// is armory already worn
int Script::getArmory(lua_State* L){
short tx = (short)luaL_checknumber(L, 1);
short ty = (short)luaL_checknumber(L, 2);
string weapon = string(luaL_checkstring(L, 3));
Inventory* inv = dynamic_cast<Creature*>(wrld.getObject(Vector2D(tx,ty)))->getInventory();
Item it = inv->getArmory(weapon);
if (it.isValid())
lua_pushnumber(L, it.getId());
else
lua_pushnumber(L, -1);
return 1;
}
示例2: useWeapon
// use weapon
short Script::useWeapon(Vector2D source, Vector2D target){
Inventory* inv = dynamic_cast<Creature*>(wrld.getObject(source))->getInventory();
Item it = inv->getArmory("right hand");
short index = it.getId();
weapon_ = it.getName();
lua_getglobal(L, "use_weapon");
lua_pushnumber(L, source.x);
lua_pushnumber(L, source.y);
lua_pushnumber(L, target.x);
lua_pushnumber(L, target.y);
lua_pushnumber(L, index);
if (lua_pcall(L, 5, 1, 0) != 0){
cerr << lua_tostring(L, -1);
}
short attack = (short)luaL_checknumber(L, -1);
lua_pop(L, 1);
return attack;
}