summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-20 21:50:54 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-20 21:50:54 +0000
commitf86f721a09fef1f93958a2abc37da555d87f8971 (patch)
tree1851c4f80e2848734dc5c2202b3478f890818253
parent3219115e22de903dd8795fc40e101d6c05ab3291 (diff)
downloadcrawl-ref-f86f721a09fef1f93958a2abc37da555d87f8971.tar.gz
crawl-ref-f86f721a09fef1f93958a2abc37da555d87f8971.zip
* Add ability descriptions to the database search.
* Xom no longer gifts stuff that unquestionably makes for a more boring adventure (scrolls of Detect/Remove Curse, Magic Mapping, Identify; potion of cure mutation, amulet of resist mutation, ring of control teleport). * Xom's "niceness" is no longer automatically defined by his mood, but it's now randomly picked according to piety > random2(200), which translates to nice, else the opposite. A "beloved toy" is extremely likely to get nice effects, and vice versa for the "beloved plaything". * In xom_acts, instead of 50% chance for piety flip, there's now a 20% chance of piety being randomly rerolled. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9523 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/abl-show.cc15
-rw-r--r--crawl-ref/source/abl-show.h2
-rw-r--r--crawl-ref/source/command.cc15
-rw-r--r--crawl-ref/source/invent.cc4
-rw-r--r--crawl-ref/source/makeitem.cc135
-rw-r--r--crawl-ref/source/xom.cc20
6 files changed, 131 insertions, 60 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index bbc6f7c5aa..dd74d1c66e 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -313,6 +313,21 @@ const struct ability_def & get_ability_def( ability_type abil )
return (Ability_List[0]);
}
+bool string_matches_ability_name(const std::string key)
+{
+ for (int i = ABIL_SPIT_POISON; i <= ABIL_RENOUNCE_RELIGION; ++i)
+ {
+ const ability_def abil = get_ability_def((ability_type) i);
+ if (abil.ability == ABIL_NON_ABILITY)
+ continue;
+
+ std::string name = lowercase_string(ability_name(abil.ability));
+ if (name.find(key) != std::string::npos)
+ return (true);
+ }
+ return (false);
+}
+
std::string print_abilities()
{
std::string text = "\n<w>a:</w> ";
diff --git a/crawl-ref/source/abl-show.h b/crawl-ref/source/abl-show.h
index c23c8800cb..e8fcedf238 100644
--- a/crawl-ref/source/abl-show.h
+++ b/crawl-ref/source/abl-show.h
@@ -74,7 +74,7 @@ int choose_ability_menu(const std::vector<talent>& talents);
* *********************************************************************** */
bool activate_ability();
std::vector<talent> your_talents(bool check_confused);
-
+bool string_matches_ability_name(const std::string key);
std::string print_abilities(void);
void set_god_ability_slots(void);
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 229f93f937..bcf81f4281 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1123,6 +1123,15 @@ static bool _card_filter(std::string key, std::string body)
return (true);
}
+static bool _ability_filter(std::string key, std::string body)
+{
+ key = lowercase_string(key);
+ if (string_matches_ability_name(key))
+ return (false);
+
+ return (true);
+}
+
typedef void (*db_keys_recap)(std::vector<std::string>&);
static void _recap_mon_keys(std::vector<std::string> &keys)
@@ -1487,7 +1496,7 @@ static bool _find_description(bool &again, std::string& error_inout)
if (!error_inout.empty())
mpr(error_inout.c_str(), MSGCH_PROMPT);
mpr("Describe a (M)onster, (S)pell, s(K)ill, (I)tem, (F)eature, (G)od, "
- "(B)ranch, or (C)ard?", MSGCH_PROMPT);
+ "(A)bility, (B)ranch, or (C)ard?", MSGCH_PROMPT);
int ch = toupper(getch());
std::string type;
@@ -1520,6 +1529,10 @@ static bool _find_description(bool &again, std::string& error_inout)
type = "skill";
filter = _skill_filter;
break;
+ case 'A':
+ type = "ability";
+ filter = _ability_filter;
+ break;
case 'C':
type = "card";
filter = _card_filter;
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index df108101d2..7ee1b3b064 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -739,8 +739,8 @@ void InvMenu::load_items(const std::vector<const item_def*> &mitems,
_get_class_hotkeys(i, glyphs);
if (!glyphs.empty())
{
- const std::string misc = "Miscellaneous";
- subtitle += std::string(misc.length()
+ const std::string str = "Magical Devices"; // longest string
+ subtitle += std::string(str.length()
- subtitle.length() + 1, ' ');
subtitle += "(select all with <w>";
for (unsigned int k = 0; k < glyphs.size(); ++k)
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 04809c5c70..b085171650 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -811,6 +811,36 @@ void item_colour(item_def &item)
}
}
+// Does Xom consider an item boring?
+static bool _is_boring_item(int type, int sub_type)
+{
+ switch (type)
+ {
+ case OBJ_POTIONS:
+ return (sub_type == POT_CURE_MUTATION);
+ case OBJ_SCROLLS:
+ // The corresponding spells are considered "boring", so Xom
+ // shouldn't gift these scrolls either.
+ switch (sub_type)
+ {
+ case SCR_DETECT_CURSE:
+ case SCR_REMOVE_CURSE:
+ case SCR_IDENTIFY:
+ case SCR_MAGIC_MAPPING:
+ return (true);
+ default:
+ break;
+ }
+ break;
+ case OBJ_JEWELLERY:
+ return (sub_type == RING_TELEPORT_CONTROL
+ || sub_type == AMU_RESIST_MUTATION);
+ default:
+ break;
+ }
+ return (false);
+}
+
static weapon_type _determine_weapon_subtype(int item_level)
{
weapon_type rc = WPN_UNKNOWN;
@@ -2301,7 +2331,7 @@ static void _generate_food_item(item_def& item, int force_quant, int force_type)
}
static void _generate_potion_item(item_def& item, int force_type,
- int item_level)
+ int item_level, int agent)
{
item.quantity = 1;
@@ -2345,12 +2375,13 @@ static void _generate_potion_item(item_def& item, int force_type,
10, POT_DECAY,
0);
}
- while ( stype == POT_POISON && item_level < 1
- || stype == POT_STRONG_POISON && item_level < 11 );
+ while (stype == POT_POISON && item_level < 1
+ || stype == POT_STRONG_POISON && item_level < 11
+ || agent == GOD_XOM && _is_boring_item(OBJ_POTIONS, stype));
- if ( stype == POT_GAIN_STRENGTH || stype == POT_GAIN_DEXTERITY
- || stype == POT_GAIN_INTELLIGENCE || stype == POT_EXPERIENCE
- || stype == POT_MAGIC || stype == POT_RESTORE_ABILITIES )
+ if (stype == POT_GAIN_STRENGTH || stype == POT_GAIN_DEXTERITY
+ || stype == POT_GAIN_INTELLIGENCE || stype == POT_EXPERIENCE
+ || stype == POT_MAGIC || stype == POT_RESTORE_ABILITIES)
{
item.quantity = 1;
}
@@ -2362,7 +2393,7 @@ static void _generate_potion_item(item_def& item, int force_type,
}
static void _generate_scroll_item(item_def& item, int force_type,
- int item_level)
+ int item_level, int agent)
{
// determine sub_type:
if (force_type != OBJ_RANDOM)
@@ -2371,40 +2402,44 @@ static void _generate_scroll_item(item_def& item, int force_type,
{
const int depth_mod = random2(1 + item_level);
- // total weight: 10000
- item.sub_type = random_choose_weighted(
- 1797, SCR_IDENTIFY,
- 1305, SCR_REMOVE_CURSE,
- 802, SCR_TELEPORTATION,
- 642, SCR_DETECT_CURSE,
- 321, SCR_FEAR,
- 321, SCR_NOISE,
- 321, SCR_MAGIC_MAPPING,
- 321, SCR_FOG,
- 321, SCR_RANDOM_USELESSNESS,
- 321, SCR_CURSE_WEAPON,
- 321, SCR_CURSE_ARMOUR,
- 321, SCR_RECHARGING,
- 321, SCR_BLINKING,
- 161, SCR_PAPER,
- 321, SCR_ENCHANT_ARMOUR,
- 321, SCR_ENCHANT_WEAPON_I,
- 321, SCR_ENCHANT_WEAPON_II,
-
- // Don't create ?oImmolation at low levels (encourage read-ID)
- 321, (item_level < 4 ? SCR_TELEPORTATION : SCR_IMMOLATION),
-
- // Medium-level scrolls
- 160, (depth_mod < 4 ? SCR_TELEPORTATION : SCR_ACQUIREMENT),
- 160, (depth_mod < 4 ? SCR_TELEPORTATION : SCR_ENCHANT_WEAPON_III),
- 160, (depth_mod < 4 ? SCR_DETECT_CURSE : SCR_SUMMONING),
- 160, (depth_mod < 4 ? SCR_PAPER : SCR_VULNERABILITY),
-
- // High-level scrolls
- 160, (depth_mod < 7 ? SCR_TELEPORTATION : SCR_VORPALISE_WEAPON),
- 160, (depth_mod < 7 ? SCR_DETECT_CURSE : SCR_TORMENT),
- 160, (depth_mod < 7 ? SCR_DETECT_CURSE : SCR_HOLY_WORD),
- 0);
+ do
+ {
+ // total weight: 10000
+ item.sub_type = random_choose_weighted(
+ 1797, SCR_IDENTIFY,
+ 1305, SCR_REMOVE_CURSE,
+ 802, SCR_TELEPORTATION,
+ 642, SCR_DETECT_CURSE,
+ 321, SCR_FEAR,
+ 321, SCR_NOISE,
+ 321, SCR_MAGIC_MAPPING,
+ 321, SCR_FOG,
+ 321, SCR_RANDOM_USELESSNESS,
+ 321, SCR_CURSE_WEAPON,
+ 321, SCR_CURSE_ARMOUR,
+ 321, SCR_RECHARGING,
+ 321, SCR_BLINKING,
+ 161, SCR_PAPER,
+ 321, SCR_ENCHANT_ARMOUR,
+ 321, SCR_ENCHANT_WEAPON_I,
+ 321, SCR_ENCHANT_WEAPON_II,
+
+ // Don't create ?oImmolation at low levels (encourage read-ID)
+ 321, (item_level < 4 ? SCR_TELEPORTATION : SCR_IMMOLATION),
+
+ // Medium-level scrolls
+ 160, (depth_mod < 4 ? SCR_TELEPORTATION : SCR_ACQUIREMENT),
+ 160, (depth_mod < 4 ? SCR_TELEPORTATION : SCR_ENCHANT_WEAPON_III),
+ 160, (depth_mod < 4 ? SCR_DETECT_CURSE : SCR_SUMMONING),
+ 160, (depth_mod < 4 ? SCR_PAPER : SCR_VULNERABILITY),
+
+ // High-level scrolls
+ 160, (depth_mod < 7 ? SCR_TELEPORTATION : SCR_VORPALISE_WEAPON),
+ 160, (depth_mod < 7 ? SCR_DETECT_CURSE : SCR_TORMENT),
+ 160, (depth_mod < 7 ? SCR_DETECT_CURSE : SCR_HOLY_WORD),
+ 0);
+ }
+ while (agent == GOD_XOM && _is_boring_item(OBJ_SCROLLS, item.sub_type));
}
// determine quantity
@@ -2593,7 +2628,7 @@ static int _determine_ring_plus(int subtype)
}
static void _generate_jewellery_item(item_def& item, bool allow_uniques,
- int force_type, int item_level)
+ int force_type, int item_level, int agent)
{
if (allow_uniques
&& _try_make_jewellery_unrandart(item, force_type, item_level))
@@ -2607,8 +2642,13 @@ static void _generate_jewellery_item(item_def& item, bool allow_uniques,
item.sub_type = force_type;
else
{
- item.sub_type = (one_chance_in(4) ? get_random_amulet_type()
- : get_random_ring_type());
+ do
+ {
+ item.sub_type = (one_chance_in(4) ? get_random_amulet_type()
+ : get_random_ring_type());
+ }
+ while (agent == GOD_XOM
+ && _is_boring_item(OBJ_JEWELLERY, item.sub_type));
}
// Everything begins as uncursed, unenchanted jewellery {dlb}:
@@ -2811,15 +2851,16 @@ int items( int allow_uniques, // not just true-false,
break;
case OBJ_POTIONS:
- _generate_potion_item(item, force_type, item_level);
+ _generate_potion_item(item, force_type, item_level, agent);
break;
case OBJ_SCROLLS:
- _generate_scroll_item(item, force_type, item_level);
+ _generate_scroll_item(item, force_type, item_level, agent);
break;
case OBJ_JEWELLERY:
- _generate_jewellery_item(item, allow_uniques, force_type, item_level);
+ _generate_jewellery_item(item, allow_uniques, force_type, item_level,
+ agent);
break;
case OBJ_BOOKS:
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 3d06a03eba..4a8c257e51 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -103,6 +103,7 @@ const char *describe_xom_favour()
else if (you.gift_timeout < 1)
return "A BORING thing.";
else
+ {
return (you.piety > 180) ? "A beloved toy of Xom." :
(you.piety > 160) ? "A favourite toy of Xom." :
(you.piety > 140) ? "A very special toy of Xom." :
@@ -113,6 +114,7 @@ const char *describe_xom_favour()
(you.piety > 40) ? "A very special plaything of Xom." :
(you.piety > 20) ? "A favourite plaything of Xom."
: "A beloved plaything of Xom.";
+ }
}
static std::string _get_xom_speech(const std::string key)
@@ -135,7 +137,7 @@ bool xom_is_nice()
if (you.religion == GOD_XOM)
// If you.gift_timeout was 0, then Xom was BORED. He HATES that.
- return (you.gift_timeout > 0 && you.piety > (MAX_PIETY / 2));
+ return (you.gift_timeout > 0 && you.piety > random2(MAX_PIETY));
else
return coinflip();
}
@@ -219,7 +221,7 @@ void xom_tick()
simple_god_message(" is getting BORED.");
if (one_chance_in(20))
- xom_acts(abs(you.piety - 100));
+ xom_acts(xom_is_nice());
}
void xom_is_stimulated(int maxinterestingness, const std::string& message,
@@ -1810,7 +1812,7 @@ static bool _xom_is_bad(int sever, int tension)
_xom_miscast(2, nasty);
done = true;
}
- else if (x_chance_in_y(7, sever) && (you.level_type != LEVEL_ABYSS))
+ else if (x_chance_in_y(7, sever) && you.level_type != LEVEL_ABYSS)
{
// The Xom teleportation train takes you on instant
// teleportation to a few random areas, stopping if either
@@ -2029,7 +2031,7 @@ void xom_acts(bool niceness, int sever)
{
niceness = false;
simple_god_message(" asks Xom for help in punishing you, and "
- "Xom happily agrees.", which_god);
+ "Xom happily agrees.", which_god);
}
else
{
@@ -2077,10 +2079,10 @@ void xom_acts(bool niceness, int sever)
}
}
- if (you.religion == GOD_XOM && coinflip())
+ if (you.religion == GOD_XOM && one_chance_in(5))
{
const std::string old_xom_favour = describe_xom_favour();
- you.piety = MAX_PIETY - you.piety;
+ you.piety = random2(MAX_PIETY+1);
const std::string new_xom_favour = describe_xom_favour();
if (old_xom_favour != new_xom_favour)
{
@@ -2099,9 +2101,9 @@ static void _xom_check_less_runes(int runes_gone)
}
int runes_avail = you.attribute[ATTR_UNIQUE_RUNES]
- + you.attribute[ATTR_DEMONIC_RUNES]
- + you.attribute[ATTR_ABYSSAL_RUNES]
- - you.attribute[ATTR_RUNES_IN_ZOT];
+ + you.attribute[ATTR_DEMONIC_RUNES]
+ + you.attribute[ATTR_ABYSSAL_RUNES]
+ - you.attribute[ATTR_RUNES_IN_ZOT];
int was_avail = runes_avail + runes_gone;
// No longer enough available runes to get into Zot.