diff options
author | Philipp Sehmisch <mana@crushnet.org> | 2010-03-22 21:55:34 +0100 |
---|---|---|
committer | Philipp Sehmisch <mana@crushnet.org> | 2010-04-11 18:27:20 +0200 |
commit | f3ad48f5ce2b3b584870674e58a7265779b3836b (patch) | |
tree | 73323079c2accbdf20f4617be21506c556e66329 /src/game-server | |
parent | e0669e4025e3772590cbde835d79fb06efea04fa (diff) | |
download | manaserv-f3ad48f5ce2b3b584870674e58a7265779b3836b.tar.gz manaserv-f3ad48f5ce2b3b584870674e58a7265779b3836b.tar.xz manaserv-f3ad48f5ce2b3b584870674e58a7265779b3836b.zip |
Added global lua event script (only on_being_death_accept for now)
Reviewed-by: Jared Adams <Jaxad0127@gmail.com>
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/character.cpp | 35 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 7 |
2 files changed, 33 insertions, 9 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 266a9b9..60b767a 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -185,19 +185,36 @@ void Character::respawn() return; } - //warp back to spawn point - int spawnMap = Configuration::getValue("respawnMap", 1); - int spawnX = Configuration::getValue("respawnX", 1024); - int spawnY = Configuration::getValue("respawnY", 1024); - GameState::enqueueWarp(this, MapManager::getMap(spawnMap), spawnX, spawnY); - //make alive again setAction(STAND); - mAttributes[BASE_ATTR_HP].mod = -mAttributes[BASE_ATTR_HP].base + 1; - modifiedAttribute(BASE_ATTR_HP); - // reset target mTarget = NULL; + + // execute respawn script + bool isScriptHandled = false; + Script *script = Script::global_event_script; + if (script) + { + script->setMap(getMap()); + script->prepare("on_chr_death_accept"); + script->push(this); + script->execute(); + isScriptHandled = true; // TODO: don't set to true when execution failed + script->setMap(NULL); + } + + if (!isScriptHandled) + { + // script-controlled respawning didn't work - fall back to + // hardcoded logic + mAttributes[BASE_ATTR_HP].mod = -mAttributes[BASE_ATTR_HP].base + 1; + modifiedAttribute(BASE_ATTR_HP); //warp back to spawn point + int spawnMap = Configuration::getValue("respawnMap", 1); + int spawnX = Configuration::getValue("respawnX", 1024); + int spawnY = Configuration::getValue("respawnY", 1024); + GameState::enqueueWarp(this, MapManager::getMap(spawnMap), spawnX, spawnY); + } + } void Character::useSpecial(int id) diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index cb6ea41..3ad265f 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -50,6 +50,7 @@ #include "net/bandwidth.hpp" #include "net/connectionhandler.hpp" #include "net/messageout.hpp" +#include "scripting/luascript.hpp" #include "utils/logger.h" #include "utils/processorutils.hpp" #include "utils/stringfilter.h" @@ -172,6 +173,12 @@ void initialize() MonsterManager::initialize(DEFAULT_MONSTERSDB_FILE); StatusManager::initialize(DEFAULT_STATUSDB_FILE); PermissionManager::initialize(DEFAULT_PERMISSION_FILE); + // Initialize global event script + Script::global_event_script = new LuaScript(); + if (!Script::global_event_script->loadFile("scripts/global_events.lua")) + { + Script::global_event_script = NULL; + } // --- Initialize the global handlers // FIXME: Make the global handlers global vars or part of a bigger |