summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-03 17:59:49 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-03 17:59:49 +0000
commit718202ee6b6445890db808f4420073e2cce506c2 (patch)
tree2640787ddfef39aca363946a32a05df0ae62c62e /crawl-ref/source/itemprop.cc
parent589e206de3965240ac0475dcc98b339914ace70b (diff)
downloadcrawl-ref-718202ee6b6445890db808f4420073e2cce506c2.tar.gz
crawl-ref-718202ee6b6445890db808f4420073e2cce506c2.zip
Manual update (David).
Added javelins and sling bullets. Only Urug gets javelins at the moment. No monster gets sling bullets, but they can be randomly generated. Added deep elf blademasters and master archers to provide Silence-users some entertainment on Elf:7. I've adjusted the non-rogue-layout Elf:7s to use blademasters. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1732 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc99
1 files changed, 35 insertions, 64 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index adf555ae1e..81a45b94b5 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -343,12 +343,14 @@ struct missile_def
static int Missile_index[NUM_MISSILES];
static missile_def Missile_prop[NUM_MISSILES] =
{
- { MI_NEEDLE, "needle", 0, 1, false },
- { MI_STONE, "stone", 4, 2, true },
- { MI_DART, "dart", 5, 3, true },
- { MI_ARROW, "arrow", 6, 5, false },
- { MI_BOLT, "bolt", 8, 5, false },
- { MI_LARGE_ROCK, "large rock", 20, 1000, true },
+ { MI_NEEDLE, "needle", 0, 1, false },
+ { MI_STONE, "stone", 4, 2, true },
+ { MI_DART, "dart", 5, 3, true },
+ { MI_ARROW, "arrow", 7, 5, false },
+ { MI_BOLT, "bolt", 9, 5, false },
+ { MI_LARGE_ROCK, "large rock", 20, 1000, true },
+ { MI_SLING_BULLET, "sling bullet", 6, 4, true },
+ { MI_JAVELIN, "javelin", 11, 40, true },
};
struct food_def
@@ -1694,6 +1696,21 @@ 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)
+{
+ 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);
+}
+
bool is_range_weapon_type( weapon_type wtype )
{
item_def wpn;
@@ -1704,78 +1721,32 @@ bool is_range_weapon_type( weapon_type wtype )
return (is_range_weapon( wpn ));
}
+const char *ammo_name(missile_type ammo)
+{
+ return (ammo < 0 || ammo >= NUM_MISSILES? "eggplant"
+ : Missile_prop[ Missile_index[ammo] ].name);
+}
+
const char * ammo_name( const item_def &bow )
{
ASSERT( is_range_weapon( bow ) );
-
- const int ammo = fires_ammo_type( bow );
-
- return (Missile_prop[ Missile_index[ammo] ].name);
+ return ammo_name(fires_ammo_type( bow ));
}
// returns true if item can be reasonably thrown without a launcher
-bool is_throwable( const item_def &wpn )
+bool is_throwable( const item_def &wpn, size_type bodysize )
{
if (wpn.base_type == OBJ_WEAPONS)
return (Weapon_prop[ Weapon_index[wpn.sub_type] ].throwable);
else if (wpn.base_type == OBJ_MISSILES)
- return (Missile_prop[ Missile_index[wpn.sub_type] ].throwable);
-
- return (false);
-}
-
-// FIXME
-#if 0
-// decide if "being" is launching or throwing "ammo"
-launch_retval is_launched( int being_id, const item_def &ammo, bool msg )
-{
- ASSERT( being_id != MHITNOT );
-
- launch_retval ret = LRET_FUMBLED;
-
- const item_def * lnch = 0;
- int fit = 0;
-
- if (being_id == MHITYOU)
- {
- const int wpn = get_inv_wielded();
- lnch = (wpn == -1) ? 0 : &you.inv[wpn];
- fit = fit_item_throwable_size( ammo, player_size() );
- }
- else // monster case
{
- const int wpn = menv[being_id].inv[MSLOT_WEAPON];
- lnch = (wpn == NON_ITEM) ? 0 : &mitm[wpn];
- fit = fit_item_throwable_size( ammo, mons_size( menv[being_id].type ) );
- }
-
- if (lnch
- && lnch->base_type == OBJ_WEAPONS
- && is_range_weapon( *lnch )
- && ammo.base_type == OBJ_MISSILES
- && ammo.sub_type == fires_ammo_type( *lnch ))
- {
- ret = LRET_LAUNCHED;
- }
- else if (is_throwable( ammo ))
- {
- if (fit == 0)
- ret = LRET_THROWN;
- else
- {
- ret = LRET_FUMBLED;
-
- if (being_id == MHITYOU && msg)
- {
- mpr( MSGCH_WARN, "It's difficult to throw such a%s object.",
- (fit > 0) ? " large" : (fit < 0) ? " small" : "n awkward" );
- }
- }
+ if (bodysize < SIZE_MEDIUM && wpn.sub_type == MI_JAVELIN)
+ return (false);
+ return (Missile_prop[ Missile_index[wpn.sub_type] ].throwable);
}
- return (ret);
+ return (false);
}
-#endif
//
// Staff/rod functions: