summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--data/scripts/libs/libtmw.lua15
-rw-r--r--src/defines.h3
-rw-r--r--src/game-server/character.cpp15
-rw-r--r--src/game-server/character.hpp6
-rw-r--r--src/game-server/gamehandler.cpp8
6 files changed, 51 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0584405a..71392004 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
* data/scripts/lib/test.lua: added constants for character skills.
* data/scripts/test.lua: Added example script for manipulating character
experience.
+ * src/game-server/character.cpp, src/game-server/character.hpp,
+ src/game-server/gamehandler.cpp, src/defines.h: Implemented basic netcode
+ for using special actions like magic. Currently triggers a function in
+ libtmw.lua which makes the caster speak some text (magic system
+ implementation phase 1 and 2)
2008-10-31 David Athay <ko2fan@gmail.com>
diff --git a/data/scripts/libs/libtmw.lua b/data/scripts/libs/libtmw.lua
index d1e397e4..2c6670f0 100644
--- a/data/scripts/libs/libtmw.lua
+++ b/data/scripts/libs/libtmw.lua
@@ -410,3 +410,18 @@ end
tmw.chr_money = function(ch)
return tmw.chr_inv_count(ch, 0)
end
+
+
+
+function cast(ch, arg)
+ if arg == 1 then
+ tmw.being_say(ch, "Kaaame...Haaame... HAAAAAA!")
+ end
+ if arg == 2 then
+ tmw.being_say(ch, "HAA-DOKEN!")
+ end
+ if arg == 3 then
+ tmw.being_say(ch, "Sonic BOOM")
+ end
+
+end
diff --git a/src/defines.h b/src/defines.h
index e7d7ae9a..7a1b4a88 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -165,6 +165,7 @@ enum {
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // B direction
GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attacktype
+ PGMSG_USE_SPECIAL = 0x0292, // B specialID
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*
@@ -191,7 +192,7 @@ enum {
PGMSG_USE_ITEM = 0x0300, // B slot
GPMSG_USE_RESPONSE = 0x0301, // B error
GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }*
- GPMSG_CREATE_EFFECT = 0x0320, // W effect id, W*2 position
+ GPMSG_CREATE_EFFECT = 0x0320, // W effect id, W*2 position
// Guild
PCMSG_GUILD_CREATE = 0x0350, // S name
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index bf8355cd..61a5e1d1 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 03006712..6e31e33b 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -68,6 +68,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.
*/
GameClient *getClient() const
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 9fd93a46..005c19c3 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 "<<specialID);
+ computer.character->useSpecial(specialID);
+ }
+
case PGMSG_ACTION_CHANGE:
{
Being::Action action = (Being::Action)message.readByte();