Attached Files |
misc_acquire_clean_up.patch [^] (4,347 bytes) 2014-03-14 22:53 [Show Content] [Hide Content]From ee662dcb96dd3ed53e0038bf5975a333c25062d8 Mon Sep 17 00:00:00 2001
From: reaver <address.auto@gmail.com>
Date: Thu, 13 Mar 2014 04:08:23 -0400
Subject: [PATCH] Clean-up selecting the item type for miscellaneous
acquirement.
The old function was mess. This clean-up changes the outcome in less
than 1% of cases. This makes miscellaneous acquirement easier to change
in case new miscellaneous items are added or somebody wants to make it a
viable option.
---
crawl-ref/source/acquire.cc | 71 +++++++++++++++++++++++++++------------------
1 file changed, 43 insertions(+), 28 deletions(-)
diff --git a/crawl-ref/source/acquire.cc b/crawl-ref/source/acquire.cc
index 1fb5240..ef82afb 100644
--- a/crawl-ref/source/acquire.cc
+++ b/crawl-ref/source/acquire.cc
@@ -655,36 +655,51 @@ static int _acquirement_staff_subtype(const has_vector& already_has)
return result;
}
+static bool _misc_acquirement_should_give_ball_of_energy()
+{
+ int mp_skill = max(you.skills[SK_SPELLCASTING], you.skills[SK_INVOCATIONS]);
+
+ int skills = you.skills[SK_EVOCATIONS] * mp_skill;
+
+ return x_chance_in_y(skills, MAX_SKILL_LEVEL^2)
+ && !you.seen_misc[MISC_CRYSTAL_BALL_OF_ENERGY];
+}
+
+static int _random_deck_misc_aquire()
+{ // Total is 17 weight, becuase that is the chance this
+ // function will be chosen in _acquire_other_misc_item()
+
+ return random_choose_weighted(2, MISC_DECK_OF_ESCAPE,
+ 2, MISC_DECK_OF_DESTRUCTION,
+ 2, MISC_DECK_OF_DUNGEONS,
+ 2, MISC_DECK_OF_WONDERS,
+ 2, MISC_DECK_OF_WAR,
+ 2, MISC_DECK_OF_CHANGES,
+ 2, MISC_DECK_OF_DEFENCE,
+ 1, MISC_DECK_OF_SUMMONING,
+ 0);
+}
+
+static int _acquire_other_misc_item()
+{ // Total is 100 wieght.
+ return random_choose_weighted( 17, _random_deck_misc_aquire(),
+ 1, MISC_SACK_OF_SPIDERS,
+ 2, MISC_BOX_OF_BEASTS,
+ you.seen_misc[MISC_DISC_OF_STORMS] ? 0 : 6, MISC_DISC_OF_STORMS,
+ you.seen_misc[MISC_LAMP_OF_FIRE] ? 0 : 8, MISC_LAMP_OF_FIRE,
+ you.seen_misc[MISC_FAN_OF_GALES] ? 0 : 10, MISC_FAN_OF_GALES,
+ you.seen_misc[MISC_STONE_OF_TREMORS] ? 0 : 14, MISC_STONE_OF_TREMORS,
+ you.seen_misc[MISC_PHIAL_OF_FLOODS] ? 0 : 19, MISC_PHIAL_OF_FLOODS,
+ you.seen_misc[MISC_LANTERN_OF_SHADOWS] ? 0 : 25, MISC_LANTERN_OF_SHADOWS,
+ 0);
+}
+
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))
- && !you.seen_misc[MISC_CRYSTAL_BALL_OF_ENERGY])
- {
- result = MISC_CRYSTAL_BALL_OF_ENERGY;
- }
-
- return result;
+ if (_misc_acquirement_should_give_ball_of_energy())
+ return MISC_CRYSTAL_BALL_OF_ENERGY;
+ else
+ return _acquire_other_misc_item();
}
static int _acquirement_wand_subtype()
--
1.8.2.1
|