85 enum terrain_class tc,
87 bool allow_gold_upkeep)
103 || ut->attack_strength < ut->transport_capacity
110 * ut->attack_strength
116 desire += desire / 6;
120 desire += desire / 2;
122 if (ut->vlayer == V_INVIS) {
123 desire += desire / 4;
126 desire -= desire / 4;
155 struct unit *hunter = NULL;
194 *
MIN(ut->attack_strength, 30)
213 if (best > choice->
want) {
221 }
else if (best >= 0) {
236 struct unit *virtualunit;
242 if (want > choice->
want) {
257 bool allow_gold_upkeep)
265 if ((!best_land_hunter && !best_sea_hunter)
276 if (best_sea_hunter) {
278 ait, pplayer, pcity, choice, best_sea_hunter,
281 if (best_land_hunter) {
283 ait, pplayer, pcity, choice, best_land_hunter,
312 int target_sanity = target->
id;
319 struct unit *sucker = NULL;
323 ACTION_SUICIDE_ATTACK)) {
330 if (move_cost > missile->moves_left /
SINGLE_MOVE) {
338 enum diplstate_type ds =
346 if (victim == target) {
378 0,
"", ACTION_TRANSPORT_ALIGHT);
403 struct unit *target,
unsigned *stackthreat,
415 *stackthreat += 5000;
424 *stackthreat += *stackcost;
442 bool is_virtual = (
punit->
id == 0);
448 unsigned original_threat = 0, original_cost = 0;
458 if (original_target) {
460 &original_threat, &original_cost);
465 if (move_cost > limit) {
479 unsigned stackthreat = 0, stackcost = 0;
480 int sanity_target = target->id;
484 struct unit *defender;
526 "giving up racing %s (%d, %d)->(%d, %d)",
542 if (defender != NULL) {
547 target->
id, stackcost,
551 stackthreat /= move_cost + 1;
553 && original_target != target
554 && original_threat > stackthreat) {
556 target->
id, original_target->
id);
565 "with want %d, dist1 %d, dist2 %d",
574 unit_data->
target = target->id;
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)
#define adv_choice_set_use(_choice, _use)
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
bool adv_unit_execute_path(struct unit *punit, struct pf_path *path)
static void dai_hunter_juiciness(struct player *pplayer, struct unit *punit, struct unit *target, unsigned *stackthreat, unsigned *stackcost)
static void eval_hunter_want(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, struct unit_type *best_type, int veteran)
static struct unit * dai_hunter_find(struct player *pplayer, struct city *pcity)
bool dai_hunter_qualify(struct player *pplayer, struct unit *punit)
static void dai_hunter_missile_want(struct player *pplayer, struct city *pcity, struct adv_choice *choice)
static struct unit_type * dai_hunter_guess_best(struct city *pcity, enum terrain_class tc, struct ai_type *ait, bool allow_gold_upkeep)
void dai_hunter_choice(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
int dai_hunter_manage(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static void dai_hunter_try_launch(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct unit *target)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
bool dai_unit_can_strike_my_unit(const struct unit *attacker, const struct unit *defender)
#define DEFENSE_POWER(ptype)
#define ATTACK_POWER(ptype)
#define UNITTYPE_COSTS(ut)
#define BV_ISSET(bv, bit)
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
#define city_owner(_pcity_)
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)
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
struct unit struct city struct unit struct tile * target_tile
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
struct unit * game_unit_by_number(int id)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
#define fc_assert_ret_val(condition, val)
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
static int index_to_map_pos_y(int mindex)
static int index_to_map_pos_x(int mindex)
int unit_move_rate(const struct unit *punit)
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
bool can_attack_non_native(const struct unit_type *utype)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_unit(const struct unit *punit)
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)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
int player_index(const struct player *pplayer)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
static bool is_barbarian(const struct player *pplayer)
#define CITY_LOG(loglevel, pcity, msg,...)
#define UNIT_LOG(loglevel, punit, msg,...)
struct unit_list * units_supported
struct unit_list * transporting
struct city * tile_city(const struct tile *ptile)
const struct unit_type * utype
struct unit * unit_transport_get(const struct unit *pcargo)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
int get_transporter_capacity(const struct unit *punit)
void unit_virtual_destroy(struct unit *punit)
bool unit_transported(const struct unit *pcargo)
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_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
const char * unit_rule_name(const struct unit *punit)
int unit_build_shield_cost_base(const struct unit *punit)
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
bool utype_acts_hostile(const struct unit_type *putype)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end