[Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missile
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles |
From: |
"Andy Smith" <andy@xxxxxxxxxxxxxx> |
Date: |
Mon, 28 Jul 2003 23:01:53 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
On Sun, Jul 27, 2003 at 12:17:38PM -0700, Per I. Mathisen wrote:
> > So I suggest:
> >
> > 1. auto-attack should make sure that your own unit can engage the enemy
> > unit at all, as a big fix.
> >
> > 2. As a game option, auto-attack should only operate on enemy units
> > that can currently be seen by the player. I say as an option
> > because I can see how this greatly reduces the power of
> > auto-attack and maybe some people desire the previous behaviour?
>
> No, this should not be an option. Auto-attack that attacks units the
> player cannot see is clearly a bug.
[...]
> Yes, please write patches for these bugs.
How's this? Appears to work:
4: doing autoattack for Cruise Missile (25/27) in Cirith Ungol, range 36(36),
city_options 15
4: found enemy unit/stack at 13,20
4: defender is Destroyer
4: can't see Destroyer at (13,20)
4: found enemy unit/stack at 27,26
4: defender is Fighter
4: Cruise Missile at (25,27) cannot attack Fighter at (27,26)
4: found enemy unit/stack at 31,26
4: defender is Helicopter
4: chosen target=Helicopter [10/3/6] (31/26)
> If you look hard, I am sure you can find plenty more bugs in this
> code. It has always been pretty bad, and nobody has fixed or
> cleaned up this code in several years.
Will do.
--- freeciv-cvs/server/autoattack.c 2003-07-17 19:56:51.000000000 +0100
+++ freeciv-patched/server/autoattack.c 2003-07-29 07:00:37.000000000 +0100
@@ -44,6 +44,7 @@
#include "unit.h"
#include "gotohand.h"
+#include "maphand.h"
#include "plrhand.h"
#include "srv_main.h"
#include "unithand.h"
@@ -111,6 +112,39 @@
}
/*
+ * Make sure the player can see both the location and the unit at that
+ * location, before allowing an auto-attack. Without this, units attack
+ * into locations they cannot see, and maybe submarines are made
+ * erroneously visible too.
+ */
+ if (!map_get_known_and_seen(x, y, pplayer)
+ || !player_can_see_unit_at_location(pplayer, enemy, x, y)) {
+ freelog(LOG_DEBUG, "can't see %s at (%d,%d)", unit_name(enemy->type),
+ x, y);
+ continue;
+ }
+
+ /*
+ * is this the correct function to use here? c_u_a_u_a_t() seems to assume
+ * that attacker is in an adjacent tile but I do not think it matters.
+ *
+ * On the other hand, we already checked everything that this function
+ * checks, except for missiles trying to attack air units, so perhaps we
+ * should just do that check here? But doing a final sanity check to make
+ * sure our attacker can engage the enemy at all seems safest.
+ *
+ * Without this check, missiles are made useless for auto-attack as they
+ * get triggered by fighters and bombers and end up being wasted when they
+ * cannot engage.
+ */
+ if (!can_unit_attack_unit_at_tile(punit, enemy, x, y)) {
+ freelog(LOG_DEBUG, "%s at (%d,%d) cannot attack %s at (%d,%d)",
+ unit_name(punit->type), punit->x, punit->y,
+ unit_name(enemy->type), x, y);
+ continue;
+ }
+
+ /*
* perhaps there is a better algorithm in the ai-package -- fisch
*/
score = (unit_type(enemy)->defense_strength + (enemy->hp / 2)
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Per I. Mathisen, 2003/07/27
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles,
Andy Smith <=
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Jason Short, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Andy Smith, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Jason Short, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Andy Smith, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Andy Smith, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Andy Smith, 2003/07/29
- Message not available
- [Freeciv-Dev] Re: (PR#4701) autoattack oddities esp. with cruise missiles, Jason Short, 2003/07/29
|
|