summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-05-20 18:30:02 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-05-20 18:30:02 +0000
commit04da189810d74df40d6f92694bd8e0285c6d07ad (patch)
tree2ee8764e5e5c5c735667230bc49f1ef18c7baa2a
parentd670bd3c8220485ca5473d1c1c7a5fe8a8c5cfc4 (diff)
downloadmana-client-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.gz
mana-client-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.bz2
mana-client-04da189810d74df40d6f92694bd8e0285c6d07ad.tar.xz
mana-client-04da189810d74df40d6f92694bd8e0285c6d07ad.zip
Removing double code and improving attack orientation thanks to Javila
-rw-r--r--The Mana World.dev4
-rw-r--r--src/game.cpp39
2 files changed, 19 insertions, 24 deletions
diff --git a/The Mana World.dev b/The Mana World.dev
index 1fb928ba..8813a4f7 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -11,10 +11,10 @@ PrivateResource=The_Mana_World_private.rc
ResourceIncludes=
MakeIncludes=
Compiler=-Dmain=SDL_main_@@_
-CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@__@@__@@_
+CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@_
Linker=-lguichan_@@_-lguichan_sdl_@@_-lguichan_opengl_@@_-lwsock32_@@_-lSDL_image_@@_-lSDL_mixer_@@_-lmingw32_@@_-lSDLmain_@@_-lSDL_@@_-llibxml2_@@_-lopengl32_@@_-lphysfs_@@_
IsCpp=1
-Icon=
+Icon=The Mana World.ico
ExeOutput=
ObjectOutput=obj
OverrideOutput=1
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));