diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-02-12 07:40:59 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-02-12 07:40:59 +0000 |
commit | 30414416d011ed83d9e7c8b753a56ac7096e6775 (patch) | |
tree | eba9d31b64f4dfb09772cf61dfc747d382d123d6 /crawl-ref/source/externs.h | |
parent | adbc8a9292e59d53a7fead4daea84f08909af94f (diff) | |
download | crawl-ref-30414416d011ed83d9e7c8b753a56ac7096e6775.tar.gz crawl-ref-30414416d011ed83d9e7c8b753a56ac7096e6775.zip |
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
Diffstat (limited to 'crawl-ref/source/externs.h')
-rw-r--r-- | crawl-ref/source/externs.h | 120 |
1 files changed, 107 insertions, 13 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 5d53e443fe..0a57670a3f 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -96,6 +96,46 @@ struct activity_interrupt_data } }; +class item_def; +class melee_attack; +class coord_def; + +class actor +{ +public: + virtual ~actor() { } + + virtual int id() const = 0; + virtual actor_type atype() const = 0; + + virtual coord_def pos() const = 0; + virtual bool swimming() const = 0; + virtual bool floundering() const = 0; + + virtual size_type body_size(int psize = PSIZE_TORSO, + bool base = false) const = 0; + + virtual int damage_type(int which_attack = -1) = 0; + virtual int damage_brand(int which_attack = -1) = 0; + virtual item_def *weapon(int which_attack = -1) = 0; + virtual item_def *shield() = 0; + + virtual void make_hungry(int nutrition, bool silent) + { + } + + virtual std::string name(description_level_type type) const = 0; + virtual std::string conj_verb(const std::string &verb) const = 0; + + virtual bool fumbles_attack(bool verbose = true) = 0; + + // Returns true if the actor has no way to attack (plants, statues). + // (statues have only indirect attacks). + virtual bool cannot_fight() const = 0; + virtual void attacking(actor *other) = 0; + virtual void go_berserk(bool intentional) = 0; +}; + struct ait_hp_loss { int hp; @@ -380,8 +420,9 @@ private: typedef std::vector<delay_queue_item> delay_queue_type; -struct player +class player : public actor { +public: bool turn_is_over; // flag signaling that player has performed a timed action bool banished; // flag signaling that the player is due a visit to the @@ -574,17 +615,52 @@ struct player FixedVector<int, 52> ability_letter_table; // ref to ability by enum public: - player(); - void init(); + player(); + void init(); + + bool is_valid() const; + std::string short_desc() const; + + // For sorting + bool operator < (const player &p) const; + +public: + bool in_water() const; + bool can_swim() const; + bool is_levitating() const; + + bool has_spell(int spell) const; + + size_type transform_size(int psize = PSIZE_TORSO) const; + + item_def *slot_item(equipment_type eq); + + // actor + int id() const; + coord_def pos() const; + bool swimming() const; + bool floundering() const; + size_type body_size(int psize = PSIZE_TORSO, bool base = false) const; + int damage_type(int attk = -1); + int damage_brand(int attk = -1); + item_def *weapon(int which_attack = -1); + item_def *shield(); + + std::string name(description_level_type type) const; + std::string conj_verb(const std::string &verb) const; + + bool fumbles_attack(bool verbose = true); + bool cannot_fight() const; - bool is_valid() const; - std::string short_desc() const; + void attacking(actor *other); + void go_berserk(bool intentional); - // For sorting - bool operator < (const player &p) const; + void make_hungry(int nutrition, bool silent); + + actor_type atype() const { return ACT_PLAYER; } }; -extern struct player you; +extern player you; class monster_spells : public FixedVector<int, NUM_MONSTER_SPELL_SLOTS> { @@ -595,8 +671,9 @@ public: void clear() { init(MS_NO_SPELL); } }; -struct monsters +class monsters : public actor { +public: int type; int hit_points; int max_hit_points; @@ -625,10 +702,27 @@ struct monsters god_type god; // Usually GOD_NO_GOD. - coord_def pos() const - { - return coord_def(x, y); - } +public: + // actor interface + int id() const; + coord_def pos() const; + bool swimming() const; + bool floundering() const; + size_type body_size(int psize = PSIZE_TORSO, bool base = false) const; + int damage_type(int attk = -1); + int damage_brand(int attk = -1); + item_def *weapon(int which_attack = -1); + item_def *shield(); + std::string name(description_level_type type) const; + std::string conj_verb(const std::string &verb) const; + + bool fumbles_attack(bool verbose = true); + bool cannot_fight() const; + + void attacking(actor *other); + void go_berserk(bool intentional); + + actor_type atype() const { return ACT_MONSTER; } }; struct cloud_struct |