Structure describing the statistics of a unit involved in the battle. More...
#include <attack.hpp>
Public Member Functions | |
battle_context_unit_stats (nonempty_unit_const_ptr u, const map_location &u_loc, int u_attack_num, bool attacking, nonempty_unit_const_ptr opp, const map_location &opp_loc, const const_attack_ptr &opp_weapon) | |
battle_context_unit_stats (const unit_type *u_type, const_attack_ptr att_weapon, bool attacking, const unit_type *opp_type, const const_attack_ptr &opp_weapon, unsigned int opp_terrain_defense, int lawful_bonus=0) | |
Used by AI for combat analysis, and by statistics_dialog. 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 instead of the recorded hp. More... | |
Public Attributes | |
const_attack_ptr | 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 | 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 50 of file attack.hpp.
battle_context_unit_stats::battle_context_unit_stats | ( | nonempty_unit_const_ptr | u, |
const map_location & | u_loc, | ||
int | u_attack_num, | ||
bool | attacking, | ||
nonempty_unit_const_ptr | opp, | ||
const map_location & | opp_loc, | ||
const const_attack_ptr & | opp_weapon | ||
) |
Definition at line 76 of file attack.cpp.
References unit_ability::ability_cfg, unit::alignment(), attack_num, unit::attacks(), 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::get_state(), unit::hitpoints(), hp, unit::is_fearless(), is_slowed, gamemap::is_village(), LOG_CF, game_board::map(), unit::max_hitpoints(), num_blows, unit_type::parent_id(), petrifies, plague_type, plagues, poisons, round_damage(), rounds, slow_damage, slows, unit::STATE_POISONED, swarm, swarm_max, swarm_min, unit::type(), unit::undead_variation(), under_leadership(), and weapon.
battle_context_unit_stats::battle_context_unit_stats | ( | const unit_type * | u_type, |
const_attack_ptr | att_weapon, | ||
bool | attacking, | ||
const unit_type * | opp_type, | ||
const const_attack_ptr & | opp_weapon, | ||
unsigned int | opp_terrain_defense, | ||
int | lawful_bonus = 0 |
||
) |
Used by AI for combat analysis, and by statistics_dialog.
Definition at line 230 of file attack.cpp.
References unit_ability::ability_cfg, unit_type::alignment(), 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_type::hitpoints(), hp, level, unit_type::level(), max_experience, max_hp, unit_type::musthave_status(), map_location::null_location(), num_blows, unit_type::parent_id(), petrifies, plague_type, plagues, poisons, unit_type::resistance_against(), round_damage(), rounds, slow_damage, slows, swarm, swarm_max, swarm_min, unit_type::undead_variation(), and weapon.
|
inline |
Definition at line 99 of file attack.hpp.
|
inline |
Calculates the number of blows we would have if we had new_hp instead of the recorded hp.
Definition at line 104 of file attack.hpp.
References max_hp, swarm_blows(), swarm_max, and swarm_min.
Referenced by battle_context_unit_stats().
int battle_context_unit_stats::attack_num |
Index into unit->attacks() or -1 for none.
Definition at line 53 of file attack.hpp.
Referenced by events::mouse_handler::attack_enemy_(), battle_context_unit_stats(), wfl::attack_callable::defender_weapon(), ai::attack_result::do_execute(), luaW_pushsimweapon(), and wfl::attack_callable::weapon().
unsigned int battle_context_unit_stats::chance_to_hit |
Effective chance to hit as a percentage (all factors accounted for).
Definition at line 71 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_defender_weapon(), luaW_pushsimweapon(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::attack_predictions::set_data(), and unit_weapons().
int battle_context_unit_stats::damage |
Effective damage of the weapon (all factors accounted for).
Definition at line 72 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_defender_weapon(), luaW_pushsimweapon(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::attack_predictions::set_data(), and unit_weapons().
bool battle_context_unit_stats::disable |
Attack has disable special.
Definition at line 64 of file attack.hpp.
Referenced by battle_context_unit_stats(), and events::mouse_handler::fill_weapon_choices().
int battle_context_unit_stats::drain_constant |
Base HP drained regardless of damage dealt.
Definition at line 75 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 74 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 58 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::experience |
Definition at line 65 of file attack.hpp.
Referenced by combatant::fight().
bool battle_context_unit_stats::firststrike |
Attack has firststrike special.
Definition at line 63 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 69 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::better_combat(), combatant::combatant(), and gui2::dialogs::attack_predictions::draw_hp_graph().
bool battle_context_unit_stats::is_attacker |
True if the unit is the attacker.
Definition at line 54 of file attack.hpp.
Referenced by gui2::dialogs::attack_predictions::set_data().
bool battle_context_unit_stats::is_poisoned |
True if the unit is poisoned at the beginning of the battle.
Definition at line 55 of file attack.hpp.
Referenced by combatant::combatant().
bool battle_context_unit_stats::is_slowed |
True if the unit is slowed at the beginning of the battle.
Definition at line 56 of file attack.hpp.
Referenced by battle_context_unit_stats(), combatant::combatant(), and gui2::dialogs::attack_predictions::set_data().
unsigned int battle_context_unit_stats::level |
Definition at line 66 of file attack.hpp.
Referenced by events::mouse_handler::attack_enemy_(), battle_context_unit_stats(), and combatant::fight().
unsigned int battle_context_unit_stats::max_experience |
Definition at line 65 of file attack.hpp.
Referenced by battle_context_unit_stats(), and combatant::fight().
unsigned int battle_context_unit_stats::max_hp |
Maximum hitpoints of the unit.
Definition at line 70 of file attack.hpp.
Referenced by combatant::average_hp(), battle_context_unit_stats(), calc_blows(), and combatant::combatant().
unsigned int battle_context_unit_stats::num_blows |
Effective number of blows, takes swarm into account.
Definition at line 76 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::choose_defender_weapon(), combatant::fight(), luaW_pushsimweapon(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::attack_predictions::set_data(), and unit_weapons().
bool battle_context_unit_stats::petrifies |
Attack petrifies opponent when it hits.
Definition at line 59 of file attack.hpp.
Referenced by battle_context_unit_stats(), gui2::dialogs::attack_predictions::draw_hp_graph(), and luaW_pushsimweapon().
std::string battle_context_unit_stats::plague_type |
The plague type used by the attack, if any.
Definition at line 80 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 60 of file attack.hpp.
Referenced by battle_context_unit_stats(), and luaW_pushsimweapon().
bool battle_context_unit_stats::poisons |
Attack poisons opponent when it hits.
Definition at line 61 of file attack.hpp.
Referenced by battle_context_unit_stats(), combatant::fight(), and luaW_pushsimweapon().
unsigned int battle_context_unit_stats::rounds |
Berserk special can force us to fight more than one round.
Definition at line 68 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 73 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 57 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 62 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 78 of file attack.hpp.
Referenced by battle_context_unit_stats(), and calc_blows().
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 77 of file attack.hpp.
Referenced by battle_context_unit_stats(), and calc_blows().
const_attack_ptr battle_context_unit_stats::weapon |
The weapon used by the unit to attack the opponent, or nullptr if there is none.
Definition at line 52 of file attack.hpp.
Referenced by battle_context_unit_stats(), battle_context::better_combat(), luaW_pushsimweapon(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::attack_predictions::set_data(), and unit_weapons().