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 | |
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')
-rw-r--r-- | crawl-ref/source/effects.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.cc | 36 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 33 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 2 |
4 files changed, 35 insertions, 47 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 58016e05a5..2b1ba69280 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1145,15 +1145,8 @@ static int _acquirement_jewellery_subtype() for (int i = 0; i < 10; i++) { // 1/3 amulets, 2/3 rings. - if (one_chance_in(3)) - { - result = AMU_FIRST_AMULET - + random2(NUM_JEWELLERY - AMU_FIRST_AMULET); - } - else - { - result = random2(NUM_RINGS); - } + result = (one_chance_in(3) ? get_random_amulet_type() + : get_random_ring_type()); // If we haven't seen this yet, we're done. if (get_ident_type(OBJ_JEWELLERY, result) == ID_UNKNOWN_TYPE) diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 620927d1b6..4a079e1501 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -2383,7 +2383,7 @@ int property( const item_def &item, int prop_type ) } // Returns true if item is evokable. -bool gives_ability( const item_def &item ) +bool gives_ability(const item_def &item) { if (!item_type_known(item)) return (false); @@ -2394,7 +2394,7 @@ bool gives_ability( const item_def &item ) { // unwielded weapon item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) + if (!weap || weap->slot != item.slot) return (false); break; } @@ -2405,8 +2405,8 @@ bool gives_ability( const item_def &item ) // unworn ring item_def *lring = you.slot_item(EQ_LEFT_RING); item_def *rring = you.slot_item(EQ_RIGHT_RING); - if ((!lring || (*lring).slot != item.slot) - && (!rring || (*rring).slot != item.slot)) + if ((!lring || lring->slot != item.slot) + && (!rring || rring->slot != item.slot)) { return (false); } @@ -2422,7 +2422,7 @@ bool gives_ability( const item_def &item ) { // unworn amulet item_def *amul = you.slot_item(EQ_AMULET); - if (!amul || (*amul).slot != item.slot) + if (!amul || amul->slot != item.slot) return (false); if (item.sub_type == AMU_RAGE) @@ -2438,7 +2438,7 @@ bool gives_ability( const item_def &item ) // unworn armour item_def *arm = you.slot_item(eq); - if (!arm || (*arm).slot != item.slot) + if (!arm || arm->slot != item.slot) return (false); break; } @@ -2458,7 +2458,7 @@ bool gives_ability( const item_def &item ) } // Returns true if the item confers an intrinsic that is shown on the % screen. -bool gives_resistance( const item_def &item ) +bool gives_resistance(const item_def &item) { if (!item_type_known(item)) return (false); @@ -2469,19 +2469,19 @@ bool gives_resistance( const item_def &item ) { // unwielded weapon item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) + if (!weap || weap->slot != item.slot) return (false); break; } case OBJ_JEWELLERY: { - if (item.sub_type < NUM_RINGS) + if (!jewellery_is_amulet(item)) { // unworn ring - item_def *lring = you.slot_item(EQ_LEFT_RING); - item_def *rring = you.slot_item(EQ_RIGHT_RING); - if ((!lring || (*lring).slot != item.slot) - && (!rring || (*rring).slot != item.slot)) + const item_def *lring = you.slot_item(EQ_LEFT_RING); + const item_def *rring = you.slot_item(EQ_RIGHT_RING); + if ((!lring || lring->slot != item.slot) + && (!rring || rring->slot != item.slot)) { return (false); } @@ -2499,8 +2499,8 @@ bool gives_resistance( const item_def &item ) else { // unworn amulet - item_def *amul = you.slot_item(EQ_AMULET); - if (!amul || (*amul).slot != item.slot) + const item_def *amul = you.slot_item(EQ_AMULET); + if (!amul || amul->slot != item.slot) return (false); if (item.sub_type != AMU_RAGE && item.sub_type != AMU_INACCURACY) @@ -2516,11 +2516,11 @@ bool gives_resistance( const item_def &item ) // unworn armour item_def *arm = you.slot_item(eq); - if (!arm || (*arm).slot != item.slot) + if (!arm || arm->slot != item.slot) return (false); break; - const int ego = get_armour_ego_type( item ); + const int ego = get_armour_ego_type(item); if (ego >= SPARM_FIRE_RESISTANCE && ego <= SPARM_SEE_INVISIBLE || ego == SPARM_RESISTANCE || ego == SPARM_POSITIVE_ENERGY) { @@ -2531,7 +2531,7 @@ bool gives_resistance( const item_def &item ) { // unwielded staff item_def *weap = you.slot_item(EQ_WEAPON); - if (!weap || (*weap).slot != item.slot) + if (!weap || weap->slot != item.slot) return (false); if (item.sub_type >= STAFF_FIRE && item.sub_type <= STAFF_POISON 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); } } diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 182032ccf2..95aa729e1e 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -7162,8 +7162,6 @@ static void _handle_monster_move(monsters *monster) || monster->type == MONS_AIR_ELEMENTAL && mons_is_submerged(monster)) { - std::vector<coord_def> moves; - mmov.reset(); int pfound = 0; for (adjacent_iterator ai(monster->pos(), false); ai; ++ai) |