The Battle for Wesnoth  1.19.7+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 direction 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 1385 of file unit.hpp.

References unit::emit_zoc_, and unit::incapacitated().

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

◆ facing()

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

The current direction this unit is facing within its hex.

Definition at line 1420 of file unit.hpp.

References unit::facing_.

Referenced by wfl::unit_callable::get_value(), unit_drawer::redraw_unit(), editor::map_context::to_config(), and UNIT_GETTER().

◆ get_emit_zoc()

bool unit::get_emit_zoc ( ) const
inline

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

Definition at line 1391 of file unit.hpp.

References unit::emit_zoc_.

Referenced by wfl::unit_callable::get_value(), and UNIT_GETTER().

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

References unit::goto_.

Referenced by events::menu_handler::execute_gotos(), unit::has_goto(), and UNIT_GETTER().

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

References unit::interrupted_move_.

◆ get_location()

const map_location& unit::get_location ( ) const
inline

The current map location this unit is at.

Definition at line 1404 of file unit.hpp.

References unit::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(), wfl::attack_map_callable::collect_possible_attacks(), unit_drawer::draw_ellipses(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), events::menu_handler::execute_gotos(), wb::find_backup_leader(), pathfind::find_vacant_castle(), terrain_filter::get_locs_impl(), events::mouse_handler::get_route(), wb::ghost_owner_unit(), impl_add_animation(), impl_unit_tostring(), intf_advance_unit(), game_lua_kernel::intf_erase_unit(), game_lua_kernel::intf_find_path(), game_lua_kernel::intf_find_vision_range(), 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::matches(), unit_filter_impl::unit_filter_compound::matches(), events::mouse_handler::move_action(), pathfind::paths::paths(), gui2::dialogs::unit_list::pre_show(), unit_drawer::redraw_unit(), REPORT_GENERATOR(), events::mouse_handler::select_hex(), gui2::dialogs::attack_predictions::set_data(), ai::move_result::test_route(), editor::map_context::to_config(), wb::unghost_owner_unit(), display_context::unit_can_move(), UNIT_GETTER(), 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 1429 of file unit.hpp.

References unit::get_goto(), and map_location::valid().

Referenced by display_context::unit_can_move().

◆ has_moved()

bool unit::has_moved ( ) const
inline

Checks if this unit has moved.

Definition at line 1359 of file unit.hpp.

References unit::movement_left(), and unit::total_movement().

Referenced by display_context::unit_can_move().

◆ is_flying()

bool unit::is_flying ( ) const
inline

Check if the unit is a flying unit.

Definition at line 1513 of file unit.hpp.

References movetype::is_flying(), and unit::movement_type_.

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

◆ jamming()

int unit::jamming ( ) const
inline

Gets the unit's jamming points.

Definition at line 1453 of file unit.hpp.

References unit::jamming_.

Referenced by pathfind::jamming_path::jamming_path(), UNIT_GETTER(), 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 1507 of file unit.hpp.

References unit::get_state(), movetype::jamming_cost(), unit::movement_type_, and unit::STATE_SLOWED.

Referenced by wfl::gamestate::DEFINE_WFL_FUNCTION(), and intf_unit_jamming_cost().

◆ move_interrupted()

bool unit::move_interrupted ( ) const
inline

Check whether the unit's move has been interrupted.

Definition at line 1459 of file unit.hpp.

References unit::interrupted_move_, unit::movement_left(), map_location::x, and map_location::y.

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

References unit::movement_, and unit::movement_left().

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

References unit::movement_left(), unit::set_movement(), unit::set_state(), unit::STATE_NOT_MOVED, and unit::total_movement().

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

References unit::resting_.

Referenced by wfl::unit_callable::get_value(), and UNIT_GETTER().

◆ set_emit_zoc()

void unit::set_emit_zoc ( bool  val)
inline

Sets the raw zone-of-control flag.

Definition at line 1397 of file unit.hpp.

References unit::emit_zoc_, unit::set_attr_changed(), and unit::UA_ZOC.

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

◆ set_facing()

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

The this unit's facing.

Definition at line 1682 of file unit.cpp.

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

Referenced by unit_display::unit_attack(), unit_display::unit_draw_weapon(), and UNIT_SETTER().

◆ set_goto()

void unit::set_goto ( const map_location new_goto)
inline

Sets this unit's long term destination.

Definition at line 1441 of file unit.hpp.

References unit::goto_.

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

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

References unit::interrupted_move_.

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

References loc, and unit::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 1256 of file unit.cpp.

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

Referenced by wb::attack::apply_temp_modifier(), wb::mapbuilder::process(), unit::remove_movement_ai(), wb::attack::remove_temp_modifier(), unit_movement_resetter::unit_movement_resetter(), UNIT_SETTER(), 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 1379 of file unit.hpp.

References unit::resting_.

Referenced by UNIT_SETTER().

◆ set_total_movement()

void unit::set_total_movement ( int  value)
inline

◆ total_movement()

int unit::total_movement ( ) const
inline

◆ vision()

int unit::vision ( ) const
inline

Gets the unit's vision points.

Definition at line 1447 of file unit.hpp.

References unit::max_movement_, and unit::vision_.

Referenced by actions::shroud_clearer::clear_unit(), UNIT_GETTER(), 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 1497 of file unit.hpp.

References unit::get_state(), unit::movement_type_, unit::STATE_SLOWED, and movetype::vision_cost().

Referenced by wfl::gamestate::DEFINE_WFL_FUNCTION(), and intf_unit_vision_cost().