summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-03-24 21:09:16 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-04-11 18:27:21 +0200
commit88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2 (patch)
treed52e8fc0d91de69cf6a9868c082bf44497c9b6c1 /src/scripting
parentf3ad48f5ce2b3b584870674e58a7265779b3836b (diff)
downloadmanaserv-88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2.tar.gz
manaserv-88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2.tar.bz2
manaserv-88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2.tar.xz
manaserv-88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2.zip
Implemented global event function call to on_chr_death
Reviewed-by: Jared Adams <Jaxad0127@gmail.com>
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/script.cpp17
-rw-r--r--src/scripting/script.hpp5
2 files changed, 22 insertions, 0 deletions
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index 12c4417a..06f99dfc 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -23,6 +23,7 @@
#include "scripting/script.hpp"
+#include "game-server/being.hpp"
#include "game-server/resourcemanager.hpp"
#include "utils/logger.h"
@@ -95,3 +96,19 @@ void Script::loadNPC(const std::string &name, int id, int x, int y,
push(y);
execute();
}
+
+bool Script::execute_global_event_function(const std::string &function, Being* obj)
+{
+ bool isScriptHandled = false;
+ Script *script = Script::global_event_script;
+ if (script)
+ {
+ script->setMap(obj->getMap());
+ script->prepare(function);
+ script->push(obj);
+ script->execute();
+ script->setMap(NULL);
+ isScriptHandled = true; // TODO: don't set to true when execution failed
+ }
+ return isScriptHandled;
+}
diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp
index 74925e8b..2c8481dd 100644
--- a/src/scripting/script.hpp
+++ b/src/scripting/script.hpp
@@ -131,6 +131,11 @@ class Script
virtual void processRemoveEvent(Thing* thing) = 0;
+ /**
+ * Runs a function in the global event script file
+ */
+ static bool execute_global_event_function(const std::string &function, Being *obj);
+
static Script* global_event_script; // the global event script
protected: