summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-05 14:30:56 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-05 14:30:56 +0000
commit91b3a4bcce5335372cf9369169a337c12157cde9 (patch)
tree18eb025ba015cef4884cd405da1140b61cdf8720 /crawl-ref/source/religion.cc
parentbeb469a9f1450e99042798eebeb1d23a4c45311b (diff)
downloadcrawl-ref-91b3a4bcce5335372cf9369169a337c12157cde9.tar.gz
crawl-ref-91b3a4bcce5335372cf9369169a337c12157cde9.zip
Updated Elf:7 levels (David).
New vaults (Lemuel). Tweaked dungeon.cc so that vault and minivault depths are no longer hardcoded, and the depth settings in .des files are respected. Okawaru now looks to see if the player already has enough ammo before doing ammo gifts (needs testing, maybe some tuning of the enough-ammo condition). Map lexer now accepts any non-space character in the map, for SUBST convenience. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@979 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc54
1 files changed, 49 insertions, 5 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 70c86b192e..31a1927af8 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -319,6 +319,54 @@ static int random_undead_servant(int religion)
return (thing_called);
}
+static const item_def *find_missile_launcher(int skill)
+{
+ for (int i = 0; i < ENDOFPACK; ++i)
+ {
+ if (!is_valid_item(you.inv[i]))
+ continue;
+
+ const item_def &item = you.inv[i];
+ if (is_range_weapon(item)
+ && range_skill(item) == skill_type(skill))
+ {
+ return (&item);
+ }
+ }
+ return (NULL);
+}
+
+static int ammo_count(const item_def *launcher)
+{
+ int count = 0;
+ const missile_type mt = launcher? fires_ammo_type(*launcher) : MI_DART;
+
+ for (int i = 0; i < ENDOFPACK; ++i)
+ {
+ if (!is_valid_item(you.inv[i]))
+ continue;
+
+ const item_def &item = you.inv[i];
+ if (item.base_type == OBJ_MISSILES && item.sub_type == mt)
+ count += item.quantity;
+ }
+
+ return (count);
+}
+
+static bool need_missile_gift()
+{
+ const int best_missile_skill = best_skill(SK_SLINGS, SK_RANGED_COMBAT);
+ const item_def *launcher = find_missile_launcher(best_missile_skill);
+ return (you.piety > 80
+ && random2( you.piety ) > 70
+ && !grid_destroys_items( grd[you.x_pos][you.y_pos] )
+ && one_chance_in(8)
+ && you.skills[ best_missile_skill ] >= 8
+ && (launcher || best_missile_skill == SK_DARTS)
+ && ammo_count(launcher) < 20 + random2(35));
+}
+
void pray(void)
{
unsigned char was_praying = you.duration[DUR_PRAYER];
@@ -526,11 +574,7 @@ void pray(void)
}
if (you.religion == GOD_OKAWARU
- && you.piety > 80
- && random2( you.piety ) > 70
- && !grid_destroys_items( grd[you.x_pos][you.y_pos] )
- && one_chance_in(8)
- && you.skills[ best_skill(SK_SLINGS, SK_RANGED_COMBAT) ] >= 9)
+ && need_missile_gift())
{
success = acquirement( OBJ_MISSILES, you.religion );
if (success)