diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-04 17:07:43 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-04 17:07:43 +0000 |
commit | 1df63f2d24648d2467da71b81ba53f039e6539c0 (patch) | |
tree | 3d55cda95aa019b4949566362e55bec7e5155982 /crawl-ref/source/makeitem.cc | |
parent | f5b7079207156bdd82d713a60cf79229fe33a109 (diff) | |
download | crawl-ref-1df63f2d24648d2467da71b81ba53f039e6539c0.tar.gz crawl-ref-1df63f2d24648d2467da71b81ba53f039e6539c0.zip |
Partially fix get_random_armour_type being completely broken (e.g. wizard
hats and caps can get generated again.) get_random_armour_type makes assumptions
about the order of armour_type, which were invalidated by r8681; I'm hesitant
to touch the order again for fear of breaking something. dolorous, can you check?
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8891 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/makeitem.cc')
-rw-r--r-- | crawl-ref/source/makeitem.cc | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 11f2332229..66cc3ec4c8 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -4322,9 +4322,9 @@ jewellery_type get_random_ring_type() const jewellery_type j = _get_raw_random_ring_type(); // Adjusted distribution here -- bwr if ((j == RING_INVISIBILITY - || j == RING_REGENERATION - || j == RING_TELEPORT_CONTROL - || j == RING_SLAYING) + || j == RING_REGENERATION + || j == RING_TELEPORT_CONTROL + || j == RING_SLAYING) && !one_chance_in(3)) { return _get_raw_random_ring_type(); @@ -4356,6 +4356,8 @@ armour_type get_random_armour_type(int item_level) armtype = ARM_ANIMAL_SKIN; } + // FIXME! This makes assumptions about the order of subtypes, and + // the assumptions are wrong! if (x_chance_in_y(11 + item_level, 60)) armtype = random2(ARM_SHIELD); // body armour of some kind @@ -4374,26 +4376,21 @@ armour_type get_random_armour_type(int item_level) // secondary armours: if (one_chance_in(5)) { - // same chance each - switch (random2(5)) - { - case 0: armtype = ARM_SHIELD; break; - case 1: armtype = ARM_CLOAK; break; - case 2: armtype = ARM_HELMET; break; - case 3: armtype = ARM_GLOVES; break; - case 4: armtype = ARM_BOOTS; break; - } + const armour_type secarmours[] = { ARM_SHIELD, ARM_CLOAK, ARM_HELMET, + ARM_GLOVES, ARM_BOOTS }; + armtype = RANDOM_ELEMENT(secarmours); if (armtype == ARM_HELMET && one_chance_in(3)) { - armtype = ARM_HELMET + random2(3); + const armour_type hats[] = { ARM_CAP, ARM_WIZARD_HAT, ARM_HELMET }; + armtype = RANDOM_ELEMENT(hats); } - else if (armtype == ARM_SHIELD) // 33.3% + else if (armtype == ARM_SHIELD) { - if (coinflip()) - armtype = ARM_BUCKLER; // 50.0% - else if (one_chance_in(3)) - armtype = ARM_LARGE_SHIELD; // 16.7% + armtype = random_choose_weighted(333, ARM_SHIELD, + 500, ARM_BUCKLER, + 167, ARM_LARGE_SHIELD, + 0); } } |