summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-01 18:06:19 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-01 18:06:19 +0000
commit085daf0f758627f85d8c940ac269129bcbfb17ea (patch)
tree3548716d68fe13e9276267d588ae0c5ae360e190
parent48917b14199931161c383bf4ff30db2323e1eccb (diff)
downloadcrawl-ref-085daf0f758627f85d8c940ac269129bcbfb17ea.tar.gz
crawl-ref-085daf0f758627f85d8c940ac269129bcbfb17ea.zip
Apply trunk r9876 to 0.5.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.5@9878 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/fight.cc13
-rw-r--r--crawl-ref/source/itemprop.cc32
-rw-r--r--crawl-ref/source/itemprop.h16
3 files changed, 43 insertions, 18 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 2f1b22783f..9900d9a501 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -1683,14 +1683,14 @@ int melee_attack::player_weapon_type_modify(int damage)
if (!weapon)
weap_type = WPN_UNARMED;
- else if (item_is_staff( *weapon ))
+ else if (item_is_staff(*weapon))
weap_type = WPN_QUARTERSTAFF;
else if (weapon->base_type == OBJ_WEAPONS)
weap_type = weapon->sub_type;
// All weak hits look the same, except for when the player
- // has a non-weapon in hand. -- bwr
- // Exception: vampire bats only _bite_ to allow for drawing blood
+ // has a non-weapon in hand. - bwr
+ // Exception: vampire bats only bite to allow for drawing blood.
if (damage < HIT_WEAK
&& (you.species != SP_VAMPIRE || !player_in_bat_form()))
{
@@ -1759,7 +1759,10 @@ int melee_attack::player_weapon_type_modify(int damage)
return (damage);
}
- switch (weapon ? get_damage_type(*weapon) : -1)
+ // Take normal hits into account. If the hit is from a weapon with
+ // more than one damage type, randomly choose one damage type from
+ // it.
+ switch (weapon ? single_damage_type(*weapon) : -1)
{
case DAM_PIERCE:
if (damage < HIT_MED)
@@ -1794,7 +1797,7 @@ int melee_attack::player_weapon_type_modify(int damage)
case DAM_BLUDGEON:
if (damage < HIT_MED)
- attack_verb = one_chance_in(4)? "thump" : "sock";
+ attack_verb = one_chance_in(4) ? "thump" : "sock";
else if (damage < HIT_STRONG)
attack_verb = "bludgeon";
else
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)
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 5b035371d1..a8ef9e5547 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -536,16 +536,17 @@ enum weapon_property_type
enum vorpal_damage_type
{
- // Types of damage a weapon can do... currently assuming that anything
- // with BLUDGEON always does "AND" with any other specified types,
- // and and sets not including BLUDGEON are "OR".
+ // These are the types of damage a weapon can do. You can set more
+ // than one of these.
DAM_BASH = 0x0000, // non-melee weapon blugeoning
DAM_BLUDGEON = 0x0001, // crushing
DAM_SLICE = 0x0002, // slicing/chopping
DAM_PIERCE = 0x0004, // stabbing/piercing
DAM_WHIP = 0x0008, // whip slashing (no butcher)
+ DAM_MAX_TYPE = DAM_WHIP,
- // These are used for vorpal weapon desc (don't set more than one)
+ // These are used for vorpal weapon descriptions. You shouldn't set
+ // more than one of these.
DVORP_NONE = 0x0000, // used for non-melee weapons
DVORP_CRUSHING = 0x1000,
DVORP_SLICING = 0x2000,
@@ -716,9 +717,10 @@ bool is_blessed_blade_convertible(const item_def &item);
bool convert2good(item_def &item, bool allow_blessed = true);
bool convert2bad(item_def &item);
-int get_vorpal_type( const item_def &item );
-int get_damage_type( const item_def &item );
-bool does_damage_type( const item_def &item, int dam_type );
+int get_vorpal_type(const item_def &item);
+int get_damage_type(const item_def &item);
+bool does_damage_type(const item_def &item, int dam_type);
+int single_damage_type(const item_def &item);
int weapon_str_weight( const item_def &wpn );
int weapon_dex_weight( const item_def &wpn );