summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2011-03-14 20:53:49 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2011-03-14 21:47:09 +0100
commit967caa8a91702510fc9b4a35292042802c27d14c (patch)
treeaa0961174ed5b180163ffb972adcf5007513722e /src/scripting
parentcc162d170bcaf7d5b3f47ffde346b1849f905662 (diff)
downloadmanaserv-967caa8a91702510fc9b4a35292042802c27d14c.tar.gz
manaserv-967caa8a91702510fc9b4a35292042802c27d14c.tar.bz2
manaserv-967caa8a91702510fc9b4a35292042802c27d14c.tar.xz
manaserv-967caa8a91702510fc9b4a35292042802c27d14c.zip
Script binding for the new screen shake effect.
The new lua function mana.chr_shake_screen can cause a screen shake for a single client with variable x-intensity, y-intensity, decay and duration. I also added an example script which causes tremors for nearby characters with intensity and direction relative to a specific point. The function is not referenced on the example map because it is quite distracting.
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 6f36bb95..11f42f50 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1395,6 +1395,50 @@ static int effect_create(lua_State *s)
return 0;
}
+
+
+/**
+ *
+ * mana.chr_shake_screen(
+ */
+static int chr_shake_screen(lua_State *s)
+{
+ Character *c = getCharacter(s, 1);
+ if (!c)
+ {
+ raiseScriptError(s, "lua chr_shake_screen called for nonexistent character.");
+ return 0;
+ }
+
+ MessageOut msg(GPMSG_SHAKE);
+ if(!lua_isnumber(s, 2) || !lua_isnumber(s, 3))
+ {
+ raiseScriptError(s, "lua chr_shake_screen called with illegal arguments.");
+ return 0;
+ }
+ else
+ {
+ int x = lua_tointeger(s, 2);
+ int y = lua_tointeger(s, 3);
+ msg.writeInt16(x);
+ msg.writeInt16(y);
+ }
+ if(lua_isnumber(s, 4))
+ {
+ msg.writeInt16((int)lua_tonumber(s, 4) * 10000);
+ }
+ if(lua_isnumber(s, 5))
+ {
+ msg.writeInt16(lua_tointeger(s, 5));
+ }
+ c->getClient()->send(msg);
+
+ return 0;
+}
+
+
+
+
/**
* Gets the exp total in a skill of a specific character
* mana.chr_get_exp (being, skill)
@@ -1840,6 +1884,7 @@ LuaScript::LuaScript():
{ "get_beings_in_circle", &get_beings_in_circle },
{ "being_register", &being_register },
{ "effect_create", &effect_create },
+ { "chr_shake_screen", &chr_shake_screen },
{ "test_tableget", &test_tableget },
{ "get_map_id", &get_map_id },
{ "item_drop", &item_drop },