summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-11-01 19:03:01 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-11-01 19:03:01 +0000
commit14ef52c7c3413f8c61b50147dcd22f4ed7238078 (patch)
tree82888985eeae2f3e21ce5e414d6ae9ac72e37d36 /src
parentbabaec33e51991475ba2ab9ec06c95bbe5f220c0 (diff)
downloadmana-14ef52c7c3413f8c61b50147dcd22f4ed7238078.tar.gz
mana-14ef52c7c3413f8c61b50147dcd22f4ed7238078.tar.bz2
mana-14ef52c7c3413f8c61b50147dcd22f4ed7238078.tar.xz
mana-14ef52c7c3413f8c61b50147dcd22f4ed7238078.zip
Magic implementation phase 1 and 2 (added netcode and a very crude gui for using special actions like magic)
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp19
-rw-r--r--src/gui/menuwindow.cpp6
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/localplayer.cpp13
-rw-r--r--src/localplayer.h2
-rw-r--r--src/net/gameserver/player.cpp7
-rw-r--r--src/net/gameserver/player.h1
-rw-r--r--src/net/protocol.h1
8 files changed, 40 insertions, 11 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 80d5610f..690cf727 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -58,6 +58,7 @@
#include "gui/help.h"
#include "gui/inventorywindow.h"
#include "gui/itemshortcutwindow.h"
+#include "gui/magic.h"
#include "gui/menuwindow.h"
#include "gui/minimap.h"
#include "gui/ministatus.h"
@@ -118,6 +119,7 @@ InventoryWindow *inventoryWindow;
NpcListDialog *npcListDialog;
NpcTextDialog *npcTextDialog;
SkillDialog *skillDialog;
+MagicDialog *magicDialog;
//NewSkillDialog *newSkillWindow;
Setup* setupWindow;
Minimap *minimap;
@@ -204,6 +206,7 @@ void createGuiWindows()
npcTextDialog = new NpcTextDialog();
npcListDialog = new NpcListDialog();
skillDialog = new SkillDialog();
+ magicDialog = new MagicDialog();
//newSkillWindow = new NewSkillDialog();
setupWindow = new Setup();
minimap = new Minimap();
@@ -252,6 +255,7 @@ void destroyGuiWindows()
delete npcListDialog;
delete npcTextDialog;
delete skillDialog;
+ delete magicDialog;
delete setupWindow;
delete minimap;
delete equipmentWindow;
@@ -640,6 +644,7 @@ void Game::handleInput()
statusWindow->setVisible(false);
inventoryWindow->setVisible(false);
skillDialog->setVisible(false);
+ magicDialog->setVisible(false);
setupWindow->setVisible(false);
equipmentWindow->setVisible(false);
helpWindow->setVisible(false);
@@ -796,19 +801,19 @@ void Game::handleInput()
// First if player is pressing key for the direction he is already going
if (direction == player_node->getWalkingDir())
- {
+ {
player_node->setWalkingDir(direction);
- }
- // Else if he is pressing a key, and its different from what he has
- // been pressing, stop (do not send this stop to the server) and
+ }
+ // Else if he is pressing a key, and its different from what he has
+ // been pressing, stop (do not send this stop to the server) and
// start in the new direction
- else if (direction && direction != player_node->getWalkingDir())
+ else if (direction && direction != player_node->getWalkingDir())
{
player_node->stopWalking(false);
player_node->setWalkingDir(direction);
}
- // Else, he is not pressing a key, stop (sending to server)
- else
+ // Else, he is not pressing a key, stop (sending to server)
+ else
{
player_node->stopWalking(true);
}
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 84340fc4..c3e572a7 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -36,6 +36,7 @@ extern Window *setupWindow;
extern Window *inventoryWindow;
extern Window *equipmentWindow;
extern Window *skillDialog;
+extern Window *magicDialog;
extern Window *statusWindow;
extern Window *guildWindow;
extern Window *itemShortcutWindow;
@@ -64,6 +65,7 @@ MenuWindow::MenuWindow():
N_("Equipment"),
N_("Inventory"),
N_("Skills"),
+ N_("Magic"),
N_("Guilds"),
N_("Shortcut"),
N_("Setup"),
@@ -110,6 +112,10 @@ void MenuWindowListener::action(const gcn::ActionEvent &event)
{
window = skillDialog;
}
+ else if (event.getId() == "Magic")
+ {
+ window = magicDialog;
+ }
else if (event.getId() == "Guilds")
{
window = guildWindow;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 53e7a9f1..b6b052bc 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -43,6 +43,7 @@ extern Window *inventoryWindow;
extern Window *equipmentWindow;
extern Window *helpWindow;
extern Window *skillDialog;
+extern Window *magicDialog;
extern Window *guildWindow;
Setup::Setup():
@@ -116,6 +117,7 @@ void Setup::action(const gcn::ActionEvent &event)
equipmentWindow->resetToDefaultSize();
helpWindow->resetToDefaultSize();
skillDialog->resetToDefaultSize();
+ magicDialog->resetToDefaultSize();
guildWindow->resetToDefaultSize();
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 6c802c5c..30ad7b2e 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -280,7 +280,7 @@ void LocalPlayer::walk(unsigned char dir)
if (dir & RIGHT)
dx += 32;
-
+
// Prevent skipping corners over colliding tiles
if (dx && !mMap->getWalk(((int) pos.x + dx) / 32,
(int) pos.y / 32, getWalkMask()))
@@ -293,12 +293,12 @@ void LocalPlayer::walk(unsigned char dir)
if (dx && dy && !mMap->getWalk((pos.x + dx) / 32,
(pos.y + dy) / 32, getWalkMask()))
dx = 16 - (int) pos.x % 32;
-
+
// Checks our path up to 5 tiles, if a blocking tile is found
// We go to the last good tile, and break out of the loop
for (dScaler = 1; dScaler <= 10; dScaler++)
{
- if ( (dx || dy) &&
+ if ( (dx || dy) &&
!mMap->getWalk( ((int) pos.x + (dx * dScaler)) / 32,
((int) pos.y + (dy * dScaler)) / 32, getWalkMask()) )
{
@@ -306,7 +306,7 @@ void LocalPlayer::walk(unsigned char dir)
break;
}
}
-
+
if (dScaler >= 0)
{
setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
@@ -477,6 +477,11 @@ void LocalPlayer::attack()
Net::GameServer::Player::attack(getSpriteDirection());
}
+void LocalPlayer::useSpecial(int special)
+{
+ Net::GameServer::Player::useSpecial(special);
+}
+
Being* LocalPlayer::getTarget() const
{
return mTarget;
diff --git a/src/localplayer.h b/src/localplayer.h
index b44ac14a..16b9715a 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -227,6 +227,8 @@ class LocalPlayer : public Player
void attack();
+ void useSpecial(int id);
+
Being* getTarget() const;
/**
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 28fd954a..79ada480 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -102,6 +102,13 @@ void Net::GameServer::Player::attack(int direction)
Net::GameServer::connection->send(msg);
}
+void Net::GameServer::Player::useSpecial(int special)
+{
+ MessageOut msg(PGMSG_USE_SPECIAL);
+ msg.writeInt8(special);
+ Net::GameServer::connection->send(msg);
+}
+
void Net::GameServer::Player::changeAction(Being::Action action)
{
MessageOut msg(PGMSG_ACTION_CHANGE);
diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h
index fa8c1376..3eba8a13 100644
--- a/src/net/gameserver/player.h
+++ b/src/net/gameserver/player.h
@@ -51,6 +51,7 @@ namespace Net
void unequip(int slot);
void useItem(int slot);
void attack(int direction);
+ void useSpecial(int special);
void changeAction(Being::Action action);
void talkToNPC(int id, bool restart);
void selectFromNPC(int id, int choice);
diff --git a/src/net/protocol.h b/src/net/protocol.h
index abbad442..bbc7d2d2 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -104,6 +104,7 @@ enum {
GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position, B speed] [, W*2 destination] }*
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // B direction
+ PGMSG_USE_SPECIAL = 0x0292, // B specialID
GPMSG_BEING_ATTACK = 0x0291, // W being id
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text