diff --git a/changelog b/changelog index 171362080de..5247ecb0d57 100644 --- a/changelog +++ b/changelog @@ -51,6 +51,8 @@ Version 1.3.6+svn: * better handling/reporting of invalid WML variable type usage * new key find_in= to allow searching a variable of previously stored locations when using the standard location filter + * new key find_in= to allow searching a variable of previously stored + units when using the standard unit filter * new extra_defines= key to define in campaigns some other preprocessor symbol *before* the files are repreprocessed * fog and shroud tiles are now defined by the TerrainWML (not [game_config]) diff --git a/src/unit.cpp b/src/unit.cpp index 5af23c45aa6..0583270053d 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -883,7 +883,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location& return false; } - if (canrecruit.empty() == false && utils::string_bool(canrecruit) != can_recruit()) { + if(canrecruit.empty() == false && utils::string_bool(canrecruit) != can_recruit()) { return false; } @@ -906,6 +906,30 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location& } } } + + if(cfg.has_attribute("find_in")) { + //allow filtering by searching a stored variable of units + wassert(gamestatus_ != NULL); + variable_info vi = gamestatus_->sog().get_variable_info(cfg["find_in"], false, + variable_info::TYPE_CONTAINER); + if(!vi.is_valid) return false; + if(vi.explicit_index) { + if(description_ != (vi.vars->get_children(vi.key)[vi.index])->get_attribute("description")) { + return false; + } + } else { + config::child_itors ch_itors = vi.vars->child_range(vi.key); + for(; ch_itors.first != ch_itors.second; ++ch_itors.first) { + if(description_ == (*ch_itors.first)->get_attribute("description")) { + break; + } + } + if(ch_itors.first == ch_itors.second) { + return false; + } + } + } + return true; } diff --git a/src/unit.hpp b/src/unit.hpp index e41a18ada4a..718608f097f 100644 --- a/src/unit.hpp +++ b/src/unit.hpp @@ -30,394 +30,392 @@ class config_writer; class unit_ability_list { - public: +public: - bool empty() const; + bool empty() const; - std::pair highest(const std::string& key, int def=0) const; - std::pair lowest(const std::string& key, int def=100) const; - - std::vector > cfgs; - private: + std::pair highest(const std::string& key, int def=0) const; + std::pair lowest(const std::string& key, int def=100) const; + std::vector > cfgs; }; class unit { - public: - // clear the status caches for esch unit, this is should be called it - // the status of a unit changes - static void clear_status_caches(); +public: + // clear the status caches for esch unit, this is should be called it + // the status of a unit changes + static void clear_status_caches(); - friend struct unit_movement_resetter; - // Copy constructor - unit(const unit& u); - // Initilizes a unit from a config - unit(const game_data& gamedata, const config& cfg); - unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams, const config& cfg); - // Initilizes a unit from a unit type - unit(const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE); - unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams, const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE); - virtual ~unit(); - unit& operator=(const unit&); + friend struct unit_movement_resetter; + // Copy constructor + unit(const unit& u); + // Initilizes a unit from a config + unit(const game_data& gamedata, const config& cfg); + unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams, const config& cfg); + // Initilizes a unit from a unit type + unit(const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE); + unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams, const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE); + virtual ~unit(); + unit& operator=(const unit&); - void set_game_context(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams); + void set_game_context(const game_data* gamedata, unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const std::vector* teams); - // Advances this unit to another type - void advance_to(const unit_type* t); - const std::vector advances_to() const { return advances_to_; } + // Advances this unit to another type + void advance_to(const unit_type* t); + const std::vector advances_to() const { return advances_to_; } - // the current type id - const std::string& id() const { return id_; } - const unit_type* type() const; - // the actual name of the unit - const std::string& name() const { if (description_.empty()) return language_name(); else return description_; } - void rename(const std::string& name) { if (!unrenamable_) custom_unit_description_ = name; } - // the unit type name - const std::string& description() const { return (custom_unit_description_); } - const std::string& underlying_description() const { return underlying_description_; } - const t_string& language_name() const { return language_name_; } - const std::string& undead_variation() const { return undead_variation_; } - // the unit's profile - const std::string& profile() const; - //information about the unit -- a detailed description of it - const std::string& unit_description() const { return cfg_["unit_description"]; } + // the current type id + const std::string& id() const { return id_; } + const unit_type* type() const; + // the actual name of the unit + const std::string& name() const { if (description_.empty()) return language_name(); else return description_; } + void rename(const std::string& name) { if (!unrenamable_) custom_unit_description_ = name; } + // the unit type name + const std::string& description() const { return (custom_unit_description_); } + const std::string& underlying_description() const { return underlying_description_; } + const t_string& language_name() const { return language_name_; } + const std::string& undead_variation() const { return undead_variation_; } + // the unit's profile + const std::string& profile() const; + //information about the unit -- a detailed description of it + const std::string& unit_description() const { return cfg_["unit_description"]; } - int hitpoints() const { return hit_points_; } - int max_hitpoints() const { return max_hit_points_; } - int experience() const { return experience_; } - int max_experience() const { return maximum(1,(max_experience_*unit_type::experience_accelerator::get_acceleration() + 50) / 100); } - int level() const { return level_; } - // adds 'xp' points to the units experience; returns true if advancement should occur - bool get_experience(int xp) { experience_ += xp; return advances(); } - SDL_Colour hp_color() const; - SDL_Colour xp_color() const; - /** < Set to true for some scenario-specific units which should not be renamed */ - bool unrenamable() const { return unrenamable_; } - unsigned int side() const { return side_; } - Uint32 team_rgb() const { return(team::get_side_rgb(side())); } - const std::string& team_color() const { return flag_rgb_; } - unit_race::GENDER gender() const { return gender_; } - void set_side(unsigned int new_side) { side_ = new_side; } - fixed_t alpha() const { return alpha_; } + int hitpoints() const { return hit_points_; } + int max_hitpoints() const { return max_hit_points_; } + int experience() const { return experience_; } + int max_experience() const { return maximum(1,(max_experience_*unit_type::experience_accelerator::get_acceleration() + 50) / 100); } + int level() const { return level_; } + // adds 'xp' points to the units experience; returns true if advancement should occur + bool get_experience(int xp) { experience_ += xp; return advances(); } + SDL_Colour hp_color() const; + SDL_Colour xp_color() const; + /** < Set to true for some scenario-specific units which should not be renamed */ + bool unrenamable() const { return unrenamable_; } + unsigned int side() const { return side_; } + Uint32 team_rgb() const { return(team::get_side_rgb(side())); } + const std::string& team_color() const { return flag_rgb_; } + unit_race::GENDER gender() const { return gender_; } + void set_side(unsigned int new_side) { side_ = new_side; } + fixed_t alpha() const { return alpha_; } - bool can_recruit() const { return utils::string_bool(cfg_["canrecruit"]); } - bool incapacitated() const { return utils::string_bool(get_state("stoned"),false); } - const std::vector& recruits() const { return recruits_; } - int total_movement() const { return max_movement_; } - int movement_left() const { return incapacitated() ? 0 : movement_; } - void set_hold_position(bool value) { hold_position_ = value; } - bool hold_position() const { return hold_position_; } - void set_user_end_turn(bool value=true) { end_turn_ = value; } - bool user_end_turn() const { return end_turn_; } - int attacks_left() const { return incapacitated() ? 0 : attacks_left_; } - void set_movement(int moves); - void set_attacks(int left) { attacks_left_ = maximum(0,minimum(left,max_attacks_)); } - void unit_hold_position() { hold_position_ = end_turn_ = true; } - void new_turn(); - void end_turn(); - void new_level(); - // called on every draw - void refresh(const game_display& disp,const gamemap::location& loc) { - if (state_ == STATE_IDLING && anim_ && anim_->animation_finished()) { - set_standing(disp, loc); - return; - } - if (state_ != STATE_STANDING || incapacitated() || (get_current_animation_tick() < next_idling_)) return; - if (get_current_animation_tick() > next_idling_ + 1000) { // prevent all units animating at the same - set_standing(disp,loc); - } else { - set_idling(disp, loc); - } + bool can_recruit() const { return utils::string_bool(cfg_["canrecruit"]); } + bool incapacitated() const { return utils::string_bool(get_state("stoned"),false); } + const std::vector& recruits() const { return recruits_; } + int total_movement() const { return max_movement_; } + int movement_left() const { return incapacitated() ? 0 : movement_; } + void set_hold_position(bool value) { hold_position_ = value; } + bool hold_position() const { return hold_position_; } + void set_user_end_turn(bool value=true) { end_turn_ = value; } + bool user_end_turn() const { return end_turn_; } + int attacks_left() const { return incapacitated() ? 0 : attacks_left_; } + void set_movement(int moves); + void set_attacks(int left) { attacks_left_ = maximum(0,minimum(left,max_attacks_)); } + void unit_hold_position() { hold_position_ = end_turn_ = true; } + void new_turn(); + void end_turn(); + void new_level(); + // called on every draw + void refresh(const game_display& disp,const gamemap::location& loc) { + if (state_ == STATE_IDLING && anim_ && anim_->animation_finished()) { + set_standing(disp, loc); + return; } + if (state_ != STATE_STANDING || incapacitated() || (get_current_animation_tick() < next_idling_)) return; + if (get_current_animation_tick() > next_idling_ + 1000) { // prevent all units animating at the same + set_standing(disp,loc); + } else { + set_idling(disp, loc); + } + } - bool take_hit(int damage) { hit_points_ -= damage; return hit_points_ <= 0; } - void heal(int amount); - void heal_all() { hit_points_ = max_hitpoints(); } - bool resting() const { return resting_; } - void set_resting(bool rest) { resting_ = rest; } + bool take_hit(int damage) { hit_points_ -= damage; return hit_points_ <= 0; } + void heal(int amount); + void heal_all() { hit_points_ = max_hitpoints(); } + bool resting() const { return resting_; } + void set_resting(bool rest) { resting_ = rest; } - const std::string get_state(const std::string& state) const; - void set_state(const std::string& state, const std::string& value); + 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 { return movement_left() != total_movement(); } - bool has_goto() const { return get_goto().valid(); } - int emits_zoc() const { return (incapacitated()) ? false : emit_zoc_; } - /* cfg: standard unit filter */ - bool matches_filter(const vconfig& cfg,const gamemap::location& loc,bool use_flat_tod=false) const; - void add_overlay(const std::string& overlay) { overlays_.push_back(overlay); } - void remove_overlay(const std::string& overlay) { overlays_.erase(std::remove(overlays_.begin(),overlays_.end(),overlay),overlays_.end()); } - const std::vector& overlays() const { return overlays_; } - /** - * Initializes this unit from a cfg object. - * - * \param cfg Configuration object from which to read the unit - */ - void read(const config& cfg); - void write(config& cfg) const; - void write(config_writer& out) const; + bool has_moved() const { return movement_left() != total_movement(); } + bool has_goto() const { return get_goto().valid(); } + int emits_zoc() const { return (incapacitated()) ? false : emit_zoc_; } + /* cfg: standard unit filter */ + bool matches_filter(const vconfig& cfg,const gamemap::location& loc,bool use_flat_tod=false) const; + void add_overlay(const std::string& overlay) { overlays_.push_back(overlay); } + void remove_overlay(const std::string& overlay) { overlays_.erase(std::remove(overlays_.begin(),overlays_.end(),overlay),overlays_.end()); } + const std::vector& overlays() const { return overlays_; } + /** + * Initializes this unit from a cfg object. + * + * \param cfg Configuration object from which to read the unit + */ + void read(const config& cfg); + void write(config& cfg) const; + void write(config_writer& out) const; - void assign_role(const std::string& role) { role_ = role; } - void assign_ai_special(const std::string& s) { ai_special_ = s;} - std::string get_ai_special() const { return(ai_special_); } - const std::vector& attacks() const { return attacks_; } - std::vector& attacks() { return attacks_; } + void assign_role(const std::string& role) { role_ = role; } + void assign_ai_special(const std::string& s) { ai_special_ = s;} + std::string get_ai_special() const { return(ai_special_); } + const std::vector& attacks() const { return attacks_; } + std::vector& attacks() { return attacks_; } - int damage_from(const attack_type& attack,bool attacker,const gamemap::location& loc) const { return resistance_against(attack,attacker,loc); } + int damage_from(const attack_type& attack,bool attacker,const gamemap::location& loc) const { return resistance_against(attack,attacker,loc); } - // a sdl surface, ready for display for place where we need a fix image of the unit - const surface still_image(bool scaled = false) const; - void redraw_unit(game_display& disp, const gamemap::location& loc); - // clear unit_halo_ and unit_anim_halo_ - void clear_haloes(); - + // a sdl surface, ready for display for place where we need a fix image of the unit + const surface still_image(bool scaled = false) const; + void redraw_unit(game_display& disp, const gamemap::location& loc); + // clear unit_halo_ and unit_anim_halo_ + void clear_haloes(); + - void set_standing(const game_display& disp,const gamemap::location& loc, bool with_bars = true); - void set_defending(const game_display &disp,const gamemap::location& loc, int damage,const attack_type* attack,const attack_type* secondary_attack,int swing_num); - void set_leading(const game_display& disp,const gamemap::location& loc); - void set_healing(const game_display& disp,const gamemap::location& loc,int damage); - void set_leveling_in(const game_display& disp,const gamemap::location& loc); - void set_leveling_out(const game_display& disp,const gamemap::location& loc); - void set_teleporting (const game_display& disp,const gamemap::location& loc); - void set_extra_anim(const game_display& disp,const gamemap::location& loc, std::string flag); - void set_dying(const game_display &disp,const gamemap::location& loc,const attack_type* attack,const attack_type* secondary_attack); - void set_walking(const game_display& disp,const gamemap::location& loc); - const unit_animation & set_attacking( const game_display &disp,const gamemap::location& loc,int damage,const attack_type& type,const attack_type* secondary_attack,int swing_num); - void set_recruited(const game_display& disp,const gamemap::location& loc); - void set_healed(const game_display& disp,const gamemap::location& loc,int healing); - void set_victorious(const game_display &disp,const gamemap::location& loc,const attack_type* attack,const attack_type* secondary_attack); - void set_poisoned(const game_display& disp,const gamemap::location& loc,int damage); - void set_idling(const game_display& disp,const gamemap::location& loc); - void restart_animation(const game_display& disp,int start_time); - const unit_animation* get_animation() const { return anim_;}; - void set_offset(double offset){offset_ = offset;} - void set_facing(gamemap::location::DIRECTION dir); - gamemap::location::DIRECTION facing() const { return facing_; } + void set_standing(const game_display& disp,const gamemap::location& loc, bool with_bars = true); + void set_defending(const game_display &disp,const gamemap::location& loc, int damage,const attack_type* attack,const attack_type* secondary_attack,int swing_num); + void set_leading(const game_display& disp,const gamemap::location& loc); + void set_healing(const game_display& disp,const gamemap::location& loc,int damage); + void set_leveling_in(const game_display& disp,const gamemap::location& loc); + void set_leveling_out(const game_display& disp,const gamemap::location& loc); + void set_teleporting (const game_display& disp,const gamemap::location& loc); + void set_extra_anim(const game_display& disp,const gamemap::location& loc, std::string flag); + void set_dying(const game_display &disp,const gamemap::location& loc,const attack_type* attack,const attack_type* secondary_attack); + void set_walking(const game_display& disp,const gamemap::location& loc); + const unit_animation & set_attacking( const game_display &disp,const gamemap::location& loc,int damage,const attack_type& type,const attack_type* secondary_attack,int swing_num); + void set_recruited(const game_display& disp,const gamemap::location& loc); + void set_healed(const game_display& disp,const gamemap::location& loc,int healing); + void set_victorious(const game_display &disp,const gamemap::location& loc,const attack_type* attack,const attack_type* secondary_attack); + void set_poisoned(const game_display& disp,const gamemap::location& loc,int damage); + void set_idling(const game_display& disp,const gamemap::location& loc); + void restart_animation(const game_display& disp,int start_time); + const unit_animation* get_animation() const { return anim_;}; + void set_offset(double offset){offset_ = offset;} + void set_facing(gamemap::location::DIRECTION dir); + gamemap::location::DIRECTION facing() const { return facing_; } - std::set overlaps(const gamemap::location &loc) const; - const t_string& traits_description() const { return traits_description_; } + std::set overlaps(const gamemap::location &loc) const; + const t_string& traits_description() const { return traits_description_; } - int value() const { return unit_value_; } - int cost () const { return unit_value_; } + int value() const { return unit_value_; } + int cost () const { return unit_value_; } - const gamemap::location& get_goto() const { return goto_; } - void set_goto(const gamemap::location& new_goto) { goto_ = new_goto; } + const gamemap::location& get_goto() const { return goto_; } + void set_goto(const gamemap::location& new_goto) { goto_ = new_goto; } - int upkeep() const; + int upkeep() const; - void set_hidden(bool state); - bool get_hidden() { return hidden_; }; - bool is_flying() const { return flying_; } - bool is_fearless() const { return is_fearless_; } - bool is_healthy() const { return is_healthy_; } - int movement_cost(const t_translation::t_letter terrain) const; - int defense_modifier(t_translation::t_letter terrain, int recurse_count=0) const; - int resistance_against(const attack_type& damage_type,bool attacker,const gamemap::location& loc) const; + void set_hidden(bool state); + bool get_hidden() { return hidden_; }; + bool is_flying() const { return flying_; } + bool is_fearless() const { return is_fearless_; } + bool is_healthy() const { return is_healthy_; } + int movement_cost(const t_translation::t_letter terrain) const; + int defense_modifier(t_translation::t_letter terrain, int recurse_count=0) const; + int resistance_against(const attack_type& damage_type,bool attacker,const gamemap::location& loc) const; // std::map movement_type() const; - bool can_advance() const { return advances_to_.empty()==false || get_modification_advances().empty() == false; } - bool advances() const { return experience_ >= max_experience() && can_advance(); } + bool can_advance() const { return advances_to_.empty()==false || get_modification_advances().empty() == false; } + bool advances() const { return experience_ >= max_experience() && can_advance(); } - std::map advancement_icons() const; - std::vector > amla_icons() const; + std::map advancement_icons() const; + std::vector > amla_icons() const; - config::child_list get_modification_advances() const; - const config::child_list& modification_advancements() const { return cfg_.get_children("advancement"); } + config::child_list get_modification_advances() const; + const config::child_list& modification_advancements() const { return cfg_.get_children("advancement"); } - size_t modification_count(const std::string& type, const std::string& id) 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); + void add_modification(const std::string& type, const config& modification, + bool no_add=false); - const t_string& modification_description(const std::string& type) const; + const t_string& modification_description(const std::string& type) const; - bool move_interrupted() const { return movement_left() > 0 && interrupted_move_.x >= 0 && interrupted_move_.y >= 0; } - const gamemap::location& get_interrupted_move() const { return interrupted_move_; } - void set_interrupted_move(const gamemap::location& interrupted_move) { interrupted_move_ = interrupted_move; } + bool move_interrupted() const { return movement_left() > 0 && interrupted_move_.x >= 0 && interrupted_move_.y >= 0; } + const gamemap::location& get_interrupted_move() const { return interrupted_move_; } + void set_interrupted_move(const gamemap::location& interrupted_move) { interrupted_move_ = interrupted_move; } - enum STATE { STATE_STANDING, STATE_ATTACKING, STATE_DEFENDING, - STATE_LEADING, STATE_HEALING, STATE_WALKING, STATE_LEVELIN, - STATE_LEVELOUT, STATE_DYING, STATE_EXTRA, STATE_TELEPORT, - STATE_RECRUITED, STATE_HEALED, STATE_POISONED, STATE_IDLEIN, STATE_IDLING, STATE_VICTORIOUS}; - const unit_animation * start_animation(const game_display &disp, const gamemap::location &loc,const unit_animation* animation, bool with_bars,bool is_attack_anim =false); + enum STATE { STATE_STANDING, STATE_ATTACKING, STATE_DEFENDING, + STATE_LEADING, STATE_HEALING, STATE_WALKING, STATE_LEVELIN, + STATE_LEVELOUT, STATE_DYING, STATE_EXTRA, STATE_TELEPORT, + STATE_RECRUITED, STATE_HEALED, STATE_POISONED, STATE_IDLEIN, STATE_IDLING, STATE_VICTORIOUS}; + const unit_animation * start_animation(const game_display &disp, const gamemap::location &loc,const unit_animation* animation, bool with_bars,bool is_attack_anim =false); - //the name of the file to game_display (used in menus - const std::string& absolute_image() const { return cfg_["image"]; } - const std::string& image_halo() const { return cfg_["halo"]; } - const std::string& image_fighting(attack_type::RANGE range) const; + //the name of the file to game_display (used in menus + const std::string& absolute_image() const { return cfg_["image"]; } + const std::string& image_halo() const { return cfg_["halo"]; } + const std::string& image_fighting(attack_type::RANGE range) const; - const std::string& get_hit_sound() const { return cfg_["get_hit_sound"]; } - const std::string& die_sound() const { return cfg_["die_sound"]; } - const std::string& image_ellipse() const { return cfg_["ellipse"]; } + const std::string& get_hit_sound() const { return cfg_["get_hit_sound"]; } + const std::string& die_sound() const { return cfg_["die_sound"]; } + const std::string& image_ellipse() const { return cfg_["ellipse"]; } - const std::string& usage() const { return cfg_["usage"]; } - unit_type::ALIGNMENT alignment() const { return alignment_; } - const std::string& race() const { return race_->name(); } + const std::string& usage() const { return cfg_["usage"]; } + unit_type::ALIGNMENT alignment() const { return alignment_; } + const std::string& race() const { return race_->name(); } - const defensive_animation* defend_animation(const game_display& disp, const gamemap::location& loc, - fighting_animation::hit_type hits,const attack_type* attack, - const attack_type* secondary_attack,int swing_num,int damage) const; - const unit_animation* teleport_animation(const game_display& disp, const gamemap::location& loc) const; - const unit_animation* extra_animation(const game_display& disp, const gamemap::location& loc,const std::string &flag) const; - const death_animation* die_animation(const game_display& disp, const gamemap::location& loc, - fighting_animation::hit_type hits,const attack_type* attack,const attack_type* secondary_attack) const; - const movement_animation* move_animation(const game_display& disp, const gamemap::location& loc) const; - const standing_animation* stand_animation(const game_display& disp, const gamemap::location& loc) const; - const leading_animation* lead_animation(const game_display& disp, const gamemap::location& loc) const; - const healing_animation* heal_animation(const game_display& disp, const gamemap::location& loc,int damage) const; - const victory_animation* victorious_animation(const game_display& disp, const gamemap::location& loc, - fighting_animation::hit_type hits,const attack_type* attack,const attack_type* secondary_attack) const; - const recruit_animation* recruiting_animation(const game_display& disp, const gamemap::location& loc) const; - const idle_animation* idling_animation(const game_display& disp, const gamemap::location& loc) const; - const levelin_animation* levelingin_animation(const game_display& disp, const gamemap::location& loc) const; - const levelout_animation* levelingout_animation(const game_display& disp, const gamemap::location& loc) const; - const healed_animation* get_healed_animation(const game_display& disp, const gamemap::location& loc,int healing) const; - const poison_animation* poisoned_animation(const game_display & disp, const gamemap::location& loc,int damage) const; + const defensive_animation* defend_animation(const game_display& disp, const gamemap::location& loc, + fighting_animation::hit_type hits,const attack_type* attack, + const attack_type* secondary_attack,int swing_num,int damage) const; + const unit_animation* teleport_animation(const game_display& disp, const gamemap::location& loc) const; + const unit_animation* extra_animation(const game_display& disp, const gamemap::location& loc,const std::string &flag) const; + const death_animation* die_animation(const game_display& disp, const gamemap::location& loc, + fighting_animation::hit_type hits,const attack_type* attack,const attack_type* secondary_attack) const; + const movement_animation* move_animation(const game_display& disp, const gamemap::location& loc) const; + const standing_animation* stand_animation(const game_display& disp, const gamemap::location& loc) const; + const leading_animation* lead_animation(const game_display& disp, const gamemap::location& loc) const; + const healing_animation* heal_animation(const game_display& disp, const gamemap::location& loc,int damage) const; + const victory_animation* victorious_animation(const game_display& disp, const gamemap::location& loc, + fighting_animation::hit_type hits,const attack_type* attack,const attack_type* secondary_attack) const; + const recruit_animation* recruiting_animation(const game_display& disp, const gamemap::location& loc) const; + const idle_animation* idling_animation(const game_display& disp, const gamemap::location& loc) const; + const levelin_animation* levelingin_animation(const game_display& disp, const gamemap::location& loc) const; + const levelout_animation* levelingout_animation(const game_display& disp, const gamemap::location& loc) const; + const healed_animation* get_healed_animation(const game_display& disp, const gamemap::location& loc,int healing) const; + const poison_animation* poisoned_animation(const game_display & disp, const gamemap::location& loc,int damage) 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 ability_tooltips(const gamemap::location& loc) const; - std::vector unit_ability_tooltips() const; - bool has_ability_type(const std::string& ability) 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 ability_tooltips(const gamemap::location& loc) const; + std::vector unit_ability_tooltips() const; + bool has_ability_type(const std::string& ability) const; - void reset_modifications(); - void backup_state(); - void apply_modifications(); - void remove_temporary_modifications(); - void generate_traits(); - void generate_traits_description(); - std::string generate_description() const { return race_->generate_name(string_gender(cfg_["gender"])); } + void reset_modifications(); + void backup_state(); + void apply_modifications(); + void remove_temporary_modifications(); + void generate_traits(); + void generate_traits_description(); + std::string generate_description() const { return race_->generate_name(string_gender(cfg_["gender"])); } - //only see_all=true use caching - bool invisible(const gamemap::location& loc, - const unit_map& units,const std::vector& teams, bool see_all=true) const; + //only see_all=true use caching + bool invisible(const gamemap::location& loc, + const unit_map& units,const std::vector& teams, bool see_all=true) const; - unit_race::GENDER generate_gender(const unit_type& type, bool gen); - std::string image_mods() const; - - private: + unit_race::GENDER generate_gender(const unit_type& type, bool gen); + std::string image_mods() const; + +private: - bool internal_matches_filter(const vconfig& cfg,const gamemap::location& loc, - bool use_flat_tod) const; - /* - * cfg: an ability WML structure - */ - 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 attack_type& damage_type) const; - int movement_cost_internal(t_translation::t_letter terrain, int recurse_count=0) const; - bool has_ability_by_id(const std::string& ability) const; + bool internal_matches_filter(const vconfig& cfg,const gamemap::location& loc, + bool use_flat_tod) const; + /* + * cfg: an ability WML structure + */ + 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 attack_type& damage_type) const; + int movement_cost_internal(t_translation::t_letter terrain, int recurse_count=0) const; + bool has_ability_by_id(const std::string& ability) const; - config cfg_; - config movement_b_; - config defense_b_; - config resistance_b_; + config cfg_; + config movement_b_; + config defense_b_; + config resistance_b_; - std::vector advances_to_; - std::string id_; - const unit_race* race_; - std::string name_; - std::string description_; - std::string custom_unit_description_; - std::string underlying_description_; - t_string language_name_; - std::string undead_variation_; - std::string variation_; + std::vector advances_to_; + std::string id_; + const unit_race* race_; + std::string name_; + std::string description_; + std::string custom_unit_description_; + std::string underlying_description_; + t_string language_name_; + std::string undead_variation_; + std::string variation_; - int hit_points_; - int max_hit_points_, max_hit_points_b_; - int experience_; - int max_experience_, 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_; + int hit_points_; + int max_hit_points_, max_hit_points_b_; + int experience_; + int max_experience_, 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_; + fixed_t alpha_; - std::vector recruits_; + std::vector recruits_; - int movement_; - int max_movement_, max_movement_b_; - mutable std::map movement_costs_; // movement cost cache - bool hold_position_; - bool end_turn_; - bool resting_; - int attacks_left_; - int max_attacks_; + int movement_; + int max_movement_, max_movement_b_; + mutable std::map movement_costs_; // movement cost cache + bool hold_position_; + bool end_turn_; + bool resting_; + int attacks_left_; + int max_attacks_; - std::map states_; - config variables_; - int emit_zoc_; - STATE state_; + std::map states_; + config variables_; + int emit_zoc_; + STATE state_; - std::vector overlays_; + std::vector overlays_; - std::string role_; - std::string ai_special_; - std::vector attacks_, attacks_b_; - gamemap::location::DIRECTION facing_; + std::string role_; + std::string ai_special_; + std::vector attacks_, attacks_b_; + gamemap::location::DIRECTION facing_; - t_string traits_description_; - int unit_value_; - gamemap::location goto_, interrupted_move_; - bool flying_, is_fearless_, is_healthy_; + t_string traits_description_; + int unit_value_; + gamemap::location goto_, interrupted_move_; + bool flying_, is_fearless_, is_healthy_; // std::map movement_costs_, movement_costs_b_; // std::map defense_mods_, defense_mods_b_; - string_map modification_descriptions_; - // animations - std::vector defensive_animations_; - std::vector teleport_animations_; - std::multimap extra_animations_; - std::vector death_animations_; - std::vector movement_animations_; - std::vector standing_animations_; - std::vector leading_animations_; - std::vector healing_animations_; - std::vector victory_animations_; - std::vector recruit_animations_; - std::vector idle_animations_; - std::vector levelin_animations_; - std::vector levelout_animations_; - std::vector healed_animations_; - std::vector poison_animations_; - unit_animation *anim_; - int next_idling_; - int frame_begin_time_; + string_map modification_descriptions_; + // animations + std::vector defensive_animations_; + std::vector teleport_animations_; + std::multimap extra_animations_; + std::vector death_animations_; + std::vector movement_animations_; + std::vector standing_animations_; + std::vector leading_animations_; + std::vector healing_animations_; + std::vector victory_animations_; + std::vector recruit_animations_; + std::vector idle_animations_; + std::vector levelin_animations_; + std::vector levelout_animations_; + std::vector healed_animations_; + std::vector poison_animations_; + unit_animation *anim_; + int next_idling_; + int frame_begin_time_; - double offset_; - int unit_halo_; - int unit_anim_halo_; - bool getsHit_; - bool refreshing_; // avoid infinite recursion - bool hidden_; - bool draw_bars_; + double offset_; + int unit_halo_; + int unit_anim_halo_; + bool getsHit_; + bool refreshing_; // avoid infinite recursion + bool hidden_; + bool draw_bars_; - config modifications_; + config modifications_; - friend void attack_type::set_specials_context(const gamemap::location& loc,const unit& un) const; - const game_data* gamedata_; - const unit_map* units_; - const gamemap* map_; - const gamestatus* gamestatus_; - const std::vector* teams_; + friend void attack_type::set_specials_context(const gamemap::location& loc,const unit& un) const; + const game_data* gamedata_; + const unit_map* units_; + const gamemap* map_; + const gamestatus* gamestatus_; + const std::vector* teams_; - // hold the visibility status cache for a unit, mutable since it's a cache - mutable std::map invisibility_cache_; + // hold the visibility status cache for a unit, mutable since it's a cache + mutable std::map invisibility_cache_; - // 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.) - void clear_visibility_cache() const { invisibility_cache_.clear(); } + // 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.) + void clear_visibility_cache() const { invisibility_cache_.clear(); } }; //object which temporarily resets a unit's movement