68 #define WAR(plr1, plr2) (player_diplstate_get(plr1, plr2)->type == DS_WAR)
69 #define NEVER_MET(plr1, plr2) \
70 (player_diplstate_get(plr1, plr2)->type == DS_NO_CONTACT)
71 #define DEFENSE_POWER(ptype) \
72 (ptype->defense_strength * ptype->hp * ptype->firepower)
73 #define ATTACK_POWER(ptype) \
74 (ptype->attack_strength * ptype->hp * ptype->firepower)
75 #define IS_ATTACKER(ptype) \
76 (ptype->attack_strength > ptype->transport_capacity)
77 #define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer) \
78 (WAR(pplayer, aplayer) || NEVER_MET(pplayer, aplayer) \
79 || dai_diplomacy_get(ait, pplayer, aplayer)->countdown >= 0)
80 #define UNITTYPE_COSTS(ut) \
81 (ut->pop_cost * 3 + ut->happy_cost + ut->upkeep[O_SHIELD] \
82 + ut->upkeep[O_FOOD] + ut->upkeep[O_GOLD])
85 #define INVASION_OCCUPY 0
86 #define INVASION_ATTACK 1
90 #define RAMPAGE_ANYTHING 1
91 #define RAMPAGE_HUT_OR_BETTER 99998
92 #define RAMPAGE_FREE_CITY_OR_BETTER 99999
93 #define BODYGUARD_RAMPAGE_THRESHOLD (SHIELD_WEIGHTING * 4)
103 struct unit *punit,
struct unit **aunit,
104 struct city **acity);
110 struct tile *dest_tile,
112 struct tile **ferry_dest,
struct tile **beachhead_tile);
116 const unit_type **pboattype,
int *pmove_time);
121 struct player *def_player,
122 struct tile *ptile,
bool fortified,
129 const struct city *pcity);
142 #define simple_ai_unit_type_iterate(_ut) \
144 struct unit_type *_ut; \
145 int _ut##_index = 0; \
146 while (nullptr != (_ut = simple_ai_types[_ut##_index++])) {
148 #define simple_ai_unit_type_iterate_end \
154 const char *unitstr);
157 const char *unitstr);
161 enum terrain_class tc);
164 const struct unit *defender);
int find_something_to_kill(ai_type *ait, player *pplayer, unit *punit, tile **pdest_tile, PFPath *ppath, pf_map **pferrymap, unit **pferryboat, const unit_type **pboattype, int *pmove_time)
int look_for_charge(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct unit **aunit, struct city **acity)
See if we can find something to defend.
void dai_unit_save(struct ai_type *ait, const char *aitstr, struct section_file *file, const struct unit *punit, const char *unitstr)
Save AI data of a unit.
void dai_manage_military(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Decide what to do with a military unit.
int unittype_def_rating_squared(const struct unit_type *att_type, const struct unit_type *def_type, struct player *def_player, struct tile *ptile, bool fortified, int veteran)
Defence rating of def_type unit against att_type unit, squared.
void dai_units_ruleset_init(struct ai_type *ait)
Initialise the unit data from the ruleset for the AI.
struct city * find_nearest_safe_city(struct unit *punit)
Find safe city to recover in.
int kill_desire(int benefit, int attack, int loss, int vuln, int attack_count)
Compute how much we want to kill certain victim we've chosen, counted in SHIELDs.
void dai_switch_to_explore(struct ai_type *ait, struct unit *punit, struct tile *target, enum override_bool *allow)
Switch to autoexploring.
const struct impr_type * utype_needs_improvement(const struct unit_type *putype, const struct city *pcity)
Returns an improvement that will make it possible to build units of the specified type the specified ...
struct unit_type * simple_ai_types[U_LAST]
int build_cost_balanced(const struct unit_type *punittype)
In the words of Syela: "Using funky fprime variable instead of f in the denom, so that def=1 units ar...
bool dai_unit_can_strike_my_unit(const struct unit *attacker, const struct unit *defender)
Returns whether 'attacker' can attack 'defender' immediately.
void dai_manage_units(struct ai_type *ait, struct player *pplayer)
Master manage unit function.
void dai_manage_unit(struct ai_type *ait, struct player *pplayer, struct unit *punit)
manage one unit Careful: punit may have been destroyed upon return from this routine!
struct unit_type * dai_role_utype_for_terrain_class(struct city *pcity, int role, enum terrain_class tc)
Get unit type player can build, suitable to role, with given move type.
void dai_unit_turn_end(struct ai_type *ait, struct unit *punit)
Free unit from use with default AI.
bool dai_can_unit_type_follow_unit_type(const struct unit_type *follower, const struct unit_type *followee, struct ai_type *ait)
See if the follower can follow the followee.
void dai_unit_init(struct ai_type *ait, struct unit *punit)
Initialize unit for use with default AI.
void dai_consider_tile_dangerous(struct ai_type *ait, struct tile *ptile, struct unit *punit, enum override_bool *result)
Are there dangerous enemies at or adjacent to the tile 'ptile'?
void dai_unit_load(struct ai_type *ait, const char *aitstr, const struct section_file *file, struct unit *punit, const char *unitstr)
Load AI data of a unit.
void dai_unit_close(struct ai_type *ait, struct unit *punit)
Free unit from use with default AI.
void dai_units_ruleset_close(struct ai_type *ait)
Close AI unit type data.
bool find_beachhead(const struct player *pplayer, struct pf_map *ferry_map, struct tile *dest_tile, const struct unit_type *cargo_type, struct tile **ferry_dest, struct tile **beachhead_tile)
Returns TRUE if a beachhead as been found to reach 'dest_tile'.
bool dai_military_rampage(struct unit *punit, int thresh_adj, int thresh_move)
Find and kill anything reachable within this turn and worth more than the relevant of the given thres...
static void attack(QVariant data1, QVariant data2)
Action "Attack" for choice dialog.
struct tile * prev_struct
struct unit_type_list * potential_charges