From 30414416d011ed83d9e7c8b753a56ac7096e6775 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 12 Feb 2007 07:40:59 +0000 Subject: Break up you_attack() into a slew of smaller functions. The functions are still fairly tangled, but they're better than the old monster. The idea is to also put monster-vs-player and monster-vs-monster into the melee_attack framework so that refactoring combat code with elements of 4.1 becomes easier. This is a big refactoring, so it's likely to be buggy. Some of the combat diagnostics - notably the damage rolls - are also AWOL. Will fix going forward. Note: The combat code is still classic b26. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@950 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/fight.h | 127 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/fight.h') diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h index fb6a1a812b..84bb0f0c28 100644 --- a/crawl-ref/source/fight.h +++ b/crawl-ref/source/fight.h @@ -16,6 +16,7 @@ #include "externs.h" +#include "randart.h" // added Sept 18, 2000 -- bwr /* *********************************************************************** @@ -50,9 +51,131 @@ void monster_attack(int monster_attacking); * *********************************************************************** */ bool monsters_fight(int monster_attacking, int monster_attacked); -int calc_your_to_hit( int heavy_armour, bool hand_and_a_half_bonus, - bool water_attack, bool random_factor ); +int calc_your_to_hit( bool random_factor ); int calc_heavy_armour_penalty( bool random_factor ); +struct melee_attack +{ +public: + // At the moment this only covers players fighting monsters + actor *attacker, *defender; + + // If attacker and/or defender are monsters, these are set. + monsters *atk, *def; + + bool did_hit; + + bool unarmed_ok; + int attack_number; + + int to_hit; + int base_damage; + int potential_damage; + int damage_done; + int special_damage; + int aux_damage; + + bool stab_attempt; + int stab_bonus; + + int min_delay; + int final_attack_delay; + + // Attacker's damage output potential: + + item_def *weapon; + int damage_brand; // Can be special even if unarmed (transforms) + int wpn_skill, hands; + int spwld; // Special wield effects? + bool hand_half_bonus; + + // If weapon is a randart, its properties. + randart_properties_t art_props; + + // Attack messages + std::string attack_verb, verb_degree; + std::string no_damage_message; + std::string special_damage_message; + std::string unarmed_attack; + + item_def *shield; + + // Armour penalties? + int heavy_armour_penalty; + bool can_do_unarmed; + + // Attacker uses watery terrain to advantage vs defender. Implies that + // both attacker and defender are in water. + bool water_attack; + +public: + melee_attack(actor *attacker, actor *defender, + bool allow_unarmed = true, int attack_num = -1); + + // Applies attack damage and other effects. + bool attack(); + + int calc_to_hit(bool random = true); + +private: + void init_attack(); + bool is_water_attack(const actor *, const actor *) const; + void check_hand_half_bonus_eligible(); + void check_autoberserk(); + void check_special_wield_effects(); + void emit_nodmg_hit_message(); + + std::string debug_damage_number(); + std::string special_attack_punctuation(); + std::string attack_strength_punctuation(); + +private: + // Monster-attack specific stuff + bool mons_attack_you(); + bool mons_attack_mons(); + int mons_to_hit(); + +private: + // Player-attack specific stuff + bool player_attack(); + bool player_aux_unarmed(); + bool player_apply_aux_unarmed(); + int player_stat_modify_damage(int damage); + int player_aux_stat_modify_damage(int damage); + int player_to_hit(bool random_factor); + void player_apply_attack_delay(); + int player_apply_water_attack_bonus(int damage); + int player_apply_weapon_bonuses(int damage); + int player_apply_weapon_skill(int damage); + int player_apply_fighting_skill(int damage, bool aux); + int player_apply_misc_modifiers(int damage); + int player_apply_monster_ac(int damage); + void player_weapon_auto_id(); + int player_stab_weapon_bonus(int damage); + int player_stab(int damage); + int player_weapon_type_modify(int damage); + + bool player_hits_monster(); + int player_calc_base_weapon_damage(); + int player_calc_base_unarmed_damage(); + bool player_hurt_monster(); + void player_exercise_combat_skills(); + bool player_monattk_hit_effects(bool mondied); + void player_calc_brand_damage(int res, const char *message_format); + bool player_apply_damage_brand(); + void player_sustain_passive_damage(); + int player_staff_damage(int skill); + void player_apply_staff_damage(); + bool player_check_monster_died(); + void player_calc_hit_damage(); + void player_stab_check(); + int player_weapon_speed(); + int player_unarmed_speed(); + int player_apply_shield_delay(int attack_delay); + void player_announce_hit(); + std::string player_why_missed(); + void player_warn_miss(); +}; + #endif -- cgit v1.2.3-54-g00ecf