<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39674 >
On Thu, 6 Sep 2007, Karl-Ingo Friese wrote:
> a behauvior which can be quite surprising if you are
> not aware of it:
>
> When a city is attacked, the unit with the best defense
> chances is choosen - even if it is the leader! Concrete:
> If a catapult attacks a city with a phalanx + leader, the
> leader will defend (and most likely die).
>
> IMHO the leader should try to stay out of the combat as
> long as he is not the only defender. He is the leader.
> Of course this only counts for cities and fortresses ...
Patch attached.
- Per
Carpe noctem
Index: common/combat.c
===================================================================
--- common/combat.c (revision 13546)
+++ common/combat.c (working copy)
@@ -551,7 +551,7 @@
const struct tile *ptile)
{
struct unit *bestdef = NULL;
- int bestvalue = -1, best_cost = 0, rating_of_best = 0;
+ int bestvalue = -99, best_cost = 0, rating_of_best = 0;
/* Simply call win_chance with all the possible defenders in turn, and
* take the best one. It currently uses build cost as a tiebreaker in
@@ -572,9 +572,15 @@
/* This will make units roughly evenly good defenders look alike. */
int unit_def
= (int) (100000 * (1 - unit_win_chance(attacker, defender)));
+ struct base_type *pbase = tile_get_base(defender->tile);
assert(unit_def >= 0);
-
+ if (unit_has_type_flag(defender, F_GAMELOSS)
+ && ((pbase && base_has_flag(pbase, BF_NO_STACK_DEATH))
+ || !game.info.killstack
+ || defender->tile->city)) {
+ unit_def = -1; // then always use leader as last defender
+ }
if (unit_def > bestvalue) {
change = TRUE;
} else if (unit_def == bestvalue) {
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev