summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-25 20:38:08 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-25 20:38:08 +0000
commita99482600e234c892e8d0c257c44ebbbef7053b8 (patch)
tree26d3ff8c3a571997b7c88929f16b9039aec0ea84 /crawl-ref
parent94d9e1a1dbf297d9882754d07021ddb2793657b2 (diff)
downloadcrawl-ref-a99482600e234c892e8d0c257c44ebbbef7053b8.tar.gz
crawl-ref-a99482600e234c892e8d0c257c44ebbbef7053b8.zip
* Use menu colours (rather than message colours) for item announcements
and the like. * Fix 'V' if there are more than 52 monsters/items in the list. * Make Xom act more often, with the probability depending strongly on tension. Also tweak a few action probabilities according to tension, so that e.g. summons are more likely for high tension. * Fix monsters being created with large quantities of curare needles. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9546 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/directn.cc53
-rw-r--r--crawl-ref/source/invent.cc3
-rw-r--r--crawl-ref/source/items.cc18
-rw-r--r--crawl-ref/source/makeitem.cc3
-rw-r--r--crawl-ref/source/menu.cc23
-rw-r--r--crawl-ref/source/stash.cc2
-rw-r--r--crawl-ref/source/travel.cc9
-rw-r--r--crawl-ref/source/xom.cc84
8 files changed, 123 insertions, 72 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 943057e7c5..b3a31e0f36 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -513,7 +513,7 @@ void full_describe_view()
}
InvMenu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE
- | MF_ALLOW_FORMATTING);
+ | MF_ALLOW_FORMATTING | MF_SELECT_BY_PAGE);
desc_menu.set_highlighter(NULL);
// FIXME: Need different title for the opposite toggle:
@@ -526,19 +526,24 @@ void full_describe_view()
desc_menu.set_type(MT_PICKUP); // necessary for sorting of the item submenu
desc_menu.allow_toggle = true;
- int menu_index = -1;
+ // Don't make a menu so tall that we recycle hotkeys on the same page.
+ if (list_mons.size() + list_items.size() > 52
+ && (desc_menu.maxpagesize() > 52 || desc_menu.maxpagesize() == 0))
+ {
+ desc_menu.set_maxpagesize(52);
+ }
+
+ menu_letter hotkey;
// Build menu entries for monsters.
if (!list_mons.empty())
{
desc_menu.add_entry( new MenuEntry("Monsters", MEL_SUBTITLE) );
- for (unsigned int i = 0; i < list_mons.size(); ++i)
+// desc_menu.mdisplay->set_num_columns(1);
+ for (unsigned int i = 0; i < list_mons.size(); ++i, ++hotkey)
{
// List monsters in the form
// (A) An angel (neutral), wielding a glowing long sword
- ++menu_index;
- const char letter = index_to_letter(menu_index);
-
// Get colour-coded letter.
unsigned char colour = get_mons_colour(list_mons[i]);
if (colour == BLACK)
@@ -570,8 +575,10 @@ void full_describe_view()
if (damage_level != MDAM_OKAY)
str += ", " + damage_desc;
+#ifndef USE_TILE
// Wraparound if the description is longer than allowed.
- linebreak_string2(str, get_number_of_cols() - 8);
+ linebreak_string2(str, get_number_of_cols() - 9);
+#endif
std::vector<formatted_string> fss;
formatted_string::parse_string_to_multiple(str, fss);
MenuEntry *me;
@@ -579,16 +586,17 @@ void full_describe_view()
{
if (j == 0)
{
- me = new MenuEntry(prefix + str, MEL_ITEM, 1, letter);
+ me = new MenuEntry(prefix + str, MEL_ITEM, 1, hotkey);
me->data = (void*) list_mons[i];
me->quantity = 1; // Hack to make monsters selectable.
}
+#ifndef USE_TILE
else
{
- str = " " + fss[j].tostring();
+ str = " " + fss[j].tostring();
me = new MenuEntry(str, MEL_ITEM, 1);
}
-
+#endif
desc_menu.add_entry(me);
}
}
@@ -605,17 +613,15 @@ void full_describe_view()
desc_menu.sort_menu(all_items, cond);
desc_menu.add_entry( new MenuEntry( "Items", MEL_SUBTITLE ) );
- for (unsigned int i = 0; i < all_items.size(); ++i)
+ for (unsigned int i = 0; i < all_items.size(); ++i, ++hotkey)
{
- ++menu_index;
- const char letter = index_to_letter(menu_index);
InvEntry *me = all_items[i];
#ifndef USE_TILE
// Show glyphs only for ASCII.
me->set_show_glyph(true);
#endif
me->tag = "pickup";
- me->hotkeys[0] = letter;
+ me->hotkeys[0] = hotkey;
me->quantity = 2; // Hack to make items selectable.
desc_menu.add_entry(me);
@@ -3045,7 +3051,10 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
std::string desc = "";
if (mondtype != DESC_NONE)
{
- desc = mon->full_name(mondtype);
+ if (print_attitude && mon->type == MONS_PLAYER_GHOST)
+ desc = get_ghost_description(*mon);
+ else
+ desc = mon->full_name(mondtype);
if (print_attitude)
{
@@ -3056,7 +3065,8 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
str = "neutral";
if (mon->type == MONS_DANCING_WEAPON
- || mon-> type == MONS_PANDEMONIUM_DEMON
+ || mon->type == MONS_PANDEMONIUM_DEMON
+ || mon->type == MONS_PLAYER_GHOST
|| mons_is_known_mimic(mon))
{
if (!str.empty())
@@ -3066,6 +3076,8 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
str += "dancing weapon";
else if (mon->type == MONS_PANDEMONIUM_DEMON)
str += "pandemonium demon";
+ else if (mon->type == MONS_PLAYER_GHOST)
+ str += "ghost";
else
str += "mimic";
}
@@ -3194,8 +3206,8 @@ static void _describe_cell(const coord_def& where, bool in_range)
{
item_def item;
get_mimic_item( mon, item );
- std::string name = get_message_colour_tags(item, DESC_NOCAP_A,
- MSGCH_FLOOR_ITEMS);
+ std::string name = get_menu_colour_prefix_tags(item,
+ DESC_NOCAP_A);
mprf("You see %s here.", name.c_str());
}
mimic_item = true;
@@ -3260,9 +3272,8 @@ static void _describe_cell(const coord_def& where, bool in_range)
mprf( MSGCH_FLOOR_ITEMS, "A pile of gold coins." );
else
{
- std::string name = get_message_colour_tags(mitm[targ_item],
- DESC_NOCAP_A,
- MSGCH_FLOOR_ITEMS);
+ std::string name = get_menu_colour_prefix_tags(mitm[targ_item],
+ DESC_NOCAP_A);
mprf( MSGCH_FLOOR_ITEMS, "You see %s here.",
name.c_str());
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index d2f8447f14..95ae61ecee 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -619,8 +619,7 @@ static bool _compare_invmenu_items(const InvEntry *a, const InvEntry *b,
const item_sort_comparators *cmps)
{
for (item_sort_comparators::const_iterator i = cmps->begin();
- i != cmps->end();
- ++i)
+ i != cmps->end(); ++i)
{
const int cmp = i->compare(a, b);
if (cmp)
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index c368440068..24d63b7dd9 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -731,8 +731,7 @@ void item_check(bool verbose)
if (items.size() == 1 )
{
item_def it(*items[0]);
- std::string name = get_message_colour_tags(it, DESC_NOCAP_A,
- MSGCH_FLOOR_ITEMS);
+ std::string name = get_menu_colour_prefix_tags(it, DESC_NOCAP_A);
strm << "You see here " << name << '.' << std::endl;
return;
}
@@ -787,8 +786,7 @@ void item_check(bool verbose)
for (unsigned int i = 0; i < items.size(); ++i)
{
item_def it(*items[i]);
- std::string name = get_message_colour_tags(it, DESC_NOCAP_A,
- MSGCH_FLOOR_ITEMS);
+ std::string name = get_menu_colour_prefix_tags(it, DESC_NOCAP_A);
strm << name << std::endl;
}
}
@@ -1259,8 +1257,8 @@ void pickup()
"y/n/a/*?g,/q)";
mprf(MSGCH_PROMPT, prompt.c_str(),
- get_message_colour_tags(mitm[o], DESC_NOCAP_A,
- MSGCH_PROMPT).c_str());
+ get_menu_colour_prefix_tags(mitm[o],
+ DESC_NOCAP_A).c_str());
mouse_control mc(MOUSE_MODE_MORE);
keyin = getch();
@@ -1616,8 +1614,8 @@ int move_item_to_player( int obj, int quant_got, bool quiet,
if (!quiet)
{
- mpr(get_message_colour_tags(you.inv[m],
- DESC_INVENTORY).c_str());
+ mpr(get_menu_colour_prefix_tags(you.inv[m],
+ DESC_INVENTORY).c_str());
}
you.turn_is_over = true;
@@ -1684,8 +1682,8 @@ int move_item_to_player( int obj, int quant_got, bool quiet,
if (!quiet)
{
- mpr(get_message_colour_tags(you.inv[freeslot],
- DESC_INVENTORY).c_str());
+ mpr(get_menu_colour_prefix_tags(you.inv[freeslot],
+ DESC_INVENTORY).c_str());
}
if (Options.tutorial_left)
{
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index b085171650..fcd502e86c 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -3814,6 +3814,9 @@ static void _give_ammo(monsters *mon, int level,
set_item_ego_type(mitm[thing_created], OBJ_MISSILES,
_got_curare_roll(level) ? SPMSL_CURARE
: SPMSL_POISONED);
+
+ if (get_ammo_brand( mitm[thing_created] ) == SPMSL_CURARE)
+ mitm[thing_created].quantity = random_range(2, 8);
}
else
{
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 175e098c12..c452cf7973 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1203,7 +1203,8 @@ void slider_menu::calc_y_offset()
int slider_menu::entry_end() const
{
int end = first_entry + pagesize;
- if (end > (int) items.size()) end = items.size();
+ if (end > (int) items.size())
+ end = items.size();
return (end);
}
@@ -1400,13 +1401,12 @@ void column_composer::clear()
flines.clear();
}
-void column_composer::add_formatted(
- int ncol,
- const std::string &s,
- bool add_separator,
- bool eol_ends_format,
- bool (*tfilt)(const std::string &),
- int margin)
+void column_composer::add_formatted(int ncol,
+ const std::string &s,
+ bool add_separator,
+ bool eol_ends_format,
+ bool (*tfilt)(const std::string &),
+ int margin)
{
ASSERT(ncol >= 0 && ncol < (int) columns.size());
@@ -1433,10 +1433,9 @@ void column_composer::add_formatted(
strip_blank_lines(newlines);
- compose_formatted_column(
- newlines,
- col.lines,
- margin == -1? col.margin : margin);
+ compose_formatted_column( newlines,
+ col.lines,
+ margin == -1? col.margin : margin );
col.lines += newlines.size();
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index a2f47ffc7a..cecf818d5c 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -515,8 +515,10 @@ void StashMenu::draw_title()
textcolor(title->colour);
cprintf( "%s", title->text.c_str());
if (title->quantity)
+ {
cprintf(", %d item%s", title->quantity,
title->quantity == 1? "" : "s");
+ }
cprintf(")");
if (can_travel)
cprintf(" [ENTER: travel]");
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index cb00257661..8e14c27a8a 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2979,7 +2979,7 @@ void start_explore(bool grab_items)
// Forget interrupted butchering.
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- you.running = grab_items? RMODE_EXPLORE_GREEDY : RMODE_EXPLORE;
+ you.running = (grab_items? RMODE_EXPLORE_GREEDY : RMODE_EXPLORE);
if (you.running == RMODE_EXPLORE_GREEDY
&& Options.stash_tracking != STM_ALL)
{
@@ -4191,7 +4191,8 @@ void explore_discoveries::add_item(const item_def &i)
items[j].thing.quantity = orig_quantity;
}
- items.push_back( named_thing<item_def>(i.name(DESC_NOCAP_A), i) );
+ items.push_back( named_thing<item_def>(get_menu_colour_prefix_tags(i,
+ DESC_NOCAP_A), i) );
// First item of this type?
// XXX: Only works when travelling.
@@ -4230,8 +4231,8 @@ void explore_discoveries::found_item(const coord_def &pos, const item_def &i)
} // if (you.running == RMODE_EXPLORE_GREEDY)
add_item(i);
- es_flags |= (you.running == RMODE_EXPLORE_GREEDY) ? ES_GREEDY_PICKUP :
- ES_PICKUP;
+ es_flags |= (you.running == RMODE_EXPLORE_GREEDY) ? ES_GREEDY_PICKUP
+ : ES_PICKUP;
}
// Expensive O(n^2) duplicate search, but we can live with that.
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 23badaf49c..1d8c25faea 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -195,6 +195,18 @@ void xom_is_stimulated(int maxinterestingness, xom_message_type message_type,
force_message);
}
+static bool _xom_is_bored()
+{
+ return (you.religion == GOD_XOM && you.gift_timeout == 0);
+}
+
+static bool _xom_feels_nasty()
+{
+ // Xom will only directly kill you with a bad effect if you're under
+ // penance from him, or if he's bored.
+ return (you.penance[GOD_XOM] || _xom_is_bored());
+}
+
void xom_tick()
{
// Xom semi-randomly drifts your piety.
@@ -226,8 +238,30 @@ void xom_tick()
if (you.gift_timeout == 1)
simple_god_message(" is getting BORED.");
- if (one_chance_in(5) && (one_chance_in(3) || get_tension(GOD_XOM)))
- xom_acts(abs(you.piety - MAX_PIETY/2));
+ if (one_chance_in(3))
+ {
+ if (_xom_is_bored())
+ xom_acts(abs(you.piety - MAX_PIETY/2));
+ else
+ {
+ const int tension = get_tension(GOD_XOM);
+/*
+ const int chance = (tension == 0 ? 1 :
+ tension <= 5 ? 2 : 3);
+
+ if (x_chance_in_y(chance, 3))
+ xom_acts(abs(you.piety - MAX_PIETY/2));
+*/
+ const int chance = (tension == 0 ? 1 :
+ tension <= 5 ? 2 :
+ tension <= 10 ? 3 :
+ tension <= 20 ? 4
+ : 5);
+
+ if (x_chance_in_y(chance, 5))
+ xom_acts(abs(you.piety - MAX_PIETY/2));
+ }
+ }
}
void xom_is_stimulated(int maxinterestingness, const std::string& message,
@@ -745,14 +779,6 @@ static bool _player_is_dead()
|| you.did_escape_death());
}
-static bool _xom_feels_nasty()
-{
- // Xom will only directly kill you with a bad effect if you're under
- // penance from him, or if he's bored.
- return (you.penance[GOD_XOM]
- || (you.religion == GOD_XOM && you.gift_timeout == 0));
-}
-
static bool _xom_do_potion()
{
bool rc = false;
@@ -812,8 +838,13 @@ static bool _xom_confuse_monsters(int sever)
static bool _xom_send_allies(int sever)
{
bool rc = false;
- const int numdemons =
- std::min(random2(random2(random2(sever+1)+1)+1)+2, 16);
+ // The number of allies is dependent on severity, though heavily
+ // randomized.
+ int numdemons = sever;
+ for (int i = 0; i < 3; i++)
+ numdemons = random2(numdemons+1);
+ numdemons = std::min(numdemons+2,16);
+
int numdifferent = 0;
// If we have a mix of demons and non-demons, there's a chance
@@ -1147,8 +1178,8 @@ static bool _xom_is_good(int sever, int tension)
// This series of random calls produces a poisson-looking
// distribution: initial hump, plus a long-ish tail.
- // Don't make the player berserk if there's no danger.
- if (tension > 0 && x_chance_in_y(2, sever))
+ // Don't make the player go berserk if there's no danger.
+ if (tension > random2(3) && x_chance_in_y(2, sever))
done = _xom_do_potion();
else if (x_chance_in_y(3, sever))
{
@@ -1161,16 +1192,16 @@ static bool _xom_is_good(int sever, int tension)
else if (x_chance_in_y(4, sever))
done = _xom_confuse_monsters(sever);
// It's pointless to send in help if there's no danger.
- else if (tension > 0 && x_chance_in_y(5, sever))
- done = _xom_send_allies(sever);
+ else if (tension > random2(5) && x_chance_in_y(5, sever))
+ done = _xom_send_one_ally(sever);
else if (x_chance_in_y(6, sever))
{
_xom_give_item(sever);
done = true;
}
// It's pointless to send in help if there's no danger.
- else if (tension > 0 && x_chance_in_y(7, sever))
- done = _xom_send_one_ally(sever);
+ else if (tension > random2(10) && x_chance_in_y(7, sever))
+ done = _xom_send_allies(sever);
else if (x_chance_in_y(8, sever))
done = _xom_polymorph_nearby_monster(true);
else if (x_chance_in_y(9, sever))
@@ -1196,7 +1227,7 @@ static bool _xom_is_good(int sever, int tension)
while (x_chance_in_y(3, 4) || player_in_a_dangerous_place());
done = true;
}
- else if (x_chance_in_y(12, sever))
+ else if (random2(tension) < 5 && x_chance_in_y(12, sever))
{
// This can fail with radius 1, or in open areas.
if (vitrify_area(random2avg(sever / 2, 3) + 1))
@@ -1205,10 +1236,13 @@ static bool _xom_is_good(int sever, int tension)
done = true;
}
}
- else if (x_chance_in_y(13, sever) && x_chance_in_y(16, how_mutated()))
+ else if (random2(tension) < 5 && x_chance_in_y(13, sever)
+ && x_chance_in_y(16, how_mutated()))
+ {
done = _xom_give_mutations(true);
+ }
// It's pointless to send in help if there's no danger.
- else if (tension > 0 && x_chance_in_y(14, sever))
+ else if (tension > random2(15) && x_chance_in_y(14, sever))
done = _xom_send_major_ally(sever);
else if (x_chance_in_y(15, sever))
done = _xom_throw_divine_lightning();
@@ -1350,9 +1384,12 @@ static void _xom_zero_miscast()
+ " seems to fall away from under you!");
vec->push_back(feat_name
+ " seems to rush up at you!");
+
if (grid_is_water(feat))
+ {
priority.push_back("Something invisible splashes into the "
"water beneath you!");
+ }
}
else if (grid_is_water(feat))
{
@@ -1409,7 +1446,8 @@ static void _xom_zero_miscast()
}
if (you.species != SP_NAGA
- && (you.species != SP_MERFOLK || !player_is_swimming()))
+ && (you.species != SP_MERFOLK || !player_is_swimming())
+ && !you.airborne())
{
messages.push_back("You do an impromptu tapdance.");
}
@@ -1856,7 +1894,7 @@ static bool _xom_is_bad(int sever, int tension)
}
else if (x_chance_in_y(8, sever))
done = _xom_chaos_upgrade_nearby_monster();
- else if (x_chance_in_y(9, sever))
+ else if (random2(tension) < 10 && x_chance_in_y(9, sever))
done = _xom_give_mutations(false);
else if (x_chance_in_y(10, sever))
done = _xom_polymorph_nearby_monster(false);