83 return "Auto settler";
105 log_error(
"Unsupported ai_unit_task %d.", task);
119 adv_want value,
int delay,
int build_cost)
124 int build_time = build_cost /
MAX(output, 1);
130 return amortize(value, delay + build_time);
165 unsigned int danger = 0;
169 bool bg_needed =
FALSE;
214 if (danger >= my_def) {
216 "want bodyguard @(%d, %d) danger=%d, my_def=%d",
217 TILE_XY(dest_tile), danger, my_def);
224 }
else if (guard != NULL) {
233#define LOGLEVEL_GOTHERE LOG_DEBUG
302 struct tile *dest_tile)
320 for (i = 1; i < path->
length; i++) {
338 "%s %s[%d] (%d,%d)->(%d,%d)",
430 bool can_get_there =
FALSE;
434 can_get_there =
TRUE;
443 can_get_there =
TRUE;
447 return can_get_there;
560 }
else if (is_ferry) {
567 switch (unit_data->
task) {
674 log_error(
"%s was on city founding mission without target tile.",
687 task, unit_data->
task);
697 unit_data->
task = task;
726 ACTION_SUICIDE_ATTACK)
737 switch (unit_data->
task) {
771 0,
"", ACTION_HOME_CITY);
784 struct unit *bodyguard,
struct tile *ptile)
789#ifndef FREECIV_NDEBUG
837 0,
"", ACTION_CAPTURE_UNITS);
842 0,
"", ACTION_BOMBARD);
847 0,
"", ACTION_BOMBARD2);
852 0,
"", ACTION_BOMBARD3);
857 0,
"", ACTION_NUKE_UNITS);
860 punit, ptile, NULL)) {
873 punit, ptile, NULL)) {
876 0,
"", ACTION_NUKE_CITY);
883 0,
"", ACTION_NUKE_CITY);
888 0,
"", ACTION_ATTACK);
893 0,
"", ACTION_SUICIDE_ATTACK);
899 0,
"", ACTION_CONQUER_CITY);
905 0,
"", ACTION_CONQUER_CITY2);
911 0,
"", ACTION_CONQUER_CITY3);
917 0,
"", ACTION_CONQUER_CITY4);
924 0,
"", ACTION_TRANSPORT_EMBARK);
931 0,
"", ACTION_TRANSPORT_EMBARK2);
938 0,
"", ACTION_TRANSPORT_EMBARK3);
940 punit, ptile, NULL)) {
943 0,
"", ACTION_TRANSPORT_DISEMBARK1);
945 punit, ptile, NULL)) {
948 0,
"", ACTION_TRANSPORT_DISEMBARK2);
950 punit, ptile, NULL)) {
953 0,
"", ACTION_TRANSPORT_DISEMBARK3);
955 punit, ptile, NULL)) {
958 0,
"", ACTION_TRANSPORT_DISEMBARK4);
961 punit, ptile, NULL)) {
964 0,
"", ACTION_CONQUER_EXTRAS);
967 punit, ptile, NULL)) {
970 0,
"", ACTION_CONQUER_EXTRAS2);
973 punit, ptile, NULL)) {
976 0,
"", ACTION_CONQUER_EXTRAS3);
979 punit, ptile, NULL)) {
982 0,
"", ACTION_CONQUER_EXTRAS4);
984 punit, ptile, NULL)) {
987 0,
"", ACTION_HUT_ENTER);
989 punit, ptile, NULL)) {
992 0,
"", ACTION_HUT_ENTER2);
994 punit, ptile, NULL)) {
997 0,
"", ACTION_HUT_ENTER3);
999 punit, ptile, NULL)) {
1002 0,
"", ACTION_HUT_ENTER4);
1004 punit, ptile, NULL)) {
1007 0,
"", ACTION_HUT_FRIGHTEN);
1009 punit, ptile, NULL)) {
1012 0,
"", ACTION_HUT_FRIGHTEN2);
1014 punit, ptile, NULL)) {
1017 0,
"", ACTION_HUT_FRIGHTEN3);
1019 punit, ptile, NULL)) {
1022 0,
"", ACTION_HUT_FRIGHTEN4);
1024 punit, ptile, NULL)) {
1027 0,
"", ACTION_UNIT_MOVE);
1029 punit, ptile, NULL)) {
1032 0,
"", ACTION_UNIT_MOVE2);
1036 0,
"", ACTION_UNIT_MOVE3);
1074 struct unit *bodyguard;
1075 struct unit *ptrans = NULL;
1078 const bool is_plr_ai =
is_ai(pplayer);
1083 "Tiles not adjacent: Unit = %d, "
1084 "from = (%d, %d]) to = (%d, %d).",
1132 punit, ptile, NULL)) {
1136 punit, ptile, NULL)) {
1140 punit, ptile, NULL)) {
1144 punit, ptile, NULL)) {
1148 punit, ptile, NULL)) {
1152 punit, ptile, NULL)) {
1156 punit, ptile, NULL)) {
1160 punit, ptile, NULL)) {
1164 punit, ptile, NULL)) {
1168 punit, ptile, NULL)) {
1172 punit, ptile, NULL)) {
1176 punit, ptile, NULL)) {
1180 punit, ptile, NULL)) {
1184 punit, ptile, NULL)) {
1199 struct tile *from_tile;
1218 "ending move early to stay out of trouble");
1226 if (paction && ptrans
1233 ACTRES_TRANSPORT_DISEMBARK)
1238 ACTRES_HUT_FRIGHTEN))) {
1249 if (is_plr_ai && bodyguard != NULL
1265 int victim_cost = 0;
1319 choice->
want = (choice->
want * pct) / 100;
1333 if (iunit != NULL) {
1336 choice->
want = want;
1359 want = choice->
want;
1376 choice->
want = want;
1410 if (happy_cost > 0) {
1411 unhap += happy_cost;
int action_number(const struct action *action)
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
bool is_action_enabled_unit_on_units(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile)
bool is_action_enabled_unit_on_city(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
static struct action * action_by_number(action_id act_id)
#define action_has_result(_act_, _res_)
#define action_id_get_target_kind(act_id)
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
bool adv_danger_at(struct unit *punit, struct tile *ptile)
int adv_unittype_att_rating(const struct unit_type *punittype, int veteran, int moves_left, int hp)
int adv_unit_att_rating(const struct unit *punit)
void adv_avoid_risks(struct pf_parameter *parameter, struct adv_risk_cost *risk_cost, struct unit *punit, const double fearfulness)
#define NORMAL_STACKING_FEARFULNESS
struct ai_dip_intel * dai_diplomacy_get(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile *dest_tile, bool with_bodyguard)
bool dai_is_ferry(struct unit *pferry, struct ai_type *ait)
void aiferry_clear_boat(struct ai_type *ait, struct unit *punit)
void aiguard_clear_charge(struct ai_type *ait, struct unit *guard)
void aiguard_request_guard(struct ai_type *ait, struct unit *punit)
void aiguard_assign_guard_city(struct ai_type *ait, struct city *charge, struct unit *guard)
struct unit * aiguard_charge_unit(struct ai_type *ait, struct unit *guard)
void aiguard_clear_guard(struct ai_type *ait, struct unit *charge)
struct unit * aiguard_guard_of(struct ai_type *ait, struct unit *charge)
#define CHECK_CHARGE_UNIT(ait, charge)
#define CHECK_GUARD(ait, guard)
#define BODYGUARD_LOG(ait, loglevel, punit, msg,...)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
struct unit_type * dai_wants_role_unit(struct ai_type *ait, struct player *pplayer, struct city *pcity, int role, int want)
#define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer)
int city_unit_unhappiness(struct unit *punit, int *free_unhappy)
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
#define city_list_iterate(citylist, pcity)
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
#define city_owner(_pcity_)
#define city_list_iterate_end
void citymap_free_city_spot(struct tile *ptile, int id)
void citymap_reserve_city_spot(struct tile *ptile, int id)
void auto_arrange_workers(struct city *pcity)
bool is_stack_vulnerable(const struct tile *ptile)
enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit, const struct action *paction, const struct unit *pdefender, const struct tile *dest_tile)
struct unit_type * dai_choose_defender_versus(struct city *pcity, struct unit *attacker)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
struct unit * game_unit_by_number(int id)
struct government * government_of_player(const struct player *pplayer)
Government_type_id government_number(const struct government *pgovern)
void handle_player_change_government(struct player *pplayer, Government_type_id government)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
const char * improvement_rule_name(const struct impr_type *pimprove)
Impr_type_id improvement_index(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_error(message,...)
#define fc_assert_ret_val_msg(condition, val, message,...)
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
int map_distance(const struct tile *tile0, const struct tile *tile1)
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
int unit_move_rate(const struct unit *punit)
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_unit(const struct unit *punit)
const struct pf_position * pf_path_last_position(const struct pf_path *path)
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
void pf_map_destroy(struct pf_map *pfm)
int pf_map_move_cost(struct pf_map *pfm, struct tile *ptile)
int player_index(const struct player *pplayer)
static bool is_barbarian(const struct player *pplayer)
int total_player_citizens(const struct player *pplayer)
#define CITY_LOG(loglevel, pcity, msg,...)
#define UNIT_LOG(loglevel, punit, msg,...)
#define LOGLEVEL_BODYGUARD
adv_want building_want[B_LAST]
struct adv_data::@92 stats
struct city::@17::@19 server
struct unit_list * units_supported
enum tile_behavior(* get_TB)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
int(* get_moves_left_req)(const struct tile *ptile, enum known_type, const struct pf_parameter *param)
bool(* get_zoc)(const struct player *pplayer, const struct tile *ptile, const struct civ_map *zmap)
struct pf_position * positions
struct city_list * cities
struct player_ai ai_common
enum unit_activity activity
struct unit::@80::@83 server
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
struct city * tile_city(const struct tile *ptile)
const struct unit_type * utype
const struct impr_type * building
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
bool is_losing_hp(const struct unit *punit)
bool can_unit_load(const struct unit *pcargo, const struct unit *ptrans)
bool unit_is_cityfounder(const struct unit *punit)
bool unit_transported(const struct unit *pcargo)
bool unit_has_orders(const struct unit *punit)
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
#define CHECK_UNIT(punit)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
const char * unit_rule_name(const struct unit *punit)
bool utype_may_act_at_all(const struct unit_type *putype)
int unit_build_shield_cost_base(const struct unit *punit)
struct unit_class * unit_class_get(const struct unit *punit)
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)