summaryrefslogtreecommitdiff
path: root/src/net/protocol.cpp
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-05-22 13:02:47 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-05-22 13:02:47 +0000
commit0c6830040481247a96ccc8fe15f9b1022506c0ae (patch)
tree1d19cac108370e3dfdb421ad3f497d02d5ab3e4f /src/net/protocol.cpp
parentc669ed4986b0a01abc78f6d793993d9081c6b49e (diff)
downloadMana-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.gz
Mana-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.bz2
Mana-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.xz
Mana-0c6830040481247a96ccc8fe15f9b1022506c0ae.zip
An attemp on auto attack, not bug free for sure
Diffstat (limited to 'src/net/protocol.cpp')
-rw-r--r--src/net/protocol.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp
index e3b84457..7dc83cfa 100644
--- a/src/net/protocol.cpp
+++ b/src/net/protocol.cpp
@@ -248,3 +248,26 @@ void attack(unsigned short x, unsigned short y, unsigned char direction)
// implement charging attacks here
char_info->lastAttackTime = 0;
}
+
+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 (dist_y > 0)
+ player_node->direction = SOUTH;
+ else
+ player_node->direction = NORTH;
+ } 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;
+ if (player_node->weapon == 2)
+ sound.playSfx("sfx/bow_shoot_1.ogg");
+ else
+ sound.playSfx("sfx/fist-swish.ogg");
+}