Feature #1171 ยป 0072-AI-Pass-civ_map-to-look_for_charge.patch
| ai/default/daimilitary.c | ||
|---|---|---|
|
if want is 0 this advisor doesn't want anything
|
||
|
**************************************************************************/
|
||
|
static void dai_unit_consider_bodyguard(struct ai_type *ait,
|
||
|
const struct civ_map *nmap,
|
||
|
struct city *pcity,
|
||
|
struct unit_type *punittype,
|
||
|
struct adv_choice *choice)
|
||
| ... | ... | |
|
= unit_virtual_create(pplayer, pcity, punittype,
|
||
|
city_production_unit_veteran_level(pcity,
|
||
|
punittype));
|
||
|
const adv_want want = look_for_charge(ait, pplayer, virtualunit,
|
||
|
const adv_want want = look_for_charge(ait, nmap, pplayer, virtualunit,
|
||
|
&aunit, &acity);
|
||
|
if (want > choice->want) {
|
||
| ... | ... | |
|
punittype = dai_choose_bodyguard(ait, nmap, pcity, TC_LAND, L_DEFEND_GOOD,
|
||
|
allow_gold_upkeep);
|
||
|
if (punittype) {
|
||
|
dai_unit_consider_bodyguard(ait, pcity, punittype, choice);
|
||
|
dai_unit_consider_bodyguard(ait, nmap, pcity, punittype, choice);
|
||
|
}
|
||
|
/* If we are in severe danger, don't consider attackers. This is probably
|
||
| ... | ... | |
|
punittype = dai_choose_bodyguard(ait, nmap, pcity, TC_OCEAN, L_DEFEND_GOOD,
|
||
|
allow_gold_upkeep);
|
||
|
if (punittype) {
|
||
|
dai_unit_consider_bodyguard(ait, pcity, punittype, choice);
|
||
|
dai_unit_consider_bodyguard(ait, nmap, pcity, punittype, choice);
|
||
|
}
|
||
|
/* Consider making an airplane */
|
||
| ai/default/daiunit.c | ||
|---|---|---|
|
do we attempt to bodyguard units with higher defense than us, or military
|
||
|
units with lower attack than us that are not transports.
|
||
|
**************************************************************************/
|
||
|
adv_want look_for_charge(struct ai_type *ait, struct player *pplayer,
|
||
|
struct unit *punit,
|
||
|
adv_want look_for_charge(struct ai_type *ait, const struct civ_map *nmap,
|
||
|
struct player *pplayer, struct unit *punit,
|
||
|
struct unit **aunit, struct city **acity)
|
||
|
{
|
||
|
struct pf_parameter parameter;
|
||
| ... | ... | |
|
int def, best_def = -1;
|
||
|
/* Arbitrary: 3 turns. */
|
||
|
const int max_move_cost = 3 * unit_move_rate(punit);
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
*aunit = NULL;
|
||
|
*acity = NULL;
|
||
| ... | ... | |
|
struct city *acity;
|
||
|
struct unit *aunit;
|
||
|
look_for_charge(ait, pplayer, punit, &aunit, &acity);
|
||
|
look_for_charge(ait, nmap, pplayer, punit, &aunit, &acity);
|
||
|
if (acity) {
|
||
|
dai_unit_new_task(ait, punit, AIUNIT_ESCORT, acity->tile);
|
||
|
aiguard_assign_guard_city(ait, acity, punit);
|
||
| ai/default/daiunit.h | ||
|---|---|---|
|
struct city *find_nearest_safe_city(struct unit *punit);
|
||
|
bool uclass_need_trans_between(struct unit_class *pclass,
|
||
|
struct tile *ctile, struct tile *ptile);
|
||
|
adv_want look_for_charge(struct ai_type *ait, struct player *pplayer,
|
||
|
struct unit *punit,
|
||
|
adv_want look_for_charge(struct ai_type *ait, const struct civ_map *nmap,
|
||
|
struct player *pplayer, struct unit *punit,
|
||
|
struct unit **aunit, struct city **acity);
|
||
|
bool dai_can_unit_type_follow_unit_type(const struct unit_type *follower,
|
||
|
const struct unit_type *followee,
|
||