diff options
author | gammafunk <gammafunk@gmail.com> | 2014-03-14 23:21:10 -0500 |
---|---|---|
committer | gammafunk <gammafunk@gmail.com> | 2014-03-15 01:03:02 -0500 |
commit | eb0b70cff52e6c5ed6fca3083a51215cf5d9bef6 (patch) | |
tree | 382e91cc57b839910545a018ed0b779d7163eab7 /crawl-ref/source/acquire.cc | |
parent | 6de5c0a430634b430feb2d3dacf5781dad626a05 (diff) | |
download | crawl-ref-eb0b70cff52e6c5ed6fca3083a51215cf5d9bef6.tar.gz crawl-ref-eb0b70cff52e6c5ed6fca3083a51215cf5d9bef6.zip |
Simplify the miscellaneous item acquirement code (Reaver, #8272)
The old code had unclear chances of acquirement due to items' chances
depending on where they were in a list. This commit clarifies the
weightings and sets these to better values.
It does the following:
* only gifts the 4 kinds of decks not gifted by nemelex.
* reduces the weights for decks overall.
* for elemental evokables not seen before, gift them with higher
weight compared to the other evokable types.
* for evokables other than the disc of storms and lantern of
shadows, allow gifting at a lower weight even if they have been
seen before.
* gifts crystal ball of energy with chance (evocations *
max(spellcasting, invocations)) out of 27^2.
Diffstat (limited to 'crawl-ref/source/acquire.cc')
-rw-r--r-- | crawl-ref/source/acquire.cc | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/crawl-ref/source/acquire.cc b/crawl-ref/source/acquire.cc index b5c3c7bc62..5e9c0878ee 100644 --- a/crawl-ref/source/acquire.cc +++ b/crawl-ref/source/acquire.cc @@ -655,30 +655,40 @@ static int _acquirement_staff_subtype(const has_vector& already_has) return result; } +/** + * Return a miscellaneous evokable item for acquirement. + * @returns The item type chosen. + */ static int _acquirement_misc_subtype() { - // Note: items listed early are less likely due to chances of being - // overwritten. - int result = random_range(MISC_FIRST_DECK, MISC_LAST_DECK); - if (result == MISC_DECK_OF_SUMMONING && coinflip()) - result = MISC_SACK_OF_SPIDERS; - if (result == MISC_DECK_OF_PUNISHMENT) - result = MISC_BOX_OF_BEASTS; - if (one_chance_in(4) && !you.seen_misc[MISC_DISC_OF_STORMS]) - result = MISC_DISC_OF_STORMS; - if (one_chance_in(4) && !you.seen_misc[MISC_LAMP_OF_FIRE]) - result = MISC_LAMP_OF_FIRE; - if (one_chance_in(4) && !you.seen_misc[MISC_FAN_OF_GALES]) - result = MISC_FAN_OF_GALES; - if (one_chance_in(4) && !you.seen_misc[MISC_STONE_OF_TREMORS]) - result = MISC_STONE_OF_TREMORS; - if (one_chance_in(4) && !you.seen_misc[MISC_PHIAL_OF_FLOODS]) - result = MISC_PHIAL_OF_FLOODS; - if (one_chance_in(4) && !you.seen_misc[MISC_LANTERN_OF_SHADOWS]) - result = MISC_LANTERN_OF_SHADOWS; - if (x_chance_in_y(you.skills[SK_EVOCATIONS], 27) - && (x_chance_in_y(max(you.skills[SK_SPELLCASTING], - you.skills[SK_INVOCATIONS]), 27)) + // Total weight if none have been seen is 100. + int result = random_choose_weighted( // Decks given lowest weight. + 2, MISC_DECK_OF_DUNGEONS, + 2, MISC_DECK_OF_WAR, + 2, MISC_DECK_OF_CHANGES, + 2, MISC_DECK_OF_DEFENCE, + // The player might want + // multiple of these. + (you.seen_misc[MISC_LAMP_OF_FIRE] ? 8 : 15), MISC_LAMP_OF_FIRE, + (you.seen_misc[MISC_PHIAL_OF_FLOODS] ? 8 : 15), MISC_PHIAL_OF_FLOODS, + (you.seen_misc[MISC_FAN_OF_GALES] ? 8 : 15), MISC_FAN_OF_GALES, + (you.seen_misc[MISC_STONE_OF_TREMORS] ? 8 : 15), MISC_STONE_OF_TREMORS, + // These have charges, so + // give them a constant + // weight. + 8, MISC_BOX_OF_BEASTS, + 8, MISC_SACK_OF_SPIDERS, + // The player never needs + // more than one. + (you.seen_misc[MISC_DISC_OF_STORMS] ? 0 : 8), MISC_DISC_OF_STORMS, + (you.seen_misc[MISC_LANTERN_OF_SHADOWS] ? 0 : 8), MISC_LANTERN_OF_SHADOWS, + 0); + + // Give a crystal ball based on both evocations and either spellcasting or + // invocations if we haven't seen one. + int skills = you.skills[SK_EVOCATIONS] + * max(you.skills[SK_SPELLCASTING], you.skills[SK_INVOCATIONS]); + if (x_chance_in_y(skills, MAX_SKILL_LEVEL * MAX_SKILL_LEVEL) && !you.seen_misc[MISC_CRYSTAL_BALL_OF_ENERGY]) { result = MISC_CRYSTAL_BALL_OF_ENERGY; |