diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-27 23:50:16 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-27 23:50:16 +0000 |
commit | 30063f42cc8d13ed241a52b90e63c2c68599115e (patch) | |
tree | 68868a0aa04007a0ad4a62d97556c27b48f057d7 /src/net | |
parent | 0ecae988adfa88cb6b8803a9f5b7215221fceb74 (diff) | |
download | mana-client-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.gz mana-client-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.bz2 mana-client-30063f42cc8d13ed241a52b90e63c2c68599115e.tar.xz mana-client-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')
-rw-r--r-- | src/net/protocol.cpp | 16 | ||||
-rw-r--r-- | src/net/protocol.h | 2 |
2 files changed, 12 insertions, 6 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; diff --git a/src/net/protocol.h b/src/net/protocol.h index 57321d45..002b4b2f 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -83,7 +83,7 @@ void walk(unsigned short x, unsigned short y, unsigned char direction); void speak(char *speech); /** Request to attack */ -int attack(unsigned short x, unsigned short y, unsigned char direction); +Being* attack(unsigned short x, unsigned short y, unsigned char direction); /** Request to attack */ void attack(Being *target); |