diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-09-19 00:05:15 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-09-19 00:09:47 +0200 |
commit | 08012983ebf16be4922a5562ab017da9edee607f (patch) | |
tree | ef6aa69b56bbb87b2a6d3d8d22745af8685160e1 /crawl-ref/source/random.cc | |
parent | ffb79818e5dccf7cbb54806d924909b0ffe903bc (diff) | |
download | crawl-ref-08012983ebf16be4922a5562ab017da9edee607f.tar.gz crawl-ref-08012983ebf16be4922a5562ab017da9edee607f.zip |
Give you.skill() a "scale" argument for partial skills, make callers use it.
Almost all uses have been converted, the only major one is unarmed base damage.
For users of raw you.skills[], hp and mp calculations have been changed as well.
you.skill() doesn't actually return partial values yet.
Diffstat (limited to 'crawl-ref/source/random.cc')
-rw-r--r-- | crawl-ref/source/random.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crawl-ref/source/random.cc b/crawl-ref/source/random.cc index 60f134a0bf..59072a12e1 100644 --- a/crawl-ref/source/random.cc +++ b/crawl-ref/source/random.cc @@ -131,6 +131,17 @@ int maybe_random2(int x, bool random_factor) return (x / 2); } +// [0, ceil(nom/denom)] +int maybe_random_div(int nom, int denom, bool random_factor) +{ + if (nom <= 0) + return (0); + if (random_factor) + return (random2(nom + denom) / denom); + else + return (nom / 2 / denom); +} + // [num, num*size] int maybe_roll_dice(int num, int size, bool random) { |