From a5248544dcc3d81873bd8e9cddad3dded307083d Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Thu, 6 Nov 2008 20:02:26 +0000 Subject: * Tweak a number of starting choice restrictions. (FR 2106062) * FR 2088441: Add an aptitudes hotkey for the book/weapon choice submenus. * FR 2196437: Check entire stack of (selected) items, even if your pack is full, in case some of them can merge. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7393 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/items.cc | 107 +++++++++++++++++++++++++++++++++----------- crawl-ref/source/newgame.cc | 27 ++++++++--- 2 files changed, 102 insertions(+), 32 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 9aff646578..39d74eb2af 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -775,6 +775,9 @@ void item_check(bool verbose) static void _pickup_menu(int item_link) { + int n_did_pickup = 0; + int n_tried_pickup = 0; + std::vector items; item_list_on_square( items, item_link, false ); @@ -782,6 +785,7 @@ static void _pickup_menu(int item_link) select_items( items, "Select items to pick up" ); redraw_screen(); + std::string pickup_warning; for (int i = 0, count = selected.size(); i < count; ++i) for (int j = item_link; j != NON_ITEM; j = mitm[j].link) { @@ -790,31 +794,58 @@ static void _pickup_menu(int item_link) if (j == item_link) item_link = mitm[j].link; + int num_to_take = selected[i].quantity; + if (Options.autopickup_no_burden && item_mass(mitm[j]) != 0) + { + int num_can_take = + (carrying_capacity(you.burden_state) - you.burden) / + item_mass(mitm[j]); + + if (num_can_take < num_to_take) + { + if (!n_tried_pickup) + { + mpr("You can't pick everything up without " + "burdening yourself."); + } + n_tried_pickup++; + num_to_take = num_can_take; + } + + if (num_can_take == 0) + continue; + } unsigned long oldflags = mitm[j].flags; mitm[j].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); - int result = move_item_to_player( j, selected[i].quantity ); + int result = move_item_to_player( j, num_to_take ); // If we cleared any flags on the items, but the pickup was // partial, reset the flags for the items that remain on the // floor. - if (is_valid_item(mitm[j])) - mitm[j].flags = oldflags; - - if (result == 0) - { - mpr("You can't carry that much weight."); - learned_something_new(TUT_HEAVY_LOAD); - return; - } - else if (result == -1) + if (result == 0 || result == -1) { - mpr("You can't carry that many items."); - learned_something_new(TUT_HEAVY_LOAD); - return; + n_tried_pickup++; + if (result == 0) + pickup_warning = "You can't carry that much weight."; + else + pickup_warning = "You can't carry that many items."; + + if (is_valid_item(mitm[j])) + mitm[j].flags = oldflags; } - break; + else + n_did_pickup++; } } + + if (!pickup_warning.empty()) + { + mpr(pickup_warning.c_str()); + learned_something_new(TUT_HEAVY_LOAD); + } + + if (n_did_pickup) + you.turn_is_over = true; } bool origin_known(const item_def &item) @@ -1167,6 +1198,8 @@ void pickup() { int next; mpr("There are several objects here."); + bool tried_pickup = false; + std::string pickup_warning; while ( o != NON_ITEM ) { // Must save this because pickup can destroy the item. @@ -1202,23 +1235,47 @@ void pickup() if (keyin == 'y' || keyin == 'a') { - mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); - int result = move_item_to_player( o, mitm[o].quantity ); - - if (result == 0) + int num_to_take = mitm[o].quantity; + if (Options.autopickup_no_burden && item_mass(mitm[o]) != 0) { - mpr("You can't carry that much weight."); - keyin = 'x'; // resets from 'a' + int num_can_take = + (carrying_capacity(you.burden_state) - you.burden) / + item_mass(mitm[o]); + + if (num_can_take < num_to_take) + { + if (!tried_pickup) + { + mpr("You can't pick everything up without " + "burdening yourself."); + tried_pickup = true; + } + num_to_take = num_can_take; + } + + if (num_can_take == 0) + continue; } - else if (result == -1) + const unsigned long old_flags(mitm[o].flags); + mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); + int result = move_item_to_player( o, num_to_take ); + + if (result == 0 || result == -1) { - mpr("You can't carry that many items."); - break; + if (result == 0) + pickup_warning = "You can't carry that much weight."; + else + pickup_warning = "You can't carry that many items."; + + mitm[o].flags = old_flags; } } o = next; } + + if (!pickup_warning.empty()) + mpr(pickup_warning.c_str()); } } // end pickup() @@ -2221,7 +2278,7 @@ bool can_autopickup() if (you.flight_mode() == FL_LEVITATE) return (false); - if ( !i_feel_safe() ) + if (!i_feel_safe()) return (false); return (true); diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index eb07efdd1e..afdeae07d3 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -1294,6 +1294,7 @@ static char_choice_restriction _class_allowed( species_type speci, case SP_NAGA: case SP_OGRE: case SP_RED_DRACONIAN: + case SP_MUMMY: case SP_VAMPIRE: return CC_RESTRICTED; default: @@ -1441,6 +1442,7 @@ static char_choice_restriction _class_allowed( species_type speci, case SP_SPRIGGAN: case SP_NAGA: case SP_KENKU: + case SP_GHOUL: return CC_RESTRICTED; default: return CC_UNRESTRICTED; @@ -1471,6 +1473,7 @@ static char_choice_restriction _class_allowed( species_type speci, case JOB_CRUSADER: switch (speci) { + case SP_DEEP_ELF: case SP_SLUDGE_ELF: case SP_MOUNTAIN_DWARF: case SP_HILL_ORC: @@ -1523,9 +1526,11 @@ static char_choice_restriction _class_allowed( species_type speci, case SP_MERFOLK: case SP_HALFLING: case SP_GNOME: + case SP_KOBOLD: case SP_SPRIGGAN: case SP_CENTAUR: case SP_TROLL: + case SP_OGRE: case SP_MINOTAUR: case SP_GHOUL: return CC_RESTRICTED; @@ -1653,14 +1658,15 @@ static char_choice_restriction _class_allowed( species_type speci, case SP_HALFLING: case SP_KOBOLD: case SP_GNOME: + case SP_SPRIGGAN: case SP_CENTAUR: case SP_TROLL: case SP_MINOTAUR: case SP_KENKU: - case SP_RED_DRACONIAN: case SP_DEMONSPAWN: case SP_MUMMY: case SP_GHOUL: + case SP_VAMPIRE: return CC_RESTRICTED; default: return CC_UNRESTRICTED; @@ -1809,7 +1815,6 @@ static char_choice_restriction _class_allowed( species_type speci, case SP_SPRIGGAN: case SP_NAGA: case SP_OGRE: - case SP_TROLL: case SP_RED_DRACONIAN: case SP_MUMMY: case SP_GHOUL: @@ -1948,7 +1953,8 @@ static bool _choose_book( item_def& book, int firstbook, int numbooks ) _print_character_info(); textcolor( CYAN ); - cprintf(EOL "You have a choice of books:" EOL); + cprintf(EOL "You have a choice of books: " + "(Press %% for a list of aptitudes)" EOL); for (int i = 0; i < numbooks; ++i) { @@ -2005,6 +2011,9 @@ static bool _choose_book( item_def& book, int firstbook, int numbooks ) else keyin = ('a' + Options.prev_book - 1); } + case '%': + list_commands('%'); + return _choose_book(book, firstbook, numbooks); default: break; } @@ -2223,7 +2232,8 @@ static bool _choose_weapon() _print_character_info(); textcolor( CYAN ); - cprintf(EOL "You have a choice of weapons:" EOL); + cprintf(EOL "You have a choice of weapons: " + "(Press %% for a list of aptitudes)" EOL); bool prevmatch = false; for (int i = 0; i < num_choices; i++) @@ -2295,6 +2305,11 @@ static bool _choose_weapon() keyin = 'a' + i; } } + case '%': + list_commands('%'); + return _choose_weapon(); + default: + break; } } while (keyin != '*' && keyin != '+' @@ -2360,7 +2375,7 @@ static char_choice_restriction _religion_restriction(god_type god) case SP_GHOUL: case SP_VAMPIRE: return (CC_BANNED); - case SP_HIGH_ELF: + case SP_SLUDGE_ELF: case SP_MOUNTAIN_DWARF: case SP_CENTAUR: case SP_MINOTAUR: @@ -2414,7 +2429,6 @@ static char_choice_restriction _religion_restriction(god_type god) case GOD_XOM: switch (you.species) { - case SP_HUMAN: case SP_MOUNTAIN_DWARF: case SP_HILL_ORC: case SP_MERFOLK: @@ -2424,7 +2438,6 @@ static char_choice_restriction _religion_restriction(god_type god) case SP_MINOTAUR: case SP_KENKU: case SP_DEMONSPAWN: - case SP_VAMPIRE: return (CC_UNRESTRICTED); default: if (player_genus(GENPC_DRACONIAN)) -- cgit v1.2.3-54-g00ecf