From 88f8e20871fadc58bc69c5b1fca4b7c4d850fdb2 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Wed, 24 Mar 2010 21:09:16 +0100 Subject: Implemented global event function call to on_chr_death Reviewed-by: Jared Adams --- src/scripting/script.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/scripting/script.cpp') 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; +} -- cgit v1.2.3-70-g09d2