Various functions that implement attacks and attack calculations. More...
#include "attack_prediction.hpp"#include "units/ptr.hpp"#include "units/unit_alignments.hpp"#include "utils/optional_fwd.hpp"#include "utils/math.hpp"#include <vector>Go to the source code of this file.
Classes | |
| struct | battle_context_unit_stats |
| Structure describing the statistics of a unit involved in the battle. More... | |
| class | battle_context |
| Computes the statistics of a battle between an attacker and a defender unit. More... | |
Namespaces | |
| namespace | randomness |
| namespace | biased_rng |
Functions | |
| bool | biased_rng::enabled () |
| Returns true if the current game uses the biased random mode with a local RNG. | |
| int | biased_rng::roll_credit (randomness::rng &rng) |
| Rolls the credit a combatant starts a fight with. | |
| bool | biased_rng::roll_hit (randomness::rng &rng, int strikes_left, int chance_to_hit, int &credit) |
| Rolls one strike. | |
| unsigned | swarm_blows (unsigned min_blows, unsigned max_blows, unsigned hp, unsigned max_hp) |
| Calculates the number of blows resulting from swarm. | |
| void | attack_unit (const map_location &attacker, const map_location &defender, int attack_with, int defend_with, bool update_display=true) |
| Performs an attack. | |
| void | attack_unit_and_advance (const map_location &attacker, const map_location &defender, int attack_with, int defend_with, bool update_display=true) |
| Performs an attack, and advanced the units afterwards. | |
| int | under_leadership (const unit &u, const map_location &loc) |
| Tests if the unit at loc is currently affected by leadership. | |
| int | under_leadership (const unit &u, const specials_context_t &loc) |
| int | combat_modifier (const unit_map &units, const gamemap &map, const map_location &loc, unit_alignments::type alignment, bool is_fearless) |
| Returns the amount that a unit's damage should be multiplied by due to the current time of day. | |
| int | combat_modifier (const time_of_day &effective_tod, unit_alignments::type alignment, bool is_fearless) |
| Returns the amount that a unit's damage should be multiplied by due to the current time of day. | |
| int | generic_combat_modifier (int lawful_bonus, unit_alignments::type alignment, bool is_fearless, int max_liminal_bonus) |
| Returns the amount that a unit's damage should be multiplied by due to a given lawful_bonus. | |
| bool | backstab_check (const map_location &attacker_loc, const map_location &defender_loc, const unit_map &units, const std::vector< team > &teams) |
| Function to check if an attack will satisfy the requirements for backstab. | |
Various functions that implement attacks and attack calculations.
Unit advancements are also included, as they usually occur as a result of combat.
Definition in file attack.hpp.
| void attack_unit | ( | const map_location & | attacker, |
| const map_location & | defender, | ||
| int | attack_with, | ||
| int | defend_with, | ||
| bool | update_display = true |
||
| ) |
Performs an attack.
Definition at line 1475 of file attack.cpp.
References dummy.
Referenced by attack_unit_and_advance(), and ai::simulated_attack().
| void attack_unit_and_advance | ( | const map_location & | attacker, |
| const map_location & | defender, | ||
| int | attack_with, | ||
| int | defend_with, | ||
| bool | update_display = true |
||
| ) |
Performs an attack, and advanced the units afterwards.
Definition at line 1485 of file attack.cpp.
References advance_unit_at(), attack_unit(), unit_map::find(), resources::gameboard, and game_board::units().
Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().
| bool backstab_check | ( | const map_location & | attacker_loc, |
| const map_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 1566 of file attack.cpp.
References unit_map::end(), unit_map::find(), get_adjacent_tiles(), and i.
Referenced by ai::ai_default_rca::aspect_attacks_base::do_attack_analysis().
| int combat_modifier | ( | const time_of_day & | effective_tod, |
| unit_alignments::type | alignment, | ||
| bool | is_fearless | ||
| ) |
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
Definition at line 1529 of file attack.cpp.
References generic_combat_modifier(), tod_manager::get_max_liminal_bonus(), time_of_day::lawful_bonus, and resources::tod_manager.
| int combat_modifier | ( | const unit_map & | units, |
| const gamemap & | map, | ||
| const map_location & | loc, | ||
| unit_alignments::type | alignment, | ||
| bool | is_fearless | ||
| ) |
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
Definition at line 1518 of file attack.cpp.
References combat_modifier(), tod_manager::get_illuminated_time_of_day(), loc, and resources::tod_manager.
Referenced by attack_info(), battle_context_unit_stats::battle_context_unit_stats(), combat_modifier(), wfl::gamestate::DEFINE_WFL_FUNCTION(), gui2::dialogs::attack_predictions::set_data(), and unit_alignment().
| int generic_combat_modifier | ( | int | lawful_bonus, |
| unit_alignments::type | alignment, | ||
| bool | is_fearless, | ||
| int | max_liminal_bonus | ||
| ) |
Returns the amount that a unit's damage should be multiplied by due to a given lawful_bonus.
Definition at line 1538 of file attack.cpp.
Referenced by battle_context_unit_stats::battle_context_unit_stats(), tod_manager::calculate_best_liminal_bonus(), combat_modifier(), help::generate_time_of_day_topics(), time_of_day_at(), and unit_box_at().
|
inline |
Calculates the number of blows resulting from swarm.
Definition at line 61 of file attack.hpp.
Referenced by attack_info(), and battle_context_unit_stats::calc_blows().
| int under_leadership | ( | const unit & | u, |
| const map_location & | loc | ||
| ) |
Tests if the unit at loc is currently affected by leadership.
(i.e. has a higher-level unit with the 'leadership' ability next to it).
Returns the bonus percentage (possibly 0 if there's no leader adjacent).
Definition at line 1504 of file attack.cpp.
References unit_abilities::EFFECT_CUMULABLE, unit::get_abilities(), unit_abilities::effect::get_composite_value(), and loc.
Referenced by attack_info(), battle_context_unit_stats::battle_context_unit_stats(), and ai::ai_default_rca::aspect_attacks_base::do_attack_analysis().
| int under_leadership | ( | const unit & | u, |
| const specials_context_t & | loc | ||
| ) |
Definition at line 1511 of file attack.cpp.
References unit_abilities::EFFECT_CUMULABLE, specials_context_t::get_abilities_weapons(), and unit_abilities::effect::get_composite_value().