From c79074eb5aec50fd5b854f10d4377b4e988a696f Mon Sep 17 00:00:00 2001 From: dolorous Date: Mon, 17 Nov 2008 19:51:48 +0000 Subject: 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 --- crawl-ref/source/itemprop.cc | 59 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'crawl-ref/source/itemprop.cc') 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: // -- cgit v1.2.3-54-g00ecf