The basic "size" of the unit - flying, small land, large land, etc. More...
#include <movetype.hpp>
Classes | |
class | resistances |
Stores a set of resistances. More... | |
class | terrain_costs |
A const-only interface for how many (movement, vision, or "jamming") points a unit needs for each hex. More... | |
class | terrain_defense |
Stores a set of defense levels. More... | |
class | terrain_info |
Stores a set of data based on terrain, in some cases with raw pointers to other instances of terrain_info (the fallback_). More... | |
Public Member Functions | |
movetype () | |
Default constructor. More... | |
movetype (const config &cfg) | |
Constructor from a config. More... | |
movetype (const movetype &that) | |
Copy constructor. More... | |
movetype (movetype &&that) | |
Move constructor. More... | |
movetype & | operator= (const movetype &that) |
movetype & | operator= (movetype &&that) |
~movetype ()=default | |
terrain_defense & | get_defense () |
resistances & | get_resistances () |
const terrain_costs & | get_movement () const |
const terrain_costs & | get_vision () const |
const terrain_costs & | get_jamming () const |
const terrain_defense & | get_defense () const |
const resistances & | get_resistances () const |
bool | is_flying () const |
Returns whether or not *this is flagged as a flying movement type. More... | |
void | set_flying (bool flies=true) |
Sets whether or not *this is flagged as a flying movement type. More... | |
int | movement_cost (const t_translation::terrain_code &terrain, bool slowed=false) const |
Returns the cost to move through the indicated terrain. More... | |
int | vision_cost (const t_translation::terrain_code &terrain, bool slowed=false) const |
Returns the cost to see through the indicated terrain. More... | |
int | jamming_cost (const t_translation::terrain_code &terrain, bool slowed=false) const |
Returns the cost to "jam" through the indicated terrain. More... | |
int | defense_modifier (const t_translation::terrain_code &terrain) const |
Returns the defensive value of the indicated terrain. More... | |
int | resistance_against (const std::string &damage_type) const |
Returns the vulnerability to the indicated damage type (higher means takes more damage). More... | |
utils::string_map_res | damage_table () const |
Returns a map from damage types to resistances. More... | |
bool | has_terrain_defense_caps (const std::set< t_translation::terrain_code > &ts) const |
Returns whether or not there are any terrain caps with respect to a set of terrains. More... | |
bool | has_vision_data () const |
Returns whether or not there are any vision-specific costs. More... | |
bool | has_jamming_data () const |
Returns whether or not there are any jamming-specific costs. More... | |
void | merge (const config &new_cfg, bool overwrite=true) |
Merges the given config over the existing data, the config should have zero or more children named "movement_costs", "defense", etc. More... | |
void | merge (const config &new_cfg, const std::string &applies_to, bool overwrite=true) |
Merges the given config over the existing data; this 3-argument version affects only the subelement identified by the applies_to argument. More... | |
const std::vector< t_string > & | special_notes () const |
Contents of any [special_note] tags. More... | |
void | write (config &cfg, bool include_notes) const |
Writes the movement type data to the provided config. More... | |
Static Public Member Functions | |
static std::unique_ptr< terrain_costs > | read_terrain_costs (const config &cfg) |
Reverse of terrain_costs::write. More... | |
Static Public Attributes | |
static const int | UNREACHABLE = 99 |
Magic value that signifies a hex is unreachable. More... | |
static const std::set< std::string > | effects |
The set of applicable effects for movement types. More... | |
Private Attributes | |
terrain_info | movement_ |
terrain_info | vision_ |
terrain_info | jamming_ |
terrain_defense | defense_ |
resistances | resist_ |
bool | flying_ |
std::vector< t_string > | special_notes_ |
Static Private Attributes | |
static const terrain_info::parameters | mvj_params_ {1, movetype::UNREACHABLE} |
Limits for movement, vision and jamming. More... | |
Friends | |
void | swap (movetype &a, movetype &b) |
Swap function for the movetype class, including its terrain_info members. More... | |
void | swap (movetype::terrain_info &a, movetype::terrain_info &b) |
The basic "size" of the unit - flying, small land, large land, etc.
This encompasses terrain costs, defenses, and resistances.
This class is used for both [movetype] and [unit] configs, which use the same data in their configs for [movement_costs], [defense], etc. However, the data for whether the unit flies is historically held in [movetype]'s "flies" vs [unit]'s "flying".
Existing behavior of 1.14:
movetype::write() will write only the "flying" key
Definition at line 43 of file movetype.hpp.
movetype::movetype | ( | ) |
Default constructor.
Definition at line 787 of file movetype.cpp.
|
explicit |
Constructor from a config.
Definition at line 802 of file movetype.cpp.
References config::child_range(), flying_, and special_notes_.
movetype::movetype | ( | const movetype & | that | ) |
Copy constructor.
Definition at line 822 of file movetype.cpp.
movetype::movetype | ( | movetype && | that | ) |
Move constructor.
Definition at line 836 of file movetype.cpp.
|
default |
|
inline |
Returns a map from damage types to resistances.
Definition at line 295 of file movetype.hpp.
References movetype::resistances::damage_table(), and resist_.
Referenced by unit::get_base_resistances(), and help::unit_topic_generator::operator()().
|
inline |
Returns the defensive value of the indicated terrain.
Definition at line 288 of file movetype.hpp.
References movetype::terrain_defense::defense(), and defense_.
Referenced by unit::defense_modifier(), wfl::gamestate::DEFINE_WFL_FUNCTION(), ai::default_recruitment::recruitment::get_average_defense(), and help::unit_topic_generator::operator()().
|
inline |
Definition at line 263 of file movetype.hpp.
References defense_.
Referenced by help::unit_topic_generator::operator()().
|
inline |
Definition at line 269 of file movetype.hpp.
References defense_.
|
inline |
Definition at line 268 of file movetype.hpp.
References jamming_.
Referenced by pathfind::jamming_path::jamming_path().
|
inline |
Definition at line 266 of file movetype.hpp.
References movement_.
Referenced by pathfind::full_cost_map::add_unit(), pathfind::paths::paths(), and ai::default_recruitment::recruitment::update_average_local_cost().
|
inline |
Definition at line 264 of file movetype.hpp.
References resist_.
|
inline |
Definition at line 270 of file movetype.hpp.
References resist_.
|
inline |
Definition at line 267 of file movetype.hpp.
References vision_.
Referenced by actions::shroud_clearer::clear_unit(), and pathfind::vision_path::vision_path().
|
inline |
Returns whether or not there are any jamming-specific costs.
Definition at line 303 of file movetype.hpp.
References movetype::terrain_info::empty(), and jamming_.
Referenced by help::unit_topic_generator::operator()().
bool movetype::has_terrain_defense_caps | ( | const std::set< t_translation::terrain_code > & | ts | ) | const |
Returns whether or not there are any terrain caps with respect to a set of terrains.
Checks if we have a defense cap (nontrivial min value) for any of the given terrain types.
Definition at line 850 of file movetype.cpp.
References movetype::terrain_defense::capped(), defense_, and t.
Referenced by help::unit_topic_generator::operator()().
|
inline |
Returns whether or not there are any vision-specific costs.
Definition at line 301 of file movetype.hpp.
References movetype::terrain_info::empty(), and vision_.
Referenced by help::unit_topic_generator::operator()().
|
inline |
Returns whether or not *this is flagged as a flying movement type.
Definition at line 273 of file movetype.hpp.
References flying_.
Referenced by unit::is_flying().
|
inline |
Returns the cost to "jam" through the indicated terrain.
Definition at line 284 of file movetype.hpp.
References movetype::terrain_costs::cost(), jamming_, and game_config::sounds::status::slowed.
Referenced by wfl::gamestate::DEFINE_WFL_FUNCTION(), unit::jamming_cost(), and help::unit_topic_generator::operator()().
void movetype::merge | ( | const config & | new_cfg, |
bool | overwrite = true |
||
) |
Merges the given config over the existing data, the config should have zero or more children named "movement_costs", "defense", etc.
Only those children will be affected (in the case of movement and vision the cascaded values in vision and jamming will also be affected).
If overwrite is true, the new values will replace the old ones. If it's false, the new values are relative improvements or maluses which will be applied on top of the old values.
If the old values included defense caps and overwrite is false, the calculations are done with absolute values and then changed back to the old sign. This means that merge() doesn't create or remove defense caps when overwrite is false.
If new_cfg["flying"] is provided, it overrides the old value, regardless of the value of overwrite.
This neither adds nor removes special notes. One purpose of this function is to have [unit_type][movement_costs] partially overwrite data from [unit_type]movetype=, and it would be unhelpful if an unrelated [unit_type][special_note] cleared the movetype's special notes.
Definition at line 858 of file movetype.cpp.
References config::child_range(), effects, and flying_.
Referenced by unit::apply_builtin_effect(), unit_type::build_help_index(), unit::init(), and help::unit_topic_generator::operator()().
void movetype::merge | ( | const config & | new_cfg, |
const std::string & | applies_to, | ||
bool | overwrite = true |
||
) |
Merges the given config over the existing data; this 3-argument version affects only the subelement identified by the applies_to argument.
applies_to | which type of movement to change ("movement_costs", etc) |
new_cfg | data which could be one of the children of the config for the two-argument form of this function. |
overwrite | if false, the new values will be added to the old. |
Definition at line 874 of file movetype.cpp.
References defense_, ERR_CF, jamming_, movetype::terrain_defense::merge(), movetype::resistances::merge(), movetype::terrain_info::merge(), movement_, resist_, and vision_.
|
inline |
Returns the cost to move through the indicated terrain.
Definition at line 278 of file movetype.hpp.
References movetype::terrain_costs::cost(), movement_, and game_config::sounds::status::slowed.
Referenced by pathfind::move_type_path_calculator::cost(), wfl::gamestate::DEFINE_WFL_FUNCTION(), unit::movement_cost(), and help::unit_topic_generator::operator()().
Definition at line 522 of file movetype.cpp.
References swap.
Definition at line 529 of file movetype.cpp.
References swap.
|
static |
Reverse of terrain_costs::write.
Never returns nullptr.
Never returns nullptr.
[in] | cfg | An initial data set |
Definition at line 427 of file movetype.cpp.
References mvj_params_.
|
inline |
Returns the vulnerability to the indicated damage type (higher means takes more damage).
Definition at line 292 of file movetype.hpp.
References resist_, and movetype::resistances::resistance_against().
Referenced by unit_type::resistance_against(), and unit::resistance_value().
|
inline |
Sets whether or not *this is flagged as a flying movement type.
Definition at line 275 of file movetype.hpp.
References flying_.
|
inline |
Contents of any [special_note] tags.
Definition at line 343 of file movetype.hpp.
References special_notes_.
Referenced by combine_special_notes().
|
inline |
Returns the cost to see through the indicated terrain.
Definition at line 281 of file movetype.hpp.
References movetype::terrain_costs::cost(), game_config::sounds::status::slowed, and vision_.
Referenced by wfl::gamestate::DEFINE_WFL_FUNCTION(), help::unit_topic_generator::operator()(), and unit::vision_cost().
void movetype::write | ( | config & | cfg, |
bool | include_notes | ||
) | const |
Writes the movement type data to the provided config.
There is no default value for the include_notes argument. Given the implied contract that a class with a constructor(const config&) and a write(config&) supports round-tripping the data, the default would need to be true. However, this method has only two callers, and neither of them want to include the notes:
Movetype patching is unaffected by the notes, as they will be ignored by movetype::merge().
[store_unit] is broken by the notes, because they end up in unit::special_notes_ instead of movetype::special_notes_ after the subsequent [unstore_unit].
cfg | output |
include_notes | if false, omits any special notes |
Definition at line 902 of file movetype.cpp.
References config::add_child(), defense_, flying_, jamming_, movement_, resist_, special_notes_, vision_, movetype::terrain_defense::write(), movetype::terrain_info::write(), and movetype::resistances::write().
Referenced by movetype::terrain_info::make_standalone(), and unit::write().
Swap function for the movetype class, including its terrain_info members.
This relies on the two sets of the terrain_infos having their movement, vision and jamming cascaded in the same way. This assumption is provided by movetype's constructors.
Definition at line 511 of file movetype.cpp.
Referenced by operator=().
|
friend |
|
private |
Definition at line 367 of file movetype.hpp.
Referenced by defense_modifier(), get_defense(), has_terrain_defense_caps(), merge(), and write().
|
static |
The set of applicable effects for movement types.
The set of strings defining effects which apply to movetypes.
Definition at line 340 of file movetype.hpp.
Referenced by unit::apply_builtin_effect(), merge(), and help::unit_topic_generator::operator()().
|
private |
Definition at line 370 of file movetype.hpp.
Referenced by is_flying(), merge(), movetype(), set_flying(), and write().
|
private |
Definition at line 366 of file movetype.hpp.
Referenced by get_jamming(), has_jamming_data(), jamming_cost(), merge(), and write().
|
private |
Definition at line 364 of file movetype.hpp.
Referenced by get_movement(), merge(), movement_cost(), and write().
|
staticprivate |
Limits for movement, vision and jamming.
Definition at line 240 of file movetype.hpp.
Referenced by read_terrain_costs().
|
private |
Definition at line 368 of file movetype.hpp.
Referenced by damage_table(), get_resistances(), merge(), resistance_against(), and write().
|
private |
Definition at line 371 of file movetype.hpp.
Referenced by movetype(), special_notes(), and write().
|
static |
Magic value that signifies a hex is unreachable.
The UNREACHABLE macro in the data tree should match this value.
Definition at line 174 of file movetype.hpp.
Referenced by pathfind::shortest_path_calculator::cost(), movetype::terrain_costs::cost(), game_display::draw_movement_info(), pathfind::find_vacant_tile(), REPORT_GENERATOR(), and unit_type_data::set_config().
|
private |
Definition at line 365 of file movetype.hpp.
Referenced by get_vision(), has_vision_data(), merge(), vision_cost(), and write().