unit Class Reference

#include <unit.hpp>

Collaboration diagram for unit:

Collaboration graph
[legend]

List of all members.

Public Types

enum  STATE { STATE_STANDING, STATE_FORGET, STATE_ANIM }
 States for animation. More...

Public Member Functions

 unit (const unit &u)
 unit (const config &cfg, bool use_traits=false)
 Initilizes a unit from a config.
 unit (unit_map *unitmap, const gamemap *map, const gamestatus *game_status, const std::vector< team > *teams, const config &cfg, bool use_traits=false, game_state *state=0)
 unit (const unit_type *t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE, std::string variation="")
 Initializes a unit from a unit type.
 unit (unit_map *unitmap, const gamemap *map, const gamestatus *game_status, const std::vector< team > *teams, const unit_type *t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE, std::string variation="")
virtual ~unit ()
unitoperator= (const unit &)
void set_game_context (unit_map *unitmap, const gamemap *map, const gamestatus *game_status, const std::vector< team > *teams)
void advance_to (const unit_type *t, bool use_traits=false, game_state *state=0)
 Advances this unit to another type.
const std::vector< std::string > advances_to () const
const std::string & type_id () const
 The type id of the unit.
const unit_typetype () const
const std::string & id () const
 The unique internal ID of the unit.
const std::string & underlying_id () const
const t_stringtype_name () const
 The unit type name.
const std::string & undead_variation () const
const std::string & name () const
 The unit name for display.
void rename (const std::string &name)
const std::string & profile () const
 The unit's profile.
const std::string & unit_description () const
 Information about the unit -- a detailed description of it.
int hitpoints () const
int max_hitpoints () const
int experience () const
int max_experience () const
int level () const
bool get_experience (int xp)
 Adds 'xp' points to the units experience; returns true if advancement should occur.
SDL_Colour hp_color () const
 Colors for the unit's hitpoints.
SDL_Colour xp_color () const
 Colors for the unit's XP.
bool unrenamable () const
 Set to true for some scenario-specific units which should not be renamed.
unsigned int side () const
Uint32 team_rgb () const
const std::string & team_color () const
unit_race::GENDER gender () const
void set_side (unsigned int new_side)
fixed_t alpha () const
bool can_recruit () const
bool incapacitated () const
const std::vector< std::string > & recruits () const
int total_movement () const
int movement_left () const
void set_hold_position (bool value)
bool hold_position () const
void set_user_end_turn (bool value=true)
bool user_end_turn () const
int attacks_left () const
void set_movement (int moves)
void set_attacks (int left)
void unit_hold_position ()
void new_turn ()
void end_turn ()
void new_level ()
void refresh (const game_display &disp, const gamemap::location &loc)
 Called on every draw.
bool take_hit (int damage)
void heal (int amount)
void heal_all ()
bool resting () const
void set_resting (bool rest)
const std::string get_state (const std::string &state) const
void set_state (const std::string &state, const std::string &value)
bool has_moved () const
bool has_goto () const
int emits_zoc () const
bool matches_filter (const vconfig &cfg, const gamemap::location &loc, bool use_flat_tod=false) const
void add_overlay (const std::string &overlay)
void remove_overlay (const std::string &overlay)
const std::vector< std::string > & overlays () const
void read (const config &cfg, bool use_traits=true, game_state *state=0)
 Initialize this unit from a cfg object.
void write (config &cfg) const
void assign_role (const std::string &role)
void assign_ai_special (const std::string &s)
std::string get_ai_special () const
const std::vector< attack_type > & attacks () const
std::vector< attack_type > & attacks ()
int damage_from (const attack_type &attack, bool attacker, const gamemap::location &loc) const
const surface still_image (bool scaled=false) const
 A SDL surface, ready for display for place where we need a still-image of the unit.
void redraw_unit (game_display &disp, const gamemap::location &loc, const bool fake=false)
 draw a unit, fake is used for temporary unit not in unit_map (so we can skip functions assuming that)
void clear_haloes ()
 Clear unit_halo_ and unit_anim_halo_.
void set_standing (const gamemap::location &loc, bool with_bars=true)
void set_idling (const game_display &disp, const gamemap::location &loc)
void set_selecting (const game_display &disp, const gamemap::location &loc)
unit_animationget_animation ()
const unit_animationget_animation () const
void set_facing (gamemap::location::DIRECTION dir)
gamemap::location::DIRECTION facing () const
std::set< gamemap::locationoverlaps (const gamemap::location &loc) const
const t_stringtraits_description () const
int cost () const
const gamemap::locationget_goto () const
void set_goto (const gamemap::location &new_goto)
int upkeep () const
void set_hidden (bool state)
bool get_hidden ()
bool is_flying () const
bool is_fearless () const
bool is_healthy () const
int movement_cost (const t_translation::t_terrain terrain) const
int defense_modifier (t_translation::t_terrain terrain, int recurse_count=0) const
int resistance_against (const std::string &damage_name, bool attacker, const gamemap::location &loc) const
int resistance_against (const attack_type &damage_type, bool attacker, const gamemap::location &loc) const
string_map get_base_resistances () const
bool can_advance () const
bool advances () const
std::map< std::string,
std::string > 
advancement_icons () const
std::vector< std::pair
< std::string, std::string > > 
amla_icons () const
config::child_list get_modification_advances () const
const config::child_listmodification_advancements () const
size_t modification_count (const std::string &type, const std::string &id) const
void add_modification (const std::string &type, const config &modification, bool no_add=false)
const t_stringmodification_description (const std::string &type) const
bool move_interrupted () const
const gamemap::locationget_interrupted_move () const
void set_interrupted_move (const gamemap::location &interrupted_move)
void start_animation (const int start_time, const gamemap::location &loc, const unit_animation *animation, bool with_bars, bool cycles=false, const std::string text="", const Uint32 text_color=0, STATE state=STATE_ANIM)
 normal anims
const std::string & absolute_image () const
 The name of the file to game_display (used in menus).
const std::string & image_halo () const
const std::string & get_hit_sound () const
const std::string & image_ellipse () const
const std::string & usage () const
unit_type::ALIGNMENT alignment () const
const unit_racerace () const
const unit_animationchoose_animation (const game_display &disp, const gamemap::location &loc, const std::string &event, const int damage=0, const unit_animation::hit_type hit_type=unit_animation::INVALID, const attack_type *attack=NULL, const attack_type *second_attack=NULL, int swing_num=0) const
bool get_ability_bool (const std::string &ability, const gamemap::location &loc) const
unit_ability_list get_abilities (const std::string &ability, const gamemap::location &loc) const
std::vector< std::string > ability_tooltips (const gamemap::location &loc) const
std::vector< std::string > unit_ability_tooltips () const
bool has_ability_type (const std::string &ability) const
bool abilities_affects_adjacent () const
const
game_logic::map_formula_callable_ptr
formula_vars () const
bool has_formula () const
const std::string & get_formula () const
void reset_modifications ()
void backup_state ()
void apply_modifications ()
void remove_temporary_modifications ()
void add_trait (std::string)
void generate_traits (bool musthaveonly=false, game_state *state=0)
void generate_traits_description ()
std::string generate_name (simple_rng *rng=0) const
bool invisible (const gamemap::location &loc, const unit_map &units, const std::vector< team > &teams, bool see_all=true) const
unit_race::GENDER generate_gender (const unit_type &type, bool gen, game_state *state=0)
std::string image_mods () const

Static Public Member Functions

static void clear_status_caches ()
 Clear the unit status cache for all units.

Private Member Functions

bool internal_matches_filter (const vconfig &cfg, const gamemap::location &loc, bool use_flat_tod) const
bool ability_active (const std::string &ability, const config &cfg, const gamemap::location &loc) const
bool ability_affects_adjacent (const std::string &ability, const config &cfg, int dir, const gamemap::location &loc) const
bool ability_affects_self (const std::string &ability, const config &cfg, const gamemap::location &loc) const
bool resistance_filter_matches (const config &cfg, bool attacker, const std::string &damage_name) const
bool resistance_filter_matches (const config &cfg, bool attacker, const attack_type &damage_type) const
int movement_cost_internal (t_translation::t_terrain terrain, int recurse_count=0) const
bool has_ability_by_id (const std::string &ability) const
void remove_ability_by_id (const std::string &ability)
void set_underlying_id ()
void clear_visibility_cache () const
 Clears the cache.

Private Attributes

config cfg_
config movement_b_
config defense_b_
config resistance_b_
config abilities_b_
std::vector< std::string > advances_to_
std::string type_
const unit_racerace_
std::string id_
std::string name_
std::string underlying_id_
t_string type_name_
std::string undead_variation_
std::string variation_
int hit_points_
int max_hit_points_
int max_hit_points_b_
int experience_
int max_experience_
int max_experience_b_
int level_
unit_type::ALIGNMENT alignment_
std::string flag_rgb_
std::string image_mods_
bool unrenamable_
unsigned int side_
unit_race::GENDER gender_
fixed_t alpha_
std::string unit_formula_
game_logic::map_formula_callable_ptr formula_vars_
std::vector< std::string > recruits_
int movement_
int max_movement_
int max_movement_b_
std::map
< t_translation::t_terrain,
int > 
movement_costs_
std::map
< t_translation::t_terrain,
int > 
defense_mods_
bool hold_position_
bool end_turn_
bool resting_
int attacks_left_
int max_attacks_
std::map< std::string,
std::string > 
states_
config variables_
int emit_zoc_
STATE state_
std::vector< std::string > overlays_
std::string role_
std::string ai_special_
std::vector< attack_typeattacks_
std::vector< attack_typeattacks_b_
gamemap::location::DIRECTION facing_
t_string traits_description_
int unit_value_
gamemap::location goto_
gamemap::location interrupted_move_
bool flying_
bool is_fearless_
bool is_healthy_
string_map modification_descriptions_
std::vector< unit_animationanimations_
unit_animationanim_
int next_idling_
int frame_begin_time_
int unit_halo_
int unit_anim_halo_
bool getsHit_
bool refreshing_
bool hidden_
bool draw_bars_
config modifications_
const unit_mapunits_
const gamemapmap_
const gamestatusgamestatus_
const std::vector< team > * teams_
std::map< gamemap::location, bool > invisibility_cache_
 Hold the visibility status cache for a unit, mutable since it's a cache.

Friends

struct unit_movement_resetter
void attack_type::set_specials_context (const gamemap::location &loc, const gamemap::location &, const unit &un, bool) const


Detailed Description

Definition at line 50 of file unit.hpp.


Member Enumeration Documentation

States for animation.

Enumerator:
STATE_STANDING 
STATE_FORGET  anim must fit in a hex
STATE_ANIM  animation will be automaticaly replaced by a standing anim when finished

Definition at line 254 of file unit.hpp.


Constructor & Destructor Documentation

unit::unit ( const unit u  ) 

Definition at line 90 of file unit.cpp.

References next_idling_, halo::NO_HALO, unit_anim_halo_, and unit_halo_.

Referenced by operator=().

unit::unit ( const config cfg,
bool  use_traits = false 
)

Initilizes a unit from a config.

Definition at line 214 of file unit.cpp.

References end_turn_, getsHit_, hidden_, read(), and refreshing_.

unit::unit ( unit_map unitmap,
const gamemap map,
const gamestatus game_status,
const std::vector< team > *  teams,
const config cfg,
bool  use_traits = false,
game_state state = 0 
)

Definition at line 186 of file unit.cpp.

References game_config::add_color_info(), end_turn_, getsHit_, hidden_, read(), and refreshing_.

unit::unit ( const unit_type t,
int  side,
bool  use_traits = false,
bool  dummy_unit = false,
unit_race::GENDER  gender = unit_race::MALE,
std::string  variation = "" 
)

unit::unit ( unit_map unitmap,
const gamemap map,
const gamestatus game_status,
const std::vector< team > *  teams,
const unit_type t,
int  side,
bool  use_traits = false,
bool  dummy_unit = false,
unit_race::GENDER  gender = unit_race::MALE,
std::string  variation = "" 
)

unit::~unit (  )  [virtual]

Definition at line 322 of file unit.cpp.

References anim_, clear_haloes(), and units_with_cache.

Referenced by operator=().


Member Function Documentation

void unit::clear_status_caches (  )  [static]

Clear the unit status cache for all units.

Currently only the hidden status of units is cached this way.

Definition at line 228 of file unit.cpp.

References units_with_cache.

Referenced by do_replay_handle(), move_unit(), game_events::pump(), events::menu_handler::redo(), and events::menu_handler::undo().

unit & unit::operator= ( const unit u  ) 

Definition at line 339 of file unit.cpp.

References unit(), and ~unit().

void unit::set_game_context ( unit_map unitmap,
const gamemap map,
const gamestatus game_status,
const std::vector< team > *  teams 
)

void unit::advance_to ( const unit_type t,
bool  use_traits = false,
game_state state = 0 
)

const std::vector<std::string> unit::advances_to (  )  const [inline]

Definition at line 77 of file unit.hpp.

References advances_to_.

Referenced by advancement_icons(), and xp_color().

const std::string& unit::type_id (  )  const [inline]

const unit_type * unit::type (  )  const

const std::string& unit::id (  )  const [inline]

The unique internal ID of the unit.

Definition at line 84 of file unit.hpp.

References id_, and type_name().

Referenced by unit_callable::get_value(), and set_underlying_id().

const std::string& unit::underlying_id (  )  const [inline]

const t_string& unit::type_name (  )  const [inline]

The unit type name.

Definition at line 88 of file unit.hpp.

References type_name_.

Referenced by dialogs::advance_unit(), dialogs::units_list_preview_pane::get_details(), and id().

const std::string& unit::undead_variation (  )  const [inline]

Definition at line 89 of file unit.hpp.

References undead_variation_.

Referenced by battle_context::unit_stats::unit_stats().

const std::string& unit::name (  )  const [inline]

void unit::rename ( const std::string &  name  )  [inline]

Definition at line 93 of file unit.hpp.

References name_, and unrenamable_.

const std::string & unit::profile (  )  const

The unit's profile.

Definition at line 585 of file unit.cpp.

References absolute_image(), and cfg_.

Referenced by advance_to().

const std::string& unit::unit_description (  )  const [inline]

Information about the unit -- a detailed description of it.

Definition at line 98 of file unit.hpp.

References cfg_.

int unit::hitpoints (  )  const [inline]

int unit::max_hitpoints (  )  const [inline]

int unit::experience (  )  const [inline]

int unit::max_experience (  )  const [inline]

int unit::level (  )  const [inline]

bool unit::get_experience ( int  xp  )  [inline]

Adds 'xp' points to the units experience; returns true if advancement should occur.

Definition at line 109 of file unit.hpp.

References advances(), and experience_.

Referenced by dialogs::animate_unit_advancement(), and get_advanced_unit().

SDL_Colour unit::hp_color (  )  const

Colors for the unit's hitpoints.

Definition at line 593 of file unit.cpp.

References hitpoints(), and max_hitpoints().

Referenced by dialogs::units_list_preview_pane::get_details(), and redraw_unit().

SDL_Colour unit::xp_color (  )  const

bool unit::unrenamable (  )  const [inline]

Set to true for some scenario-specific units which should not be renamed.

Definition at line 115 of file unit.hpp.

References unrenamable_.

unsigned int unit::side (  )  const [inline]

Uint32 unit::team_rgb (  )  const [inline]

Definition at line 117 of file unit.hpp.

References team::get_side_rgb(), and side().

const std::string& unit::team_color (  )  const [inline]

Definition at line 118 of file unit.hpp.

References flag_rgb_.

unit_race::GENDER unit::gender (  )  const [inline]

void unit::set_side ( unsigned int  new_side  )  [inline]

Definition at line 120 of file unit.hpp.

References side_.

Referenced by get_player_info().

fixed_t unit::alpha (  )  const [inline]

Definition at line 121 of file unit.hpp.

References alpha_.

bool unit::can_recruit (  )  const [inline]

bool unit::incapacitated (  )  const [inline]

Definition at line 124 of file unit.hpp.

References get_state(), and utils::string_bool().

Referenced by attacks_left(), emits_zoc(), movement_left(), and refresh().

const std::vector<std::string>& unit::recruits (  )  const [inline]

Definition at line 125 of file unit.hpp.

References recruits_.

int unit::total_movement (  )  const [inline]

int unit::movement_left (  )  const [inline]

void unit::set_hold_position ( bool  value  )  [inline]

Definition at line 128 of file unit.hpp.

References hold_position_.

bool unit::hold_position (  )  const [inline]

Definition at line 129 of file unit.hpp.

References hold_position_.

void unit::set_user_end_turn ( bool  value = true  )  [inline]

Definition at line 130 of file unit.hpp.

References end_turn_, and value.

bool unit::user_end_turn (  )  const [inline]

Definition at line 131 of file unit.hpp.

References end_turn_.

Referenced by redraw_unit().

int unit::attacks_left (  )  const [inline]

Definition at line 132 of file unit.hpp.

References attacks_left_, and incapacitated().

void unit::set_movement ( int  moves  ) 

Definition at line 667 of file unit.cpp.

References end_turn_, hold_position_, max_movement_, and movement_.

Referenced by ai::multistep_move_possible(), and recruit_unit().

void unit::set_attacks ( int  left  )  [inline]

Definition at line 134 of file unit.hpp.

References attacks_left_, and max_attacks_.

Referenced by attack::attack(), and recruit_unit().

void unit::unit_hold_position (  )  [inline]

Definition at line 135 of file unit.hpp.

References end_turn_, and hold_position_.

void unit::new_turn (  ) 

void unit::end_turn (  ) 

void unit::new_level (  ) 

void unit::refresh ( const game_display disp,
const gamemap::location loc 
) [inline]

bool unit::take_hit ( int  damage  )  [inline]

Definition at line 153 of file unit.hpp.

References hit_points_.

void unit::heal ( int  amount  ) 

Definition at line 727 of file unit.cpp.

References hit_points_, and max_hitpoints().

void unit::heal_all (  )  [inline]

Definition at line 155 of file unit.hpp.

References hit_points_, and max_hitpoints().

Referenced by add_modification(), advance_to(), attack::attack(), new_level(), and recruit_unit().

bool unit::resting (  )  const [inline]

Definition at line 156 of file unit.hpp.

References resting_.

void unit::set_resting ( bool  rest  )  [inline]

Definition at line 157 of file unit.hpp.

References resting_.

const std::string unit::get_state ( const std::string &  state  )  const

void unit::set_state ( const std::string &  state,
const std::string &  value 
)

Definition at line 749 of file unit.cpp.

References states_.

Referenced by add_modification(), advance_to(), end_turn(), new_level(), new_turn(), and read().

bool unit::has_moved (  )  const [inline]

Definition at line 162 of file unit.hpp.

References movement_left(), and total_movement().

bool unit::has_goto (  )  const [inline]

Definition at line 163 of file unit.hpp.

References get_goto(), and gamemap::location::valid().

int unit::emits_zoc (  )  const [inline]

Definition at line 164 of file unit.hpp.

References emit_zoc_, and incapacitated().

bool unit::matches_filter ( const vconfig cfg,
const gamemap::location loc,
bool  use_flat_tod = false 
) const

void unit::add_overlay ( const std::string &  overlay  )  [inline]

Definition at line 167 of file unit.hpp.

References overlays_.

void unit::remove_overlay ( const std::string &  overlay  )  [inline]

Definition at line 168 of file unit.hpp.

References overlays_, and halo::remove().

const std::vector<std::string>& unit::overlays (  )  const [inline]

Definition at line 169 of file unit.hpp.

References overlays_.

Referenced by redraw_unit().

void unit::read ( const config cfg,
bool  use_traits = true,
game_state state = 0 
)

void unit::write ( config cfg  )  const

void unit::assign_role ( const std::string &  role  )  [inline]

Definition at line 181 of file unit.hpp.

References role_.

void unit::assign_ai_special ( const std::string &  s  )  [inline]

Definition at line 182 of file unit.hpp.

References ai_special_.

std::string unit::get_ai_special (  )  const [inline]

Definition at line 183 of file unit.hpp.

References ai_special_.

const std::vector<attack_type>& unit::attacks (  )  const [inline]

std::vector<attack_type>& unit::attacks (  )  [inline]

Definition at line 185 of file unit.hpp.

References attacks_.

int unit::damage_from ( const attack_type attack,
bool  attacker,
const gamemap::location loc 
) const [inline]

Definition at line 187 of file unit.hpp.

References resistance_against().

Referenced by battle_context::unit_stats::unit_stats().

const surface unit::still_image ( bool  scaled = false  )  const

A SDL surface, ready for display for place where we need a still-image of the unit.

Definition at line 1522 of file unit.cpp.

References absolute_image(), image::get_image(), image_mods(), image::SCALED_TO_ZOOM, and image::UNSCALED.

Referenced by dialogs::units_list_preview_pane::get_details(), and redraw_unit().

void unit::redraw_unit ( game_display disp,
const gamemap::location loc,
const bool  fake = false 
)

draw a unit, fake is used for temporary unit not in unit_map (so we can skip functions assuming that)

Definition at line 1605 of file unit.cpp.

References absolute_image(), halo::add(), game_config::ally_ball_image, anim_, surface::assign(), boost::foreach_detail_::begin(), frame_parameters::blend_ratio, frame_parameters::blend_with, buf, can_advance(), can_recruit(), clear_haloes(), game_display::draw_bar(), draw_bars_, display::drawing_buffer_add(), game_config::enemy_ball_image, game_config::energy_image, experience(), facing_, game_display::float_label(), display::fogged(), frame_begin_time_, ftofxp, unit_animation::get_current_frame_begin_time(), unit_animation::get_current_params(), gamemap::location::get_direction(), gamemap::get_drawing_order(), image::locator::get_filename(), image::get_image(), display::get_location_x(), display::get_location_y(), display::get_map(), team::get_side_colour_index(), game_display::get_singleton(), get_state(), game_display::get_teams(), gamemap::get_terrain(), gamemap::get_terrain_info(), game_display::get_units(), display::get_zoom_factor(), frame_parameters::halo, frame_parameters::halo_x, frame_parameters::halo_y, display::hex_size(), hidden_, frame_parameters::highlight_ratio, hitpoints(), game_config::hp_bar_scaling, hp_color(), halo::HREVERSE, frame_parameters::image, frame_parameters::image_diagonal, image_ellipse(), image_halo(), frame_parameters::image_mod, image_mods(), invisible(), is_flying(), image::locator::is_void(), display::LAYER_UNIT_BAR, display::LAYER_UNIT_BG, display::LAYER_UNIT_FG, level_, map, display::map_outside_area(), max_experience(), max_hitpoints(), display::mouseover_hex(), game_config::moved_ball_image, movement_left(), halo::NO_HALO, halo::NORMAL, gamemap::location::NORTH, gamemap::location::NORTH_WEST, surface::null(), frame_parameters::offset, overlays(), game_config::partmoved_ball_image, sound::play_sound(), game_display::playing_team(), rects_overlap(), unit_animation::redraw(), refreshing_, halo::remove(), display::render_unit_image(), display::rgb(), image::SCALED_TO_ZOOM, display::selected_hex(), halo::set_location(), set_standing(), preferences::show_side_colours(), side(), side_, frame_parameters::sound, gamemap::location::SOUTH, gamemap::location::SOUTH_WEST, still_image(), utils::string_bool(), frame_parameters::submerge, game_display::team_valid(), frame_parameters::text, frame_parameters::text_color, total_movement(), unit_anim_halo_, unit_can_move(), unit_halo_, terrain_type::unit_height_adjust(), terrain_type::unit_submerge(), game_config::unmoved_ball_image, unit_animation::update_last_draw_time(), user_end_turn(), gamemap::location::valid(), game_display::viewing_team(), frame_parameters::x, game_config::xp_bar_scaling, xp_color(), and frame_parameters::y.

Referenced by game_display::draw().

void unit::clear_haloes (  ) 

Clear unit_halo_ and unit_anim_halo_.

Definition at line 1870 of file unit.cpp.

References halo::NO_HALO, halo::remove(), unit_anim_halo_, and unit_halo_.

Referenced by redraw_unit(), game_display::remove_temporary_unit(), set_hidden(), and ~unit().

void unit::set_standing ( const gamemap::location loc,
bool  with_bars = true 
)

void unit::set_idling ( const game_display disp,
const gamemap::location loc 
)

Definition at line 1559 of file unit.cpp.

References choose_animation(), start_animation(), and STATE_FORGET.

Referenced by refresh().

void unit::set_selecting ( const game_display disp,
const gamemap::location loc 
)

unit_animation* unit::get_animation (  )  [inline]

const unit_animation* unit::get_animation (  )  const [inline]

Definition at line 204 of file unit.hpp.

References anim_.

void unit::set_facing ( gamemap::location::DIRECTION  dir  ) 

Definition at line 1598 of file unit.cpp.

References facing_, and gamemap::location::NDIRECTIONS.

Referenced by unit_display::move_unit(), and move_unit_between().

gamemap::location::DIRECTION unit::facing (  )  const [inline]

Definition at line 206 of file unit.hpp.

References facing_.

Referenced by unit_animation::matches(), and unit_display::unit_die().

std::set< gamemap::location > unit::overlaps ( const gamemap::location loc  )  const

const t_string& unit::traits_description (  )  const [inline]

Definition at line 209 of file unit.hpp.

References traits_description_.

Referenced by dialogs::units_list_preview_pane::get_details().

int unit::cost (  )  const [inline]

const gamemap::location& unit::get_goto (  )  const [inline]

Definition at line 213 of file unit.hpp.

References goto_.

Referenced by has_goto().

void unit::set_goto ( const gamemap::location new_goto  )  [inline]

Definition at line 214 of file unit.hpp.

References goto_.

int unit::upkeep (  )  const

Definition at line 1942 of file unit.cpp.

References can_recruit(), cfg_, and level().

Referenced by events::delete_recall_unit::button_pressed().

void unit::set_hidden ( bool  state  ) 

Definition at line 2948 of file unit.cpp.

References clear_haloes(), and hidden_.

Referenced by unit_display::move_unit().

bool unit::get_hidden (  )  [inline]

Definition at line 219 of file unit.hpp.

References hidden_.

Referenced by unit_display::move_unit().

bool unit::is_flying (  )  const [inline]

Definition at line 220 of file unit.hpp.

References flying_.

Referenced by overlaps(), and redraw_unit().

bool unit::is_fearless (  )  const [inline]

Definition at line 221 of file unit.hpp.

References is_fearless_.

Referenced by battle_context::unit_stats::unit_stats().

bool unit::is_healthy (  )  const [inline]

Definition at line 222 of file unit.hpp.

References is_healthy_.

int unit::movement_cost ( const t_translation::t_terrain  terrain  )  const

int unit::defense_modifier ( t_translation::t_terrain  terrain,
int  recurse_count = 0 
) const

int unit::resistance_against ( const std::string &  damage_name,
bool  attacker,
const gamemap::location loc 
) const

int unit::resistance_against ( const attack_type damage_type,
bool  attacker,
const gamemap::location loc 
) const [inline]

Definition at line 226 of file unit.hpp.

References resistance_against(), and attack_type::type().

string_map unit::get_base_resistances (  )  const

Definition at line 2154 of file unit.cpp.

References cfg_, config::child(), and config::values.

bool unit::can_advance (  )  const [inline]

Definition at line 233 of file unit.hpp.

References advances_to_, and get_modification_advances().

Referenced by advancement_icons(), advances(), and redraw_unit().

bool unit::advances (  )  const [inline]

Definition at line 234 of file unit.hpp.

References can_advance(), experience_, and max_experience().

Referenced by amla_icons(), get_experience(), and get_modification_advances().

std::map< std::string, std::string > unit::advancement_icons (  )  const

std::vector< std::pair< std::string, std::string > > unit::amla_icons (  )  const

Definition at line 2202 of file unit.cpp.

References advances(), get_modification_advances(), and modification_count().

config::child_list unit::get_modification_advances (  )  const

const config::child_list& unit::modification_advancements (  )  const [inline]

Definition at line 240 of file unit.hpp.

References cfg_, and config::get_children().

Referenced by get_modification_advances().

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

Definition at line 2297 of file unit.cpp.

References config::get_children(), and modifications_.

Referenced by amla_icons(), and get_modification_advances().

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

const t_string & unit::modification_description ( const std::string &  type  )  const

Definition at line 2685 of file unit.cpp.

References empty_string, and modification_descriptions_.

bool unit::move_interrupted (  )  const [inline]

const gamemap::location& unit::get_interrupted_move (  )  const [inline]

Definition at line 250 of file unit.hpp.

References interrupted_move_.

void unit::set_interrupted_move ( const gamemap::location interrupted_move  )  [inline]

Definition at line 251 of file unit.hpp.

References interrupted_move_.

Referenced by end_turn().

void unit::start_animation ( const int  start_time,
const gamemap::location loc,
const unit_animation animation,
bool  with_bars,
bool  cycles = false,
const std::string  text = "",
const Uint32  text_color = 0,
STATE  state = STATE_ANIM 
)

const std::string& unit::absolute_image (  )  const [inline]

The name of the file to game_display (used in menus).

Definition at line 261 of file unit.hpp.

References cfg_.

Referenced by dialogs::advance_unit(), profile(), redraw_unit(), and still_image().

const std::string& unit::image_halo (  )  const [inline]

Definition at line 262 of file unit.hpp.

References cfg_.

Referenced by redraw_unit().

const std::string& unit::get_hit_sound (  )  const [inline]

Definition at line 264 of file unit.hpp.

References cfg_.

const std::string& unit::image_ellipse (  )  const [inline]

Definition at line 265 of file unit.hpp.

References cfg_.

Referenced by redraw_unit().

const std::string& unit::usage (  )  const [inline]

Definition at line 267 of file unit.hpp.

References cfg_.

Referenced by ai::analyze_potential_recruit_movements().

unit_type::ALIGNMENT unit::alignment (  )  const [inline]

const unit_race* unit::race (  )  const [inline]

Definition at line 269 of file unit.hpp.

References race_.

Referenced by internal_matches_filter().

const unit_animation * unit::choose_animation ( const game_display disp,
const gamemap::location loc,
const std::string &  event,
const int  damage = 0,
const unit_animation::hit_type  hit_type = unit_animation::INVALID,
const attack_type attack = NULL,
const attack_type second_attack = NULL,
int  swing_num = 0 
) const

bool unit::get_ability_bool ( const std::string &  ability,
const gamemap::location loc 
) const

unit_ability_list unit::get_abilities ( const std::string &  ability,
const gamemap::location loc 
) const

std::vector< std::string > unit::ability_tooltips ( const gamemap::location loc  )  const

Definition at line 226 of file unit_abilities.cpp.

References ability_active(), config::all_children(), cfg_, config::child(), and name().

std::vector< std::string > unit::unit_ability_tooltips (  )  const

bool unit::has_ability_type ( const std::string &  ability  )  const

Definition at line 407 of file unit_abilities.cpp.

References cfg_, config::child(), and config::get_children().

bool unit::abilities_affects_adjacent (  )  const

Definition at line 197 of file unit_abilities.cpp.

References cfg_, and config::child().

Referenced by overlaps().

const game_logic::map_formula_callable_ptr& unit::formula_vars (  )  const [inline]

Definition at line 280 of file unit.hpp.

References formula_vars_.

Referenced by unit_callable::get_value().

bool unit::has_formula (  )  const [inline]

Definition at line 281 of file unit.hpp.

References unit_formula_.

Referenced by write().

const std::string& unit::get_formula (  )  const [inline]

Definition at line 282 of file unit.hpp.

References unit_formula_.

void unit::reset_modifications (  ) 

void unit::backup_state (  ) 

void unit::apply_modifications (  ) 

void unit::remove_temporary_modifications (  ) 

void unit::add_trait ( std::string   ) 

Definition at line 363 of file unit.cpp.

References apply_modifications().

void unit::generate_traits ( bool  musthaveonly = false,
game_state state = 0 
)

void unit::generate_traits_description (  ) 

std::string unit::generate_name ( simple_rng rng = 0  )  const [inline]

Definition at line 291 of file unit.hpp.

References cfg_, unit_race::generate_name(), race_, and string_gender().

Referenced by read(), and unit().

bool unit::invisible ( const gamemap::location loc,
const unit_map units,
const std::vector< team > &  teams,
bool  see_all = true 
) const

Todo:
FIXME: We use the cache only when using the default see_all=true Maybe add a second cache if the see_all=false become more frequent.

Definition at line 2772 of file unit.cpp.

References unit_map::begin(), unit_map::end(), get_ability_bool(), get_state(), invisibility_cache_, side_, utils::string_bool(), tiles_adjacent(), and units_with_cache.

Referenced by internal_matches_filter(), unit_display::move_unit(), overlaps(), redraw_unit(), route_turns_to_complete(), and unit_display::unit_visible_on_path().

unit_race::GENDER unit::generate_gender ( const unit_type type,
bool  gen,
game_state state = 0 
)

std::string unit::image_mods (  )  const

Definition at line 2935 of file unit.cpp.

References flag_rgb_, team::get_side_colour_index(), image_mods_, and side().

Referenced by overlaps(), redraw_unit(), and still_image().

bool unit::internal_matches_filter ( const vconfig cfg,
const gamemap::location loc,
bool  use_flat_tod 
) const [private]

bool unit::ability_active ( const std::string &  ability,
const config cfg,
const gamemap::location loc 
) const [private]

bool unit::ability_affects_adjacent ( const std::string &  ability,
const config cfg,
int  dir,
const gamemap::location loc 
) const [private]

bool unit::ability_affects_self ( const std::string &  ability,
const config cfg,
const gamemap::location loc 
) const [private]

bool unit::resistance_filter_matches ( const config cfg,
bool  attacker,
const std::string &  damage_name 
) const [private]

Definition at line 2102 of file unit.cpp.

References utils::split().

Referenced by resistance_against(), and resistance_filter_matches().

bool unit::resistance_filter_matches ( const config cfg,
bool  attacker,
const attack_type damage_type 
) const [inline, private]

Definition at line 312 of file unit.hpp.

References resistance_filter_matches(), and attack_type::type().

int unit::movement_cost_internal ( t_translation::t_terrain  terrain,
int  recurse_count = 0 
) const [private]

bool unit::has_ability_by_id ( const std::string &  ability  )  const [private]

Definition at line 762 of file unit.cpp.

References config::all_children(), cfg_, and config::child().

Referenced by add_modification(), and internal_matches_filter().

void unit::remove_ability_by_id ( const std::string &  ability  )  [private]

void unit::set_underlying_id (  )  [private]

Definition at line 2818 of file unit.cpp.

References get_random(), unit_type::id(), id(), name_, type(), and underlying_id_.

Referenced by read(), and unit().

void unit::clear_visibility_cache (  )  const [inline, private]

Clears the cache.

Since we don't change the state of the object we're marked const (also required since the objects in the cache need to be marked const).

Definition at line 417 of file unit.hpp.

References invisibility_cache_.


Friends And Related Function Documentation

friend struct unit_movement_resetter [friend]

Definition at line 59 of file unit.hpp.

void attack_type::set_specials_context ( const gamemap::location loc,
const gamemap::location ,
const unit un,
bool   
) const [friend]


Member Data Documentation

config unit::cfg_ [private]

Definition at line 322 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

Definition at line 323 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

Definition at line 324 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

Definition at line 325 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

std::vector<std::string> unit::advances_to_ [private]

std::string unit::type_ [private]

Definition at line 328 of file unit.hpp.

Referenced by advance_to(), read(), set_game_context(), and type_id().

const unit_race* unit::race_ [private]

Definition at line 329 of file unit.hpp.

Referenced by advance_to(), generate_name(), internal_matches_filter(), race(), read(), and write().

std::string unit::id_ [private]

Definition at line 330 of file unit.hpp.

Referenced by id(), internal_matches_filter(), and read().

std::string unit::name_ [private]

Definition at line 331 of file unit.hpp.

Referenced by internal_matches_filter(), name(), read(), rename(), set_underlying_id(), unit(), and write().

std::string unit::underlying_id_ [private]

Definition at line 332 of file unit.hpp.

Referenced by read(), set_underlying_id(), underlying_id(), and write().

Definition at line 333 of file unit.hpp.

Referenced by advance_to(), read(), type_name(), and write().

std::string unit::undead_variation_ [private]

Definition at line 334 of file unit.hpp.

Referenced by advance_to(), read(), undead_variation(), and write().

std::string unit::variation_ [private]

Definition at line 335 of file unit.hpp.

Referenced by add_modification(), advance_to(), read(), and write().

int unit::hit_points_ [private]

Definition at line 337 of file unit.hpp.

Referenced by add_modification(), advance_to(), heal(), heal_all(), hitpoints(), read(), take_hit(), and write().

int unit::max_hit_points_ [private]

int unit::max_hit_points_b_ [private]

Definition at line 338 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

int unit::experience_ [private]

Definition at line 339 of file unit.hpp.

Referenced by advances(), experience(), get_experience(), read(), unit(), and write().

int unit::max_experience_ [private]

int unit::max_experience_b_ [private]

Definition at line 340 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

int unit::level_ [private]

Definition at line 342 of file unit.hpp.

Referenced by advance_to(), alignment(), read(), and write().

std::string unit::flag_rgb_ [private]

Definition at line 343 of file unit.hpp.

Referenced by advance_to(), image_mods(), read(), team_color(), and write().

std::string unit::image_mods_ [private]

Definition at line 344 of file unit.hpp.

Referenced by add_modification(), and image_mods().

bool unit::unrenamable_ [private]

Definition at line 346 of file unit.hpp.

Referenced by read(), rename(), unit(), unrenamable(), and write().

unsigned int unit::side_ [private]

Definition at line 347 of file unit.hpp.

Referenced by invisible(), read(), redraw_unit(), set_side(), side(), unit(), and write().

Definition at line 348 of file unit.hpp.

Referenced by add_modification(), advance_to(), apply_modifications(), gender(), read(), unit(), and write().

fixed_t unit::alpha_ [private]

Definition at line 350 of file unit.hpp.

Referenced by advance_to(), alpha(), read(), and write().

std::string unit::unit_formula_ [private]

Definition at line 352 of file unit.hpp.

Referenced by get_formula(), has_formula(), read(), and write().

Definition at line 353 of file unit.hpp.

Referenced by formula_vars(), read(), and write().

std::vector<std::string> unit::recruits_ [private]

Definition at line 355 of file unit.hpp.

Referenced by read(), recruits(), and write().

int unit::movement_ [private]

int unit::max_movement_ [private]

int unit::max_movement_b_ [private]

Definition at line 358 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

Definition at line 359 of file unit.hpp.

Referenced by add_modification(), advance_to(), and movement_cost_internal().

Definition at line 360 of file unit.hpp.

Referenced by add_modification(), advance_to(), and defense_modifier().

bool unit::hold_position_ [private]

bool unit::end_turn_ [private]

bool unit::resting_ [private]

Definition at line 363 of file unit.hpp.

Referenced by end_turn(), read(), resting(), set_resting(), and write().

int unit::attacks_left_ [private]

Definition at line 364 of file unit.hpp.

Referenced by attacks_left(), end_turn(), new_turn(), read(), set_attacks(), unit(), and write().

int unit::max_attacks_ [private]

Definition at line 365 of file unit.hpp.

Referenced by advance_to(), end_turn(), new_turn(), read(), set_attacks(), and write().

std::map<std::string,std::string> unit::states_ [private]

Definition at line 367 of file unit.hpp.

Referenced by get_state(), read(), set_state(), and write().

Definition at line 368 of file unit.hpp.

Referenced by read(), and write().

int unit::emit_zoc_ [private]

Definition at line 369 of file unit.hpp.

Referenced by add_modification(), advance_to(), emits_zoc(), read(), and write().

STATE unit::state_ [private]

Definition at line 370 of file unit.hpp.

Referenced by refresh(), and start_animation().

std::vector<std::string> unit::overlays_ [private]

Definition at line 372 of file unit.hpp.

Referenced by add_overlay(), overlays(), read(), remove_overlay(), and write().

std::string unit::role_ [private]

Definition at line 374 of file unit.hpp.

Referenced by assign_role(), internal_matches_filter(), new_level(), read(), and write().

std::string unit::ai_special_ [private]

std::vector<attack_type> unit::attacks_ [private]

Definition at line 376 of file unit.hpp.

Referenced by add_modification(), advance_to(), attacks(), backup_state(), and reset_modifications().

std::vector<attack_type> unit::attacks_b_ [private]

Definition at line 376 of file unit.hpp.

Referenced by backup_state(), reset_modifications(), and write().

Definition at line 377 of file unit.hpp.

Referenced by facing(), overlaps(), read(), redraw_unit(), set_facing(), start_animation(), and write().

Definition at line 379 of file unit.hpp.

Referenced by apply_modifications(), and traits_description().

int unit::unit_value_ [private]

Definition at line 380 of file unit.hpp.

Referenced by advance_to(), cost(), read(), and write().

Definition at line 381 of file unit.hpp.

Referenced by get_goto(), new_level(), read(), set_goto(), unit(), and write().

Definition at line 381 of file unit.hpp.

Referenced by get_interrupted_move(), move_interrupted(), and set_interrupted_move().

bool unit::flying_ [private]

Definition at line 382 of file unit.hpp.

Referenced by advance_to(), is_flying(), read(), and write().

bool unit::is_fearless_ [private]

Definition at line 382 of file unit.hpp.

Referenced by apply_modifications(), and is_fearless().

bool unit::is_healthy_ [private]

Definition at line 382 of file unit.hpp.

Referenced by apply_modifications(), end_turn(), and is_healthy().

Definition at line 384 of file unit.hpp.

Referenced by add_modification(), apply_modifications(), and modification_description().

std::vector<unit_animation> unit::animations_ [private]

Definition at line 386 of file unit.hpp.

Referenced by add_modification(), advance_to(), choose_animation(), and read().

Definition at line 388 of file unit.hpp.

Referenced by get_animation(), overlaps(), redraw_unit(), refresh(), start_animation(), unit(), and ~unit().

int unit::next_idling_ [private]

Definition at line 389 of file unit.hpp.

Referenced by refresh(), start_animation(), and unit().

int unit::frame_begin_time_ [private]

Definition at line 390 of file unit.hpp.

Referenced by redraw_unit(), start_animation(), and unit().

int unit::unit_halo_ [private]

Definition at line 393 of file unit.hpp.

Referenced by clear_haloes(), redraw_unit(), and unit().

int unit::unit_anim_halo_ [private]

Definition at line 394 of file unit.hpp.

Referenced by clear_haloes(), redraw_unit(), and unit().

bool unit::getsHit_ [private]

Definition at line 395 of file unit.hpp.

Referenced by unit().

bool unit::refreshing_ [private]

Definition at line 396 of file unit.hpp.

Referenced by advance_to(), redraw_unit(), and unit().

bool unit::hidden_ [private]

Definition at line 397 of file unit.hpp.

Referenced by advance_to(), get_hidden(), redraw_unit(), set_hidden(), and unit().

bool unit::draw_bars_ [private]

Definition at line 398 of file unit.hpp.

Referenced by redraw_unit(), and start_animation().

const unit_map* unit::units_ [private]

const gamemap* unit::map_ [private]

const gamestatus* unit::gamestatus_ [private]

const std::vector<team>* unit::teams_ [private]

Hold the visibility status cache for a unit, mutable since it's a cache.

Definition at line 409 of file unit.hpp.

Referenced by clear_visibility_cache(), and invisible().


The documentation for this class was generated from the following files:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs