summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-05-22 13:17:30 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-05-22 13:17:30 +0000
commit347246d6719e12e426f5681085493dc0227345ed (patch)
tree0361e73edb89580d1fcba2a3a2ac88fa96d579e4 /src/net
parent0c6830040481247a96ccc8fe15f9b1022506c0ae (diff)
downloadmana-client-347246d6719e12e426f5681085493dc0227345ed.tar.gz
mana-client-347246d6719e12e426f5681085493dc0227345ed.tar.bz2
mana-client-347246d6719e12e426f5681085493dc0227345ed.tar.xz
mana-client-347246d6719e12e426f5681085493dc0227345ed.zip
This way auto attack should work with left ctrl too (also
some docs updates)
Diffstat (limited to 'src/net')
-rw-r--r--src/net/protocol.cpp29
-rw-r--r--src/net/protocol.h2
2 files changed, 15 insertions, 16 deletions
diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp
index 7dc83cfa..4b94a66c 100644
--- a/src/net/protocol.cpp
+++ b/src/net/protocol.cpp
@@ -224,29 +224,28 @@ void action(char type, int id)
WFIFOSET(7);
}
-void attack(unsigned short x, unsigned short y, unsigned char direction)
+int attack(unsigned short x, unsigned short y, unsigned char direction)
{
- int monster_id = 0;
+ Being *target;
if (direction == SOUTH) {
- monster_id = findMonster(x, y + 1);
- if (monster_id != 0)
- action(0, monster_id);
+ target = findNode(x, y + 1);
} else if(direction == WEST) {
- monster_id = findMonster(x - 1, y);
- if (monster_id != 0)
- action(0, monster_id);
+ target = findNode(x - 1, y);
} else if(direction == NORTH) {
- monster_id = findMonster(x, y - 1);
- if (monster_id != 0)
- action(0, monster_id);
+ target = findNode(x, y - 1);
} else if(direction==EAST) {
- monster_id = findMonster(x + 1, y);
- if (monster_id != 0)
- action(0, monster_id);
+ target = findNode(x + 1, y);
}
- // implement charging attacks here
+ if (target && target->isMonster()) {
+ attack(target);
+ return target->id;
+ }
+
+ // Implement charging attacks here
char_info->lastAttackTime = 0;
+
+ return 0;
}
void attack(Being *target) {
diff --git a/src/net/protocol.h b/src/net/protocol.h
index dd6b36e2..07684298 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -81,7 +81,7 @@ void walk(unsigned short x, unsigned short y, unsigned char direction);
void speak(char *speech);
/** Request to attack */
-void attack(unsigned short x, unsigned short y, unsigned char direction);
+int attack(unsigned short x, unsigned short y, unsigned char direction);
/** Request to attack */
void attack(Being *target);