Functions | |
attack_itors | unit::attacks () |
Gets an iterator over this unit's attacks. More... | |
const_attack_itors | unit::attacks () const |
Const overload of attacks. More... | |
template<typename... Args> | |
attack_ptr | unit::add_attack (attack_itors::iterator position, Args &&... args) |
Adds a new attack to the unit. More... | |
bool | unit::remove_attack (attack_ptr atk) |
Remove an attack from the unit. More... | |
void | unit::remove_attacks_ai () |
Set the unit to have no attacks left for this turn. More... | |
int | unit::damage_from (const attack_type &attack, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr) const |
Calculates the damage this unit would take from a certain attack. More... | |
int | unit::max_attacks () const |
The maximum number of attacks this unit may perform per turn, usually 1. More... | |
void | unit::set_max_attacks (int value) |
int | unit::attacks_left () const |
Gets the remaining number of attacks this unit can perform this turn. More... | |
int | unit::attacks_left (bool base_value) const |
Gets the remaining number of attacks this unit can perform this turn. More... | |
void | unit::set_attacks (int left) |
Sets the number of attacks this unit has left this turn. More... | |
int | unit::defense_modifier (const t_translation::terrain_code &terrain) const |
The unit's defense on a given terrain. More... | |
int | unit::resistance_against (const std::string &damage_name, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr, const_attack_ptr opp_weapon=nullptr) const |
The unit's resistance against a given damage type. More... | |
int | unit::resistance_against (const attack_type &atk, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr) const |
The unit's resistance against a given attack. More... | |
utils::string_map_res | unit::get_base_resistances () const |
Gets resistances without any abilities applied. More... | |
bool | unit::resistance_filter_matches (const config &cfg, bool attacker, const std::string &damage_name, int res) const |
|
inline |
Adds a new attack to the unit.
position | An iterator pointing to the attack before which to insert the new one. |
args | The arguments for constructing the attack |
Definition at line 945 of file unit.hpp.
References unit::attacks_, unit::set_attr_changed(), and unit::UA_ATTACKS.
Referenced by impl_unit_attacks_set().
|
inline |
Gets an iterator over this unit's attacks.
Definition at line 928 of file unit.hpp.
References unit::attacks_, and make_attack_itors().
Referenced by battle_context_unit_stats::battle_context_unit_stats(), get_attack_iter(), wfl::unit_callable::get_value(), impl_unit_attacks_len(), impl_unit_attacks_set(), ai::readonly_context_impl::power_projection(), ai::ai_default_rca::move_to_targets_phase::rate_group(), gui2::unit_preview_pane::set_displayed_unit(), unit::unit_special_notes(), and unit_weapons().
|
inline |
Const overload of attacks.
Definition at line 934 of file unit.hpp.
References unit::attacks_, and make_attack_itors().
|
inline |
Gets the remaining number of attacks this unit can perform this turn.
If the 'incapacitated' status is set, this will always be 0.
Definition at line 995 of file unit.hpp.
References unit::attacks_left_, and unit::incapacitated().
Referenced by wb::attack::apply_temp_modifier(), unit::attacks_left(), ai::attack_analysis::execute_self(), wfl::unit_callable::get_value(), wb::attack::remove_temp_modifier(), display_context::unit_can_move(), display_context::unit_orb_status(), and unit_weapons().
|
inline |
Gets the remaining number of attacks this unit can perform this turn.
base_value | If false, consider the incapacitated flag. |
Definition at line 1007 of file unit.hpp.
References unit::attacks_left(), and unit::attacks_left_.
|
inline |
Calculates the damage this unit would take from a certain attack.
attack | The attack to consider. |
attacker | Whether this unit should be considered the attacker. |
loc | The unit's location (to resolve [resistance] abilities) |
weapon | The weapon to check for any abilities or weapon specials |
Definition at line 973 of file unit.hpp.
References unit::resistance_against().
Referenced by battle_context_unit_stats::battle_context_unit_stats().
int unit::defense_modifier | ( | const t_translation::terrain_code & | terrain | ) | const |
The unit's defense on a given terrain.
terrain | The terrain to check |
Definition at line 1743 of file unit.cpp.
References movetype::defense_modifier(), unit_ability_list::empty(), unit::get_abilities(), unit_abilities::effect::get_composite_value(), and unit::movement_type_.
Referenced by battle_context_unit_stats::battle_context_unit_stats(), ai::ai_default_rca::move_to_targets_phase::choose_move(), pathfind::shortest_path_calculator::cost(), wfl::gamestate::DEFINE_WFL_FUNCTION(), ai::ai_default_rca::get_villages_phase::find_villages(), intf_unit_defense(), ai::readonly_context_impl::power_projection(), ai::ai_default_rca::move_to_targets_phase::rate_group(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), REPORT_GENERATOR(), and unit_defense().
|
inline |
Gets resistances without any abilities applied.
Definition at line 1050 of file unit.hpp.
References movetype::damage_table(), and unit::movement_type_.
Referenced by gui2::unit_preview_pane::set_displayed_unit(), and unit_hp().
|
inline |
The maximum number of attacks this unit may perform per turn, usually 1.
Definition at line 979 of file unit.hpp.
References unit::max_attacks_.
Referenced by wfl::unit_callable::get_value(), display_context::unit_orb_status(), and unit_weapons().
bool unit::remove_attack | ( | attack_ptr | atk | ) |
Remove an attack from the unit.
atk | A pointer to the attack to remove |
Definition at line 2764 of file unit.cpp.
References unit::attacks_, unit::set_attr_changed(), and unit::UA_ATTACKS.
Referenced by impl_unit_attacks_set().
void unit::remove_attacks_ai | ( | ) |
Set the unit to have no attacks left for this turn.
Definition at line 2775 of file unit.cpp.
References unit::attacks_left_, unit::max_attacks_, and unit::set_attacks().
|
inline |
The unit's resistance against a given attack.
atk | The attack |
attacker | True if this unit is on the offensive (to resolve [resistance] abilities) |
loc | The unit's location (to resolve [resistance] abilities) |
weapon | The weapon to check for any abilities or weapon specials |
Definition at line 1044 of file unit.hpp.
References unit::resistance_against(), and attack_type::type().
int unit::resistance_against | ( | const std::string & | damage_name, |
bool | attacker, | ||
const map_location & | loc, | ||
const_attack_ptr | weapon = nullptr , |
||
const_attack_ptr | opp_weapon = nullptr |
||
) | const |
The unit's resistance against a given damage type.
damage_name | The damage type |
attacker | True if this unit is on the offensive (to resolve [resistance] abilities) |
loc | The unit's location (to resolve [resistance] abilities) |
weapon | The weapon to check for any abilities or weapon specials |
opp_weapon | The opponent's weapon to check for any abilities or weapon specials |
Definition at line 1786 of file unit.cpp.
References unit_ability_list::empty(), utils::erase_if(), unit::get_abilities_weapons(), unit_abilities::effect::get_composite_value(), unit_ability_list::highest(), i, unit::movement_type_, movetype::resistance_against(), and unit::resistance_filter_matches().
Referenced by unit::damage_from(), wfl::gamestate::DEFINE_WFL_FUNCTION(), intf_unit_resistance(), unit::resistance_against(), and unit_hp().
|
private |
Definition at line 1758 of file unit.cpp.
References unit_abilities::filter_base_matches(), and utils::split().
Referenced by unit::resistance_against().
|
inline |
Sets the number of attacks this unit has left this turn.
left | The number of attacks left |
Definition at line 1016 of file unit.hpp.
References unit::attacks_left_.
Referenced by wb::attack::apply_temp_modifier(), unit::remove_attacks_ai(), and wb::attack::remove_temp_modifier().
|
inline |
Definition at line 984 of file unit.hpp.
References unit::max_attacks_, unit::set_attr_changed(), and unit::UA_MAX_AP.
Referenced by unit::apply_builtin_effect(), and unit::init().