本文整理汇总了C++中Npc::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Npc::getPosition方法的具体用法?C++ Npc::getPosition怎么用?C++ Npc::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npc
的用法示例。
在下文中一共展示了Npc::getPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: placeNpc
bool TalkAction::placeNpc(Player* player, const std::string& words, const std::string& param)
{
if (!player)
{
return false;
}
Npc* npc = Npc::createNpc(param);
if (!npc)
{
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "This NPC does not exist.");
return false;
}
// Place the npc
if (g_game.placeCreature(npc, player->getPosition()))
{
g_game.addMagicEffect(player->getPosition(), NM_ME_MAGIC_BLOOD);
npc->setMasterPos(npc->getPosition());
return true;
}
else
{
delete npc;
player->sendCancelMessage(RET_NOTENOUGHROOM);
g_game.addMagicEffect(player->getPosition(), NM_ME_PUFF);
}
return false;
}
示例2: luagetDistanceTo
int NpcScriptInterface::luagetDistanceTo(lua_State *L)
{
//getDistanceTo(uid)
uint32_t uid = popNumber(L);
ScriptEnviroment* env = getScriptEnv();
Npc* npc = env->getNpc();
Thing* thing = env->getThingByUID(uid);
if(thing && npc){
Position thing_pos = thing->getPosition();
Position npc_pos = npc->getPosition();
if(npc_pos.z != thing_pos.z){
lua_pushnumber(L, -1);
}
else{
int32_t dist = std::max(std::abs(npc_pos.x - thing_pos.x), std::abs(npc_pos.y - thing_pos.y));
lua_pushnumber(L, dist);
}
}
else{
reportErrorFunc(getErrorDesc(LUA_ERROR_THING_NOT_FOUND));
lua_pushnil(L);
}
return 1;
}
示例3: luaSelfGetPos
int32_t NpcScriptInterface::luaSelfGetPos(lua_State* L)
{
//selfGetPosition()
Npc* npc = getScriptEnv()->getNpc();
if (npc) {
pushPosition(L, npc->getPosition(), 0);
} else {
lua_pushnil(L);
}
return 1;
}
示例4: luaGetNpcPos
int32_t NpcScriptInterface::luaGetNpcPos(lua_State* L)
{
//getNpcPos()
Position pos;
uint32_t stackpos = 0;
Npc* npc = getScriptEnv()->getNpc();
if (npc) {
pos = npc->getPosition();
stackpos = npc->getParent()->__getIndexOfThing(npc);
}
pushPosition(L, pos, stackpos);
return 1;
}
示例5: luaSelfGetPos
int32_t NpcScriptInterface::luaSelfGetPos(lua_State* L)
{
//selfGetPosition()
ScriptEnvironment* env = getScriptEnv();
Npc* npc = env->getNpc();
if (npc) {
Position pos = npc->getPosition();
pushPosition(L, pos);
} else {
lua_pushnil(L);
}
return 1;
}
示例6: placeNpc
void Commands::placeNpc(Player* player, const std::string& cmd, const std::string& param)
{
Npc* npc = Npc::createNpc(param);
if (!npc) {
return;
}
// Place the npc
if (g_game.placeCreature(npc, player->getPosition())) {
g_game.addMagicEffect(player->getPosition(), NM_ME_MAGIC_BLOOD);
npc->setMasterPos(npc->getPosition());
} else {
delete npc;
player->sendCancelMessage(RET_NOTENOUGHROOM);
g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
}
}
示例7: luaSelfGetPos
int NpcScriptInterface::luaSelfGetPos(lua_State *L)
{
//selfGetPosition()
ScriptEnviroment* env = getScriptEnv();
Npc* npc = env->getNpc();
if(npc){
Position pos = npc->getPosition();
lua_pushnumber(L, pos.x);
lua_pushnumber(L, pos.y);
lua_pushnumber(L, pos.z);
}
else{
lua_pushnil(L);
lua_pushnil(L);
lua_pushnil(L);
}
return 3;
}
示例8: sortCondition
bool sortCondition(Npc &s1, Npc &s2) {
return s1.getPosition().y < s2.getPosition().y;
}