summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-02-27 13:54:35 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-02-27 13:54:35 +0000
commit2c6abfdf3ccfca0650def767bf024f8496928a83 (patch)
treef2e2f321ee6fe73d8153a71f836e72ebdb809ffd
parent250c1b1becc72585e121dd0c181c9cb1f260bd25 (diff)
downloadmanaserv-2c6abfdf3ccfca0650def767bf024f8496928a83.tar.gz
manaserv-2c6abfdf3ccfca0650def767bf024f8496928a83.tar.bz2
manaserv-2c6abfdf3ccfca0650def767bf024f8496928a83.tar.xz
manaserv-2c6abfdf3ccfca0650def767bf024f8496928a83.zip
Implemented player respawn.
-rw-r--r--ChangeLog6
-rw-r--r--src/defines.h1
-rw-r--r--src/game-server/character.cpp22
-rw-r--r--src/game-server/character.hpp5
-rw-r--r--src/game-server/gamehandler.cpp5
5 files changed, 39 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6edd2f5b..ced9c664 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-27 Philipp Sehmisch <tmw@crushnet.org>
+
+ * src/defines.h, src/game-server/character.cpp,
+ src/game-server/character.hpp, src/game-server/gamehandler.cpp:
+ Implemented provisorical player respawn.
+
2008-02-23 Philipp Sehmisch <tmw@crushnet.org>
* src/game-server/monster.cpp: Improved monster AI by making monster only
diff --git a/src/defines.h b/src/defines.h
index 665adecf..d78d6d9e 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -146,6 +146,7 @@ enum {
GPMSG_RAISE_ATTRIBUTE_RESPONSE = 0x0161, // B error
PGMSG_LOWER_ATTRIBUTE = 0x0170, // B attribute
GPMSG_LOWER_ATTRIBUTE_RESPONSE = 0x0171, // B error
+ PGMSG_RESPAWN = 0x0180, // -
GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position
// character: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }*
// monster: W type id
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 02094edd..c13f3805 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -35,6 +35,7 @@
#include "game-server/gamehandler.hpp"
#include "game-server/mapcomposite.hpp"
#include "game-server/mapmanager.hpp"
+#include "game-server/state.hpp"
#include "game-server/trade.hpp"
#include "net/messagein.hpp"
#include "net/messageout.hpp"
@@ -110,6 +111,27 @@ void Character::perform()
performAttack(damage, attackRange, attackAngle);
}
+void Character::respawn()
+{
+ if (mAction != DEAD)
+ {
+ LOG_WARN("Character \""<<mName<<"\" tried to respawn without being dead");
+ return;
+ }
+
+ //warp back to spawn point
+ static const int spawnMap = 1;
+ static const int spawnX = 1024;
+ static const int spawnY = 1024;
+ GameState::enqueueWarp(this, MapManager::getMap(spawnMap), spawnX, spawnY);
+
+ //restore hit points
+ mAttributes[BASE_ATTR_HP].mod = 0;
+
+ //make alive again
+ setAction(STAND);
+}
+
int Character::getMapId() const
{
return getMap()->getID();
diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp
index 316c4c79..b90d2b3c 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -61,6 +61,11 @@ class Character : public Being
void perform();
/**
+ * makes the character respawn
+ */
+ void respawn();
+
+ /**
* Gets client computer.
*/
GameClient *getClient() const
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 6edbce12..249745f4 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -426,6 +426,11 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
result.writeByte(attribute);
} break;
+ case PGMSG_RESPAWN:
+ {
+ computer.character->respawn(); // plausibility check is done by character class
+ } break;
+
// The following messages should be handled by the chat server, not the game server.
#if 0