The Battle for Wesnoth  1.15.2+dev
Functions
Movement and location functions

Functions

int unit::total_movement () const
 The maximum moves this unit has. More...
 
void unit::set_total_movement (int value)
 
int unit::movement_left () const
 Gets how far a unit can move, considering the incapacitated flag. More...
 
int unit::movement_left (bool base_value) const
 Gets how far a unit can move. More...
 
void unit::set_movement (int moves, bool unit_action=false)
 Set this unit's remaining movement to moves. More...
 
bool unit::has_moved () const
 Checks if this unit has moved. More...
 
void unit::remove_movement_ai ()
 Sets the unit to have no moves left for this turn. More...
 
bool unit::resting () const
 Checks whether this unit is 'resting'. More...
 
void unit::set_resting (bool rest)
 Sets this unit's resting status. More...
 
bool unit::emits_zoc () const
 Tests whether the unit has a zone-of-control, considering incapacitated. More...
 
bool unit::get_emit_zoc () const
 Gets the raw zone-of-control flag, disregarding incapacitated. More...
 
void unit::set_emit_zoc (bool val)
 Sets the raw zone-of-control flag. More...
 
const map_locationunit::get_location () const
 The current map location this unit is at. More...
 
void unit::set_location (const map_location &loc)
 Sets this unit's map location. More...
 
map_location::DIRECTION unit::facing () const
 The current directin this unit is facing within its hex. More...
 
void unit::set_facing (map_location::DIRECTION dir) const
 The this unit's facing. More...
 
bool unit::has_goto () const
 Gets whether this unit has a multi-turn destination set. More...
 
const map_locationunit::get_goto () const
 The map location to which this unit is moving over multiple turns, if any. More...
 
void unit::set_goto (const map_location &new_goto)
 Sets this unit's long term destination. More...
 
int unit::vision () const
 Gets the unit's vision points. More...
 
int unit::jamming () const
 Gets the unit's jamming points. More...
 
bool unit::move_interrupted () const
 Check whether the unit's move has been interrupted. More...
 
const map_locationunit::get_interrupted_move () const
 Get the target location of the unit's interrupted move. More...
 
void unit::set_interrupted_move (const map_location &interrupted_move)
 Set the target location of the unit's interrupted move. More...
 
const movetypeunit::movement_type () const
 Get the unit's movement type. More...
 
int unit::movement_cost (const t_translation::terrain_code &terrain) const
 Get the unit's movement cost on a particular terrain. More...
 
int unit::vision_cost (const t_translation::terrain_code &terrain) const
 Get the unit's vision cost on a particular terrain. More...
 
int unit::jamming_cost (const t_translation::terrain_code &terrain) const
 Get the unit's jamming cost on a particular terrain. More...
 
bool unit::is_flying () const
 Check if the unit is a flying unit. More...
 

Detailed Description

Function Documentation

◆ emits_zoc()

bool unit::emits_zoc ( ) const
inline

Tests whether the unit has a zone-of-control, considering incapacitated.

Definition at line 1282 of file unit.hpp.

Referenced by pathfind::enemy_zoc(), and unit_drawer::redraw_unit().

◆ facing()

map_location::DIRECTION unit::facing ( ) const
inline

The current directin this unit is facing within its hex.

Definition at line 1317 of file unit.hpp.

Referenced by wfl::unit_callable::get_value(), unit_animation::matches(), and unit_drawer::redraw_unit().

◆ get_emit_zoc()

bool unit::get_emit_zoc ( ) const
inline

Gets the raw zone-of-control flag, disregarding incapacitated.

Definition at line 1288 of file unit.hpp.

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

◆ get_goto()

const map_location& unit::get_goto ( ) const
inline

The map location to which this unit is moving over multiple turns, if any.

Definition at line 1332 of file unit.hpp.

References goto_.

Referenced by events::menu_handler::execute_gotos().

◆ get_interrupted_move()

const map_location& unit::get_interrupted_move ( ) const
inline

Get the target location of the unit's interrupted move.

Definition at line 1362 of file unit.hpp.

◆ get_location()

const map_location& unit::get_location ( ) const
inline

The current map location this unit is at.

Definition at line 1301 of file unit.hpp.

References loc_.

Referenced by actions::actor_sighted(), pathfind::full_cost_map::add_unit(), gui2::dialogs::add_unit_entry(), game_state::can_recruit_from(), game_state::can_recruit_on(), can_see(), ai::cfun_ai_get_suitable_keep(), actions::shroud_clearer::clear_dest(), actions::shroud_clearer::clear_unit(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), events::menu_handler::execute_gotos(), wb::find_backup_leader(), actions::find_recall_location(), pathfind::find_vacant_castle(), terrain_filter::get_locs_impl(), actions::get_recalls(), events::mouse_handler::get_route(), wb::ghost_owner_unit(), impl_add_animation(), impl_unit_tostring(), intf_advance_unit(), game_lua_kernel::intf_erase_unit(), intf_find_cost_map_helper(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_put_unit(), intf_unit_resistance(), unit::invisible(), unit::is_visible_to_team(), luaW_pushfaivariant(), terrain_filter::match_impl(), unit_filter_impl::unit_filter_compound::matches(), unit_filter::matches(), events::mouse_handler::move_action(), pathfind::paths::paths(), gui2::dialogs::unit_list::pre_show(), unit_drawer::redraw_unit(), REPORT_GENERATOR(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_displayed_unit(), ai::move_result::test_route(), wb::unghost_owner_unit(), display_context::unit_can_move(), unit_display::unit_healing(), unit_weapons(), ai::default_recruitment::recruitment::update_important_hexes(), and playsingle_controller::hotkey_handler::whiteboard_suppose_dead().

◆ has_goto()

bool unit::has_goto ( ) const
inline

Gets whether this unit has a multi-turn destination set.

Definition at line 1326 of file unit.hpp.

Referenced by display_context::unit_can_move().

◆ has_moved()

bool unit::has_moved ( ) const
inline

Checks if this unit has moved.

Definition at line 1256 of file unit.hpp.

Referenced by display_context::unit_can_move(), and events::menu_handler::update_shroud_now().

◆ is_flying()

bool unit::is_flying ( ) const
inline

Check if the unit is a flying unit.

Definition at line 1410 of file unit.hpp.

Referenced by unit_animation_component::invalidate(), and unit_drawer::redraw_unit().

◆ jamming()

int unit::jamming ( ) const
inline

Gets the unit's jamming points.

Definition at line 1350 of file unit.hpp.

Referenced by pathfind::jamming_path::jamming_path(), and unit_vision().

◆ jamming_cost()

int unit::jamming_cost ( const t_translation::terrain_code terrain) const
inline

Get the unit's jamming cost on a particular terrain.

Parameters
terrainThe terrain to check
Returns
the number of jamming points to jam that terrain

Definition at line 1404 of file unit.hpp.

Referenced by intf_unit_jamming_cost().

◆ move_interrupted()

bool unit::move_interrupted ( ) const
inline

Check whether the unit's move has been interrupted.

Definition at line 1356 of file unit.hpp.

◆ movement_cost()

int unit::movement_cost ( const t_translation::terrain_code terrain) const
inline

◆ movement_left() [1/2]

int unit::movement_left ( ) const
inline

◆ movement_left() [2/2]

int unit::movement_left ( bool  base_value) const
inline

Gets how far a unit can move.

Parameters
base_valueIf false, consider the incapacitated flag.
Returns
If base_value is true, the raw value is returned.

Definition at line 1238 of file unit.hpp.

◆ movement_type()

const movetype& unit::movement_type ( ) const
inline

◆ remove_movement_ai()

void unit::remove_movement_ai ( )

Sets the unit to have no moves left for this turn.

Definition at line 2626 of file unit.cpp.

◆ resting()

bool unit::resting ( ) const
inline

Checks whether this unit is 'resting'.

Resting refers to whether this unit has not moved yet this turn. Note that this can be true even if movement_left is not equal to total_movement.

Definition at line 1270 of file unit.hpp.

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

◆ set_emit_zoc()

void unit::set_emit_zoc ( bool  val)
inline

Sets the raw zone-of-control flag.

Definition at line 1294 of file unit.hpp.

Referenced by unit::init().

◆ set_facing()

void unit::set_facing ( map_location::DIRECTION  dir) const

The this unit's facing.

Definition at line 1613 of file unit.cpp.

References unit::appearance_changed_, unit::facing_, and map_location::NDIRECTIONS.

Referenced by unit_display::unit_draw_weapon().

◆ set_goto()

void unit::set_goto ( const map_location new_goto)
inline

Sets this unit's long term destination.

Definition at line 1338 of file unit.hpp.

References goto_.

Referenced by events::mouse_handler::attack_enemy_(), events::menu_handler::execute_gotos(), and events::mouse_handler::move_action().

◆ set_interrupted_move()

void unit::set_interrupted_move ( const map_location interrupted_move)
inline

Set the target location of the unit's interrupted move.

Definition at line 1368 of file unit.hpp.

Referenced by unit::end_turn().

◆ set_location()

void unit::set_location ( const map_location loc)
inline

Sets this unit's map location.

Note this should only be called by unit_map or for temporary units.

Definition at line 1311 of file unit.hpp.

References loc_.

◆ set_movement()

void unit::set_movement ( int  moves,
bool  unit_action = false 
)

Set this unit's remaining movement to moves.

This does not affect maximum movement.

Parameters
movesThe new number of moves
unit_actionIf to true, the "end turn" and "hold position" flags will be cleared (as they should be if a unit acts, as opposed to the movement being set by the engine for other reasons).

Definition at line 1208 of file unit.cpp.

References unit::end_turn_, unit::hold_position_, and unit::movement_.

Referenced by wb::attack::apply_temp_modifier(), wb::mapbuilder::process(), wb::attack::remove_temp_modifier(), unit_movement_resetter::unit_movement_resetter(), and unit_movement_resetter::~unit_movement_resetter().

◆ set_resting()

void unit::set_resting ( bool  rest)
inline

Sets this unit's resting status.

Definition at line 1276 of file unit.hpp.

◆ set_total_movement()

void unit::set_total_movement ( int  value)
inline

Definition at line 1215 of file unit.hpp.

Referenced by unit::apply_builtin_effect(), and unit::init().

◆ total_movement()

int unit::total_movement ( ) const
inline

◆ vision()

int unit::vision ( ) const
inline

Gets the unit's vision points.

Definition at line 1344 of file unit.hpp.

Referenced by actions::shroud_clearer::clear_unit(), unit_vision(), and pathfind::vision_path::vision_path().

◆ vision_cost()

int unit::vision_cost ( const t_translation::terrain_code terrain) const
inline

Get the unit's vision cost on a particular terrain.

Parameters
terrainThe terrain to check
Returns
the number of vision points to see into that terrain

Definition at line 1394 of file unit.hpp.

Referenced by intf_unit_vision_cost().