diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-27 13:54:18 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-02-27 13:54:18 +0000 |
commit | 7dff43c3cc3733c7222e3f036b76e896aa86d4e9 (patch) | |
tree | 1ab421a28db6b7969a53efbe8cc39429021309a6 /src/net | |
parent | 9355a8113d0a3e084d67aa181ead54715702ee98 (diff) | |
download | mana-client-7dff43c3cc3733c7222e3f036b76e896aa86d4e9.tar.gz mana-client-7dff43c3cc3733c7222e3f036b76e896aa86d4e9.tar.bz2 mana-client-7dff43c3cc3733c7222e3f036b76e896aa86d4e9.tar.xz mana-client-7dff43c3cc3733c7222e3f036b76e896aa86d4e9.zip |
Implemented provisorical player respawn.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 31 | ||||
-rw-r--r-- | src/net/gameserver/player.cpp | 11 | ||||
-rw-r--r-- | src/net/gameserver/player.h | 10 | ||||
-rw-r--r-- | src/net/protocol.h | 1 |
4 files changed, 52 insertions, 1 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 38299b8d..28791975 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -37,6 +37,12 @@ #include "../particle.h" #include "../sound.h" +#include "../gui/ok_dialog.h" + +#include "../utils/gettext.h" + +#include "gameserver/player.h" + const int EMOTION_TIME = 150; /**< Duration of emotion icon */ BeingHandler::BeingHandler() @@ -592,9 +598,32 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg) void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) { Being* being = beingManager->findBeing(msg.readInt16()); + Being::Action action = (Being::Action) msg.readInt8(); if (!being) return; - being->setAction((Being::Action) msg.readInt8()); + being->setAction(action); + + if (action == Being::DEAD && being==player_node) + { + static char const *const deadMsg[] = + { + _("You are dead."), + _("We regret to inform you that your character was killed in battle."), + _("You are not that alive anymore."), + _("The cold hands of the grim reaper are grabbing for your soul."), + _("Game Over!"), + _("No, kids. Your character did not really die. It... err... went to a better place."), + _("Your plan of breaking your enemies weapon by bashing it with your throat failed."), + _("I guess this did not run too well."), + _("Do you want your possessions identified?"), // Nethack reference + _("Sadly, no trace of you was ever found..."), // Secret of Mana reference + + }; + std::string message(deadMsg[rand()%10]); + message.append(" Press OK to respawn"); + OkDialog *dlg = new OkDialog(_("You died"), message); + dlg->addActionListener(&(Net::GameServer::Player::respawnListener)); + } } void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg) diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp index 67edc7ad..d8050d2b 100644 --- a/src/net/gameserver/player.cpp +++ b/src/net/gameserver/player.cpp @@ -29,6 +29,11 @@ #include "../messageout.h" #include "../protocol.h" +void RespawnRequestListener::action(const gcn::ActionEvent &event) +{ + Net::GameServer::Player::respawn(); +} + void Net::GameServer::Player::say(const std::string &text) { MessageOut msg(PGMSG_SAY); @@ -168,3 +173,9 @@ void Net::GameServer::Player::lowerAttribute(int attribute) msg.writeInt8(attribute); Net::GameServer::connection->send(msg); } + +void Net::GameServer::Player::respawn() +{ + MessageOut msg(PGMSG_RESPAWN); + Net::GameServer::connection->send(msg); +} diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h index 7ebb2830..eea15c2b 100644 --- a/src/net/gameserver/player.h +++ b/src/net/gameserver/player.h @@ -26,8 +26,16 @@ #include "../../being.h" +#include <guichan/actionlistener.hpp> + #include <iosfwd> + +struct RespawnRequestListener : public gcn::ActionListener +{ + void action(const gcn::ActionEvent &event); +}; + namespace Net { namespace GameServer @@ -53,6 +61,8 @@ namespace Net void tradeWithNPC(int item, int amount); void raiseAttribute(int attribute); void lowerAttribute(int attribute); + void respawn(); + static RespawnRequestListener respawnListener; } } } diff --git a/src/net/protocol.h b/src/net/protocol.h index e6f5869b..eb65febe 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -90,6 +90,7 @@ enum { GPMSG_RAISE_ATTRIBUTE_RESPONSE = 0x0161, // B error, B attribute PGMSG_LOWER_ATTRIBUTE = 0x0170, // B attribute GPMSG_LOWER_ATTRIBUTE_RESPONSE = 0x0171, // B error, B attribute + PGMSG_RESPAWN = 0x0180, // - GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position // player: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* // monster: W type id |