From 6a7804a077312c11ade9582bf5957628046ea3d7 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 8 Feb 2007 09:12:58 +0000 Subject: Hydras now behave the same way in monster-vs-monster combat as they do in player vs monster. Specifically, hydras get their as many attacks as they have heads vs other monsters, and other monsters can chop off hydra heads (at 25% of the probability that the player has of chopping off heads). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@936 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'crawl-ref/source/mon-util.cc') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index d0fb486907..04bd443b97 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1326,6 +1326,11 @@ void define_monster(int index) mons.enchantment[i] = ENCH_NONE; } // end define_monster() +std::string str_monam(const monsters *mon, description_level_type desc, + bool force_seen) +{ + return (ptr_monam(mon, desc, force_seen)); +} /* ------------------------- monam/moname ------------------------- */ const char *ptr_monam( const monsters *mon, char desc, bool force_seen ) @@ -1626,6 +1631,61 @@ bool mons_aligned(int m1, int m2) return (fr1 == fr2); } +bool mons_wields_two_weapons(const monsters *m) +{ + return (m->type == MONS_TWO_HEADED_OGRE || m->type == MONS_ETTIN); +} + +// Does not check whether the monster can dual-wield - that is the +// caller's responsibility. +int mons_offhand_weapon_index(const monsters *m) +{ + return (m->inv[1]); +} + +int mons_weapon_index(const monsters *m) +{ + // This randomly picks one of the wielded weapons for monsters that can use + // two weapons. Not ideal, but better than nothing. fight.cc does it right, + // for various values of right. + int weap = m->inv[MSLOT_WEAPON]; + + if (mons_wields_two_weapons(m)) + { + const int offhand = mons_offhand_weapon_index(m); + if (offhand != NON_ITEM && (weap == NON_ITEM || coinflip())) + weap = offhand; + } + + return (weap); +} + +int mons_base_damage_type(const monsters *m) +{ + return (mons_class_flag(m->type, M_CLAWS)? DVORP_CLAWING : DVORP_CRUSHING); +} + +int mons_damage_type(const monsters *m) +{ + const int mweap = mons_weapon_index(m); + + if (mweap == NON_ITEM) + return (mons_base_damage_type(m)); + + return (get_vorpal_type(mitm[mweap])); +} + +int mons_damage_brand(const monsters *m) +{ + const int mweap = mons_weapon_index(m); + + if (mweap == NON_ITEM) + return (SPWPN_NORMAL); + + const item_def &weap = mitm[mweap]; + return (!is_range_weapon(weap)? get_weapon_brand(weap) : SPWPN_NORMAL); +} + bool mons_friendly(const monsters *m) { return (m->attitude == ATT_FRIENDLY || mons_has_ench(m, ENCH_CHARM)); -- cgit v1.2.3-54-g00ecf