00001 #ifndef MELEE_ATTACK_H
00002 #define MELEE_ATTACK_H
00003
00004 #include "artefact.h"
00005 #include "random-var.h"
00006
00007 class melee_attack
00008 {
00009 public:
00010 actor *attacker, *defender;
00011
00012 bool cancel_attack;
00013 bool did_hit, perceived_attack, obvious_effect;
00014
00015
00016 bool needs_message;
00017 bool attacker_visible, defender_visible;
00018 bool attacker_invisible, defender_invisible;
00019
00020 bool unarmed_ok;
00021 int attack_number;
00022
00023 int to_hit;
00024 int ev_margin;
00025 int damage_done;
00026 int special_damage;
00027 int aux_damage;
00028
00029 bool stab_attempt;
00030 int stab_bonus;
00031
00032 int min_delay;
00033 int final_attack_delay;
00034
00035 int noise_factor;
00036 int extra_noise;
00037
00038
00039
00040 item_def *weapon;
00041 int damage_brand;
00042 int wpn_skill, hands;
00043 bool hand_half_bonus;
00044
00045 bool skip_chaos_message;
00046
00047
00048 artefact_properties_t art_props;
00049
00050
00051 unrandart_entry *unrand_entry;
00052
00053
00054 std::string attack_verb, verb_degree;
00055 std::string no_damage_message;
00056 std::string special_damage_message;
00057 std::string aux_attack, aux_verb;
00058 beam_type special_damage_flavour;
00059
00060 item_def *shield;
00061 item_def *defender_shield;
00062
00063
00064
00065 int player_body_armour_penalty;
00066 int player_shield_penalty;
00067
00068
00069 int player_armour_tohit_penalty;
00070 int player_shield_tohit_penalty;
00071
00072 bool can_do_unarmed;
00073 bool apply_bleeding;
00074
00075
00076
00077 int miscast_level;
00078 int miscast_type;
00079 actor* miscast_target;
00080
00081 public:
00082 melee_attack(actor *attacker, actor *defender,
00083 bool allow_unarmed = true, int attack_num = -1);
00084
00085
00086 bool attack();
00087
00088 int calc_to_hit(bool random = true);
00089 random_var player_calc_attack_delay();
00090
00091 static void chaos_affect_actor(actor *victim);
00092
00093 static std::string anon_name(description_level_type desc,
00094 bool actor_invisible);
00095 static std::string actor_name(const actor *a, description_level_type desc,
00096 bool actor_visible, bool actor_invisible);
00097 static std::string pronoun(const actor *a, pronoun_type ptyp,
00098 bool actor_visible);
00099 static std::string anon_pronoun(pronoun_type ptyp);
00100
00101 private:
00102 void init_attack();
00103 bool is_banished(const actor *) const;
00104 void check_autoberserk();
00105 bool check_unrand_effects(bool mondied = false);
00106 void emit_nodmg_hit_message();
00107 void identify_mimic(actor *mon);
00108
00109 std::string debug_damage_number();
00110 std::string special_attack_punctuation();
00111 std::string attack_strength_punctuation();
00112 std::string evasion_margin_adverb();
00113
00114 std::string atk_name(description_level_type desc) const;
00115 std::string def_name(description_level_type desc) const;
00116 std::string wep_name(description_level_type desc = DESC_NOCAP_YOUR,
00117 unsigned long ignore_flags = ISFLAG_KNOW_CURSE
00118 | ISFLAG_KNOW_PLUSES) const;
00119
00120 bool attack_shield_blocked(bool verbose);
00121 bool apply_damage_brand();
00122 void calc_elemental_brand_damage(beam_type flavour,
00123 int res,
00124 const char *verb);
00125 int fire_res_apply_cerebov_downgrade(int res);
00126 void drain_defender();
00127 void rot_defender(int amount, int immediate = 0);
00128 void splash_defender_with_acid(int strength);
00129 void splash_monster_with_acid(int strength);
00130 bool decapitate_hydra(int damage_done, int damage_type = -1);
00131 bool chop_hydra_head(int damage_done,
00132 int dam_type,
00133 int wpn_brand);
00134
00135
00136 bool distortion_affects_defender();
00137
00138 void chaos_affects_defender();
00139 void chaos_affects_attacker();
00140 void chaos_killed_defender(monster* def_copy);
00141 int random_chaos_brand();
00142 void do_miscast();
00143
00144 void handle_noise(const coord_def & pos);
00145
00146 private:
00147
00148 bool mons_attack_you();
00149 bool mons_attack_mons();
00150 int mons_to_hit();
00151 bool mons_self_destructs();
00152 bool mons_attack_warded_off();
00153 int mons_attk_delay();
00154 int mons_calc_damage(const mon_attack_def &attk);
00155 bool do_trample();
00156 void mons_apply_attack_flavour(const mon_attack_def &attk);
00157 int mons_apply_defender_ac(int damage, int damage_max);
00158 bool mons_perform_attack();
00159 void mons_perform_attack_rounds();
00160 void mons_check_attack_perceived();
00161 std::string mons_attack_verb(const mon_attack_def &attk);
00162 std::string mons_attack_desc(const mon_attack_def &attk);
00163 void mons_announce_hit(const mon_attack_def &attk);
00164 void mons_announce_dud_hit(const mon_attack_def &attk);
00165 void mons_set_weapon(const mon_attack_def &attk);
00166 void mons_do_poison(const mon_attack_def &attk);
00167 void mons_do_napalm();
00168 std::string mons_defender_name();
00169 void wasp_paralyse_defender();
00170 void mons_do_passive_freeze();
00171 void mons_do_spines();
00172 void mons_do_eyeball_confusion();
00173
00174 mon_attack_flavour random_chaos_attack_flavour();
00175
00176 private:
00177
00178 bool player_attack();
00179
00180
00181 bool player_aux_unarmed();
00182 unarmed_attack_type player_aux_choose_baseattack();
00183 void player_aux_setup(unarmed_attack_type atk);
00184 bool player_aux_test_hit();
00185 bool player_aux_apply(unarmed_attack_type atk);
00186
00187 int player_stat_modify_damage(int damage);
00188 int player_aux_stat_modify_damage(int damage);
00189 int player_to_hit(bool random_factor);
00190 void calc_player_armour_shield_tohit_penalty(bool random_factor);
00191 void player_apply_attack_delay();
00192 int player_apply_weapon_bonuses(int damage);
00193 int player_apply_weapon_skill(int damage);
00194 int player_apply_fighting_skill(int damage, bool aux);
00195 int player_apply_misc_modifiers(int damage);
00196 int player_apply_monster_ac(int damage);
00197 void player_weapon_auto_id();
00198 int player_stab_weapon_bonus(int damage);
00199 int player_stab(int damage);
00200 int player_weapon_type_modify(int damage);
00201
00202 int player_hits_monster();
00203 int player_calc_base_weapon_damage();
00204 int player_calc_base_unarmed_damage();
00205 void player_exercise_combat_skills();
00206 bool player_monattk_hit_effects(bool mondied);
00207 void player_sustain_passive_damage();
00208 int player_staff_damage(int skill);
00209 void player_apply_staff_damage();
00210 bool player_check_monster_died();
00211 void player_calc_hit_damage();
00212 void player_stab_check();
00213 random_var player_weapon_speed();
00214 random_var player_unarmed_speed();
00215 void player_announce_aux_hit();
00216 void player_announce_hit();
00217 std::string player_why_missed();
00218 void player_warn_miss();
00219 void player_check_weapon_effects();
00220 void _monster_die(monster* mons, killer_type killer, int killer_index);
00221 };
00222
00223 #endif