summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-26 20:07:20 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-26 20:07:20 +0000
commit1c43b2cdee5a5508a6e771b477100517deae07e7 (patch)
tree5a5df16ea526daed5b8268f26d4e63c76017dec4 /src/game.cpp
parentea17e8e26173d641fc9b3710b65209c03af5aff3 (diff)
downloadmana-1c43b2cdee5a5508a6e771b477100517deae07e7.tar.gz
mana-1c43b2cdee5a5508a6e771b477100517deae07e7.tar.bz2
mana-1c43b2cdee5a5508a6e771b477100517deae07e7.tar.xz
mana-1c43b2cdee5a5508a6e771b477100517deae07e7.zip
Added Being::Type enumeration and type-aware findNode(). Fixed font not being reset after drawing speech. Target marker drawing moved into engine.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp119
1 files changed, 69 insertions, 50 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 16addcd4..df5033be 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -536,39 +536,47 @@ void do_input()
if (target)
{
- // NPC default: talk
- if ((target->isNpc()) && (current_npc == 0))
+ switch (target->getType())
{
- WFIFOW(0) = net_w_value(0x0090);
- WFIFOL(2) = net_l_value(target->getId());
- WFIFOB(6) = 0;
- WFIFOSET(7);
- current_npc = target->getId();
- }
- // Monster default: attack
- else if (target->isMonster())
- {
- /**
- * TODO: Move player to mouse click position before
- * attack the monster (maybe using follow mode).
- */
- if (target->action != MONSTER_DEAD &&
- player_node->action==STAND)
- {
- attack(target);
- // Autotarget by default with mouse
- //if (keys[SDLK_LSHIFT])
- //{
+ // Player default: trade
+ case Being::PLAYER:
+ WFIFOW(0) = net_w_value(0x00e4);
+ WFIFOL(2) = net_l_value(target->getId());
+ WFIFOSET(6);
+ break;
+
+ // NPC default: talk
+ case Being::NPC:
+ if (!current_npc)
+ {
+ WFIFOW(0) = net_w_value(0x0090);
+ WFIFOL(2) = net_l_value(target->getId());
+ WFIFOB(6) = 0;
+ WFIFOSET(7);
+ current_npc = target->getId();
+ }
+ break;
+
+ // Monster default: attack
+ case Being::MONSTER:
+ /**
+ * TODO: Move player to mouse click position before
+ * attack the monster (maybe using follow mode).
+ */
+ if (target->action != MONSTER_DEAD &&
+ player_node->action==STAND)
+ {
+ attack(target);
+ // Autotarget by default with mouse
+ //if (keys[SDLK_LSHIFT])
+ //{
autoTarget = target;
- //}
- }
- }
- // Player default: trade
- else if (target->isPlayer())
- {
- WFIFOW(0) = net_w_value(0x00e4);
- WFIFOL(2) = net_l_value(target->getId());
- WFIFOSET(6);
+ //}
+ }
+ break;
+
+ default:
+ break;
}
}
// Check for default action to items on the floor
@@ -947,19 +955,26 @@ void do_parse()
{
if (RFIFOB(6) == 1)
{ // Death
- if (being->isMonster())
- {
- being->action = MONSTER_DEAD;
- being->frame = 0;
- being->walk_time = tick_time;
- }
- else
+ switch (being->getType())
{
- being->action = DEAD;
+ case Being::MONSTER:
+ being->action = MONSTER_DEAD;
+ being->frame = 0;
+ being->walk_time = tick_time;
+ break;
+
+ default:
+ being->action = DEAD;
+ break;
}
//remove_node(RFIFOL(2));
}
- else remove_node(RFIFOL(2));
+ else {
+ remove_node(RFIFOL(2));
+ if (being == autoTarget) {
+ autoTarget = NULL;
+ }
+ }
}
break;
@@ -1354,16 +1369,20 @@ void do_parse()
if (RFIFOL(2) != player_node->getId()) { // buggy
being = findNode(RFIFOL(2));
- if (being != NULL) {
- if (being->isPlayer()) {
- being->action = ATTACK;
- being->frame = 0;
- being->walk_time = tick_time;
- }
- else {
- being->action = MONSTER_ATTACK;
- being->frame = 0;
- being->walk_time = tick_time;
+ if (being) {
+ switch (being->getType())
+ {
+ case Being::PLAYER:
+ being->action = ATTACK;
+ being->frame = 0;
+ being->walk_time = tick_time;
+ break;
+
+ default:
+ being->action = MONSTER_ATTACK;
+ being->frame = 0;
+ being->walk_time = tick_time;
+ break;
}
being->frame = 0;
}