The Battle for Wesnoth  1.15.6+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...
 
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 2262 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(), config::child_range(), unit::describe_builtin_effect(), t_string::empty(), config::empty(), resources::filter_con, unit::get_state(), unit::level_, unit::loc_, resources::lua_kernel, unit::modifications_, unit::set_state(), unit::STATE_POISONED, mariadb::value::string, and VGETTEXT.

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

◆ 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 1920 of file unit.cpp.

References a, unit::abilities_, config::add_child(), game_config::add_color_info(), unit::advance_to(), unit::advancements_, unit::advances_to_, unit::anim_comp_, unit::appearance_changed_, config::append(), utils::apply_modifier(), unit::attacks_, c, config::child(), config::child_range(), unit::description_, movetype::effects, unit::emit_zoc_, preferences::encountered_units(), unit::experience_, unit_type_data::find(), resources::gameboard, config::get(), unit::has_ability_by_id(), config::has_child(), unit::heal_fully(), unit::hit_points_, i, unit::image_mods_, unit::is_fearless_, unit::is_healthy_, unit::jamming_, LOG_UT, unit::max_attacks_, unit::max_experience_, unit::max_hit_points_, unit::max_movement_, movetype::merge(), unit::movement_, unit::movement_type_, unit::overlays_, unit_type::parent_id(), utils::parenthetical_split(), unit::recall_cost(), unit::recall_cost_, gui2::dialogs::tip::remove(), unit::remove_ability_by_id(), 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(), mariadb::value::string, game_board::teams(), unit::type(), unit::upkeep_loyal::type(), unit::UA_ABILITIES, unit::UA_ADVANCEMENTS, unit::UA_ATTACKS, unit::UA_IS_FEARLESS, unit::UA_IS_HEALTHY, unit::UA_MOVEMENT_TYPE, unit::UA_ZOC, unit::unit(), 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 1855 of file unit.cpp.

References a, unit::attacks_, utils::format_conjunct_list(), utils::print_modifier(), mariadb::value::string, 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 1214 of file unit.cpp.

References unit::advance_to(), unit::anim_comp_, config::child(), config::child_count(), config::get(), get_unit_type(), unit::hit_points_, unit::max_movement_, mod_duration_match(), unit::modifications_, unit::movement_, 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 1465 of file unit.hpp.

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 1471 of file unit.hpp.

References mariadb::value::string.

◆ modification_count()

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 1829 of file unit.cpp.

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

Referenced by unit::amla_icons(), and unit::get_modification_advances().

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",
"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 1503 of file unit.hpp.

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