From 7cdecda38dc75dd855a45af6faad14d1c1e4e72f Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sat, 1 Nov 2008 19:03:14 +0000 Subject: Magic implementation roadmap phase 1 and 2 (calling a script function on PGMSG_USE_SPECIAL) --- src/game-server/character.cpp | 15 +++++++++++++++ src/game-server/character.hpp | 6 ++++++ src/game-server/gamehandler.cpp | 8 ++++++++ 3 files changed, 29 insertions(+) (limited to 'src/game-server') diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index bf8355c..61a5e1d 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -39,6 +39,7 @@ #include "game-server/mapmanager.hpp" #include "game-server/state.hpp" #include "game-server/trade.hpp" +#include "scripting/script.hpp" #include "net/messagein.hpp" #include "net/messageout.hpp" #include "serialize/characterdata.hpp" @@ -141,6 +142,20 @@ void Character::respawn() modifiedAttribute(BASE_ATTR_HP); } +void Character::useSpecial(int id) +{ + //TODO: look up which of its special attacks the character wants to use + //TODO: check if the character is allowed to use it right now + + Script *s = getMap()->getScript(); + s->prepare("cast"); + s->push(this); + s->push(id); + s->execute(); + + return; +} + int Character::getMapId() const { return getMap()->getID(); diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp index 0300671..6e31e33 100644 --- a/src/game-server/character.hpp +++ b/src/game-server/character.hpp @@ -67,6 +67,12 @@ class Character : public Being */ void respawn(); + /** + * makes the character perform a special action + * when it is allowed to do so + */ + void useSpecial(int id); + /** * Gets client computer. */ diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index 9fd93a4..005c19c 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -321,6 +321,14 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message) computer.character->setAction(Being::ATTACK); } break; + case PGMSG_USE_SPECIAL: + { + int specialID = message.readByte(); + LOG_DEBUG("Character " << computer.character->getPublicID() + << " tries to use his special attack "<useSpecial(specialID); + } + case PGMSG_ACTION_CHANGE: { Being::Action action = (Being::Action)message.readByte(); -- cgit