The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Public Attributes | List of all members
battle_context_unit_stats Struct Reference

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

Detailed Description

Structure describing the statistics of a unit involved in the battle.

Definition at line 50 of file attack.hpp.

Constructor & Destructor Documentation

◆ battle_context_unit_stats() [1/2]

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 
)

◆ battle_context_unit_stats() [2/2]

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 
)

◆ ~battle_context_unit_stats()

battle_context_unit_stats::~battle_context_unit_stats ( )
inline

Definition at line 99 of file attack.hpp.

Member Function Documentation

◆ calc_blows()

unsigned int battle_context_unit_stats::calc_blows ( unsigned  new_hp) const
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().

Member Data Documentation

◆ attack_num

int battle_context_unit_stats::attack_num

◆ chance_to_hit

unsigned int battle_context_unit_stats::chance_to_hit

◆ damage

int battle_context_unit_stats::damage

◆ disable

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

◆ drain_constant

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

◆ drain_percent

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

◆ drains

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

◆ experience

unsigned int battle_context_unit_stats::experience

Definition at line 65 of file attack.hpp.

Referenced by combatant::fight().

◆ firststrike

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

◆ hp

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

◆ is_attacker

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

◆ is_poisoned

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

◆ is_slowed

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

◆ level

unsigned int battle_context_unit_stats::level

◆ max_experience

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

◆ max_hp

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

◆ num_blows

unsigned int battle_context_unit_stats::num_blows

◆ petrifies

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

◆ plague_type

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

◆ plagues

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

◆ poisons

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

◆ rounds

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

◆ slow_damage

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

◆ slows

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

◆ swarm

bool battle_context_unit_stats::swarm

Attack has swarm special.

Definition at line 62 of file attack.hpp.

Referenced by battle_context_unit_stats().

◆ swarm_max

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

◆ swarm_min

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

◆ weapon

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


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