The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
Ability functions

Functions

bool unit::get_ability_bool (const std::string &tag_name, const map_location &loc, const display_context &dc) const
 Checks whether this unit currently possesses or is affected by a given ability. More...
 
bool unit::get_ability_bool (const std::string &tag_name, const display_context &dc) const
 Checks whether this unit currently possesses or is affected by a given ability. More...
 
unit_ability_list unit::get_abilities (const std::string &tag_name, const map_location &loc) const
 Gets the unit's active abilities of a particular type if it were on a specified location. More...
 
unit_ability_list unit::get_abilities (const std::string &tag_name) const
 Gets the unit's active abilities of a particular type. More...
 
std::vector< std::tuple
< t_string, t_string, t_string > > 
unit::ability_tooltips (boost::dynamic_bitset<> *active_list=nullptr) const
 Gets the names and descriptions of this unit's abilities. More...
 
std::vector< std::string > unit::get_ability_list () const
 Get a list of all abilities by ID. More...
 
bool unit::has_ability_type (const std::string &ability) const
 Check if the unit has an ability of a specific type. More...
 
bool unit::has_ability_by_id (const std::string &ability) const
 Check if the unit has an ability of a specific ID. More...
 
void unit::remove_ability_by_id (const std::string &ability)
 Removes a unit's abilities with a specific ID. More...
 
bool unit::ability_active (const std::string &ability, const config &cfg, const map_location &loc) const
 Check if an ability is active. More...
 
bool unit::ability_affects_adjacent (const std::string &ability, const config &cfg, int dir, const map_location &loc, const unit &from) const
 Check if an ability affects adjacent units. More...
 
bool unit::ability_affects_self (const std::string &ability, const config &cfg, const map_location &loc) const
 Check if an ability affects the owning unit. More...
 
unit_formula_managerunit::formula_manager () const
 Get the unit formula manager. More...
 
void unit::generate_name ()
 Generates a random race-appropriate name if one has not already been provided. More...
 
bool unit::invisible (const map_location &loc, const display_context &dc, bool see_all=true) const
 
bool unit::is_visible_to_team (const team &team, const display_context &dc, bool const see_all=true) const
 
void unit::write (config &cfg) const
 Serializes the current unit metadata values. More...
 
unitunit::clone (bool is_temporary=true)
 Mark this unit as clone so it can be inserted to unit_map. More...
 

Detailed Description

Function Documentation

bool unit::ability_active ( const std::string &  ability,
const config cfg,
const map_location loc 
) const
private
bool unit::ability_affects_adjacent ( const std::string &  ability,
const config cfg,
int  dir,
const map_location loc,
const unit from 
) const
private

Check if an ability affects adjacent units.

Parameters
abilityThe type (tag name) of the ability
cfgan ability WML structure
locThe location on which to resolve the ability
fromThe "other unit" for filter matching

Definition at line 376 of file abilities.cpp.

References config::child_range(), resources::filter_con, gui2::event::find(), i, and map_location::parse_directions().

Referenced by unit::get_abilities(), and unit::get_ability_bool().

bool unit::ability_affects_self ( const std::string &  ability,
const config cfg,
const map_location loc 
) const
private

Check if an ability affects the owning unit.

Parameters
abilityThe type (tag name) of the ability
cfgan ability WML structure
locThe location on which to resolve the ability

Definition at line 400 of file abilities.cpp.

References config::child(), resources::filter_con, unit_filter::matches(), and unit_filter::set_use_flat_tod().

Referenced by unit::get_abilities(), and unit::get_ability_bool().

std::vector< std::tuple< t_string, t_string, t_string > > unit::ability_tooltips ( boost::dynamic_bitset<> *  active_list = nullptr) const

Gets the names and descriptions of this unit's abilities.

Parameters
active_listIf nullptr, then all abilities are forced active. If not, this vector will be the same length as the returned one and will indicate whether or not the corresponding ability is active.
Returns
A list of triples consisting of (in order) base name, male or female name as appropriate for the unit, and description.

Definition at line 261 of file abilities.cpp.

References unit::abilities_, unit::ability_active(), config::all_children_range(), config_attribute_value::blank(), t_string::empty(), unit::gender_, unit::loc_, unit::name(), and config_attribute_value::t_str().

Referenced by gui2::unit_preview_pane::set_displayed_unit(), and unit_abilities().

unit & unit::clone ( bool  is_temporary = true)
unit_formula_manager& unit::formula_manager ( ) const
inline

Get the unit formula manager.

Definition at line 1528 of file unit.hpp.

References unit::formula_man_.

Referenced by wfl::unit_callable::get_value().

void unit::generate_name ( )

Generates a random race-appropriate name if one has not already been provided.

Definition at line 796 of file unit.cpp.

References t_string::empty(), unit::gender_, unit_race::generate_name(), unit::generate_name_, unit::name_, and unit::race_.

Referenced by unit::unit().

unit_ability_list unit::get_abilities ( const std::string &  tag_name,
const map_location loc 
) const

Gets the unit's active abilities of a particular type if it were on a specified location.

Parameters
tag_nameThe type of ability to check for
locThe location to use for resolving abilities
Returns
A list of active abilities, paired with the location they are active on

Definition at line 177 of file abilities.cpp.

References unit::abilities_, unit::ability_active(), unit::ability_affects_adjacent(), unit::ability_affects_self(), config::child_range(), unit_map::end(), unit_map::find(), resources::gameboard, get_adjacent_tiles(), i, unit::loc_, unit_ability_list::push_back(), unit::side(), and resources::units.

Referenced by unit::defense_modifier(), unit::get_abilities(), pathfind::get_teleport_locations(), unit_display::reset_helpers(), and unit::resistance_against().

unit_ability_list unit::get_abilities ( const std::string &  tag_name) const
inline

Gets the unit's active abilities of a particular type.

Parameters
tag_nameThe type of ability to check for
Returns
A list of active abilities, paired with the location they are active on

Definition at line 1458 of file unit.hpp.

References unit::get_abilities(), and unit::loc_.

bool unit::get_ability_bool ( const std::string &  tag_name,
const map_location loc,
const display_context dc 
) const

Checks whether this unit currently possesses or is affected by a given ability.

This means that the ability could be owned by this unit itself or by an adjacent unit, should the ability affect an AoE in which this unit happens to be.

Parameters
tag_nameThe name of the ability to check for.
locThe location around which to check for affected units. This may or may not be the location of this unit.
dcA display_context object, used in calculations.

Definition at line 138 of file abilities.cpp.

References unit::abilities_, unit::ability_active(), unit::ability_affects_adjacent(), unit::ability_affects_self(), config::child_range(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), i, unit::side(), display_context::teams(), and resources::units.

Referenced by pathfind::shortest_path_calculator::cost(), ai::ai_default_rca::get_healing_phase::evaluate(), pathfind::find_routes(), unit::get_ability_bool(), pathfind::get_teleport_locations(), game_lua_kernel::intf_unit_ability(), unit::invisible(), pathfind::mark_route(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), and ai::default_ai_context_impl::rate_terrain().

bool unit::get_ability_bool ( const std::string &  tag_name,
const display_context dc 
) const
inline

Checks whether this unit currently possesses or is affected by a given ability.

This means that the ability could be owned by this unit itself or by an adjacent unit, should the ability affect an AoE in which this unit happens to be.

This overload uses the location of this unit for calculations.

Parameters
tag_nameThe name of the ability to check for.
dcA display_context object, used in calculations.

Definition at line 1440 of file unit.hpp.

References unit::get_ability_bool(), and unit::loc_.

std::vector< std::string > unit::get_ability_list ( ) const

Get a list of all abilities by ID.

Definition at line 219 of file abilities.cpp.

References unit::abilities_, and config::all_children_range().

Referenced by wfl::unit_callable::get_value(), impl_unit_get(), and gui2::unit_preview_pane::set_displayed_unit().

bool unit::has_ability_by_id ( const std::string &  ability) const

Check if the unit has an ability of a specific ID.

Parameters
abilityThe ID of ability to check for.
Returns
true if the ability is present

Definition at line 1360 of file unit.cpp.

References unit::abilities_, and config::all_children_range().

Referenced by unit::apply_builtin_effect().

bool unit::has_ability_type ( const std::string &  ability) const

Check if the unit has an ability of a specific type.

Parameters
abilityThe type of ability (tag name) to check for.
Returns
true if the ability is present

Definition at line 408 of file abilities.cpp.

References unit::abilities_, and config::child_range().

bool unit::invisible ( const map_location loc,
const display_context dc,
bool  see_all = true 
) const
bool unit::is_visible_to_team ( const team team,
const display_context dc,
bool const  see_all = true 
) const
void unit::remove_ability_by_id ( const std::string &  ability)

Removes a unit's abilities with a specific ID.

Parameters
abilityThe type of ability (tag name) to remove.

Definition at line 1371 of file unit.cpp.

References unit::abilities_, config::erase(), i, config::ordered_begin(), and config::ordered_end().

Referenced by unit::apply_builtin_effect().

void unit::write ( config cfg) const

Serializes the current unit metadata values.

Parameters
cfgThe config to write to.

Definition at line 1383 of file unit.cpp.

References unit::abilities_, config::add_child(), unit::advancements_, unit::advances_to_, unit::alignment_, config::append(), unit::attacks_, unit::attacks_left_, unit_type::base_id(), unit::can_recruit(), config::clear_children(), unit::description_, unit::ellipse_, unit::emit_zoc_, unit::events_, unit::experience_, unit::facing_, unit::filter_recall_, unit::flag_rgb_, unit::formula_man_, unit::gender_, gender_string(), unit::generate_name_, unit::get_states(), unit::goto_, unit::halo_, unit::hit_points_, i, unit_type::icon(), unit_race::id(), unit::id_, unit_type::image(), unit::jamming_, utils::join(), unit::level_, unit::max_attacks_, unit::max_experience_, unit::max_hit_points_, unit::max_movement_, unit::modifications_, unit::movement_, unit::movement_type_, unit::name_, unit::overlays_, unit::profile_, unit::race_, unit::random_traits_, unit::recall_cost_, unit::recruit_list_, unit::resting_, unit::role_, unit::side_, unit::small_profile_, unit::type(), unit::type_id(), unit::type_name_, unit::undead_variation_, unit::underlying_id_, unit::unit_description(), unit::unit_value_, unit::unrenamable_, unit::usage_, n_unit::unit_id::value, unit::variables_, unit::variation_, unit::vision_, map_location::wml_x(), map_location::wml_y(), movetype::write(), map_location::write_direction(), and unit::write_upkeep().

Referenced by get_checksum(), impl_unit_get(), and game_events::WML_HANDLER_FUNCTION().