[Freeciv-Dev] (PR#6280) improve ai_unit_execute_path()
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#6280) improve ai_unit_execute_path() |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Thu, 25 Sep 2003 07:59:00 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
Improve ai_unit_execute_path() so that it can be used with non-military
units and non-attack gotos. We now only attack something if it is on the
end of our path.
- Per
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.289
diff -u -r1.289 aiunit.c
--- ai/aiunit.c 21 Sep 2003 09:06:43 -0000 1.289
+++ ai/aiunit.c 25 Sep 2003 15:47:27 -0000
@@ -1082,8 +1082,18 @@
/* We start with i = 1 for i = 0 is our present position */
for (i = 1; i < path->length; i++) {
int x = path->positions[i].x, y = path->positions[i].y;
+ bool result;
- if (!ai_unit_attack(punit, x, y)) {
+ /* We use ai_unit_move() for everything but the last step
+ * of the way so that we abort if unexpected opposition
+ * shows up. Any enemy on the target tile is expected to
+ * be our target and any attack there intentional. */
+ if (i == path->length) {
+ result = ai_unit_attack(punit, x, y);
+ } else {
+ result = ai_unit_move(punit, x, y);
+ }
+ if (!result) {
/* Died... */
return FALSE;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#6280) improve ai_unit_execute_path(),
Per I. Mathisen <=
|
|