The Battle for Wesnoth  1.19.7+dev
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)
 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::string & get_error_name (int error_code)
 get human-readable name of the error by code. More...
 

Static Private Attributes

static const std::map< int, std::string > error_names_
 

Detailed Description

Definition at line 311 of file actions.hpp.

Member Function Documentation

◆ execute_attack_action()

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 
)
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
possibleresults: ok, something wrong, attacker and/or defender are invalid, or attacker doesn't have the specified weapon

Definition at line 1030 of file actions.cpp.

References ai::execute_or_check().

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

◆ execute_move_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
unreach_is_okwhether it's okay for a destination to be unreachable
Return values
possibleresults: ok, something wrong, move is interrupted, or move is impossible

Definition at line 1042 of file actions.cpp.

References ai::execute_or_check().

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

◆ execute_recall_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.
fromthe location where the unit was recruited from.
Return values
possibleresults: ok, something wrong, leader not on keep, no free space on keep, or not enough gold

Definition at line 1054 of file actions.cpp.

References ai::execute_or_check().

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

◆ execute_recruit_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.
fromthe location where the unit was recruited from.
Return values
possibleresults: ok, something wrong, leader not on keep, no free space on keep, or not enough gold

Definition at line 1065 of file actions.cpp.

References ai::execute_or_check(), and unit_name().

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

◆ execute_stopunit_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
possibleresults: ok, something wrong, or nothing to do

Definition at line 1076 of file actions.cpp.

References ai::execute_or_check().

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().

◆ execute_synced_command_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
possibleresults: ok, something wrong, or nothing to do

Definition at line 1087 of file actions.cpp.

References ai::execute_or_check().

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

◆ get_error_name()

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 1097 of file actions.cpp.

References ERR_AI_ACTIONS, error_names_, and i.

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

Member Data Documentation

◆ error_names_

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

Definition at line 428 of file actions.hpp.

Referenced by get_error_name().


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