diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 16:47:06 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 16:47:06 +0000 |
commit | 200b4c0e08504a7c8df898d77a9d72b3fa573c04 (patch) | |
tree | b6cf73c902a55861ab60656e0225f0385c2c3a59 /crawl-ref/source/spells3.cc | |
parent | 7f2ded93231941b48fba24bcc9a55602295f72bd (diff) | |
download | crawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.tar.gz crawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.zip |
Add a function x_chance_in_y(x,y) to replace the various
random2(y) < x checks, e.g. x_chance_in_y(weight, totalweight). This
should make things a bit more readable. Apply it to a number of files.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6428 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r-- | crawl-ref/source/spells3.cc | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index d866db7181..aabfc95a42 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -97,10 +97,9 @@ bool cast_selective_amnesia(bool force) mpr( "You don't know that spell." ); else { - if (!force - && (you.religion != GOD_SIF_MUNA - && random2(you.skills[SK_SPELLCASTING]) - < random2(spell_difficulty( spell )))) + if (!force && you.religion != GOD_SIF_MUNA + && random2(you.skills[SK_SPELLCASTING]) + < random2(spell_difficulty( spell ))) { mpr("Oops! This spell sure is a blunt instrument."); forget_map(20 + random2(50)); @@ -397,12 +396,10 @@ bool cast_sublimation_of_blood(int pow) food += 15; for (int loopy = 0; loopy < (you.hp > 1 ? 3 : 0); ++loopy) - { - if (random2(pow) < 6) + if (x_chance_in_y(6, pow)) dec_hp(1, false); - } - if (random2(pow) < 6) + if (x_chance_in_y(6, pow)) break; } @@ -1196,9 +1193,9 @@ bool cast_summon_wraiths(int pow, god_type god) canned_msg(MSG_NOTHING_HAPPENS); //jmf: Kiku sometimes deflects this - if (!(you.religion == GOD_KIKUBAAQUDGHA - && (!player_under_penance() && you.piety >= piety_breakpoint(3) - && you.piety > random2(MAX_PIETY)))) + if (you.religion != GOD_KIKUBAAQUDGHA + || player_under_penance() || you.piety < piety_breakpoint(3) + || !x_chance_in_y(you.piety, MAX_PIETY)) { disease_player(25 + random2(50)); } |