From 200b4c0e08504a7c8df898d77a9d72b3fa573c04 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 6 Jul 2008 16:47:06 +0000 Subject: 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 --- crawl-ref/source/ouch.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crawl-ref/source/ouch.cc') diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 4ff2e61713..e60da7c57b 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -233,7 +233,7 @@ int check_your_resists(int hurted, beam_type flavour) break; case BEAM_MIASMA: - if (player_prot_life() > random2(3)) + if (x_chance_in_y(player_prot_life(), 3)) { canned_msg(MSG_YOU_RESIST); hurted = 0; @@ -398,8 +398,8 @@ void item_corrode( int itco ) // {dlb} if (chance_corr >= 0 && chance_corr <= 4) { - it_resists = (random2(100) < - 2 + (4 << chance_corr) + (chance_corr * 8)); + it_resists + = x_chance_in_y(2 + (4 << chance_corr) + chance_corr * 8, 100); } else it_resists = true; // no idea how often this occurs {dlb} @@ -497,7 +497,7 @@ static void _expose_invent_to_element(beam_type flavour, int strength) for (int j = 0; j < you.inv[i].quantity; ++j) { - if (random2(100) < strength) + if (x_chance_in_y(strength, 100)) { num_dest++; -- cgit v1.2.3-54-g00ecf