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/spells4.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/spells4.cc')
-rw-r--r-- | crawl-ref/source/spells4.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 4384a84ced..5d62772b28 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -291,7 +291,7 @@ static int _shatter_walls(int x, int y, int pow, int garbage) break; } - if (random2(100) < chance) + if (x_chance_in_y(chance, 100)) { noisy(30, x, y); @@ -1699,7 +1699,7 @@ void do_monster_rot(int mon) { int damage = 1 + random2(3); - if (mons_holiness(&menv[mon]) == MH_UNDEAD && random2(5)) + if (mons_holiness(&menv[mon]) == MH_UNDEAD && !one_chance_in(5)) { apply_area_cloud(make_a_normal_cloud, menv[mon].x, menv[mon].y, 10, 1, CLOUD_MIASMA, KC_YOU); @@ -1815,7 +1815,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike blast.colour = LIGHTGREY; - if (random2(50) < (pow / 5)) // potential insta-kill + if (x_chance_in_y(pow / 5, 50)) // potential insta-kill { monster_die(&menv[mon], KILL_YOU, 0); blast.damage.num = 4; |