diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-06-01 17:58:23 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-06-01 17:58:23 +0000 |
commit | e9a58044e36966a261704a21681e1240f985ea45 (patch) | |
tree | 004a32ac09987e6ca2f0bfffcf921b7330bc65da /crawl-ref/source/itemprop.cc | |
parent | d813da0afb4ebeea2c25dbdae36060eee5424d45 (diff) | |
download | crawl-ref-e9a58044e36966a261704a21681e1240f985ea45.tar.gz crawl-ref-e9a58044e36966a261704a21681e1240f985ea45.zip |
Fix [2794986]: Special damage descriptions weren't being displayed for
weapons with multiple damage types.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9876 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r-- | crawl-ref/source/itemprop.cc | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 1cf82700c3..387fd72b18 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1537,31 +1537,51 @@ int weapon_rarity( int w_type ) return (0); } -int get_vorpal_type( const item_def &item ) +int get_vorpal_type(const item_def &item) { int ret = DVORP_NONE; if (item.base_type == OBJ_WEAPONS) - ret = (Weapon_prop[ Weapon_index[item.sub_type] ].dam_type & DAMV_MASK); + ret = (Weapon_prop[Weapon_index[item.sub_type]].dam_type & DAMV_MASK); return (ret); } -int get_damage_type( const item_def &item ) +int get_damage_type(const item_def &item) { int ret = DAM_BASH; if (item.base_type == OBJ_WEAPONS) - ret = (Weapon_prop[ Weapon_index[item.sub_type] ].dam_type & DAM_MASK); + ret = (Weapon_prop[Weapon_index[item.sub_type]].dam_type & DAM_MASK); return (ret); } -bool does_damage_type( const item_def &item, int dam_type ) +bool does_damage_type(const item_def &item, int dam_type) { - return (get_damage_type( item ) & dam_type); + return (get_damage_type(item) & dam_type); } +int single_damage_type(const item_def &item) +{ + int ret = get_damage_type(item); + + if (ret > 0) + { + int count = 0; + + for (int i = 1; i <= DAM_MAX_TYPE; i <<= 1) + { + if (!does_damage_type(item, i)) + continue; + + if (one_chance_in(++count)) + ret = i; + } + } + + return (ret); +} hands_reqd_type hands_reqd(object_class_type base_type, int sub_type, size_type size) |