summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-03-04 18:19:22 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-03-05 20:25:48 +0100
commit0f913b8c947403557bef8533a2e5779e6ca2bc7b (patch)
tree70696cb22003720e3f3283af45284d0fde679acb
parentd4f9a3370ed27cdae23da6f8c94c68619431cd48 (diff)
downloadmanaserv-0f913b8c947403557bef8533a2e5779e6ca2bc7b.tar.gz
manaserv-0f913b8c947403557bef8533a2e5779e6ca2bc7b.tar.xz
manaserv-0f913b8c947403557bef8533a2e5779e6ca2bc7b.zip
Added lua function for getting pvp status of map
mana.map_get_pvp() now returns one of the constants in libmana-constants.lua Reviewed-by: Bertram.
-rw-r--r--scripts/lua/libmana-constants.lua4
-rw-r--r--src/game-server/mapcomposite.h4
-rw-r--r--src/scripting/lua.cpp13
3 files changed, 19 insertions, 2 deletions
diff --git a/scripts/lua/libmana-constants.lua b/scripts/lua/libmana-constants.lua
index 08d26c5..9638588 100644
--- a/scripts/lua/libmana-constants.lua
+++ b/scripts/lua/libmana-constants.lua
@@ -121,3 +121,7 @@ LOG_ERROR = 1
LOG_WARN = 2
LOG_INFO = 3
LOG_DEBUG = 4
+
+-- PvP
+PVP_NONE = 0
+PVP_FREE = 1
diff --git a/src/game-server/mapcomposite.h b/src/game-server/mapcomposite.h
index 355f0f4..5433466 100644
--- a/src/game-server/mapcomposite.h
+++ b/src/game-server/mapcomposite.h
@@ -42,8 +42,8 @@ struct MapZone;
enum PvPRules
{
- PVP_NONE, // no PvP on this map
- PVP_FREE // unrestricted PvP on this map
+ PVP_NONE = 0, // no PvP on this map
+ PVP_FREE // unrestricted PvP on this map
// [space for additional PvP modes]
};
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index bdbb311..1c32c4f 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1970,6 +1970,18 @@ static int is_walkable(lua_State *s)
return 1;
}
+static int map_get_pvp(lua_State *s)
+{
+ MapComposite *m = getScript(s)->getMap();
+ if (!m)
+ {
+ raiseScriptError(s, "map_get_pvp called outside a map.");
+ return 0;
+ }
+ lua_pushinteger(s, m->getPvP());
+ return 1;
+}
+
static int item_class_on(lua_State *s)
{
ItemClass *itemClass = LuaItemClass::check(s, 1);
@@ -2320,6 +2332,7 @@ LuaScript::LuaScript():
{ "get_map_id", &get_map_id },
{ "get_map_property", &get_map_property },
{ "is_walkable", &is_walkable },
+ { "map_get_pvp", &map_get_pvp },
{ "item_drop", &item_drop },
{ "item_get_name", &item_get_name },
{ "npc_ask_integer", &npc_ask_integer },