Structure describing the statistics of a unit involved in the battle. More...
#include <attack.hpp>
Public Member Functions | |
battle_context_unit_stats (const unit &u, const map_location &u_loc, int u_attack_num, bool attacking, const unit &opp, const map_location &opp_loc, const attack_type *opp_weapon, const unit_map &units) | |
battle_context_unit_stats (const unit_type *u_type, const attack_type *att_weapon, bool attacking, const unit_type *opp_type, const attack_type *opp_weapon, unsigned int opp_terrain_defense, int lawful_bonus=0) | |
Used by AI for combat analysis. More... | |
~battle_context_unit_stats () | |
unsigned int | calc_blows (unsigned new_hp) const |
Calculates the number of blows we would have if we had new_hp. More... | |
Public Attributes | |
const attack_type * | weapon |
The weapon used by the unit to attack the opponent, or nullptr if there is none. More... | |
int | attack_num |
Index into unit->attacks() or -1 for none. More... | |
bool | is_attacker |
True if the unit is the attacker. More... | |
bool | is_poisoned |
True if the unit is poisoned at the beginning of the battle. More... | |
bool | is_slowed |
True if the unit is slowed at the beginning of the battle. More... | |
bool | slows |
Attack slows opponent when it hits. More... | |
bool | drains |
Attack drains opponent when it hits. More... | |
bool | petrifies |
Attack petrifies opponent when it hits. More... | |
bool | plagues |
Attack turns opponent into a zombie when fatal. More... | |
bool | poisons |
Attack poisons opponent when it hits. More... | |
bool | backstab_pos |
True if the attacker is in position to backstab the defender (this is used to determine whether to apply the backstab bonus in case the attacker has backstab). More... | |
bool | swarm |
Attack has swarm special. More... | |
bool | firststrike |
Attack has firststrike special. More... | |
bool | disable |
Attack has disable special. More... | |
unsigned int | experience |
unsigned int | max_experience |
unsigned int | level |
unsigned int | rounds |
Berserk special can force us to fight more than one round. More... | |
unsigned int | hp |
Hitpoints of the unit at the beginning of the battle. More... | |
unsigned int | max_hp |
Maximum hitpoints of the unit. More... | |
unsigned int | chance_to_hit |
Effective chance to hit as a percentage (all factors accounted for). More... | |
int | damage |
Effective damage of the weapon (all factors accounted for). More... | |
int | slow_damage |
Effective damage if unit becomes slowed (== damage, if already slowed) More... | |
int | drain_percent |
Percentage of damage recovered as health. More... | |
int | drain_constant |
Base HP drained regardless of damage dealt. More... | |
unsigned int | num_blows |
Effective number of blows, takes swarm into account. More... | |
unsigned int | swarm_min |
Minimum number of blows with swarm (equal to num_blows if swarm isn't used). More... | |
unsigned int | swarm_max |
Maximum number of blows with swarm (equal to num_blows if swarm isn't used). More... | |
std::string | plague_type |
The plague type used by the attack, if any. More... | |
Structure describing the statistics of a unit involved in the battle.
Definition at line 49 of file attack.hpp.
battle_context_unit_stats::battle_context_unit_stats | ( | const unit & | u, |
const map_location & | u_loc, | ||
int | u_attack_num, | ||
bool | attacking, | ||
const unit & | opp, | ||
const map_location & | opp_loc, | ||
const attack_type * | opp_weapon, | ||
const unit_map & | units | ||
) |
Definition at line 68 of file attack.cpp.
References attack_type::accuracy(), unit::alignment(), attack_num, unit::attacks(), backstab_check(), backstab_pos, unit_type::base_id(), calc_blows(), chance_to_hit, combat_modifier(), damage, unit::damage_from(), unit::defense_modifier(), disable, distance_between(), drain_constant, drain_percent, drains, unit_ability_list::empty(), firststrike, unit_ability_list::front(), resources::gameboard, unit_abilities::effect::get_composite_value(), attack_type::get_special_bool(), attack_type::get_specials(), unit::get_state(), unit_ability_list::highest(), unit::hitpoints(), hp, is_attacker, unit::is_fearless(), is_slowed, LOG_CF, unit::max_hitpoints(), attack_type::max_range(), attack_type::min_range(), attack_type::modified_attacks(), attack_type::modified_damage(), num_blows, attack_type::parry(), petrifies, plague_type, plagues, poisons, round_damage(), rounds, attack_type::set_specials_context(), slow_damage, slows, unit::STATE_POISONED, swarm, swarm_max, swarm_min, resources::teams, unit::type(), unit::undead_variation(), under_leadership(), resources::units, map_location::valid(), and weapon.
battle_context_unit_stats::battle_context_unit_stats | ( | const unit_type * | u_type, |
const attack_type * | att_weapon, | ||
bool | attacking, | ||
const unit_type * | opp_type, | ||
const attack_type * | opp_weapon, | ||
unsigned int | opp_terrain_defense, | ||
int | lawful_bonus = 0 |
||
) |
Used by AI for combat analysis.
Definition at line 202 of file attack.cpp.
References attack_type::accuracy(), backstab_pos, unit_type::base_id(), calc_blows(), chance_to_hit, damage, disable, drain_constant, drain_percent, drains, unit_ability_list::empty(), unit_type::experience_needed(), firststrike, unit_ability_list::front(), generic_combat_modifier(), unit_abilities::effect::get_composite_value(), attack_type::get_special_bool(), attack_type::get_specials(), unit_ability_list::highest(), unit_type::hitpoints(), hp, unit_type::level(), max_experience, max_hp, attack_type::modified_attacks(), attack_type::modified_damage(), unit_type::musthave_status(), map_location::null_location(), num_blows, attack_type::parry(), petrifies, plague_type, plagues, poisons, unit_type::resistance_against(), round_damage(), rounds, attack_type::set_specials_context(), slow_damage, slows, swarm, swarm_max, swarm_min, attack_type::type(), unit_type::undead_variation(), and weapon.
|
inline |
Definition at line 98 of file attack.hpp.
|
inline |
Calculates the number of blows we would have if we had new_hp.
Definition at line 103 of file attack.hpp.
References swarm_blows().
Referenced by battle_context_unit_stats(), and combatant::split_summary().
int battle_context_unit_stats::attack_num |
Index into unit->attacks() or -1 for none.
Definition at line 52 of file attack.hpp.
Referenced by events::mouse_handler::attack_enemy_(), battle_context_unit_stats(), battle_context::choose_attacker_weapon(), battle_context::choose_defender_weapon(), game_logic::attack_callable::defender_weapon(), ai::attack_result::do_execute(), luaW_pushsimweapon(), and game_logic::attack_callable::weapon().
bool battle_context_unit_stats::backstab_pos |
True if the attacker is in position to backstab the defender (this is used to determine whether to apply the backstab bonus in case the attacker has backstab).
Definition at line 61 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_prediction_pane::get_unit_strings(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::chance_to_hit |
Effective chance to hit as a percentage (all factors accounted for).
Definition at line 74 of file attack.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context_unit_stats(), battle_context::choose_defender_weapon(), battle_prediction_pane::get_unit_strings(), luaW_pushsimweapon(), gui2::set_weapon_info(), and unit_weapons().
int battle_context_unit_stats::damage |
Effective damage of the weapon (all factors accounted for).
Definition at line 75 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_defender_weapon(), battle_prediction_pane::get_unit_strings(), luaW_pushsimweapon(), gui2::set_weapon_info(), and unit_weapons().
bool battle_context_unit_stats::disable |
Attack has disable special.
Definition at line 67 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_attacker_weapon(), and battle_context::choose_defender_weapon().
int battle_context_unit_stats::drain_constant |
Base HP drained regardless of damage dealt.
Definition at line 78 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
int battle_context_unit_stats::drain_percent |
Percentage of damage recovered as health.
Definition at line 77 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
bool battle_context_unit_stats::drains |
Attack drains opponent when it hits.
Definition at line 57 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::experience |
Definition at line 68 of file attack.hpp.
bool battle_context_unit_stats::firststrike |
Attack has firststrike special.
Definition at line 66 of file attack.hpp.
Referenced by battle_context_unit_stats(), combatant::fight(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::hp |
Hitpoints of the unit at the beginning of the battle.
Definition at line 72 of file attack.hpp.
Referenced by battle_context_unit_stats(), combatant::combatant(), and battle_prediction_pane::get_hp_distrib_surface().
bool battle_context_unit_stats::is_attacker |
True if the unit is the attacker.
Definition at line 53 of file attack.hpp.
Referenced by battle_context_unit_stats(), and battle_prediction_pane::get_unit_strings().
bool battle_context_unit_stats::is_poisoned |
True if the unit is poisoned at the beginning of the battle.
Definition at line 54 of file attack.hpp.
Referenced by ai::attack_analysis::analyze(), and combatant::combatant().
bool battle_context_unit_stats::is_slowed |
True if the unit is slowed at the beginning of the battle.
Definition at line 55 of file attack.hpp.
Referenced by battle_context_unit_stats(), combatant::combatant(), and battle_prediction_pane::get_unit_strings().
unsigned int battle_context_unit_stats::level |
Definition at line 69 of file attack.hpp.
Referenced by events::mouse_handler::attack_enemy_().
unsigned int battle_context_unit_stats::max_experience |
Definition at line 68 of file attack.hpp.
Referenced by battle_context_unit_stats().
unsigned int battle_context_unit_stats::max_hp |
Maximum hitpoints of the unit.
Definition at line 73 of file attack.hpp.
Referenced by combatant::average_hp(), battle_context_unit_stats(), combatant::combatant(), and combatant::split_summary().
unsigned int battle_context_unit_stats::num_blows |
Effective number of blows, takes swarm into account.
Definition at line 79 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_defender_weapon(), combatant::fight(), battle_prediction_pane::get_unit_strings(), luaW_pushsimweapon(), combatant::split_summary(), and unit_weapons().
bool battle_context_unit_stats::petrifies |
Attack petrifies opponent when it hits.
Definition at line 58 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_prediction_pane::get_hp_distrib_surface(), and luaW_pushsimweapon().
std::string battle_context_unit_stats::plague_type |
The plague type used by the attack, if any.
Definition at line 83 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
bool battle_context_unit_stats::plagues |
Attack turns opponent into a zombie when fatal.
Definition at line 59 of file attack.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context_unit_stats(), and luaW_pushsimweapon().
bool battle_context_unit_stats::poisons |
Attack poisons opponent when it hits.
Definition at line 60 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::rounds |
Berserk special can force us to fight more than one round.
Definition at line 71 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
int battle_context_unit_stats::slow_damage |
Effective damage if unit becomes slowed (== damage, if already slowed)
Definition at line 76 of file attack.hpp.
Referenced by battle_context_unit_stats().
bool battle_context_unit_stats::slows |
Attack slows opponent when it hits.
Definition at line 56 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
bool battle_context_unit_stats::swarm |
Attack has swarm special.
Definition at line 65 of file attack.hpp.
Referenced by battle_context_unit_stats().
unsigned int battle_context_unit_stats::swarm_max |
Maximum number of blows with swarm (equal to num_blows if swarm isn't used).
Definition at line 81 of file attack.hpp.
Referenced by battle_context_unit_stats(), and combatant::split_summary().
unsigned int battle_context_unit_stats::swarm_min |
Minimum number of blows with swarm (equal to num_blows if swarm isn't used).
Definition at line 80 of file attack.hpp.
Referenced by battle_context_unit_stats(), and combatant::split_summary().
const attack_type* battle_context_unit_stats::weapon |
The weapon used by the unit to attack the opponent, or nullptr if there is none.
Definition at line 51 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_prediction_pane::battle_prediction_pane(), battle_prediction_pane::get_unit_strings(), luaW_pushsimweapon(), gui2::set_weapon_info(), and unit_weapons().