From fa362030f57011d35e9e254b86b193c971132dfa Mon Sep 17 00:00:00 2001 From: dolorous Date: Sun, 1 Jun 2008 02:29:25 +0000 Subject: Clean up and consolidate random_uselessness(), as well as its associated outsourced text. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5388 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dat/database/miscname.txt | 46 ++++++++++++++++-------------- crawl-ref/source/effects.cc | 25 ++++++++-------- crawl-ref/source/effects.h | 2 +- crawl-ref/source/item_use.cc | 4 +-- crawl-ref/source/misc.cc | 5 ---- crawl-ref/source/misc.h | 2 -- crawl-ref/source/spl-cast.cc | 6 ++-- 7 files changed, 43 insertions(+), 47 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dat/database/miscname.txt b/crawl-ref/source/dat/database/miscname.txt index 4b6e152662..010078dfbd 100644 --- a/crawl-ref/source/dat/database/miscname.txt +++ b/crawl-ref/source/dat/database/miscname.txt @@ -5,7 +5,7 @@ # # This file contains a list of names for miscellaneous things. # This is currently only used for colours, writing types, -# roaring animals, smells, and sounds. +# smells, and sounds. ###################################################### %%%% glowing_adj @@ -157,6 +157,27 @@ writing_name @writing_adj@ @colour_name@ @writing_noun@ +%%%% +smell_name + +baking bread + +burning hair + +coffee + +fire and brimstone + +salt + +womething weird + +sulphur + +tea + +wet wool + %%%% roaring_animal_name # This doesn't necessarily have to make sense. For example, a name of a @@ -177,24 +198,7 @@ pill bug slug -%%%% -smell_name - -baking bread - -burning hair - -coffee - -fire and brimstone - -salt - -womething weird - -sulphur - -wet wool +yak %%%% sound_name @@ -207,11 +211,11 @@ a very strange noise indeed a voice calling someone else's name -roaring flame +roaring flames snatches of song -the bellowing of a yak +the distant roaring of an enraged @roaring_animal_name@ the chiming of a distant gong diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 965a00bff3..2e9ca80f70 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -729,11 +729,15 @@ void mons_direct_effect(struct bolt &pbolt, int i) return; } -void random_uselessness(unsigned char ru, unsigned char sc_read_2) +void random_uselessness(int scroll_slot) { - int temp_rand = 0; // probability determination {dlb} + int temp_rand = random2(8); - switch (ru) + // If this isn't from a scroll, skip the first two possibilities. + if (scroll_slot == -1) + temp_rand = 2 + random2(6); + + switch (temp_rand) { case 0: mprf("The dust glows %s!", weird_glowing_colour().c_str()); @@ -741,7 +745,7 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) case 1: mpr("The scroll reassembles itself in your hand!"); - inc_inv_item_quantity( sc_read_2, 1 ); + inc_inv_item_quantity(scroll_slot, 1); break; case 2: @@ -759,11 +763,6 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) break; case 3: - mprf("You hear the distant roaring of an enraged %s!", - weird_roaring_animal().c_str()); - break; - - case 4: if (player_can_smell()) mprf("You smell %s.", weird_smell().c_str()); else if (you.species == SP_MUMMY) @@ -772,11 +771,11 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) canned_msg(MSG_NOTHING_HAPPENS); break; - case 5: + case 4: mpr("You experience a momentary feeling of inescapable doom!"); break; - case 6: + case 5: temp_rand = random2(3); mprf("Your %s", (temp_rand == 0) ? "ears itch." : @@ -784,12 +783,12 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) : "nose twitches suddenly!"); break; - case 7: + case 6: mpr("You hear the tinkle of a tiny bell.", MSGCH_SOUND); cast_summon_butterflies( 100 ); break; - case 8: + case 7: mprf(MSGCH_SOUND, "You hear %s.", weird_sound().c_str()); break; } diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index 2db26ffb4d..5a52d7b7fe 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -57,7 +57,7 @@ bool lose_stat(unsigned char which_stat, unsigned char stat_loss, /* *********************************************************************** * called from: item_use - spell - spells * *********************************************************************** */ -void random_uselessness(unsigned char ru, unsigned char sc_read_2); +void random_uselessness(int scroll_slot = -1); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 950ea4ba6c..d0c1b8e051 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -4205,7 +4205,7 @@ void read_scroll( int slot ) { if (you.duration[DUR_CONF]) { - random_uselessness(random2(9), item_slot); + random_uselessness(item_slot); dec_inv_item_quantity( item_slot, 1 ); return; } @@ -4228,7 +4228,7 @@ void read_scroll( int slot ) break; case SCR_RANDOM_USELESSNESS: - random_uselessness(random2(9), item_slot); + random_uselessness(item_slot); id_the_scroll = false; break; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 4a9ef1d06f..2050a507fb 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2414,11 +2414,6 @@ std::string weird_writing() return getMiscString("writing_name"); } -std::string weird_roaring_animal() -{ - return getMiscString("roaring_animal_name"); -} - std::string weird_smell() { return getMiscString("smell_name"); diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 3c9a88a23a..7e56008d7c 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -105,8 +105,6 @@ std::string weird_glowing_colour(); * *********************************************************************** */ std::string weird_writing(); -std::string weird_roaring_animal(); - std::string weird_smell(); std::string weird_sound(); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 0720b60d95..e24f6bf58f 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -673,7 +673,7 @@ bool cast_a_spell() const bool staff_energy = player_energy(); if (you.duration[DUR_CONF]) - random_uselessness( 2 + random2(7), 0 ); + random_uselessness(); else { const spret_type cast_result = your_spells( spell ); @@ -2297,7 +2297,7 @@ static void _miscast_enchantment(int severity, const char* cause) potion_effect(POT_LEVITATION, 20); break; case 1: - random_uselessness(2 + random2(7), 0); + random_uselessness(); break; } break; @@ -2993,7 +2993,7 @@ static void _miscast_transmigration(int severity, const char* cause) ouch(1 + random2avg(11, 2), 0, KILLED_BY_WILD_MAGIC, cause); break; case 1: - random_uselessness(2 + random2(7), 0); + random_uselessness(); break; } break; -- cgit v1.2.3-54-g00ecf