summaryrefslogtreecommitdiff
path: root/src/net
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
parentc669ed4986b0a01abc78f6d793993d9081c6b49e (diff)
downloadmana-client-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.gz
mana-client-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.bz2
mana-client-0c6830040481247a96ccc8fe15f9b1022506c0ae.tar.xz
mana-client-0c6830040481247a96ccc8fe15f9b1022506c0ae.zip
An attemp on auto attack, not bug free for sure
Diffstat (limited to 'src/net')
-rw-r--r--src/net/protocol.cpp23
-rw-r--r--src/net/protocol.h3
2 files changed, 26 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");
+}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 14c21d59..dd6b36e2 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -83,6 +83,9 @@ void speak(char *speech);
/** Request to attack */
void attack(unsigned short x, unsigned short y, unsigned char direction);
+/** Request to attack */
+void attack(Being *target);
+
/** Request action */
void action(char type, int id);