diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-05-20 18:30:02 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-05-20 18:30:02 +0000 |
commit | 04da189810d74df40d6f92694bd8e0285c6d07ad (patch) | |
tree | 2ee8764e5e5c5c735667230bc49f1ef18c7baa2a /src | |
parent | d670bd3c8220485ca5473d1c1c7a5fe8a8c5cfc4 (diff) | |
download | mana-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.gz mana-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.bz2 mana-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.xz mana-04da189810d74df40d6f92694bd8e0285c6d07ad.zip |
Removing double code and improving attack orientation thanks to Javila
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/game.cpp b/src/game.cpp index 7b7bbd98..6bac6458 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -384,23 +384,26 @@ void do_input() } } else if (target->isMonster()) { - if (player_node->action == STAND) { - if (my > player_node->y) + int dist_x = mx - player_node->x; + int dist_y = my - player_node->y; + if (abs(dist_y) >= abs(dist_x)) { + if (dist_y > 0) player_node->direction = SOUTH; - else if (my < player_node->y) + else player_node->direction = NORTH; - else if (mx > player_node->x) + } else { + if (dist_x > 0) player_node->direction = EAST; - else if (mx < player_node->x) - 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"); + 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"); } else if (target->isPlayer()) { // Begin a trade @@ -1242,7 +1245,7 @@ void do_parse() else chatWindow->chat_log("Unable to sell", BY_SERVER); break; - // Add item to inventory after you bought it + // Add item to inventory after you bought it/picked up case 0x00a0: if (RFIFOB(22) > 0) chatWindow->chat_log("Unable to pick up item", BY_SERVER); @@ -1312,16 +1315,8 @@ void do_parse() case 0x010c: chatWindow->chat_log("MVP player", BY_SERVER); break; - // Item is found + // Item found/dropped case 0x009d: - floorItem = new FloorItem(); - floorItem->id = net_w_value(RFIFOW(6)); - floorItem->x = net_w_value(RFIFOW(9)); - floorItem->y = net_w_value(RFIFOW(11)); - floorItem->int_id = net_l_value(RFIFOL(2)); - add_floor_item(floorItem); - break; - // Item drop case 0x009e: floorItem = new FloorItem(); floorItem->id = net_w_value(RFIFOW(6)); |