From 5c5abafd2b0dcbcdeefad625b03732949c56056f Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Fri, 8 Jan 2010 22:53:26 +0100 Subject: Added script binding for checking the kill count for each monster so that uninventive server admins can implement their boring kill-ten-rats quests. --- src/scripting/lua.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 1c79ede9..3b33a3d1 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1291,6 +1291,34 @@ static int chr_get_hair_color(lua_State *s) return 1; } +/** + * Get the number of monsters the player killed of a type + * mana.chr_get_kill_count (character, monsterType) + */ +static int chr_get_kill_count(lua_State *s) +{ + Character *c = getCharacter(s, 1); + if (!c) + { + raiseScriptError(s, "chr_get_kill_count called for nonexistent character."); + return 0; + } + + if (!lua_isnumber(s, 2)) + { + raiseScriptError(s, "chr_get_kill_count called with incorect parameters"); + return 0; + } + + int id = lua_tointeger(s, 2); + + int kills = c->getKillCount(id); + + lua_pushinteger(s, kills); + return 1; +} + + /** * Returns the rights level of a character. * mana.chr_get_rights (being) @@ -1463,6 +1491,7 @@ LuaScript::LuaScript(): { "chr_get_hair_style", &chr_get_hair_style }, { "chr_set_hair_color", &chr_set_hair_color }, { "chr_get_hair_color", &chr_get_hair_color }, + { "chr_get_kill_count", &chr_get_kill_count }, { "exp_for_level", &exp_for_level }, { "monster_create", &monster_create }, { "monster_load_script", &monster_load_script }, -- cgit v1.2.3-70-g09d2