summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--README1
-rw-r--r--src/game.cpp15
-rw-r--r--src/gui/menu.cpp2
-rw-r--r--src/net/protocol.cpp29
-rw-r--r--src/net/protocol.h2
6 files changed, 24 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 40cca7e6..7175921f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-0.0.13 (... 2005)
+0.0.13 (5 June 2005)
- Added server field to login dialog
- Added item descriptions to inventory and buy/sell dialogs
- Added confirmation dialog before quitting
@@ -9,6 +9,7 @@
- Fixed a crash in OpenGL mode
- Fixed rendering of minimap, progress bars and player sprite in OpenGL mode
- Fixed 100% CPU usage when minimized
+- Added ability to auto attack
0.0.12 (1 May 2005)
- Added new map (a cave), tiles, monsters and items
diff --git a/README b/README
index b101db7f..544256fb 100644
--- a/README
+++ b/README
@@ -48,6 +48,7 @@ over NPC's feet to talk to them or over a monster to attack it. Other keys:
- Alt + I show inventory
- Alt + E show equipment
- Alt + C show setup window
+- Left Shift hold it when attacking to lock target for auto attack
3. Skills
---------
diff --git a/src/game.cpp b/src/game.cpp
index 5fe8354c..ee52b0c3 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -547,17 +547,10 @@ void do_input()
if (keys[SDLK_LCTRL])
{
player_node->action = ATTACK;
- attack(player_node->x,
- player_node->y,
- player_node->direction);
- 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");
- }
+ int monsterId = attack(player_node->x,
+ player_node->y, player_node->direction);
+ if (keys[SDLK_LSHIFT])
+ autoTarget = monsterId;
}
}
}
diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp
index 8018b561..9c648db4 100644
--- a/src/gui/menu.cpp
+++ b/src/gui/menu.cpp
@@ -48,5 +48,7 @@ void Menu::fill(std::vector<MenuItem *> items)
i=i+10;
add(*item);
}
+
+ resizeToContent();
}
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);