From c78ed8ca5a6f1528db2bfe1f846e24bef6695a89 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 2 Jun 2008 08:39:09 +0000 Subject: Fix 1981533: Mouseclick allows eating inappropriate food types. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5434 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/changes.stone_soup | 4 ++- crawl-ref/source/food.cc | 59 ++++++++++++++++++++++++++++++++------- crawl-ref/source/item_use.cc | 21 +++++++++----- crawl-ref/source/mon-util.cc | 11 ++++---- crawl-ref/source/spells1.cc | 2 +- crawl-ref/source/tutorial.cc | 2 +- crawl-ref/source/view.cc | 4 ++- 7 files changed, 77 insertions(+), 26 deletions(-) diff --git a/crawl-ref/docs/changes.stone_soup b/crawl-ref/docs/changes.stone_soup index e242390519..69a3ee7df0 100644 --- a/crawl-ref/docs/changes.stone_soup +++ b/crawl-ref/docs/changes.stone_soup @@ -13,6 +13,7 @@ Interface * Overhauled (f)iring interface: abolish (t)hrowing, output quiver in status. * Allow selection of equipment slots from '%' overview screen. * Improved butchering interface. +* Greatly improved the tutorial. * Allow searching item/monster/spell descriptions ('?\' command). * Allow swapping (' command) to non-weapons that need to be wielded for spells. * Fixed weapon swap ignoring {!w}. @@ -121,6 +122,7 @@ Levels * Several new vaults. * Fixed some levels having the wrong amount of stairs. * Treat adjacent doors as one (large) gate, opening/closing together. +* Minotaurs may map labyrinths. * Removed amnesia traps. * Introduced shafts. * Added blood spattering. @@ -131,7 +133,7 @@ Tiles * Save files between tile and non-tile games are compatible. * Added lots of new tiles, and corrected misdisplayed ones. * wininit.txt is now autocreated, if missing. -* Tutorial improvement for tiles. +* Adapted tutorial for tiles. * Improved mouse-click inventory/dungeon interaction. * Show travel exclusion in tile map and mini-map. * Fixed ghosts changing icons between saves. diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 6638f544b0..bea45db105 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -1114,6 +1114,8 @@ int eat_from_floor() bool need_more = false; int unusable_corpse = 0; + int inedible_food = 0; + item_def wonteat; bool found_valid = false; for (int o = igrd[you.x_pos][you.y_pos]; o != NON_ITEM; o = mitm[o].link) { @@ -1138,6 +1140,25 @@ int eat_from_floor() unusable_corpse++; continue; } + else if (!can_ingest(item.base_type, item.sub_type, true)) + { + if (!inedible_food) + { + wonteat = item; + inedible_food++; + } + else + { + // Increase only if we're dealing with different subtypes. + // FIXME: Use a common check for herbivorous/carnivorous + // dislikes, for e.g. "Blech! You need blood!" + ASSERT(is_valid_item(wonteat)); + if (wonteat.sub_type != item.sub_type) + inedible_food++; + } + + continue; + } found_valid = true; std::ostringstream prompt; @@ -1148,9 +1169,9 @@ int eat_from_floor() const int ans = yesnoquit( prompt.str().c_str(), true, 0, false, false, 'E' ); - if ( ans == -1 ) // quit + if (ans == -1) // quit return -1; - else if ( ans == 1 ) // yes + else if (ans == 1) // yes { if (can_ingest(item.base_type, item.sub_type, false)) { @@ -1162,17 +1183,35 @@ int eat_from_floor() // else no: try next one } - if (!found_valid && unusable_corpse) + if (!found_valid) { - if (you.species == SP_VAMPIRE) + // Give a message about why these food items can not actually be eaten. + if (unusable_corpse) { - mprf("%s devoid of blood.", - (unusable_corpse == 1) ? "This corpse is" - : "These corpses are"); + if (you.species == SP_VAMPIRE) + { + mprf("%s devoid of blood.", + (unusable_corpse == 1) ? "This corpse is" + : "These corpses are"); + } + else + _player_can_eat_rotten_meat(true); + } + else if (inedible_food) + { + if (inedible_food == 1) + { + ASSERT(is_valid_item(wonteat)); + // Use the normal cannot ingest message. + if (can_ingest(wonteat.base_type, wonteat.sub_type, false)) + { + mprf(MSGCH_DIAGNOSTICS, "Error: Can eat %s after all?", + wonteat.name(DESC_PLAIN).c_str() ); + } + } + else // Several different food items. + mpr("You refuse to eat these food items."); } - else - _player_can_eat_rotten_meat(true); - need_more = true; } diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 2db9c511e4..95337fcec1 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -2722,7 +2722,10 @@ void jewellery_wear_effects(item_def &item) case RING_LEVITATION: if (!scan_randarts( RAP_LEVITATE )) { - mpr("You feel buoyant."); + if (player_is_airborne()) + mpr("You feel vaguely more buoyant than before."); + else + mpr("You feel buoyant."); if (artefact) fake_rap = RAP_LEVITATE; else @@ -3781,7 +3784,7 @@ static bool affix_weapon_enchantment() torment_monsters(you.x_pos, you.y_pos, 0, TORMENT_GENERIC); success = false; - // is only naughty if you know you're doing it + // Is only naughty if you know you're doing it. did_god_conduct(DID_UNHOLY, 10, get_ident_type(OBJ_SCROLLS, SCR_ENCHANT_WEAPON_III) == ID_KNOWN_TYPE); @@ -3811,7 +3814,7 @@ static bool affix_weapon_enchantment() bool enchant_weapon( enchant_stat_type which_stat, bool quiet, item_def &wpn ) { - // cannot be enchanted nor uncursed + // Cannot be enchanted nor uncursed. if (!is_enchantable_weapon(wpn, true)) { if (!quiet) @@ -3822,7 +3825,7 @@ bool enchant_weapon( enchant_stat_type which_stat, bool quiet, item_def &wpn ) const bool is_cursed = item_cursed(wpn); - // missiles only have one stat + // Missiles only have one stat. if (wpn.base_type == OBJ_MISSILES) which_stat = ENCHANT_TO_HIT; @@ -3916,7 +3919,7 @@ bool enchant_armour( int &ac_change, bool quiet, item_def &arm ) { ac_change = 0; - // cannot be enchanted nor uncursed + // Cannot be enchanted nor uncursed. if (!is_enchantable_armour(arm, true)) { if (!quiet) @@ -4608,7 +4611,10 @@ void use_randart(item_def &item) if (unknown_proprt(RAP_LEVITATE) && !items_give_ability(item.link, RAP_LEVITATE)) { - mpr("You feel buoyant."); + if (player_is_airborne()) + mpr("You feel vaguely more buoyant than before."); + else + mpr("You feel buoyant."); randart_wpn_learn_prop(item, RAP_LEVITATE); } @@ -4692,7 +4698,8 @@ void tile_use_item(int idx, InvAction act) || mitm[idx].base_type == OBJ_FOOD && you.is_undead != US_UNDEAD && you.species != SP_VAMPIRE) { - eat_floor_item(idx); + if (can_ingest(mitm[idx].base_type, mitm[idx].sub_type, false)) + eat_floor_item(idx); } return; } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 9244100c08..104c77d3b3 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -584,17 +584,18 @@ int get_shout_noise_level(const shout_type shout) } // Only the beast uses S_RANDOM for noise type. -// Pandemonium lords can also get here but they can use almost anything. +// Pandemonium lords can also get here but this mostly used for the +// "says" verb used for insults. static bool _shout_fits_monster(int type, int shout) { if (shout == NUM_SHOUTS || shout >= NUM_LOUDNESS) return (false); // For demon lords almost everything is fair game. - // It's only used for the shouting verb ("say", "whine", "roar", ...) + // It's only used for the shouting verb ("say", "bellow", "roar", ...) // anyway. if (type != MONS_BEAST) - return (shout != S_BUZZ && shout != S_WHINE); + return (shout != S_BUZZ && shout != S_WHINE && shout != S_CROAK); switch (shout) { @@ -612,8 +613,8 @@ static bool _shout_fits_monster(int type, int shout) } } -// If demon_shout is true, we're trying to find a random loudness for -// a pandemonium lord trying to shout. +// If demon_shout is true, we're trying to find a random verb and loudness +// for a pandemonium lord trying to shout. shout_type mons_shouts(int mc, bool demon_shout) { shout_type u = smc->shouts; diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 1296f1f418..70e5b71fe2 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -1515,7 +1515,7 @@ void cast_swiftness(int power) you.duration[DUR_SWIFTNESS] = 100; else you.duration[DUR_SWIFTNESS] += dur_incr; -} // end cast_swiftness() +} void cast_fly(int power) { diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index bf4a0299ab..1c7fe0a5dd 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -103,7 +103,7 @@ void init_tutorial_options() // missing item types at the end of it, NetHack like. // Unfortunately I can't think of a remotely non-hacky way // to do this. - strncpy(Options.tile_show_items, "!?/%=([)x}+\\_", 18); + strncpy(Options.tile_show_items, "!?/%=([)x}+\\_.", 18); #endif } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 9e5367e852..8cf0f47afe 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -873,6 +873,8 @@ void handle_monster_shouts(monsters* monster, bool force) // Get it once, since monster might be S_RANDOM, in which case // mons_shouts() will return a different value every time. + // Demon lords will insult you as a greeting, but later we'll + // choose a random verb and loudness for them. shout_type s_type = mons_shouts(monster->type, false); // Silent monsters can give noiseless "visual shouts" if the @@ -995,7 +997,7 @@ void handle_monster_shouts(monsters* monster, bool force) } else if (s_type == S_SILENT && (msg == "" || msg == "__NONE")) { - ; // No "visual shout" defined for silent monster, do nothing + ; // No "visual shout" defined for silent monster, do nothing. } else if (msg == "") { -- cgit v1.2.3-54-g00ecf