? ai/aidiplomat.c ? ai/aidiplomat.h Index: ai/Makefile.am =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/Makefile.am,v retrieving revision 1.11 diff -u -r1.11 Makefile.am --- ai/Makefile.am 1 Nov 2002 17:40:45 -0000 1.11 +++ ai/Makefile.am 7 Nov 2002 18:42:12 -0000 @@ -40,4 +40,6 @@ aitools.c \ aitools.h \ aiunit.c \ - aiunit.h + aiunit.h \ + aidiplomat.c \ + aidiplomat.h Index: ai/advmilitary.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v retrieving revision 1.119 diff -u -r1.119 advmilitary.c --- ai/advmilitary.c 7 Nov 2002 16:15:21 -0000 1.119 +++ ai/advmilitary.c 7 Nov 2002 18:42:12 -0000 @@ -26,6 +26,7 @@ #include "aiair.h" #include "aicity.h" +#include "aidiplomat.h" #include "aihand.h" #include "ailog.h" #include "aitools.h" @@ -1323,6 +1324,9 @@ freelog(LOG_DEBUG, "Assessed danger for %s = %d, Def = %d", pcity->name, danger, def); + ai_choose_diplomat_defensive(pplayer, pcity, choice, def); + + if (danger != 0) { /* otherwise might be able to wait a little longer to defend */ if (danger >= def) { if (urgency == 0) danger = 100; /* don't waste money otherwise */ @@ -1387,6 +1391,9 @@ choice->want); return; } + + /* Consider making an offensive diplomat */ + ai_choose_diplomat_offensive(pplayer, pcity, choice); /* Consider making a sea bodyguard */ unit_type = ai_choose_bodyguard(pcity, SEA_MOVING, L_DEFEND_GOOD); Index: ai/aiunit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.h,v retrieving revision 1.34 diff -u -r1.34 aiunit.h --- ai/aiunit.h 21 Mar 2002 20:57:29 -0000 1.34 +++ ai/aiunit.h 7 Nov 2002 18:42:12 -0000 @@ -24,6 +24,17 @@ */ #define POWER_DIVIDER (POWER_FACTOR * 3) +/* Simple military power macros */ +#define DEFENCE_POWER(punit) \ + (unit_type(punit)->defense_strength * unit_type(punit)->hp \ + * unit_type(punit)->firepower) +#define ATTACK_POWER(punit) \ + (unit_type(punit)->attack_strength * unit_type(punit)->hp \ + * unit_type(punit)->firepower) +#define IS_ATTACKER(punit) \ + (unit_type(aunit)->attack_strength > \ + unit_type(aunit)->transport_capacity) + struct player; struct city; struct unit; Index: common/city.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.h,v retrieving revision 1.115 diff -u -r1.115 city.h --- common/city.h 7 Nov 2002 15:45:06 -0000 1.115 +++ common/city.h 7 Nov 2002 18:42:12 -0000 @@ -217,6 +217,9 @@ int invasion; /* who's coming to kill us, for attack co-ordination */ int attack, bcost; /* This is also for invasion - total power and value of * all units coming to kill us. */ + + /* Used by _other_ cities temporarily while assigning diplomat targets */ + bool already_considered_for_diplomat; }; struct city { Index: common/player.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.h,v retrieving revision 1.84 diff -u -r1.84 player.h --- common/player.h 1 Nov 2002 17:40:46 -0000 1.84 +++ common/player.h 7 Nov 2002 18:42:12 -0000 @@ -40,7 +40,7 @@ enum handicap_type { H_NONE=0, /* no handicaps */ - H_RIGIDPROD=1, /* can't switch to/from building_unit without penalty */ + H_DIPLOMAT=1, /* can't build offensive diplomats */ H_MAP=2, /* only knows map_get_known tiles */ H_TECH=4, /* doesn't know what enemies have researched */ H_CITYBUILDINGS=8, /* doesn't know what buildings are in enemy cities */ Index: server/stdinhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v retrieving revision 1.260 diff -u -r1.260 stdinhand.c --- server/stdinhand.c 7 Nov 2002 16:04:55 -0000 1.260 +++ server/stdinhand.c 7 Nov 2002 18:42:13 -0000 @@ -1612,9 +1612,10 @@ int h[11] = { -1, H_NONE, H_NONE, - H_RATES | H_TARGETS | H_HUTS | H_NOPLANES | H_DEFENSIVE, + H_RATES | H_TARGETS | H_HUTS | H_NOPLANES | H_DEFENSIVE + | H_DIPLOMAT, H_NONE, - H_RATES | H_TARGETS | H_HUTS, + H_RATES | H_TARGETS | H_HUTS | H_DIPLOMAT, H_NONE, H_NONE, H_NONE,