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;
216 if (danger >= my_def) {
218 "want bodyguard @(%d, %d) danger=%d, my_def=%d",
219 TILE_XY(dest_tile), danger, my_def);
226 }
else if (guard != NULL) {
235#define LOGLEVEL_GOTHERE LOG_DEBUG
304 struct tile *dest_tile)
322 for (i = 1; i < path->
length; i++) {
340 "%s %s[%d] (%d,%d)->(%d,%d)",
432 bool can_get_there =
FALSE;
436 can_get_there =
TRUE;
445 can_get_there =
TRUE;
449 return can_get_there;
562 }
else if (is_ferry) {
569 switch (unit_data->
task) {
676 log_error(
"%s was on city founding mission without target tile.",
689 task, unit_data->
task);
699 unit_data->
task = task;
728 ACTION_SUICIDE_ATTACK)
739 switch (unit_data->
task) {
773 0,
"", ACTION_HOME_CITY);
786 struct unit *bodyguard,
struct tile *ptile)
791#ifndef FREECIV_NDEBUG
839 0,
"", ACTION_CAPTURE_UNITS);
844 0,
"", ACTION_BOMBARD);
849 0,
"", ACTION_BOMBARD2);
854 0,
"", ACTION_BOMBARD3);
859 0,
"", ACTION_NUKE_UNITS);
862 punit, ptile, NULL)) {
875 punit, ptile, NULL)) {
878 0,
"", ACTION_NUKE_CITY);
885 0,
"", ACTION_NUKE_CITY);
890 0,
"", ACTION_ATTACK);
895 0,
"", ACTION_SUICIDE_ATTACK);
901 0,
"", ACTION_CONQUER_CITY);
907 0,
"", ACTION_CONQUER_CITY2);
913 0,
"", ACTION_CONQUER_CITY3);
919 0,
"", ACTION_CONQUER_CITY4);
926 0,
"", ACTION_TRANSPORT_EMBARK);
933 0,
"", ACTION_TRANSPORT_EMBARK2);
940 0,
"", ACTION_TRANSPORT_EMBARK3);
942 punit, ptile, NULL)) {
945 0,
"", ACTION_TRANSPORT_DISEMBARK1);
947 punit, ptile, NULL)) {
950 0,
"", ACTION_TRANSPORT_DISEMBARK2);
952 punit, ptile, NULL)) {
955 0,
"", ACTION_TRANSPORT_DISEMBARK3);
957 punit, ptile, NULL)) {
960 0,
"", ACTION_TRANSPORT_DISEMBARK4);
963 punit, ptile, NULL)) {
966 0,
"", ACTION_CONQUER_EXTRAS);
969 punit, ptile, NULL)) {
972 0,
"", ACTION_CONQUER_EXTRAS2);
975 punit, ptile, NULL)) {
978 0,
"", ACTION_CONQUER_EXTRAS3);
981 punit, ptile, NULL)) {
984 0,
"", ACTION_CONQUER_EXTRAS4);
986 punit, ptile, NULL)) {
989 0,
"", ACTION_HUT_ENTER);
991 punit, ptile, NULL)) {
994 0,
"", ACTION_HUT_ENTER2);
996 punit, ptile, NULL)) {
999 0,
"", ACTION_HUT_ENTER3);
1001 punit, ptile, NULL)) {
1004 0,
"", ACTION_HUT_ENTER4);
1006 punit, ptile, NULL)) {
1009 0,
"", ACTION_HUT_FRIGHTEN);
1011 punit, ptile, NULL)) {
1014 0,
"", ACTION_HUT_FRIGHTEN2);
1016 punit, ptile, NULL)) {
1019 0,
"", ACTION_HUT_FRIGHTEN3);
1021 punit, ptile, NULL)) {
1024 0,
"", ACTION_HUT_FRIGHTEN4);
1026 punit, ptile, NULL)) {
1029 0,
"", ACTION_UNIT_MOVE);
1031 punit, ptile, NULL)) {
1034 0,
"", ACTION_UNIT_MOVE2);
1038 0,
"", ACTION_UNIT_MOVE3);
1076 struct unit *bodyguard;
1077 struct unit *ptrans = NULL;
1080 const bool is_plr_ai =
is_ai(pplayer);
1085 "Tiles not adjacent: Unit = %d, "
1086 "from = (%d, %d]) to = (%d, %d).",
1134 punit, ptile, NULL)) {
1138 punit, ptile, NULL)) {
1142 punit, ptile, NULL)) {
1146 punit, ptile, NULL)) {
1150 punit, ptile, NULL)) {
1154 punit, ptile, NULL)) {
1158 punit, ptile, NULL)) {
1162 punit, ptile, NULL)) {
1166 punit, ptile, NULL)) {
1170 punit, ptile, NULL)) {
1174 punit, ptile, NULL)) {
1178 punit, ptile, NULL)) {
1182 punit, ptile, NULL)) {
1186 punit, ptile, NULL)) {
1201 struct tile *from_tile;
1220 "ending move early to stay out of trouble");
1228 if (paction && ptrans
1235 ACTRES_TRANSPORT_DISEMBARK)
1240 ACTRES_HUT_FRIGHTEN))) {
1251 if (is_plr_ai && bodyguard != NULL
1267 int victim_cost = 0;
1321 choice->
want = (choice->
want * pct) / 100;
1335 if (iunit != NULL) {
1338 choice->
want = want;
1361 want = choice->
want;
1378 choice->
want = want;
1413 if (happy_cost > 0) {
1414 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_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)
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
#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)