summaryrefslogtreecommitdiff
path: root/src/net/protocol.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-27 23:50:16 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-27 23:50:16 +0000
commit30063f42cc8d13ed241a52b90e63c2c68599115e (patch)
tree68868a0aa04007a0ad4a62d97556c27b48f057d7 /src/net/protocol.cpp
parent0ecae988adfa88cb6b8803a9f5b7215221fceb74 (diff)
downloadMana-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.gz
Mana-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.bz2
Mana-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.xz
Mana-30063f42cc8d13ed241a52b90e63c2c68599115e.zip
autoTarget is now a Being*, also may have fixed related crash and added label
to show current target.
Diffstat (limited to 'src/net/protocol.cpp')
-rw-r--r--src/net/protocol.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp
index 0187f69e..f357b103 100644
--- a/src/net/protocol.cpp
+++ b/src/net/protocol.cpp
@@ -224,7 +224,7 @@ void action(char type, int id)
WFIFOSET(7);
}
-int attack(unsigned short x, unsigned short y, unsigned char direction)
+Being* attack(unsigned short x, unsigned short y, unsigned char direction)
{
Being *target;
@@ -237,32 +237,38 @@ int attack(unsigned short x, unsigned short y, unsigned char direction)
} else if(direction==EAST) {
target = findNode(x + 1, y);
}
+
if (target && target->isMonster()) {
attack(target);
- return target->id;
+ return target;
}
// Implement charging attacks here
char_info->lastAttackTime = 0;
- return 0;
+ return NULL;
}
void attack(Being *target)
{
int dist_x = target->x - player_node->x;
int dist_y = target->y - player_node->y;
- if (abs(dist_y) >= abs(dist_x)) {
+
+ if (abs(dist_y) >= abs(dist_x))
+ {
if (dist_y > 0)
player_node->direction = SOUTH;
else
player_node->direction = NORTH;
- } else {
+ }
+ else
+ {
if (dist_x > 0)
player_node->direction = EAST;
else
player_node->direction = WEST;
}
+
player_node->action = ATTACK;
action(0, target->id);
player_node->walk_time = tick_time;