#include "actions.hpp"
#include "attack_prediction.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "game_events.hpp"
#include "game_preferences.hpp"
#include "gamestatus.hpp"
#include "gettext.hpp"
#include "halo.hpp"
#include "hotkeys.hpp"
#include "log.hpp"
#include "menu_events.hpp"
#include "mouse_events.hpp"
#include "pathfind.hpp"
#include "random.hpp"
#include "replay.hpp"
#include "sound.hpp"
#include "statistics.hpp"
#include "unit_abilities.hpp"
#include "unit_display.hpp"
#include "wml_exception.hpp"
#include "wml_separators.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
#include <cassert>
Go to the source code of this file.
Namespaces | |
namespace | victory_conditions |
Classes | |
struct | castle_cost_calculator |
Defines | |
#define | DBG_NG LOG_STREAM(debug, engine) |
#define | LOG_NG LOG_STREAM(info, engine) |
#define | ERR_NG LOG_STREAM(err, engine) |
Functions | |
void | victory_conditions::set_victory_when_enemies_defeated (const bool on) |
static bool | victory_conditions::victory_when_enemies_defeated () |
void | victory_conditions::set_carryover_percentage (const int percentage) |
static int | victory_conditions::get_carryover_percentage () |
void | victory_conditions::set_carryover_add (const bool add) |
static bool | victory_conditions::get_carryover_add () |
bool | can_recruit_on (const gamemap &map, const gamemap::location &leader, const gamemap::location loc) |
std::string | recruit_unit (const gamemap &map, const int side, unit_map &units, unit new_unit, gamemap::location &recruit_location, const bool is_recall, const bool show, const bool need_castle, const bool full_movement, const bool wml_triggered) |
Function which recruits a unit into the game. | |
gamemap::location | under_leadership (const unit_map &units, const gamemap::location &loc, int *bonus) |
function which tests if the unit at loc is currently affected by leadership. | |
static std::string | unit_dump (std::pair< gamemap::location, unit > const &u) |
int | village_owner (const gamemap::location &loc, const std::vector< team > &teams) |
Given the location of a village, will return the 0-based index of the team that currently owns it, and -1 if it is unowned. | |
bool | get_village (const gamemap::location &loc, game_display &disp, std::vector< team > &teams, size_t team_num, const unit_map &units, int *action_timebonus) |
Makes it so the village at the given location is owned by the given 0-based team number. | |
unit_map::iterator | find_leader (unit_map &units, int side) |
Given the 1-based side, will find the leader of that side, and return an iterator to the leader. | |
unit_map::const_iterator | find_leader (const unit_map &units, int side) |
void | reset_resting (unit_map &units, unsigned int side) |
Resets resting for all units on this side: should be called after calculate_healing(). | |
void | calculate_healing (game_display &disp, const gamemap &map, unit_map &units, unsigned int side, const std::vector< team > &teams, bool update_display) |
Calculates healing for all units for the given side. | |
unit | get_advanced_unit (unit_map &units, const gamemap::location &loc, const std::string &advance_to) |
Function which, given the location of a unit that is advancing, and the name of the unit it is advancing to, Will return the advanced version of this unit. | |
void | advance_unit (unit_map &units, gamemap::location loc, const std::string &advance_to) |
Function which will advance the unit at loc to 'advance_to'. | |
void | check_victory (unit_map &units, std::vector< team > &teams, display &disp) |
Checks to see if a side has won, and will throw an end_level_exception if one has. | |
time_of_day | timeofday_at (const gamestatus &status, const unit_map &units, const gamemap::location &loc, const gamemap &map) |
Gets the time of day at a certain tile. | |
int | combat_modifier (const gamestatus &status, const unit_map &units, const gamemap::location &loc, unit_type::ALIGNMENT alignment, bool is_fearless, const gamemap &map) |
Returns the amount that a unit's damage should be multiplied by due to the current time of day. | |
bool | clear_shroud_loc (const gamemap &map, team &tm, const gamemap::location &loc, std::vector< gamemap::location > *cleared) |
bool | clear_shroud_unit (const gamemap &map, const unit_map &units, const gamemap::location &loc, std::vector< team > &teams, int team, const std::set< gamemap::location > *known_units=NULL, std::set< gamemap::location > *seen_units=NULL, std::set< gamemap::location > *stoned_units=NULL) |
Returns true if some shroud is cleared. | |
void | recalculate_fog (const gamemap &map, unit_map &units, std::vector< team > &teams, int team) |
Function which recalculates the fog. | |
bool | clear_shroud (game_display &disp, const gamemap &map, unit_map &units, std::vector< team > &teams, int team) |
Function which will clear shroud away for the given 0-based team based on current unit positions. | |
size_t | move_unit (game_display *disp, const gamemap &map, unit_map &units, std::vector< team > &teams, std::vector< gamemap::location > route, replay *move_recorder, undo_list *undo_stack, gamemap::location *next_unit, bool continue_move, bool should_clear_shroud) |
function which moves a unit along the sequence of locations given by steps. | |
bool | unit_can_move (const gamemap::location &loc, const unit_map &units, const gamemap &map, const std::vector< team > &teams) |
Will return true iff the unit at 'loc' has any possible moves it can do (including attacking etc). | |
void | apply_shroud_changes (undo_list &undos, game_display *disp, const gamemap &map, unit_map &units, std::vector< team > &teams, int team) |
Function to apply pending shroud changes in the undo stack. | |
bool | backstab_check (const gamemap::location &attacker_loc, const gamemap::location &defender_loc, const unit_map &units, const std::vector< team > &teams) |
Function to check if an attack will satisfy the requirements for backstab. | |
Variables | |
static bool | victory_conditions::when_enemies_defeated = true |
static int | victory_conditions::carryover_percentage = 80 |
static bool | victory_conditions::carryover_add = false |
Definition in file actions.cpp.
#define DBG_NG LOG_STREAM(debug, engine) |
Definition at line 45 of file actions.cpp.
Referenced by game_config::add_color_info(), attack::attack(), check_victory(), default_map_generator::create_scenario(), default_map_generator::generate_map(), replay_controller::init_gui(), move_unit(), play_replay_level(), recruit_unit(), and write_player().
#define ERR_NG LOG_STREAM(err, engine) |
Definition at line 47 of file actions.cpp.
Referenced by scoped_recall_unit::activate(), scoped_xy_unit::activate(), game_config::add_color_info(), events::chat_handler::change_logging(), default_generate_map(), terrain_filter::get_locations(), vconfig::get_parsed_config(), get_player_info(), mp::level_to_gamestate(), terrain_filter::match(), terrain_builder::parse_mapstring(), events::menu_handler::recall(), events::menu_handler::recruit(), recruit_unit(), events::menu_handler::redo(), terrain_builder::replace_token(), terrain_builder::rotate_rule(), game_config::tc_info(), events::menu_handler::undo(), and variable_info::variable_info().
#define LOG_NG LOG_STREAM(info, engine) |
Definition at line 46 of file actions.cpp.
Referenced by advance_unit(), dialogs::animate_unit_advancement(), apply_shroud_changes(), attack::attack(), events::menu_handler::autosave(), cave_map_generator::cave_map_generator(), events::chat_handler::change_logging(), playsingle_controller::check_time_over(), check_victory(), unit_map::clean_invalid(), commit_new_handlers(), commit_wmi_commands(), cave_map_generator::create_scenario(), player_info::debug(), default_generate_map(), play_controller::finish_turn(), attack::fire_event(), generate_height_map(), generate_name(), generate_river_internal(), get_player_info(), play_controller::init(), playsingle_controller::init_gui(), play_controller::init_managers(), mp::level_to_gamestate(), playsingle_controller::linger(), playmp_controller::linger(), team::log_recruitable(), game_events::manager::manager(), play_controller::place_sides_in_preferred_locations(), playsingle_controller::play_ai_turn(), playmp_controller::play_network_turn(), playsingle_controller::play_scenario(), playsingle_controller::play_side(), playmp_controller::play_side(), playsingle_controller::play_turn(), playsingle_scenario(), game_events::pump(), events::menu_handler::recall(), recruit_unit(), remove_old_auto_saves(), show_intro(), show_intro_part(), team::team(), and team::team_info::team_info().
void advance_unit | ( | unit_map & | units, | |
gamemap::location | loc, | |||
const std::string & | advance_to | |||
) |
Function which will advance the unit at loc to 'advance_to'.
Definition at line 1723 of file actions.cpp.
References statistics::advance_unit(), unit_map::count(), preferences::encountered_units(), game_events::fire(), get_advanced_unit(), lg::info, LOG_NG, LOG_STREAM, unit_map::replace(), and unit::type_id().
void apply_shroud_changes | ( | undo_list & | undos, | |
game_display * | disp, | |||
const gamemap & | map, | |||
unit_map & | units, | |||
std::vector< team > & | teams, | |||
int | team | |||
) |
Function to apply pending shroud changes in the undo stack.
It needs tons of parameters because it calls clear_shroud(...) (see above)
Definition at line 2401 of file actions.cpp.
References unit_map::begin(), clear_shroud(), clear_shroud_unit(), game_display::draw(), unit_map::end(), unit_map::find(), display::invalidate_all(), display::invalidate_game_status(), game_display::invalidate_unit(), LOG_NG, game_events::pump(), game_events::raise(), recalculate_fog(), and display::recalculate_minimap().
Referenced by events::mouse_handler::clear_undo_stack(), events::menu_handler::clear_undo_stack(), play_controller::execute_command(), and move_unit().
bool backstab_check | ( | const gamemap::location & | attacker_loc, | |
const gamemap::location & | defender_loc, | |||
const unit_map & | units, | |||
const std::vector< team > & | teams | |||
) |
Function to check if an attack will satisfy the requirements for backstab.
Input:
Definition at line 2518 of file actions.cpp.
References unit_map::end(), unit_map::find(), and get_adjacent_tiles().
Referenced by ai::do_attack_analysis(), and battle_context::unit_stats::unit_stats().
void calculate_healing | ( | game_display & | disp, | |
const gamemap & | map, | |||
unit_map & | units, | |||
unsigned int | side, | |||
const std::vector< team > & | teams, | |||
bool | update_display | |||
) |
Calculates healing for all units for the given side.
Should be called at the beginning of a side's turn.
Definition at line 1551 of file actions.cpp.
References unit_abilities::effect::begin(), unit_map::begin(), unit_ability_list::cfgs, unit_abilities::effect::end(), unit_map::end(), unit_map::find(), unit_abilities::effect::get_composite_value(), gamemap::gives_healing(), game_display::invalidate_unit(), replay::is_skipping(), game_config::poison_amount, recorder, game_config::rest_heal_amount, utils::string_bool(), unit_display::unit_healing(), and game_display::viewing_team().
Referenced by play_controller::init_side().
bool can_recruit_on | ( | const gamemap & | map, | |
const gamemap::location & | leader, | |||
const gamemap::location | loc | |||
) |
Definition at line 106 of file actions.cpp.
References a_star_search(), gamemap::h(), gamemap::is_castle(), gamemap::on_board(), paths::route::steps, and gamemap::w().
Referenced by play_controller::in_context_menu(), and recruit_unit().
Checks to see if a side has won, and will throw an end_level_exception if one has.
Will also remove control of villages from sides with dead leaders.
Definition at line 1742 of file actions.cpp.
References unit_map::begin(), DBG_NG, DEFEAT, unit_map::end(), game_events::fire(), victory_conditions::get_carryover_add(), victory_conditions::get_carryover_percentage(), display::invalidate_all(), is_observer(), LOG_NG, non_interactive(), VICTORY, and victory_conditions::victory_when_enemies_defeated().
Referenced by ai_interface::attack_enemy(), events::mouse_handler::attack_enemy_(), do_replay_handle(), and playsingle_controller::play_turn().
bool clear_shroud | ( | game_display & | disp, | |
const gamemap & | map, | |||
unit_map & | units, | |||
std::vector< team > & | teams, | |||
int | team | |||
) |
Function which will clear shroud away for the given 0-based team based on current unit positions.
Returns true if some shroud is actually cleared away.
Definition at line 1990 of file actions.cpp.
References unit_map::begin(), clear_shroud_unit(), unit_map::end(), display::labels(), game_events::pump(), recalculate_fog(), and map_labels::recalculate_shroud().
Referenced by apply_shroud_changes(), do_replay_handle(), and events::mouse_handler::left_click().
bool @2::clear_shroud_loc | ( | const gamemap & | map, | |
team & | tm, | |||
const gamemap::location & | loc, | |||
std::vector< gamemap::location > * | cleared | |||
) | [static] |
Definition at line 1866 of file actions.cpp.
References team::clear_fog(), team::clear_shroud(), get_adjacent_tiles(), gamemap::h(), gamemap::on_board(), gamemap::w(), gamemap::location::x, and gamemap::location::y.
Referenced by clear_shroud_unit().
bool @2::clear_shroud_unit | ( | const gamemap & | map, | |
const unit_map & | units, | |||
const gamemap::location & | loc, | |||
std::vector< team > & | teams, | |||
int | team, | |||
const std::set< gamemap::location > * | known_units = NULL , |
|||
std::set< gamemap::location > * | seen_units = NULL , |
|||
std::set< gamemap::location > * | stoned_units = NULL | |||
) | [static] |
Returns true if some shroud is cleared.
seen_units will return new units that have been seen by this unit. If known_units is NULL, seen_units can be NULL and will not be changed.
Definition at line 1917 of file actions.cpp.
References clear_shroud_loc(), unit_map::end(), unit_map::find(), paths::routes, and utils::string_bool().
Referenced by apply_shroud_changes(), clear_shroud(), move_unit(), and recalculate_fog().
int combat_modifier | ( | const gamestatus & | status, | |
const unit_map & | units, | |||
const gamemap::location & | loc, | |||
unit_type::ALIGNMENT | alignment, | |||
bool | is_fearless, | |||
const gamemap & | map | |||
) |
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
Definition at line 1843 of file actions.cpp.
References unit_type::CHAOTIC, time_of_day::lawful_bonus, unit_type::NEUTRAL, and timeofday_at().
Referenced by battle_context::unit_stats::unit_stats().
unit_map::const_iterator find_leader | ( | const unit_map & | units, | |
int | side | |||
) |
unit_map::iterator find_leader | ( | unit_map & | units, | |
int | side | |||
) |
Given the 1-based side, will find the leader of that side, and return an iterator to the leader.
Definition at line 1522 of file actions.cpp.
References unit_map::begin(), and unit_map::end().
Referenced by ai::analyze_potential_recruit_movements(), ai::do_move(), ai::do_recruitment(), ai::find_threats(), get_village(), ai::get_villages(), ai::leader_can_reach_keep(), ai::move_leader_after_recruit(), ai::move_leader_to_goals(), ai::move_leader_to_keep(), turn_info::process_network_data(), and game_display::scroll_to_leader().
unit get_advanced_unit | ( | unit_map & | units, | |
const gamemap::location & | loc, | |||
const std::string & | advance_to | |||
) |
Function which, given the location of a unit that is advancing, and the name of the unit it is advancing to, Will return the advanced version of this unit.
(with traits and items retained).
Definition at line 1707 of file actions.cpp.
References unit::advance_to(), unit_map::end(), boost::foreach_detail_::end(), unit_map::find(), unit::get_experience(), unit::max_experience(), and unit_type_data::types().
Referenced by dialogs::advance_unit(), and advance_unit().
bool get_village | ( | const gamemap::location & | loc, | |
game_display & | disp, | |||
std::vector< team > & | teams, | |||
size_t | team_num, | |||
const unit_map & | units, | |||
int * | time_bonus = NULL | |||
) |
Makes it so the village at the given location is owned by the given 0-based team number.
Returns true if getting the village triggered a mutating event.
Definition at line 1482 of file actions.cpp.
References unit_map::end(), find_leader(), and game_display::invalidate().
Referenced by do_replay_handle(), ai::find_targets(), move_unit(), ai_interface::move_unit_partial(), events::menu_handler::redo(), and events::menu_handler::undo().
size_t move_unit | ( | game_display * | disp, | |
const gamemap & | map, | |||
unit_map & | units, | |||
std::vector< team > & | teams, | |||
std::vector< gamemap::location > | steps, | |||
replay * | move_recorder, | |||
undo_list * | undos, | |||
gamemap::location * | next_unit = NULL , |
|||
bool | continue_move = false , |
|||
bool | should_clear_shroud = true | |||
) |
function which moves a unit along the sequence of locations given by steps.
If the unit cannot make it completely along the path this turn, a goto order will be set. If move_recorder is not NULL, the move will be recorded in it. If undos is not NULL, undo information will be added.
Definition at line 2021 of file actions.cpp.
References _, unit_map::add(), replay::add_movement(), display::announce(), apply_shroud_changes(), team::auto_shroud_updates(), font::BAD_COLOUR, boost::foreach_detail_::begin(), unit_map::begin(), unit_ability_list::cfgs, clear_shroud_unit(), unit::clear_status_caches(), unit_map::count(), DBG_NG, game_display::draw(), unit_map::end(), enemy_zoc(), unit_map::extract(), unit_map::find(), team::fogged(), get_adjacent_tiles(), hotkey::get_hotkey(), hotkey::hotkey_item::get_name(), get_village(), font::GOOD_COLOUR, hotkey::HOTKEY_CONTINUE_MOVE, display::invalidate_all(), team::is_enemy(), gamemap::is_village(), lexical_cast(), loc, message, unit_display::move_unit(), font::NORMAL_COLOUR, hotkey::hotkey_item::null(), team::owns_village(), game_events::pump(), game_events::raise(), display::recalculate_minimap(), team::see(), tiles_adjacent(), team::uses_fog(), team::uses_shroud(), vgettext(), village_owner(), and vngettext().
Referenced by events::mouse_handler::move_unit_along_current_route(), and events::menu_handler::move_unit_to_loc().
void recalculate_fog | ( | const gamemap & | map, | |
unit_map & | units, | |||
std::vector< team > & | teams, | |||
int | team | |||
) |
Function which recalculates the fog.
Definition at line 1966 of file actions.cpp.
References unit_map::begin(), clear_shroud_unit(), unit_map::end(), and game_events::pump().
Referenced by playsingle_controller::after_human_turn(), apply_shroud_changes(), attack::attack(), clear_shroud(), events::console_handler::do_fog(), and attack::fire_event().
std::string recruit_unit | ( | const gamemap & | map, | |
const int | side, | |||
unit_map & | units, | |||
unit | new_unit, | |||
gamemap::location & | recruit_location, | |||
const bool | is_recall, | |||
const bool | show, | |||
const bool | need_castle, | |||
const bool | full_movement, | |||
const bool | wml_triggered | |||
) |
Function which recruits a unit into the game.
Definition at line 123 of file actions.cpp.
References _, unit_map::add(), unit_map::begin(), can_recruit_on(), cfg, unit_map::count(), DBG_NG, unit_map::end(), ERR_NG, unit_map::find(), find_vacant_tile(), game_events::fire(), get_checksum(), get_random_results(), unit::heal_all(), game_config::ignore_replay_errors, gamemap::is_keep(), LOG_NG, gamemap::on_board(), unit::set_attacks(), unit::set_movement(), set_random_results(), unit::total_movement(), unit::type_id(), unit_display::unit_recruited(), VACANT_ANY, VACANT_CASTLE, and unit::write().
Referenced by do_replay_handle(), events::menu_handler::recall(), ai_interface::recruit(), and events::menu_handler::redo().
void reset_resting | ( | unit_map & | units, | |
unsigned int | side | |||
) |
Resets resting for all units on this side: should be called after calculate_healing().
Definition at line 1543 of file actions.cpp.
References unit_map::begin(), and unit_map::end().
Referenced by play_controller::init_side().
time_of_day timeofday_at | ( | const gamestatus & | status, | |
const unit_map & | units, | |||
const gamemap::location & | loc, | |||
const gamemap & | map | |||
) |
Gets the time of day at a certain tile.
Certain tiles may have a time of day that differs from 'the' time of day, if a unit that illuminates is in that tile or adjacent.
Definition at line 1811 of file actions.cpp.
References unit_map::end(), unit_map::find(), get_adjacent_tiles(), unit_abilities::effect::get_composite_value(), gamemap::get_terrain(), gamemap::get_terrain_info(), gamestatus::get_time_of_day(), unit_ability_list::highest(), and gamemap::location::valid().
Referenced by combat_modifier(), game_display::draw(), game_display::draw_report(), reports::generate_report(), and terrain_filter::match_internal().
gamemap::location under_leadership | ( | const unit_map & | units, | |
const gamemap::location & | loc, | |||
int * | bonus = NULL | |||
) |
function which tests if the unit at loc is currently affected by leadership.
(i.e. has a higher-level 'leadership' unit next to it). If it does, then the location of the leader unit will be returned, Otherwise gamemap::location::null_location will be returned. If 'bonus' is not NULL, the % bonus will be stored in it.
Definition at line 236 of file actions.cpp.
References unit_map::end(), unit_map::find(), unit_ability_list::highest(), and gamemap::location::null_location.
Referenced by unit_display::unit_attack(), and battle_context::unit_stats::unit_stats().
bool unit_can_move | ( | const gamemap::location & | loc, | |
const unit_map & | units, | |||
const gamemap & | map, | |||
const std::vector< team > & | teams | |||
) |
Will return true iff the unit at 'loc' has any possible moves it can do (including attacking etc).
Definition at line 2363 of file actions.cpp.
References unit_map::end(), unit_map::find(), get_adjacent_tiles(), team::is_enemy(), and gamemap::on_board().
Referenced by events::menu_handler::end_turn(), unit::redraw_unit(), and events::mouse_handler::unit_in_cycle().
static std::string unit_dump | ( | std::pair< gamemap::location, unit > const & | u | ) | [static] |
int village_owner | ( | const gamemap::location & | loc, | |
const std::vector< team > & | teams | |||
) |
Given the location of a village, will return the 0-based index of the team that currently owns it, and -1 if it is unowned.
Definition at line 1472 of file actions.cpp.
Referenced by ai::do_recruitment(), do_replay_handle(), reports::generate_report(), terrain_filter::match_internal(), move_unit(), and ai::rate_terrain().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |