From ba3d08acb430062418484ed3e778474cd3b9482b Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 3 Dec 2008 16:16:06 +0000 Subject: Implement harpyes. They ... * appear in bands of 2-5 * use bat like movement * may steal (= destroy) the player's food. Still needs a tile. Also, actually use the M_BATTY flag instead of hardcoding batty monsters. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7734 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/ouch.cc | 79 ++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'crawl-ref/source/ouch.cc') diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 6cdfe1c2fb..436d24a82f 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -428,6 +428,7 @@ static int _get_target_class(beam_type flavour) break; case BEAM_SPORE: + case BEAM_STEAL_FOOD: target_class = OBJ_FOOD; break; @@ -441,13 +442,13 @@ static int _get_target_class(beam_type flavour) // XXX: These expose functions could use being reworked into a real system... // the usage and implementation is currently very hacky. // Handles the destruction of inventory items from the elements. -static void _expose_invent_to_element(beam_type flavour, int strength) +static bool _expose_invent_to_element(beam_type flavour, int strength) { int num_dest = 0; const int target_class = _get_target_class( flavour ); if (target_class == OBJ_UNASSIGNED) - return; + return (false); // Currently we test against each stack (and item in the stack) // independently at strength%... perhaps we don't want that either @@ -458,13 +459,15 @@ static void _expose_invent_to_element(beam_type flavour, int strength) if (!is_valid_item(you.inv[i])) continue; - if (is_valid_item(you.inv[i]) - && (you.inv[i].base_type == target_class - || target_class == OBJ_FOOD - && you.inv[i].base_type == OBJ_CORPSES)) + if (you.inv[i].base_type == target_class + || target_class == OBJ_FOOD + && you.inv[i].base_type == OBJ_CORPSES) { - if (player_item_conserve() && !one_chance_in(10)) + if (flavour != BEAM_STEAL_FOOD + && player_item_conserve() && !one_chance_in(10)) + { continue; + } for (int j = 0; j < you.inv[i].quantity; ++j) { @@ -484,36 +487,38 @@ static void _expose_invent_to_element(beam_type flavour, int strength) } } - if (num_dest > 0) + if (!num_dest) + return (false); + + switch (target_class) { - switch (target_class) - { - case OBJ_SCROLLS: - mprf("%s you are carrying %s fire!", - (num_dest > 1) ? "Some of the scrolls" : "A scroll", - (num_dest > 1) ? "catch" : "catches" ); - break; - - case OBJ_POTIONS: - mprf("%s you are carrying %s and %s!", - (num_dest > 1) ? "Some of the potions" : "A potion", - (num_dest > 1) ? "freeze" : "freezes", - (num_dest > 1) ? "shatter" : "shatters" ); - break; - - case OBJ_FOOD: - mpr("Some of your food is covered with spores!"); - break; + case OBJ_SCROLLS: + mprf("%s you are carrying %s fire!", + (num_dest > 1) ? "Some of the scrolls" : "A scroll", + (num_dest > 1) ? "catch" : "catches" ); + break; - default: - mprf("%s you are carrying %s destroyed!", - (num_dest > 1) ? "Some items" : "An item", - (num_dest > 1) ? "were" : "was" ); - break; - } + case OBJ_POTIONS: + mprf("%s you are carrying %s and %s!", + (num_dest > 1) ? "Some of the potions" : "A potion", + (num_dest > 1) ? "freeze" : "freezes", + (num_dest > 1) ? "shatter" : "shatters" ); + break; - xom_is_stimulated((num_dest > 1) ? 32 : 16); + case OBJ_FOOD: + if (flavour == BEAM_SPORE) + mpr("Some of your food is covered with spores!"); + break; + + default: + mprf("%s you are carrying %s destroyed!", + (num_dest > 1) ? "Some items" : "An item", + (num_dest > 1) ? "were" : "was" ); + break; } + + xom_is_stimulated((num_dest > 1) ? 32 : 16); + return (true); } void expose_items_to_element(beam_type flavour, const coord_def& where, @@ -588,7 +593,7 @@ void expose_items_to_element(beam_type flavour, const coord_def& where, // This function now calls _expose_invent_to_element() if strength > 0. // // XXX: This function is far from perfect and a work in progress. -void expose_player_to_element(beam_type flavour, int strength) +bool expose_player_to_element(beam_type flavour, int strength) { // Note that BEAM_TELEPORT is sent here when the player // blinks or teleports. @@ -601,8 +606,10 @@ void expose_player_to_element(beam_type flavour, int strength) remove_condensation_shield(); } - if (strength > 0) - _expose_invent_to_element( flavour, strength ); + if (strength <= 0) + return (false); + + return (_expose_invent_to_element( flavour, strength )); } void lose_level() -- cgit v1.2.3-54-g00ecf