From 41472ab7f6cdbfc55c44c6487956a36f7fb16508 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Thu, 22 May 2008 19:25:20 +0000 Subject: --- src/scripting/lua.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 16 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 9f160bca..622096eb 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -31,10 +31,12 @@ extern "C" { #include "defines.h" #include "game-server/buysell.hpp" #include "game-server/character.hpp" +#include "game-server/collisiondetection.hpp" #include "game-server/gamehandler.hpp" #include "game-server/inventory.hpp" #include "game-server/item.hpp" #include "game-server/itemmanager.hpp" +#include "game-server/mapcomposite.hpp" #include "game-server/mapmanager.hpp" #include "game-server/monster.hpp" #include "game-server/monstermanager.hpp" @@ -441,6 +443,29 @@ static int LuaBeing_Say(lua_State *s) return 0; } + +/** + * Applies combat damage to a being + * tmw.being_damage(victim, value, delta, cth, type, element) + */ +static int LuaBeing_Damage(lua_State *s) +{ + Being *being = getBeing(s, 1); + + Damage damage; + damage.base = lua_tointeger(s, 2); + damage.delta = lua_tointeger(s, 3); + damage.cth = lua_tointeger(s, 4); + damage.type = lua_tointeger(s, 5); + damage.element = lua_tointeger(s, 6); + damage.usedSkill = 0; + + being->damage(NULL, damage); + + return 0; +} + + /** * Function for getting the x-coordinate of the position of a being */ @@ -656,6 +681,45 @@ static int LuaChatmessage(lua_State *s) return 0; } +/** + * Gets a LUA table with the being IDs of all beings + * inside of a circular area of the current map. + * tmw.get_beings_in_circle (x, y, radius) + */ +static int LuaGetBeingsInCircle(lua_State *s) +{ + int x = lua_tointeger(s, 1); + int y = lua_tointeger(s, 2); + int r = lua_tointeger(s, 3); + + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast