From c19654b6135f04e1b846a12818319d829d704fe8 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 10 Jan 2007 12:13:52 +0000 Subject: [1632207] Dropping items on an altar while praying will offer those items to $DEITY. If it's a multidrop, only the last item will trigger the altar-offer to avoid spammy messages. Interrupted multidrop will not do the offer, nor will the offer happen if prayer ends before the last item is dropped. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@821 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/delay.cc | 3 ++- crawl-ref/source/describe.cc | 4 ++-- crawl-ref/source/items.cc | 24 +++++++++++++------ crawl-ref/source/items.h | 2 +- crawl-ref/source/religion.cc | 56 +++++++++++++++++--------------------------- crawl-ref/source/religion.h | 1 + 6 files changed, 44 insertions(+), 46 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 1a9f7b48af..5c3d01ba4f 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -391,7 +391,8 @@ void handle_delay( void ) break; case DELAY_MULTIDROP: drop_item( items_for_multidrop[0].slot, - items_for_multidrop[0].quantity ); + items_for_multidrop[0].quantity, + items_for_multidrop.size() == 1 ); items_for_multidrop.erase( items_for_multidrop.begin() ); break; default: diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index f0f997464a..8c3c21fe8c 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -254,7 +254,7 @@ static void randart_descpr( std::string &description, const item_def &item ) else if (proprt[ RAP_NEGATIVE_ENERGY ] == 2) description += "$It protects you from negative energy. "; else if (proprt[ RAP_NEGATIVE_ENERGY ] > 2) - description += "$It renders you almost immune negative energy. "; + description += "$It renders you almost immune to negative energy. "; if (proprt[ RAP_MAGIC ]) description += "$It protects you from magic. "; @@ -1044,7 +1044,7 @@ static std::string describe_weapon( const item_def &item, bool verbose) if (verbose) { - description += "$Damage rating: "; + description += "$Damage rating: "; append_value(description, property( item, PWPN_DAMAGE ), false); description += "$Accuracy rating: "; diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 8db00d95c8..86defb8de3 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1708,7 +1708,8 @@ bool move_top_item( int src_x, int src_y, int dest_x, int dest_y ) return (true); } -bool drop_item( int item_dropped, int quant_drop ) { +bool drop_item( int item_dropped, int quant_drop, bool try_offer ) +{ if (quant_drop < 0 || quant_drop > you.inv[item_dropped].quantity) quant_drop = you.inv[item_dropped].quantity; @@ -1774,9 +1775,10 @@ bool drop_item( int item_dropped, int quant_drop ) { const unsigned char my_grid = grd[you.x_pos][you.y_pos]; - if ( !grid_destroys_items(my_grid) && - !copy_item_to_grid( you.inv[item_dropped], - you.x_pos, you.y_pos, quant_drop, true )) { + if ( !grid_destroys_items(my_grid) + && !copy_item_to_grid( you.inv[item_dropped], + you.x_pos, you.y_pos, quant_drop, true )) + { mpr( "Too many items on this level, not dropping the item." ); return (false); } @@ -1785,13 +1787,20 @@ bool drop_item( int item_dropped, int quant_drop ) { quant_name( you.inv[item_dropped], quant_drop, DESC_NOCAP_A, str_pass ); mprf( "You drop %s.", str_pass ); - if ( grid_destroys_items(my_grid) ) { + if ( grid_destroys_items(my_grid) ) mprf(MSGCH_SOUND, grid_item_destruction_message(my_grid)); - } dec_inv_item_quantity( item_dropped, quant_drop ); you.turn_is_over = true; + if (try_offer + && you.religion != GOD_NO_GOD + && you.duration[DUR_PRAYER] + && grid_altar_god(grd[you.x_pos][you.y_pos]) == you.religion) + { + offer_items(); + } + return (true); } @@ -1948,7 +1957,8 @@ void drop(void) if ( items_for_multidrop.size() == 1 ) // only one item { drop_item( items_for_multidrop[0].slot, - items_for_multidrop[0].quantity ); + items_for_multidrop[0].quantity, + true ); items_for_multidrop.clear(); you.turn_is_over = true; } diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index d741cbf8fe..af0ab9d4f7 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -126,7 +126,7 @@ void cmd_destroy_item( void ); bool pickup_single_item(int link, int qty); -bool drop_item( int item_dropped, int quant_drop ); +bool drop_item( int item_dropped, int quant_drop, bool try_offer = false ); int get_equip_slot(const item_def *item); diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 38fd7ed69c..46574758b4 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -333,19 +333,18 @@ void pray(void) you.turn_is_over = true; if (you.religion != GOD_NO_GOD - && grd[you.x_pos][you.y_pos] == 179 + you.religion) + && grid_altar_god(grd[you.x_pos][you.y_pos]) == you.religion) { altar_prayer(); } - else if (grd[you.x_pos][you.y_pos] >= 180 - && grd[you.x_pos][you.y_pos] <= 199) + else if (grid_altar_god(grd[you.x_pos][you.y_pos]) != GOD_NO_GOD) { if (you.species == SP_DEMIGOD) { mpr("Sorry, a being of your status cannot worship here."); return; } - god_pitch(grd[you.x_pos][you.y_pos] - 179); + god_pitch( grid_altar_god(grd[you.x_pos][you.y_pos]) ); return; } @@ -2305,18 +2304,6 @@ static bool bless_weapon( int god, int brand, int colour ) void altar_prayer(void) { - int i, j, next; - char subst_id[4][50]; - char str_pass[ ITEMNAME_SIZE ]; - - for (i = 0; i < 4; i++) - { - for (j = 0; j < 50; j++) - { - subst_id[i][j] = 1; - } - } - mpr( "You kneel at the altar and pray." ); if (you.religion == GOD_XOM) @@ -2373,13 +2360,24 @@ void altar_prayer(void) bless_weapon(GOD_LUCY, SPWPN_DISTORTION, RED); } - i = igrd[you.x_pos][you.y_pos]; + offer_items(); +} // end altar_prayer() + +void offer_items() +{ + if (you.religion == GOD_NO_GOD) + return; + + char subst_id[4][50]; + memset(subst_id, 1, sizeof subst_id); + + int i = igrd[you.x_pos][you.y_pos]; while (i != NON_ITEM) { if (one_chance_in(1000)) break; - next = mitm[i].link; // in case we can't get it later. + const int next = mitm[i].link; // in case we can't get it later. const int value = item_value( mitm[i], subst_id, true ); @@ -2389,10 +2387,7 @@ void altar_prayer(void) case GOD_OKAWARU: case GOD_MAKHLEB: case GOD_NEMELEX_XOBEH: - it_name(i, DESC_CAP_THE, str_pass); - strcpy(info, str_pass); - strcat(info, sacrifice[you.religion - 1]); - mpr(info); + mprf("%s%s", it_name(i, DESC_CAP_THE), sacrifice[you.religion - 1]); #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Sacrifice item value: %d", value); @@ -2409,10 +2404,7 @@ void altar_prayer(void) break; case GOD_SIF_MUNA: - it_name(i, DESC_CAP_THE, str_pass); - strcpy(info, str_pass); - strcat(info, sacrifice[you.religion - 1]); - mpr(info); + mprf("%s%s", it_name(i, DESC_CAP_THE), sacrifice[you.religion - 1]); if (value >= 150) gain_piety(1 + random2(3)); @@ -2425,10 +2417,7 @@ void altar_prayer(void) if (mitm[i].base_type != OBJ_CORPSES) break; - it_name(i, DESC_CAP_THE, str_pass); - strcpy(info, str_pass); - strcat(info, sacrifice[you.religion - 1]); - mpr(info); + mprf("%s%s", it_name(i, DESC_CAP_THE), sacrifice[you.religion - 1]); gain_piety(1); destroy_item(i); @@ -2441,10 +2430,7 @@ void altar_prayer(void) break; } - it_name(i, DESC_CAP_THE, str_pass); - strcpy(info, str_pass); - strcat(info, sacrifice[you.religion - 1]); - mpr(info); + mprf("%s%s", it_name(i, DESC_CAP_THE), sacrifice[you.religion - 1]); if (random2(value) >= random2(50) || (mitm[i].base_type == OBJ_WEAPONS @@ -2462,7 +2448,7 @@ void altar_prayer(void) i = next; } -} // end altar_prayer() +} void god_pitch(unsigned char which_god) { diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h index 11b2739227..0a8d565cca 100644 --- a/crawl-ref/source/religion.h +++ b/crawl-ref/source/religion.h @@ -33,5 +33,6 @@ void handle_god_time(void); char god_colour(char god); void god_pitch(unsigned char which_god); int piety_rank(int piety = -1); +void offer_items(); #endif -- cgit v1.2.3-54-g00ecf