summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-17 19:51:48 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-17 19:51:48 +0000
commitc79074eb5aec50fd5b854f10d4377b4e988a696f (patch)
tree51d106e8f678b70de4a292d2e71bd443a2d999f9 /crawl-ref/source/itemprop.cc
parent0297f504cb6467826e35d3c2a86d93d3964058f2 (diff)
downloadcrawl-ref-c79074eb5aec50fd5b854f10d4377b4e988a696f.tar.gz
crawl-ref-c79074eb5aec50fd5b854f10d4377b4e988a696f.zip
Make all the checks for throwable items consistent.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7465 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc59
1 files changed, 29 insertions, 30 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 4290ed583e..79735afe46 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2010,51 +2010,35 @@ int get_inv_in_hand( void )
//
// Launcher and ammo functions:
//
-missile_type fires_ammo_type( const item_def &item )
+missile_type fires_ammo_type(const item_def &item)
{
if (item.base_type != OBJ_WEAPONS)
return (MI_NONE);
- return (Weapon_prop[ Weapon_index[item.sub_type] ].ammo);
+ return (Weapon_prop[Weapon_index[item.sub_type]].ammo);
}
-missile_type fires_ammo_type( weapon_type wtype )
+missile_type fires_ammo_type(weapon_type wtype)
{
item_def wpn;
wpn.base_type = OBJ_WEAPONS;
- wpn.sub_type = wtype;
+ wpn.sub_type = wtype;
return (fires_ammo_type(wpn));
}
-bool is_range_weapon( const item_def &item )
-{
- return (fires_ammo_type( item ) != MI_NONE);
-}
-
-// Decide if something is launched or thrown.
-launch_retval is_launched(actor *actor, const item_def *launcher,
- const item_def &missile)
+bool is_range_weapon(const item_def &item)
{
- if (missile.base_type == OBJ_MISSILES
- && launcher
- && missile.launched_by(*launcher))
- {
- return (LRET_LAUNCHED);
- }
-
- return (is_throwable(missile, actor->body_size()) ? LRET_THROWN
- : LRET_FUMBLED);
+ return (fires_ammo_type(item) != MI_NONE);
}
-bool is_range_weapon_type( weapon_type wtype )
+bool is_range_weapon_type(weapon_type wtype)
{
item_def wpn;
-
wpn.base_type = OBJ_WEAPONS;
wpn.sub_type = wtype;
- return (is_range_weapon( wpn ));
+ return (is_range_weapon(wpn));
}
const char *ammo_name(missile_type ammo)
@@ -2063,14 +2047,14 @@ const char *ammo_name(missile_type ammo)
: Missile_prop[ Missile_index[ammo] ].name);
}
-const char *ammo_name( const item_def &bow )
+const char *ammo_name(const item_def &bow)
{
- ASSERT( is_range_weapon( bow ) );
- return ammo_name(fires_ammo_type( bow ));
+ ASSERT(is_range_weapon(bow));
+ return ammo_name(fires_ammo_type(bow));
}
// Returns true if item has an associated launcher.
-bool has_launcher( const item_def &ammo )
+bool has_launcher(const item_def &ammo)
{
ASSERT(ammo.base_type == OBJ_MISSILES);
return (ammo.sub_type != MI_LARGE_ROCK
@@ -2079,13 +2063,13 @@ bool has_launcher( const item_def &ammo )
}
// Returns true if item can be reasonably thrown without a launcher.
-bool is_throwable( const item_def &wpn, size_type bodysize )
+bool is_throwable(const item_def &wpn, size_type bodysize, bool force)
{
if (wpn.base_type == OBJ_WEAPONS)
return (Weapon_prop[ Weapon_index[wpn.sub_type] ].throwable);
else if (wpn.base_type == OBJ_MISSILES)
{
- if (bodysize < SIZE_MEDIUM
+ if (!force && bodysize < SIZE_MEDIUM
&& (wpn.sub_type == MI_JAVELIN || wpn.sub_type == MI_THROWING_NET))
{
return (false);
@@ -2095,6 +2079,21 @@ bool is_throwable( const item_def &wpn, size_type bodysize )
return (false);
}
+// Decide if something is launched or thrown.
+launch_retval is_launched(actor *actor, const item_def *launcher,
+ const item_def &missile)
+{
+ if (missile.base_type == OBJ_MISSILES
+ && launcher
+ && missile.launched_by(*launcher))
+ {
+ return (LRET_LAUNCHED);
+ }
+
+ return (is_throwable(missile, actor->body_size()) ? LRET_THROWN
+ : LRET_FUMBLED);
+}
+
//
// Staff/rod functions:
//