73 struct unit *attacker)
83 int fpatt, fpdef, defense,
attack;
85 struct unit *defender;
87 punittype, EFT_VETERAN_BUILD);
97 loss =
static_cast<double>(defense) * punittype->hp * fpdef
99 want = (loss +
MAX(0, loss - attacker->
hp)) / cost;
101 if (want > best || (want == best && cost <= best_cost)) {
103 bestunit = punittype;
121 enum terrain_class tc,
122 bool allow_gold_upkeep)
131 if (!allow_gold_upkeep
167 enum terrain_class tc,
168 enum unit_role_id role,
169 bool allow_gold_upkeep)
178 if (unit_role_id_is_valid(role)) {
187 if (!allow_gold_upkeep
221 bool igwall,
bool quadratic,
225 bool do_wall =
false;
252 defense *= wall_value;
264 int defense = 0, walls = 0;
266 const bool igwall =
false;
273 while (walls * walls < city_data->
wallvalue * 10) {
283 if (defense > 1 << 12) {
285 "Overflow danger in assess_defense_quadratic:"
288 if (defense > 1 << 15) {
293 return defense * defense;
301 struct unit *punit,
bool igwall)
352 const struct unit *punit,
int *move_time)
357 const struct unit *ferry;
379 *move_time = pos.
turn;
385 *move_time = pos.
turn;
407 return danger * 100 /
MAX(mod, 1);
448 int urgency,
int danger,
int defense)
450 if (*value == 0 || danger <= 0) {
454 *value =
MAX(*value, 100 + urgency);
456 if (urgency > 0 && danger > defense * 2) {
458 }
else if (defense != 0 && danger > defense) {
459 *value =
MAX(danger * 100.f / defense, *value);
488 int danger_reduced[
B_LAST];
494 int total_danger = 0;
495 int defense_bonuses_pct[
U_LAST];
496 bool defender_type_handled[
U_LAST] = {
false};
503 memset(&danger_reduced, 0,
sizeof(danger_reduced));
540 > defense_bonuses_pct[idx]) {
541 defense_bonuses_pct[idx] =
565 struct unit_list *units;
576 if (ul_cb !=
nullptr) {
577 units = ul_cb(aplayer);
579 units = aplayer->units;
604 if (3 >= move_time) {
606 if (1 >= move_time) {
612 defbonus_pct = defense_bonuses_pct[
utype_index(utype)];
613 if (defbonus_pct > 100) {
614 defbonus_pct = (defbonus_pct + 100) / 2;
616 vulnerability = vulnerability * 100 / (defbonus_pct + 100);
618 vulnerability /
MAX(move_time, 1));
624 vulnerability *= vulnerability;
626 vulnerability /= move_time;
635 danger_reduced[defender] += vulnerability /
MAX(move_time, 1);
641 danger_reduced[defender] += vulnerability /
MAX(move_time, 1);
645 total_danger += vulnerability;
672 for (i = 0; i <
B_LAST; i++) {
673 if (0 < danger_reduced[i]) {
675 urgency, danger_reduced[i], defense);
684 city_data->
danger = total_danger;
700 int desire = punittype->
hp;
703 int maxbonus_pct = 0;
719 if (maxbonus_pct > 100) {
720 maxbonus_pct = (maxbonus_pct + 100) / 2;
722 desire += desire * maxbonus_pct / 100;
736 int desire = punittype->
hp;
745 desire += desire / 2;
751 desire += desire / 2;
754 desire += desire / 4;
757 desire += desire / 4;
768 struct city *pcity,
int danger,
781 struct unit_type *best_unit_type =
nullptr;
782 int best_unit_cost = 1;
786 memset(tech_desire, 0,
sizeof(tech_desire));
826 if ((best_unit_cost > limit_cost && build_cost < best_unit_cost)
828 || (desire == best && build_cost <= best_unit_cost))
829 && (best_unit_type ==
nullptr
831 || limit_cost <= pcity->shield_stock + 40))) {
833 best_unit_type = punittype;
834 best_unit_cost = build_cost;
842 int notzero = city_list_size(pplayer->
cities);
869 if (best_unit_type) {
870 if (!walls && !
utype_has_flag(best_unit_type, UTYF_BADCITYDEFENDER)) {
875 best_unit_cost = 100;
891 tech_desire[
utype_index(punittype)] * best_unit_cost / best;
896 "+ %d for %s to defend %s", desire,
902 if (!best_unit_type) {
907 choice->
want = danger;
931 const struct unit_type *victim_unit_type,
932 struct player *victim_player,
int veteran,
945 int victim_count = 1;
951 struct ai_city *acity_data =
nullptr;
953 if (acity !=
nullptr) {
966 victim_count += unit_list_size(ptile->
units);
978 && punittype->attack_strength > 0 ) {
985 nullptr, pplayer,
nullptr, pcity,
nullptr,
city_tile(pcity),
986 nullptr, punittype,
nullptr,
nullptr,
nullptr, EFT_VETERAN_BUILD);
990 int notzero = city_list_size(pplayer->
cities);
1020 if (
nullptr != ferry_map) {
1021 struct tile *dest_tile;
1023 if (
find_beachhead(pplayer, ferry_map, ptile, punittype, &dest_tile,
1026 move_time = pos.
turn;
1030 if (atile == dest_tile) {
1032 move_time += pos.
turn;
1034 }
else if (atile == ptile) {
1037 move_time = pos.
turn;
1045 if (-1 == move_time) {
1047 move_time = pos.
turn;
1057 if (victim_unit_type) {
1059 victim_player, ptile,
false,
1079 float finishing_factor = 1;
1085 desire = acity_data->
worth * 10 * finishing_factor;
1094 int city_attack = acity_data->
attack * acity_data->
attack;
1100 if (value * city_attack > acity_data->
bcost * vuln) {
1105 desire =
MAX(desire, kd);
1118 bcost_balanced + needferry);
1121 if (tech_dist > 0) {
1131 }
else if (want > best_choice->
want) {
1140 " [attack=%d,value=%d,move_time=%d,vuln=%d,bcost=%d]",
1143 attack, value, move_time, vuln, bcost);
1146 best_choice->
want = want;
1148 }
else if (!((impr_req =
1160 best_choice->
want = want;
1189 struct unit *myunit,
1199 struct player *def_owner;
1204 struct unit *ferryboat;
1209 struct pf_map *ferry_map =
nullptr;
1232 &ferryboat, &boattype, &move_time);
1233 if (
nullptr == ptile || ptile ==
unit_tile(myunit)
1240 if (myunit->
id != 0) {
1241 qCritical(
"%s(): non-virtual unit!", __FUNCTION__);
1252 if (
nullptr != acity) {
1263 if (1 < move_time && def_type) {
1280 if (vulnerability < m) {
1291 float finishing_factor = 1;
1297 benefit += acity_data->
worth * finishing_factor / 3;
1302 if (
nullptr != ferry_map) {
1304 ferry_map =
nullptr;
1321 if (
nullptr == ferry_map) {
1323 ptile, best_choice,
nullptr,
nullptr,
nullptr);
1330 ptile, best_choice, ferry_map, ferryboat,
1339 "kill_something_with()"
1344 if (
nullptr != ferry_map && !ferryboat) {
1352 #ifdef FREECIV_DEBUG
1355 log_debug(
"kill_something_with() %s has chosen attacker ferry, "
1367 if (best_choice != choice) {
1373 if (
nullptr != ferry_map) {
1390 struct unit *virtualunit;
1392 struct unit *aunit =
nullptr;
1393 struct city *acity =
nullptr;
1396 pplayer, pcity, punittype,
1399 if (choice->
want < 100) {
1403 if (want > choice->
want) {
1404 choice->
want = want;
1460 int our_def, urgency;
1462 struct unit *virtualunit;
1465 bool martial_need =
false;
1467 bool allow_gold_upkeep;
1480 martial_need =
true;
1483 if (!martial_need) {
1488 martial_need =
true;
1504 if (city_data->
danger != 0 || martial_value > 0) {
1506 int num_defenders = unit_list_size(ptile->
units);
1507 int wall_id, danger;
1508 bool build_walls =
true;
1512 if (city_data->
danger >= our_def) {
1516 }
else if (our_def == 0) {
1517 danger = 200 + urgency;
1519 danger =
MIN(200, 100 * city_data->
danger / our_def) + urgency;
1522 danger = 100 * city_data->
danger / our_def;
1530 "m_a_c_d urgency=%d danger=%d num_def=%d "
1532 urgency, danger, num_defenders, our_def);
1538 choice->
want = 100 + danger;
1540 build_walls =
false;
1558 if (wall_id !=
B_LAST && pcity->
server.adv->building_want[wall_id] != 0
1560 && (danger < 101 || num_defenders > 1
1565 if (pcity->
server.adv->building_want[wall_id] > 0) {
1569 choice->
want = pcity->
server.adv->building_want[wall_id];
1575 if (urgency == 0 && choice->
want > 100) {
1584 build_walls =
false;
1587 build_walls =
false;
1589 if ((danger > 0 && num_defenders <= urgency) || martial_value > 0) {
1602 uchoice.
want =
MIN(49, danger);
1604 uchoice.
want =
MIN(25, danger);
1607 uchoice.
want = danger;
1610 uchoice.
want += martial_value;
1613 if (!build_walls || uchoice.
want > choice->
want) {
1644 allow_gold_upkeep =
true;
1646 allow_gold_upkeep =
false;
1689 pplayer, pcity, punittype,
1711 if (choice->
want <= 0) {
void adv_deinit_choice(struct adv_choice *choice)
Clear choice without freeing it itself.
void adv_init_choice(struct adv_choice *choice)
Sets the values of the choice to initial values.
struct adv_choice * adv_new_choice()
Dynamically allocate a new choice.
void adv_free_choice(struct adv_choice *choice)
Free dynamically allocated choice.
bool is_unit_choice_type(enum choice_type type)
Does choice type refer to unit.
#define adv_choice_set_use(_choice, _use)
static void adv_choice_copy(struct adv_choice *dest, struct adv_choice *src)
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
There are some signs that a player might be dangerous: We are at war with him, he has done lots of ig...
int adv_unittype_att_rating(const struct unit_type *punittype, int veteran, int moves_left, int hp)
Attack rating of this kind of unit.
int adv_unit_att_rating(const struct unit *punit)
Attack rating of this particular unit assuming that it has a complete move left.
bool dai_choose_attacker_air(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Chooses the best available and usable air unit and records it in choice, if it's better than previous...
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Get current default ai data related to player.
void dai_choose_diplomat_defensive(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, int def)
Calculates our need for diplomats as defensive units.
void dai_choose_diplomat_offensive(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice)
Calculates our need for diplomats as offensive units.
bool dai_is_ferry_type(const struct unit_type *pferry, struct ai_type *ait)
Print the list of boats of pplayer.
void dai_hunter_choice(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Check if we want to build a hunter.
#define TECH_LOG(ait, _, pplayer, padvance, msg,...)
void dai_choose_paratrooper(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Chooses to build a paratroopers if necessary.
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
struct unit_type * dai_wants_defender_against(struct ai_type *ait, struct player *pplayer, struct city *pcity, const struct unit_type *att, int want)
Returns the best defense multiplier unit we can build, or nullptr if none.
int ai_trait_get_value(enum trait tr, struct player *pplayer)
Get current value of player trait.
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.
int find_something_to_kill(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile **pdest_tile, PFPath *ppath, struct pf_map **pferrymap, struct unit **pferryboat, const struct unit_type **pboattype, int *pmove_time)
Find something to kill! This function is called for units to find targets to destroy and for cities t...
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.
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 ...
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_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.
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'.
int kill_desire(int benefit, int attack, int loss, int vuln, int victim_count)
Compute how much we want to kill certain victim we've chosen, counted in SHIELDs.
#define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer)
#define simple_ai_unit_type_iterate_end
#define simple_ai_unit_type_iterate(_ut)
bool can_city_build_unit_later(const struct city *pcity, const struct unit_type *punittype)
Returns whether player can eventually build given unit in the city; returns FALSE if unit can never p...
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
How many veteran levels will created unit of this type get?
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Return whether given city can build given building; returns FALSE if the building is obsolete.
bool city_got_defense_effect(const struct city *pcity, const struct unit_type *attacker)
This can be City Walls, Coastal defense...
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool can_city_build_unit_direct(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit, ignoring whether unit is obsolete.
int city_total_unit_gold_upkeep(const struct city *pcity)
Get the total amount of gold needed to pay upkeep costs for all supported units of the city.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
struct unit * get_defender(const struct unit *attacker, const struct tile *ptile)
Finds the best defender on the tile, given an attacker.
bool is_stack_vulnerable(const struct tile *ptile)
Is it a city/fortress/air base or will the whole stack die in an attack.
int get_fortified_defense_power(const struct unit *attacker, struct unit *defender)
Return total defense power of the unit if it fortifies, if possible, where it is.
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
return the modified defense power of a unit.
int get_total_attack_power(const struct unit *attacker, const struct unit *defender)
Return the modified attack power of a unit.
bool can_unit_attack_tile(const struct unit *punit, const struct tile *dest_tile)
Is unit (1) diplomatically allowed to attack and (2) physically able to do so?
void get_modified_firepower(const struct unit *attacker, const struct unit *defender, int *att_fp, int *def_fp)
A unit's effective firepower depend on the situation.
Impr_type_id dai_find_source_building(struct city *pcity, enum effect_type effect_type, const struct unit_type *utype)
Returns a buildable, non-obsolete building that can provide the effect.
adv_want dai_content_effect_value(const struct player *pplayer, const struct city *pcity, int amount, int num_cities, int happiness_step)
How desirable particular effect making people content is for a particular city?
static struct adv_choice * kill_something_with(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct unit *myunit, struct adv_choice *choice)
This function.
static void process_attacker_want(struct ai_type *ait, struct city *pcity, int value, const struct unit_type *victim_unit_type, struct player *victim_player, int veteran, struct tile *ptile, struct adv_choice *best_choice, struct pf_map *ferry_map, struct unit *boat, const struct unit_type *boattype)
This function decides, what unit would be best for erasing enemy.
void dai_assess_danger_player(struct ai_type *ait, struct player *pplayer, const struct civ_map *dmap)
Call assess_danger() for all cities owned by pplayer.
static int assess_danger_unit(const struct city *pcity, struct pf_reverse_map *pcity_map, const struct unit *punit, int *move_time)
How dangerous and far a unit is for a city?
int assess_defense(struct ai_type *ait, struct city *pcity)
Estimate defense strength of city.
struct unit_type * dai_choose_defender_versus(struct city *pcity, struct unit *attacker)
Choose the best unit the city can build to defend against attacker v.
static struct unit_type * dai_choose_bodyguard(struct ai_type *ait, struct city *pcity, enum terrain_class tc, enum unit_role_id role, bool allow_gold_upkeep)
Choose best defender based on movement type.
struct adv_choice * military_advisor_choose_build(struct ai_type *ait, struct player *pplayer, struct city *pcity, const struct civ_map *mamap, player_unit_list_getter ul_cb)
This function selects either a defender or an attacker to be built.
int dai_unit_attack_desirability(struct ai_type *ait, const struct unit_type *punittype)
How much we would want that unit to attack with?
static void dai_unit_consider_bodyguard(struct ai_type *ait, struct city *pcity, struct unit_type *punittype, struct adv_choice *choice)
This function should assign a value to choice and want and type, where want is a value between 1 and ...
bool dai_process_defender_want(struct ai_type *ait, struct player *pplayer, struct city *pcity, int danger, struct adv_choice *choice)
What would be the best defender for that city? Records the best defender type in choice.
static void adjust_ai_unit_choice(struct city *pcity, struct adv_choice *choice)
Before building a military unit, AI builds a barracks/port/airport NB: It is assumed this function is...
static void dai_reevaluate_building(struct city *pcity, adv_want *value, int urgency, int danger, int defense)
Set (overwrite) our want for a building.
int dai_unit_defence_desirability(struct ai_type *ait, const struct unit_type *punittype)
How much we would want that unit to defend a city? (Do not use this function to find bodyguards for s...
int assess_defense_quadratic(struct ai_type *ait, struct city *pcity)
Need positive feedback in m_a_c_b and bodyguard routines.
static int base_assess_defense_unit(struct city *pcity, struct unit *punit, bool igwall, bool quadratic, int wall_value)
Helper for assess_defense_quadratic and assess_defense_unit.
static struct unit_type * dai_choose_attacker(struct ai_type *ait, struct city *pcity, enum terrain_class tc, bool allow_gold_upkeep)
Choose best attacker based on movement type.
static int assess_danger(struct ai_type *ait, struct city *pcity, const struct civ_map *dmap, player_unit_list_getter ul_cb)
Create cached information about danger, urgency and grave danger to our cities.
static int assess_defense_backend(struct ai_type *ait, struct city *pcity, bool igwall)
Most of the time we don't need/want positive feedback.
int assess_defense_unit(struct ai_type *ait, struct city *pcity, struct unit *punit, bool igwall)
One unit only, mostly for findjob; handling boats correctly.
static int assess_defense_igwall(struct ai_type *ait, struct city *pcity)
Estimate defense strength of city without considering how buildings help defense.
struct unit_list *() player_unit_list_getter(struct player *pplayer)
#define FINISH_HIM_CITY_COUNT
static void attack(QVariant data1, QVariant data2)
Action "Attack" for choice dialog.
bool ai_fuzzy(const struct player *pplayer, bool normal_decision)
Return the value normal_decision (a boolean), except if the AI is fuzzy, then sometimes flip the valu...
int get_target_bonus_effects(struct effect_list *plist, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, enum effect_type effect_type, enum vision_layer vision_layer)
Returns the effect bonus that applies at a tile for a given unittype.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
int impr_buy_gold_cost(const struct city *pcity, const struct impr_type *pimprove, int shields_in_stock)
Returns the amount of gold it takes to rush this improvement.
constexpr auto LOG_VERBOSE
#define fc_assert_ret_msg(condition, message,...)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
This tile is native to unit.
bool can_attack_from_non_native(const struct unit_type *utype)
This unit can attack from non-native tiles (Marines can attack from transport, ships from harbour cit...
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Is there native tile adjacent to given tile.
bool can_attack_non_native(const struct unit_type *utype)
This unit can attack non-native tiles (eg.
struct city_list * cities
bool pf_reverse_map_unit_position(struct pf_reverse_map *pfrm, const struct unit *punit, struct pf_position *pos)
Fill the position.
const struct pf_parameter * pf_map_parameter(const struct pf_map *pfm)
Return the pf_parameter for given pf_map.
bool pf_map_position(struct pf_map *pfm, struct tile *ptile, struct pf_position *pos)
Get info about position at ptile and put it in pos.
void pf_map_iter_position(struct pf_map *pfm, struct pf_position *pos)
Read all info about the current position into pos.
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
Factory function to create a new map according to the parameter.
struct pf_reverse_map * pf_reverse_map_new_for_city(const struct city *pcity, const struct player *attacker, int max_turns, bool omniscient, const struct civ_map *map)
'pf_reverse_map' constructor for city.
void pf_reverse_map_destroy(struct pf_reverse_map *pfrm)
'pf_reverse_map' destructor.
void pf_map_destroy(struct pf_map *pfm)
After usage the map must be destroyed.
#define pf_map_tiles_iterate(ARG_pfm, NAME_tile, COND_from_start)
#define pf_map_tiles_iterate_end
#define players_iterate_end
#define players_iterate(_pplayer)
static bool player_is_cpuhog(const struct player *pplayer)
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Returns the number of technologies the player need to research to get the goal technology.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
Function to determine cost (in bulbs) of reaching goal technology.
int get_specialist_output(const struct city *pcity, Specialist_type_id sp, Output_type_id otype)
Return the output for the specialist type with this output type.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define CITY_LOG(_, pcity, msg,...)
#define TIMING_LOG(timer, activity)
enum server_states server_state()
Return current server state.
struct ai_invasion invasion
adv_want tech_want[A_LAST+1]
struct ai_plr::@155 stats
struct city::@15::@17 server
citizens feel[CITIZEN_LAST][FEELING_LAST]
citizens specialists[SP_MAX]
struct city_list * cities
struct player_economic economic
struct unit_type::@82 adv
struct unit_type::@83 cache
int defense_mp_bonuses_pct[U_LAST]
Tech_type_id advance_index(const struct advance *padvance)
Return the advance index.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define TRAIT_DEFAULT_VALUE
const struct unit_type * utype
const struct impr_type * building
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
bool utype_has_role(const struct unit_type *punittype, int role)
Return whether the given unit type has the role.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
int utype_build_shield_cost_base(const struct unit_type *punittype)
Returns the number of shields this unit type represents.
int unit_build_shield_cost_base(const struct unit *punit)
Returns the number of shields this unit represents.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
bool unit_can_take_over(const struct unit *punit)
Return whether the unit can take over enemy cities.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
bool utype_can_take_over(const struct unit_type *punittype)
Return whether the unit type can take over enemy cities.
bool utype_acts_hostile(const struct unit_type *putype)
Return TRUE iff units of this type can do hostile actions controlled by generalized (ruleset defined)...
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
Return pointer to ai data of given unit type and ai type.
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end