summaryrefslogtreecommitdiff
path: root/src/game-server/character.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-03-22 21:55:34 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-04-11 18:27:20 +0200
commitf3ad48f5ce2b3b584870674e58a7265779b3836b (patch)
tree73323079c2accbdf20f4617be21506c556e66329 /src/game-server/character.cpp
parente0669e4025e3772590cbde835d79fb06efea04fa (diff)
downloadmanaserv-f3ad48f5ce2b3b584870674e58a7265779b3836b.tar.gz
manaserv-f3ad48f5ce2b3b584870674e58a7265779b3836b.tar.bz2
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/character.cpp')
-rw-r--r--src/game-server/character.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 266a9b95..60b767a3 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)