From b794d555277836316ec842421c5287ff50641ff9 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 22 Dec 2006 13:42:49 +0000 Subject: Added option 'autopickup_no_burden' which, if set, will prevent autopickup from picking up items beyond the burden limit. (Partial pickup will take place if you can take some of the items for a stack, e.g., 3 of the 5 potions of healing.) Defaults to false. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@692 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/crawl_options.txt | 12 +++++++++--- crawl-ref/init.txt | 1 + crawl-ref/source/chardump.cc | 2 ++ crawl-ref/source/clua.cc | 1 + crawl-ref/source/externs.h | 3 ++- crawl-ref/source/initfile.cc | 5 +++++ crawl-ref/source/items.cc | 20 +++++++++++++++++++- crawl-ref/source/mutation.cc | 2 +- crawl-ref/source/player.cc | 19 ++++++++++--------- crawl-ref/source/player.h | 2 +- 10 files changed, 51 insertions(+), 16 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt index cc1a6f7ff2..7045a31296 100644 --- a/crawl-ref/docs/crawl_options.txt +++ b/crawl-ref/docs/crawl_options.txt @@ -18,9 +18,10 @@ The contents of this text are: gearset.lua, eat.lua, trapwalk.lua 4- Interface. 4-a Dropping and Picking up. - autopickup, default_autopickup, safe_autopickup, safe_zero_exp, - pickup_thrown, pickup_dropped, assign_item_slot, ban_pickup, - drop_mode, pickup_mode, drop_filter; + autopickup, default_autopickup, safe_autopickup, + autopickup_no_burden, safe_zero_exp, pickup_thrown, + pickup_dropped, assign_item_slot, ban_pickup, drop_mode, + pickup_mode, drop_filter; lua: ch_autopickup (advanced autopickup exceptions) 4-b Targeting. target_zero_exp, target_oos, target_los_first, @@ -232,6 +233,11 @@ safe_autopickup = true monsters (or statues.) If safe_zero_exp is set (the default), zero-XP monsters are considered friendly. +autopickup_no_burden = false + When set, autopickup will not pick up items which would increase + your burden status (from unencumbered to burdened, or from encumbered + to overloaded.) + safe_zero_exp = true If set, presence of only zero experience monsters (like plants) will cause autopickups, even if safe_autopickup=true is set. This option diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt index 5065da9c19..5416042806 100644 --- a/crawl-ref/init.txt +++ b/crawl-ref/init.txt @@ -67,6 +67,7 @@ lua_file = lua/trapwalk.lua # autopickup = $?!+"/% # default_autopickup = false # safe_autopickup = false +# autopickup_no_burden = true # safe_zero_exp = false # pickup_thrown = false # pickup_dropped = true diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 98744a962c..1c5d0f7167 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -179,6 +179,8 @@ static void sdump_burden(const std::string &, std::string &text) case BS_ENCUMBERED: text += "You are encumbered.\n"; break; + default: + break; } } diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 18d0a92af2..20005febc9 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1885,6 +1885,7 @@ static option_handler handlers[] = { "increasing_skill_progress", &Options.increasing_skill_progress, option_hboolean }, { "confirm_self_target", &Options.confirm_self_target, option_hboolean }, { "safe_autopickup", &Options.safe_autopickup, option_hboolean }, + { "autopickup_no_burden", &Options.autopickup_no_burden, option_hboolean }, { "note_skill_max", &Options.note_skill_max, option_hboolean }, { "use_notes", &Options.use_notes, option_hboolean }, { "delay_message_clear", &Options.delay_message_clear, option_hboolean }, diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 6447ad5fec..26a0cd736c 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -461,7 +461,7 @@ struct player FixedVector< item_def, ENDOFPACK > inv; int burden; - char burden_state; + burden_state_type burden_state; FixedVector spells; char spell_no; unsigned char char_direction; // @@ -810,6 +810,7 @@ public: bool increasing_skill_progress; // skills go from 0-10 or 10-0 bool confirm_self_target; // require confirmation before selftarget bool safe_autopickup; // don't autopickup when monsters visible + bool autopickup_no_burden; // don't autopickup if it changes burden bool note_skill_max; // take note when skills reach new max bool note_all_spells; // take note when learning any spell bool use_notes; // take (and dump) notes diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 6705e3a084..9e761cbb7c 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -573,6 +573,7 @@ void game_options::reset_options() hp_warning = 10; confirm_self_target = true; safe_autopickup = true; + autopickup_no_burden = false; use_notes = true; note_skill_max = false; note_all_spells = false; @@ -1688,6 +1689,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) { safe_autopickup = read_bool( field, safe_autopickup ); } + else if (key == "autopickup_no_burden") + { + autopickup_no_burden = read_bool( field, autopickup_no_burden ); + } else if (key == "use_notes") { use_notes = read_bool( field, use_notes ); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 24df6761d9..1832f36a90 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2962,12 +2962,30 @@ static void autopickup(void) if (item_needs_autopickup(mitm[o])) { + + int num_to_take = mitm[o].quantity; + if ( Options.autopickup_no_burden ) + { + int num_can_take = + (carrying_capacity(you.burden_state) - you.burden) / + item_mass(mitm[o]); + + if ( num_can_take == 0 ) + { + o = next; + continue; + } + + if ( num_can_take < num_to_take ) + num_to_take = num_can_take; + } + if (!(mitm[o].flags & ISFLAG_THROWN)) unthrown++; mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); - result = move_item_to_player( o, mitm[o].quantity); + result = move_item_to_player(o, num_to_take); if (result == 0) { diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index 03174b9b99..19358af48f 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -1160,7 +1160,7 @@ bool mutate(int which_mutation, bool failMsg) } // Undead bodies don't mutate, they fall apart. -- bwr - // except for demonspawn in lichform -- haranp + // except for demonspawn (or other permamutations) in lichform -- haranp if (you.is_undead && !demonspawn) { if ((!wearing_amulet(AMU_RESIST_MUTATION) && coinflip()) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index e48b343516..84f08d09bb 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -2007,10 +2007,15 @@ unsigned char player_sust_abil(bool calc_unid) return sa; } // end player_sust_abil() -int carrying_capacity(void) +int carrying_capacity( burden_state_type bs ) { - // Originally: 1000 + you.strength * 200 + ( you.levitation ? 1000 : 0 ) - return (3500 + (you.strength * 100) + (player_is_levitating() ? 1000 : 0)); + int cap = 3500+(you.strength * 100)+(player_is_levitating() ? 1000 : 0); + if ( bs == BS_UNENCUMBERED ) + return (cap * 5) / 6; + else if ( bs == BS_ENCUMBERED ) + return (cap * 11) / 12; + else + return cap; } int burden_change(void) @@ -2019,8 +2024,6 @@ int burden_change(void) you.burden = 0; - int max_carried = carrying_capacity(); - if (you.duration[DUR_STONEMAIL]) you.burden += 800; @@ -2046,8 +2049,7 @@ int burden_change(void) set_redraw_status( REDRAW_BURDEN ); // changed the burdened levels to match the change to max_carried - if (you.burden < (max_carried * 5) / 6) - // (you.burden < max_carried - 1000) + if (you.burden < carrying_capacity(BS_UNENCUMBERED)) { you.burden_state = BS_UNENCUMBERED; @@ -2055,8 +2057,7 @@ int burden_change(void) if (old_burdenstate != you.burden_state) mpr("Your possessions no longer seem quite so burdensome."); } - else if (you.burden < (max_carried * 11) / 12) - // (you.burden < max_carried - 500) + else if (you.burden < carrying_capacity(BS_ENCUMBERED)) { you.burden_state = BS_ENCUMBERED; diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 088f290228..d9a964c0f9 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -86,7 +86,7 @@ int burden_change(void); /* *********************************************************************** * called from: items - misc * *********************************************************************** */ -int carrying_capacity(void); +int carrying_capacity( burden_state_type bs = BS_OVERLOADED ); /* *********************************************************************** -- cgit v1.2.3-54-g00ecf