Freeciv-3.3
|
Go to the source code of this file.
Macros | |
#define | POWER_FACTOR 10 |
Enumerations | |
enum | unit_attack_result { ATT_OK , ATT_NON_ATTACK , ATT_UNREACHABLE , ATT_NONNATIVE_SRC , ATT_NONNATIVE_DST , ATT_NOT_WIPABLE } |
Returns the attack power, modified by moves left, and veteran status.
Definition at line 550 of file combat.c.
Referenced by adv_unittype_att_rating(), and get_attack_power().
Returns the defense power, modified by veteran status.
Definition at line 574 of file combat.c.
Referenced by adv_unit_def_rating_basic(), get_defense_power(), and has_defense().
bool can_unit_attack_tile | ( | const struct unit * | punit, |
const struct action * | paction, | ||
const struct tile * | dest_tile | ||
) |
Is unit (1) diplomatically allowed to attack and (2) physically able to do so?
Definition at line 312 of file combat.c.
Referenced by can_units_attack_at(), dai_evaluate_tile_for_air_attack(), dai_hunter_manage(), dai_hunter_try_launch(), dai_military_attack(), dai_rampage_want(), find_best_tile_to_paradrop_to(), find_something_to_bomb(), find_something_to_kill(), is_action_possible(), and kill_something_with().
int combat_bonus_against | ( | const struct combat_bonus_list * | list, |
const struct unit_type * | enemy, | ||
enum combat_bonus_type | type | ||
) |
Get bonus value against given unit type from bonus list.
Consider using cached values instead of calling this recalculation directly.
Definition at line 1007 of file combat.c.
Referenced by dai_wants_defender_against(), defense_multiplication(), get_modified_firepower(), and set_unit_type_caches().
Convenience wrapper for base_get_attack_power().
Definition at line 540 of file combat.c.
Referenced by get_total_attack_power().
struct unit * get_attacker | ( | const struct civ_map * | nmap, |
const struct unit * | defender, | ||
const struct tile * | ptile | ||
) |
Get unit at (x, y) that wants to kill defender.
Works like get_defender(); see comment there. This function is mostly used by the AI.
Definition at line 911 of file combat.c.
Referenced by popup_advanced_terrain_dialog().
struct unit * get_defender | ( | const struct civ_map * | nmap, |
const struct unit * | attacker, | ||
const struct tile * | ptile, | ||
const struct action * | paction | ||
) |
Finds the best defender on the tile, given an attacker. The diplomatic relationship of attacker and defender is ignored; the caller should check this.
Definition at line 841 of file combat.c.
Referenced by action_prob(), dai_evaluate_tile_for_air_attack(), dai_hunter_manage(), dai_rampage_want(), do_attack(), find_best_tile_to_paradrop_to(), find_something_to_kill(), kill_something_with(), popup_advanced_terrain_dialog(), and unit_survive_autoattack().
struct unit * get_diplomatic_defender | ( | const struct unit * | act_unit, |
const struct unit * | pvictim, | ||
const struct tile * | tgt_tile, | ||
const struct action * | paction | ||
) |
Returns the defender of the tile in a diplomatic battle or NULL if no diplomatic defender could be found.
act_unit | the diplomatic attacker, trying to perform an action. |
pvictim | unit that should be excluded as a defender. |
tgt_tile | the tile to defend. |
paction | action that the attacker performs. |
Definition at line 947 of file combat.c.
Referenced by ap_diplomat_battle(), and diplomat_infiltrate_tile().
Return total defense power of the unit if it fortifies, if possible, where it is. attacker might be NULL to skip calculating attacker specific bonuses.
Definition at line 786 of file combat.c.
Referenced by base_assess_defense_unit().
void get_modified_firepower | ( | const struct civ_map * | nmap, |
const struct unit * | attacker, | ||
const struct unit * | defender, | ||
int * | att_fp, | ||
int * | def_fp | ||
) |
A unit's effective firepower depend on the situation.
Definition at line 411 of file combat.c.
Referenced by dai_choose_defender_versus(), do_attack(), get_defense_rating(), unit_bombs_unit(), unit_versus_unit(), and unit_win_chance().
int get_total_attack_power | ( | const struct unit * | attacker, |
const struct unit * | defender, | ||
const struct action * | paction | ||
) |
Return the modified attack power of a unit.
Definition at line 615 of file combat.c.
Referenced by dai_choose_defender_versus(), do_attack(), unit_bombs_unit(), unit_versus_unit(), and unit_win_chance().
return the modified defense power of a unit. An veteran aegis cruiser in a mountain city with SAM and SDI defense being attacked by a missile gets defense 288.
Definition at line 772 of file combat.c.
Referenced by actres_possible(), dai_choose_defender_versus(), do_attack(), get_defense_rating(), unit_bombs_unit(), unit_def_rating(), unit_versus_unit(), unit_win_chance(), and unit_wipe_units_at_tile_result().
int get_virtual_defense_power | ( | const struct civ_map * | nmap, |
const struct unit_type * | att_type, | ||
const struct unit_type * | def_type, | ||
struct player * | def_player, | ||
struct tile * | ptile, | ||
bool | fortified, | ||
int | veteran | ||
) |
May be called with a non-existing att_type to avoid any effects which depend on the attacker.
Definition at line 717 of file combat.c.
Referenced by find_a_good_partisan_spot(), is_my_turn(), and unittype_def_rating_squared().
Is it a city/fortress/air base or will the whole stack die in an attack
Definition at line 994 of file combat.c.
Referenced by collect_ransom(), dai_rampage_want(), find_best_tile_to_paradrop_to(), get_defender(), kill_unit(), process_attacker_want(), stack_cost(), and stack_value().
Returns if the attack is going to be a tired attack
Definition at line 532 of file combat.c.
Referenced by base_get_attack_power(), and unit_tired_attack_string().
bool is_unit_reachable_at | ( | const struct unit * | defender, |
const struct unit * | attacker, | ||
const struct tile * | location | ||
) |
Can unit attack other at given location
Definition at line 86 of file combat.c.
Referenced by actres_possible(), kill_unit(), unit_attack_unit_at_tile_result(), unit_bombard(), and unit_wipe_units_at_tile_result().
struct city * sdi_try_defend | ( | const struct civ_map * | nmap, |
const struct player * | owner, | ||
const struct tile * | ptile | ||
) |
Try defending against nuclear attack; if successful, return a city which had enough luck and EFT_NUKE_PROOF. If the attack was successful return NULL.
Definition at line 503 of file combat.c.
Referenced by unit_nuke().
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 | ||
) |
Checks if a unit can physically attack pdefender at the tile (assuming it is adjacent and at war).
Unit can NOT attack if: 1) its unit type is unable to perform any attack action. 2) it is a ground unit without marine ability and it attacks from ocean. 3) it is a ground unit and it attacks a target on an ocean square or it is a sailing unit without shore bombardment capability and it attempts to attack land. 4) it is not a fighter and defender is a flying unit (except city/airbase).
Does NOT check: 1) Moves left 2) Adjacency 3) Diplomatic status
Definition at line 123 of file combat.c.
Referenced by adv_danger_at(), dai_consider_tile_dangerous(), dai_hunter_manage(), find_best_tile_to_paradrop_to(), get_defender(), is_my_turn(), stack_cost(), unit_attack_all_at_tile_result(), and unit_attack_any_at_tile_result().
enum unit_attack_result unit_attack_units_at_tile_result | ( | const struct unit * | punit, |
const struct action * | paction, | ||
const struct tile * | ptile | ||
) |
Check if unit can attack unit stack at tile.
Definition at line 257 of file combat.c.
Referenced by adv_danger_at(), can_unit_attack_tile(), dai_consider_tile_dangerous(), expl_act_not_enabl(), is_action_possible(), and is_my_turn().
Get unit's current bombard rate.
Definition at line 1025 of file combat.c.
Referenced by unit_bombs_unit().
double unit_win_chance | ( | const struct civ_map * | nmap, |
const struct unit * | attacker, | ||
const struct unit * | defender, | ||
const struct action * | paction | ||
) |
Returns a double in the range [0;1] indicating the attackers chance of winning. The calculation takes all factors into account.
Definition at line 480 of file combat.c.
Referenced by action_prob(), combat_odds_to_astr(), dai_evaluate_tile_for_air_attack(), dai_hunter_manage(), dai_rampage_want(), find_best_tile_to_paradrop_to(), get_attacker(), get_defender(), sdl_get_chance_to_win(), and unit_survive_autoattack().
enum unit_attack_result unit_wipe_units_at_tile_result | ( | const struct unit * | punit, |
const struct tile * | ptile | ||
) |
Check if unit can wipe unit stack from tile.
Definition at line 272 of file combat.c.
Referenced by expl_act_not_enabl().
Returns the chance of the attacker winning, a number between 0 and 1. If you want the chance that the defender wins just use 1-chance(...)
NOTE: this number can be very small, fx in a battle between an ironclad and a battleship the ironclad has less than 1/100000 chance of winning.
The algoritm calculates the probability of each possible number of HP's the attacker has left. Maybe that info should be preserved for use in the AI.
Definition at line 334 of file combat.c.
Referenced by unit_win_chance().