summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game-server/npc.hpp14
-rw-r--r--src/scripting/lua.cpp30
2 files changed, 44 insertions, 0 deletions
diff --git a/src/game-server/npc.hpp b/src/game-server/npc.hpp
index 7c909d25..2d790c4c 100644
--- a/src/game-server/npc.hpp
+++ b/src/game-server/npc.hpp
@@ -54,6 +54,20 @@ class NPC : public Being
int getNPC() const
{ return mID; }
+ /**
+ * Gets the way an NPC is blocked by other things on the map
+ */
+ virtual unsigned char getWalkMask() const
+ { return 0x83; } // blocked like a monster by walls, monsters and characters ( bin 1000 0011)
+
+ protected:
+
+ /**
+ * Gets the way a monster blocks pathfinding for other objects
+ */
+ virtual Map::BlockType getBlockType() const
+ { return Map::BLOCKTYPE_CHARACTER; } //blocks like a player character
+
private:
Script *mScript; /**< Script describing NPC behavior. */
unsigned short mID; /**< ID of the NPC. */
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 7437af83..3d706619 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -400,6 +400,34 @@ static int LuaBeing_Walk(lua_State *s)
}
/**
+ * Function for getting the x-coordinate of the position of a being
+ */
+static int LuaPosX(lua_State *s)
+{
+ lua_pushlightuserdata(s, (void *)&registryKey);
+ lua_gettable(s, LUA_REGISTRYINDEX);
+
+ int x = getBeing(s, 1)->getPosition().x;
+ lua_pushinteger(s, x);
+
+ return 1;
+}
+
+/**
+ * Function for getting the y-coordinate of the position of a being
+ */
+static int LuaPosY(lua_State *s)
+{
+ lua_pushlightuserdata(s, (void *)&registryKey);
+ lua_gettable(s, LUA_REGISTRYINDEX);
+
+ int y = getBeing(s, 1)->getPosition().y;
+ lua_pushinteger(s, y);
+
+ return 1;
+}
+
+/**
* Callback for creating a monster on the current map.
* tmw.monster_create(int type, int x, int y)
*/
@@ -524,6 +552,8 @@ LuaScript::LuaScript():
{ "chr_set_quest", &LuaChr_SetQuest },
{ "monster_create", &LuaMonster_Create },
{ "being_walk", &LuaBeing_Walk },
+ { "posX", &LuaPosX },
+ { "posY", &LuaPosY },
{ NULL, NULL }
};
luaL_register(mState, "tmw", callbacks);