From 26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Fri, 9 Jul 2010 15:21:50 +0200 Subject: Added LUA script bindings for manipulating the specials available to a character. Added script call for getting the cost of a special (recharge only for now) Deleting specials works server-sided but the client isn't informed about it properly. Specials without recharge cost don't appear for the player. Both of these features require an additional netcode message. Reviewed-by: Freeyorp --- src/scripting/script.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/scripting/script.cpp') diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp index fe3c5d8d..359e94bd 100644 --- a/src/scripting/script.cpp +++ b/src/scripting/script.cpp @@ -33,6 +33,7 @@ typedef std::map< std::string, Script::Factory > Engines; static Engines *engines = NULL; Script *Script::global_event_script = NULL; +Script *Script::special_actions_script = NULL; Script::Script(): mMap(NULL), @@ -122,3 +123,32 @@ bool Script::execute_global_event_function(const std::string &function, Being* o } return isScriptHandled; } + + +void Script::addDataToSpecial(int id, Special* special) +{ + /* currently only gets the recharge cost. + TODO: get any other info in a similar way, but + first we have to agree on what other + info we actually want to provide. + */ + Script *script = Script::special_actions_script; + script->prepare("get_special_recharge_cost"); + script->push(id); + int scriptReturn = script->execute(); + special->neededMana = scriptReturn; + +} + +bool Script::perform_special_action(int specialId, Being* caster) +{ + Script *script = Script::special_actions_script; + if (script) + { + script->prepare("use_special"); + script->push(caster); + script->push(specialId); + script->execute(); + } + return true; +} -- cgit v1.2.3-70-g09d2