The Battle for Wesnoth  1.19.5+dev
Functions | Variables
Modification functions

Functions

configunit::get_modifications ()
 Get the raw modifications. More...
 
const configunit::get_modifications () const
 Set the raw modifications. More...
 
std::size_t unit::modification_count (const std::string &type, const std::string &id) const
 Count modifications of a particular type. More...
 
std::size_t unit::modification_count (const std::string &type) const
 Count modifications of a particular type. More...
 
std::size_t unit::traits_count () const
 
std::size_t unit::objects_count () const
 
std::size_t unit::advancements_count () const
 
void unit::add_modification (const std::string &type, const config &modification, bool no_add=false)
 Add a new modification to the unit. More...
 
void unit::expire_modifications (const std::string &duration)
 Clears those modifications whose duration has expired. More...
 
void unit::apply_builtin_effect (std::string type, const config &effect)
 Apply a builtin effect to the unit. More...
 
std::string unit::describe_builtin_effect (std::string type, const config &effect)
 Construct a string describing a built-in effect. More...
 
void unit::apply_modifications ()
 Re-apply all saved modifications. More...
 

Variables

static const std::set< std::string > unit::builtin_effects
 

Detailed Description

Function Documentation

◆ add_modification()

void unit::add_modification ( const std::string &  type,
const config modification,
bool  no_add = false 
)

Add a new modification to the unit.

Parameters
typeThe type of modification to add. Valid values are "advancement", "trait", "object"
modificationThe details of the modification
no_addIf true, apply the modification but don't save it for unit rebuild time. Defaults to false.

Definition at line 2439 of file unit.cpp.

References config::add_child(), unit::add_trait_description(), unit::apply_builtin_effect(), game_lua_kernel::apply_effect(), unit::builtin_effects, config::child_range(), unit::describe_builtin_effect(), t_string::empty(), resources::filter_con, unit::level_, unit::loc_, resources::lua_kernel, unit::modifications_, config::remove_children(), VGETTEXT, and WRN_UT.

Referenced by unit::apply_modifications(), unit::init(), and intf_add_modification().

◆ advancements_count()

std::size_t unit::advancements_count ( ) const
inline

Definition at line 1564 of file unit.hpp.

References unit::modification_count().

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

◆ apply_builtin_effect()

void unit::apply_builtin_effect ( std::string  type,
const config effect 
)

Apply a builtin effect to the unit.

Parameters
typeThe effect to apply. Must be one of the effects in builtin_effects.
effectThe details of the effect

Definition at line 2035 of file unit.cpp.

References unit::abilities_, config::add_child(), game_config::add_color_info(), game_events::manager::add_events(), unit::advance_to(), unit::advancements_, unit::advances_to_, unit::anim_comp_, unit::appearance_changed_, config::append(), utils::apply_modifier(), unit::attacks_, c, config::child_range(), deprecated_message(), unit::description_, movetype::effects, unit::emit_zoc_, prefs::encountered_units(), utils::erase(), utils::erase_if(), unit::experience_, unit_type_data::find(), resources::game_events, resources::gameboard, unit::gender_, prefs::get(), config::get(), string_enums::enum_base< Definition >::get_enum(), unit_type::get_gender_unit_type(), game_board::get_team(), unit::has_ability_by_id(), config::has_child(), unit_type::has_variation(), unit::heal_fully(), unit::hit_points_, i, unit::image_mods_, INDEFINITE, unit::is_fearless_, unit::is_healthy_, unit::jamming_, unit::level_, LOG_UT, resources::lua_kernel, unit::max_attacks_, unit::max_experience_, unit::max_hit_points_, unit::max_movement_, movetype::merge(), unit::movement_, unit::movement_type_, config::optional_child(), unit::overlays_, unit_type::parent_id(), utils::parenthetical_split(), team::recall_cost(), unit::recall_cost(), unit::recall_cost_, gui2::dialogs::tip::remove(), unit::remove_ability_by_attribute(), unit::remove_ability_by_id(), cursor::set(), unit::set_alignment(), unit::set_attr_changed(), unit::set_big_profile(), unit::set_image_ellipse(), unit::set_image_halo(), unit::set_max_attacks(), unit::set_max_experience(), unit::set_max_hitpoints(), unit::set_small_profile(), unit::set_state(), unit::set_total_movement(), unit::side_, unit::special_notes_, utils::split(), unit::upkeep_loyal::type(), unit::type(), unit::UA_ABILITIES, unit::UA_ADVANCEMENTS, unit::UA_ATTACKS, unit::UA_IS_FEARLESS, unit::UA_IS_HEALTHY, unit::UA_LEVEL, unit::UA_MOVEMENT_TYPE, unit::UA_ZOC, unit_types, unit::upkeep_, unit::variation_, unit::vision_, game_config_view::wrap(), and WRN_UT.

Referenced by unit::add_modification(), and game_lua_kernel::cfun_builtin_effect().

◆ apply_modifications()

void unit::apply_modifications ( )

◆ describe_builtin_effect()

std::string unit::describe_builtin_effect ( std::string  type,
const config effect 
)

Construct a string describing a built-in effect.

Parameters
typeThe effect to describe. Must be one of the effects in builtin_effects.
effectThe details of the effect

Definition at line 1970 of file unit.cpp.

References unit::attacks_, utils::format_conjunct_list(), utils::print_modifier(), VGETTEXT, and VNGETTEXT.

Referenced by unit::add_modification(), and game_lua_kernel::cfun_builtin_effect().

◆ expire_modifications()

void unit::expire_modifications ( const std::string &  duration)

Clears those modifications whose duration has expired.

Parameters
durationIf empty, all temporary modifications (those not lasting forever) expire. Otherwise, modifications whose duration equals duration expire.

Definition at line 1281 of file unit.cpp.

References unit::advance_to(), unit::anim_comp_, config::child_count(), config::get(), get_unit_type(), config::mandatory_child(), mod_duration_match(), unit::modifications_, config::remove_child(), and unit::type().

Referenced by unit::end_turn(), intf_remove_modifications(), unit::new_scenario(), and unit::new_turn().

◆ get_modifications() [1/2]

config& unit::get_modifications ( )
inline

Get the raw modifications.

Definition at line 1526 of file unit.hpp.

References unit::modifications_.

Referenced by intf_remove_modifications(), and gui2::dialogs::unit_advance::pre_show().

◆ get_modifications() [2/2]

const config& unit::get_modifications ( ) const
inline

Set the raw modifications.

Definition at line 1532 of file unit.hpp.

References unit::modifications_.

◆ modification_count() [1/2]

std::size_t unit::modification_count ( const std::string &  type) const

Count modifications of a particular type.

Parameters
typeThe type of modification to count. Valid values are "advancement", "trait", "object"
Returns
The total number of modifications of that type.

Definition at line 951 of file unit.cpp.

References config::child_range(), unit::modification_count(), unit::modifications_, and unit::type().

◆ modification_count() [2/2]

std::size_t unit::modification_count ( const std::string &  type,
const std::string &  id 
) const

Count modifications of a particular type.

Parameters
typeThe type of modification to count. Valid values are "advancement", "trait", "object"
idThe ID of the modification to count
Returns
The total number of modifications of that type and ID.

Definition at line 1944 of file unit.cpp.

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

Referenced by unit::advancements_count(), unit::amla_icons(), unit::get_modification_advances(), unit::modification_count(), unit::objects_count(), and unit::traits_count().

◆ objects_count()

std::size_t unit::objects_count ( ) const
inline

Definition at line 1559 of file unit.hpp.

References unit::modification_count().

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

◆ traits_count()

std::size_t unit::traits_count ( ) const
inline

Definition at line 1554 of file unit.hpp.

References unit::modification_count().

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

Variable Documentation

◆ builtin_effects

const std::set< std::string > unit::builtin_effects
static
Initial value:
{
"alignment", "attack", "defense", "ellipse", "experience", "fearless",
"halo", "healthy", "hitpoints", "image_mod", "jamming", "jamming_costs", "level",
"loyal", "max_attacks", "max_experience", "movement", "movement_costs",
"new_ability", "new_advancement", "new_animation", "new_attack", "overlay", "profile",
"recall_cost", "remove_ability", "remove_advancement", "remove_attacks", "resistance",
"status", "type", "variation", "vision", "vision_costs", "zoc"
}

Definition at line 1587 of file unit.hpp.

Referenced by unit::add_modification(), and game_lua_kernel::game_lua_kernel().