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 (const 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_value (unit_ability_list resistance_list, const std::string &damage_name) const |
For the provided list of resistance abilities, determine the damage resistance based on which are active and any max_value that's present. More... | |
int | unit::resistance_against (const std::string &damage_name, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr, const 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, 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 950 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 933 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(), unit::init(), ai::readonly_context_impl::power_projection(), ai::ai_default_rca::move_to_targets_phase::rate_group(), gui2::unit_preview_pane::set_display_data(), display_context::unit_can_move(), unit::unit_special_notes(), and unit_weapons().
|
inline |
Const overload of attacks.
Definition at line 939 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 1000 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(), UNIT_GETTER(), 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 1012 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 978 of file unit.hpp.
References loc, and 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 1717 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 1064 of file unit.hpp.
References movetype::damage_table(), and unit::movement_type_.
Referenced by gui2::unit_preview_pane::set_display_data(), and unit_hp().
|
inline |
The maximum number of attacks this unit may perform per turn, usually 1.
Definition at line 984 of file unit.hpp.
References unit::max_attacks_.
Referenced by wfl::unit_callable::get_value(), UNIT_GETTER(), display_context::unit_orb_status(), and unit_weapons().
bool unit::remove_attack | ( | const attack_ptr & | atk | ) |
Remove an attack from the unit.
atk | A pointer to the attack to remove |
Definition at line 2748 of file unit.cpp.
References unit::attacks_, utils::find(), 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 2759 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 1058 of file unit.hpp.
References loc, 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 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 1781 of file unit.cpp.
References unit_ability_list::empty(), utils::erase_if(), unit::get_abilities_weapons(), i, loc, resistance_filter_matches_base(), and unit::resistance_value().
Referenced by unit::damage_from(), wfl::gamestate::DEFINE_WFL_FUNCTION(), intf_unit_resistance(), unit::resistance_against(), and unit_hp().
|
private |
Definition at line 1732 of file unit.cpp.
References unit_abilities::filter_base_matches(), utils::find(), and utils::split().
Referenced by unit::resistance_value().
int unit::resistance_value | ( | unit_ability_list | resistance_list, |
const std::string & | damage_name | ||
) | const |
For the provided list of resistance abilities, determine the damage resistance based on which are active and any max_value that's present.
resistance_list | A list of resistance abilities that the unit has. |
damage_name | The name of the damage type, for example "blade". |
Definition at line 1756 of file unit.cpp.
References unit_ability_list::empty(), utils::erase_if(), unit_abilities::effect::get_composite_value(), i, unit::movement_type_, movetype::resistance_against(), and unit::resistance_filter_matches().
Referenced by unit::resistance_against(), and select_alternative_type().
|
inline |
Sets the number of attacks this unit has left this turn.
left | The number of attacks left |
Definition at line 1021 of file unit.hpp.
References unit::attacks_left_.
Referenced by wb::attack::apply_temp_modifier(), unit::remove_attacks_ai(), wb::attack::remove_temp_modifier(), and UNIT_SETTER().
|
inline |
Definition at line 989 of file unit.hpp.
References unit::max_attacks_, unit::set_attr_changed(), and unit::UA_MAX_AP.
Referenced by unit::apply_builtin_effect(), unit::init(), and UNIT_SETTER().