diff options
author | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-10 21:42:49 -0700 |
---|---|---|
committer | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-10 22:57:30 -0700 |
commit | 94659acff8f46a088507c1675e61fdf1d7f1418d (patch) | |
tree | 4514cf3c3338f19c96d04012ad20718a4f32c5af /crawl-ref/source/itemprop.cc | |
parent | af8ee80d6102c5729bd6535decbe71fee48ffa34 (diff) | |
download | crawl-ref-94659acff8f46a088507c1675e61fdf1d7f1418d.tar.gz crawl-ref-94659acff8f46a088507c1675e61fdf1d7f1418d.zip |
Partially refactor mulching
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r-- | crawl-ref/source/itemprop.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 2657c4b002..ee111dca8a 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1827,6 +1827,70 @@ launch_retval is_launched(const actor *actor, const item_def *launcher, } +/** + * Returns whether a given missile will always destroyed on impact. + * + * @param missile The missile in question. + * @return Whether the missile should always be destroyed on + * impact. + */ +bool ammo_always_destroyed(const item_def &missile) +{ + const int brand = get_ammo_brand(missile); + return brand == SPMSL_CHAOS + || brand == SPMSL_DISPERSAL + || brand == SPMSL_EXPLODING; +} + +/** + * Returns whether a given missile will never destroyed on impact. + * + * @param missile The missile in question. + * @return Whether the missile should never be destroyed on impact. + */ +bool ammo_never_destroyed(const item_def &missile) +{ + return missile.sub_type == MI_THROWING_NET; +} + +/** + * Returns the one_chance_in for a missile type for be destroyed on impact. + * + * @param missile_type The missile type to get the mulch chance for. + * @return The inverse of the missile type's mulch chance. + */ +int ammo_type_destroy_chance(int missile_type) +{ + switch (missile_type) + { + +#if TAG_MAJOR_VERSION == 34 + case MI_DART: + return 6; +#endif + + case MI_SLING_BULLET: + case MI_STONE: + case MI_ARROW: + case MI_BOLT: + return 8; + + case MI_NEEDLE: + return 12; + + case MI_TOMAHAWK: + case MI_JAVELIN: + return 20; + + case MI_LARGE_ROCK: + return 30; + + default: + die("Unknown missile type"); + } +} + + // // Reaching functions: |