The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Static Public Member Functions | Static Private Attributes | List of all members
ai::actions Class Reference

#include <actions.hpp>

Static Public Member Functions

static attack_result_ptr execute_attack_action (side_number side, bool execute, const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon, double aggression, const unit_advancements_aspect &advancements=unit_advancements_aspect())
 Ask the game to attack an enemy defender using our unit attacker from attackers current location,. More...
 
static move_result_ptr execute_move_action (side_number side, bool execute, const map_location &from, const map_location &to, bool remove_movement, bool unreach_is_ok=false)
 Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial move. More...
 
static recall_result_ptr execute_recall_action (side_number side, bool execute, const std::string &unit_id, const map_location &where, const map_location &from)
 Ask the game to recall a unit for us on specified location. More...
 
static recruit_result_ptr execute_recruit_action (side_number side, bool execute, const std::string &unit_name, const map_location &where, const map_location &from)
 Ask the game to recruit a unit for us on specified location. More...
 
static stopunit_result_ptr execute_stopunit_action (side_number side, bool execute, const map_location &unit_location, bool remove_movement, bool remove_attacks)
 Ask the game to remove unit movements and/or attack. More...
 
static synced_command_result_ptr execute_synced_command_action (side_number side, bool execute, const std::string &lua_code, const map_location &location)
 Ask the game to run Lua code. More...
 
static const std::stringget_error_name (int error_code)
 get human-readable name of the error by code. More...
 

Static Private Attributes

static std::map< int, std::stringerror_names_
 

Detailed Description

Definition at line 315 of file actions.hpp.

Member Function Documentation

attack_result_ptr ai::actions::execute_attack_action ( side_number  side,
bool  execute,
const map_location attacker_loc,
const map_location defender_loc,
int  attacker_weapon,
double  aggression,
const unit_advancements_aspect advancements = unit_advancements_aspect() 
)
static

Ask the game to attack an enemy defender using our unit attacker from attackers current location,.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
attacker_loclocation of attacker
defender_loclocation of defender
attacker_weaponweapon of attacker
aggressionaggression of attacker, is used to determine attacker's weapon if it is not specified
Return values
possibleresult: ok
possibleresult: something wrong
possibleresult: attacker and/or defender are invalid
possibleresult: attacker doesn't have the specified weapon

Definition at line 994 of file actions.cpp.

Referenced by ai::ai_attack(), ai::readonly_context_impl::check_attack_action(), and ai::readwrite_context_impl::execute_attack_action().

move_result_ptr ai::actions::execute_move_action ( side_number  side,
bool  execute,
const map_location from,
const map_location to,
bool  remove_movement,
bool  unreach_is_ok = false 
)
static

Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial move.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
fromlocation of our unit
towhere to move
remove_movementset unit movement to 0 in case of successful move
Return values
possibleresult: ok
possibleresult: something wrong
possibleresult: move is interrupted
possibleresult: move is impossible

Definition at line 1007 of file actions.cpp.

Referenced by ai::ai_move(), ai::readonly_context_impl::check_move_action(), and ai::readwrite_context_impl::execute_move_action().

recall_result_ptr ai::actions::execute_recall_action ( side_number  side,
bool  execute,
const std::string unit_id,
const map_location where,
const map_location from 
)
static

Ask the game to recall a unit for us on specified location.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
unit_idthe id of the unit to be recalled.
wherelocation where the unit is to be recalled.
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultleader not on keep
possible_resultno free space on keep
possible_resultnot enough gold

Definition at line 1019 of file actions.cpp.

Referenced by ai::ai_recall(), ai::readonly_context_impl::check_recall_action(), and ai::readwrite_context_impl::execute_recall_action().

recruit_result_ptr ai::actions::execute_recruit_action ( side_number  side,
bool  execute,
const std::string unit_name,
const map_location where,
const map_location from 
)
static

Ask the game to recruit a unit for us on specified location.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
unit_namethe name of the unit to be recruited.
wherelocation where the unit is to be recruited.
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultleader not on keep
possible_resultno free space on keep
possible_resultnot enough gold

Definition at line 1030 of file actions.cpp.

Referenced by ai::ai_recruit(), ai::readonly_context_impl::check_recruit_action(), and ai::readwrite_context_impl::execute_recruit_action().

stopunit_result_ptr ai::actions::execute_stopunit_action ( side_number  side,
bool  execute,
const map_location unit_location,
bool  remove_movement,
bool  remove_attacks 
)
static

Ask the game to remove unit movements and/or attack.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
unit_locationthe location of our unit
remove_movementset remaining movements to 0
remove_attacksset remaining attacks to 0
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultnothing to do

Definition at line 1041 of file actions.cpp.

Referenced by ai::ai_stopunit_select(), ai::readonly_context_impl::check_stopunit_action(), ai::move_result::do_execute(), and ai::readwrite_context_impl::execute_stopunit_action().

synced_command_result_ptr ai::actions::execute_synced_command_action ( side_number  side,
bool  execute,
const std::string lua_code,
const map_location location 
)
static

Ask the game to run Lua code.

Parameters
sidethe side which tries to execute the move
executeshould move be actually executed or not
lua_codethe code to be run
locationlocation to be passed to the code as x1/y1
Return values
possibleresult: ok
possible_resultsomething wrong
possible_resultnothing to do

Definition at line 1052 of file actions.cpp.

Referenced by ai::ai_synced_command(), ai::readonly_context_impl::check_synced_command_action(), and ai::readwrite_context_impl::execute_synced_command_action().

const std::string & ai::actions::get_error_name ( int  error_code)
static

get human-readable name of the error by code.

Parameters
error_codeerror code.
Return values
resultthe name of the error.

Definition at line 1062 of file actions.cpp.

References ai::action_result::AI_ACTION_FAILURE, ai::action_result::AI_ACTION_STARTED, ai::action_result::AI_ACTION_SUCCESS, ai::move_result::E_AMBUSHED, ai::attack_result::E_ATTACKER_AND_DEFENDER_NOT_ADJACENT, ai::recall_result::E_BAD_RECALL_LOCATION, ai::recruit_result::E_BAD_RECRUIT_LOCATION, ai::attack_result::E_EMPTY_ATTACKER, ai::attack_result::E_EMPTY_DEFENDER, ai::move_result::E_EMPTY_MOVE, ai::move_result::E_FAILED_TELEPORT, ai::attack_result::E_INCAPACITATED_ATTACKER, ai::attack_result::E_INCAPACITATED_DEFENDER, ai::move_result::E_INCAPACITATED_UNIT, ai::stopunit_result::E_INCAPACITATED_UNIT, ai::recall_result::E_LEADER_NOT_ON_KEEP, ai::recruit_result::E_LEADER_NOT_ON_KEEP, ai::attack_result::E_NO_ATTACKS_LEFT, ai::recall_result::E_NO_GOLD, ai::recruit_result::E_NO_GOLD, ai::recall_result::E_NO_LEADER, ai::recruit_result::E_NO_LEADER, ai::move_result::E_NO_ROUTE, ai::move_result::E_NO_UNIT, ai::stopunit_result::E_NO_UNIT, ai::recall_result::E_NOT_AVAILABLE_FOR_RECALLING, ai::recruit_result::E_NOT_AVAILABLE_FOR_RECRUITING, ai::attack_result::E_NOT_ENEMY_DEFENDER, ai::attack_result::E_NOT_OWN_ATTACKER, ai::move_result::E_NOT_OWN_UNIT, ai::stopunit_result::E_NOT_OWN_UNIT, ai::move_result::E_NOT_REACHED_DESTINATION, ai::attack_result::E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON, ai::recruit_result::E_UNKNOWN_OR_DUMMY_UNIT_TYPE, ai::attack_result::E_WRONG_ATTACKER_WEAPON, ERR_AI_ACTIONS, error_names_, and i.

Referenced by ai::action_result::set_error(), and ai::transform_ai_action().

Member Data Documentation

std::map< int, std::string > ai::actions::error_names_
staticprivate

Definition at line 448 of file actions.hpp.

Referenced by get_error_name().


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