From 4bd11a2119ce0fd7f137233e16cd7f745c13a2dd Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Mon, 28 Dec 2009 01:52:41 -0800 Subject: Rename MF_CREATED_FRIENDLY to MF_NO_REWARD, since that's all it's used for these days. --- crawl-ref/source/religion.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 763f1c0709..3a0c43fb0f 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -2683,7 +2683,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known, } if (thing_done == DID_ATTACK_HOLY && victim - && !testbits(victim->flags, MF_CREATED_FRIENDLY) + && !testbits(victim->flags, MF_NO_REWARD) && !testbits(victim->flags, MF_WAS_NEUTRAL)) { break; @@ -3029,7 +3029,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known, case GOD_SHINING_ONE: case GOD_ELYVILON: if (victim - && !testbits(victim->flags, MF_CREATED_FRIENDLY) + && !testbits(victim->flags, MF_NO_REWARD) && !testbits(victim->flags, MF_WAS_NEUTRAL)) { break; @@ -3097,7 +3097,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known, case GOD_SHINING_ONE: case GOD_ELYVILON: if (victim - && !testbits(victim->flags, MF_CREATED_FRIENDLY) + && !testbits(victim->flags, MF_NO_REWARD) && !testbits(victim->flags, MF_WAS_NEUTRAL)) { break; -- cgit v1.2.3-54-g00ecf From 4db1d75dca2405e186a3e9869a2aa9e058cbf71f Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Wed, 30 Dec 2009 00:57:03 -0800 Subject: Allow tiles to destroy only some items. --- crawl-ref/source/dgn-shoals.cc | 26 +++++++----- crawl-ref/source/effects.cc | 51 ++++++++++-------------- crawl-ref/source/items.cc | 17 ++------ crawl-ref/source/l_feat.cc | 5 +-- crawl-ref/source/mon-pathfind.cc | 2 +- crawl-ref/source/religion.cc | 21 ++++------ crawl-ref/source/spells4.cc | 14 +++---- crawl-ref/source/terrain.cc | 86 ++++++++++++++++++++++++---------------- crawl-ref/source/terrain.h | 5 +-- crawl-ref/source/wiz-item.cc | 7 ---- crawl-ref/source/xom.cc | 7 +--- 11 files changed, 113 insertions(+), 128 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 367ca497d4..3547932a43 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -867,7 +867,7 @@ static void _shoals_run_tide(int &tide, int &acc) } static coord_def _shoals_escape_place_from(coord_def bad_place, - bool monster_free) + actor *act, item_def *it) { int best_height = -1000; coord_def chosen; @@ -875,8 +875,8 @@ static coord_def _shoals_escape_place_from(coord_def bad_place, { coord_def p(*ai); const dungeon_feature_type feat(grd(p)); - if (!feat_is_solid(feat) && !feat_destroys_items(feat) - && (!monster_free || !actor_at(p))) + if ((!act || (feat_has_solid_floor(feat) && !actor_at(p))) + && (!it || !feat_destroys_item(feat, *it))) { if (best_height == -1000 || shoals_heights(p) > best_height) { @@ -894,12 +894,18 @@ static bool _shoals_tide_sweep_items_clear(coord_def c) if (link == NON_ITEM) return true; - const coord_def target(_shoals_escape_place_from(c, false)); - // Don't abort tide entry because of items. If we can't sweep the - // item clear here, let dungeon_terrain_changed teleport the item - // to the nearest safe square. - if (!target.origin()) - move_item_stack_to_grid(c, target); + for (stack_iterator si(c); si; ++si) + { + const coord_def target(_shoals_escape_place_from(c, NULL, &*si)); + // Don't abort tide entry because of items. If we can't sweep the + // item clear here, let dungeon_terrain_changed teleport the item + // to the nearest safe square. + int id = si.link(); + + if (!target.origin()) + move_item_to_grid(&id, target); + } + return true; } @@ -921,7 +927,7 @@ static bool _shoals_tide_sweep_actors_clear(coord_def c) if (monster_habitable_grid(mvictim, DNGN_DEEP_WATER)) return true; } - coord_def evacuation_point(_shoals_escape_place_from(c, true)); + coord_def evacuation_point(_shoals_escape_place_from(c, victim, NULL)); // The tide moves on even if we cannot evacuate the tile! if (!evacuation_point.origin()) victim->move_to_pos(evacuation_point); diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index dcec8a0373..a4a765177e 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -2319,6 +2319,17 @@ int acquirement_create_item(object_class_type class_wanted, if (thing_created != NON_ITEM && !quiet) canned_msg(MSG_SOMETHING_APPEARS); + // If a god wants to give you something but the floor doesn't want it, + // it counts as a failed acquirement - no piety, etc cost. + if (feat_destroys_item(grd(pos), thing) && (agent > GOD_NO_GOD) && + (agent < NUM_GODS)) + { + if (agent == GOD_XOM) + simple_god_message(" snickers.", GOD_XOM); + else + return _failed_acquirement(quiet); + } + move_item_to_grid( &thing_created, pos ); return (thing_created); @@ -2378,23 +2389,6 @@ bool acquirement(object_class_type class_wanted, int agent, } } - if (feat_destroys_items(grd(you.pos()))) - { - if (agent > GOD_NO_GOD && agent < NUM_GODS) - { - if (agent == GOD_XOM) - simple_god_message(" snickers.", GOD_XOM); - else - { - ASSERT(!"God gave gift item while player was on grid which " - "destroys items."); - mprf(MSGCH_ERROR, "%s gave a god gift while you were on " - "terrain which destroys items.", - god_name((god_type) agent).c_str()); - } - } - } - acquirement_create_item(class_wanted, agent, quiet, you.pos(), debug); return (true); @@ -2956,11 +2950,6 @@ static void _hell_effects() } } -static bool _is_floor(const dungeon_feature_type feat) -{ - return (!feat_is_solid(feat) && !feat_destroys_items(feat)); -} - // This function checks whether we can turn a wall into a floor space and // still keep a corridor-like environment. The wall in position x is a // a candidate for switching if it's flanked by floor grids to two sides @@ -2982,8 +2971,8 @@ static bool _feat_is_flanked_by_walls(const coord_def &p) return (false); return (feat_is_wall(grd(adjs[0])) && feat_is_wall(grd(adjs[1])) - && _is_floor(grd(adjs[2])) && _is_floor(grd(adjs[3])) - || _is_floor(grd(adjs[0])) && _is_floor(grd(adjs[1])) + && feat_has_solid_floor(grd(adjs[2])) && feat_has_solid_floor(grd(adjs[3])) + || feat_has_solid_floor(grd(adjs[0])) && feat_has_solid_floor(grd(adjs[1])) && feat_is_wall(grd(adjs[2])) && feat_is_wall(grd(adjs[3]))); } @@ -3088,7 +3077,7 @@ static bool _deadend_check_floor(const coord_def &p) continue; const coord_def a(p.x, p.y+2*i); - if (!in_bounds(a) || _is_floor(grd(a))) + if (!in_bounds(a) || feat_has_solid_floor(grd(a))) continue; for (int j = -1; j <= 1; j++) @@ -3101,7 +3090,7 @@ static bool _deadend_check_floor(const coord_def &p) continue; const coord_def c(p.x+j, p.y+i); - if (_is_floor(grd(c)) && !_is_floor(grd(b))) + if (feat_has_solid_floor(grd(c)) && !feat_has_solid_floor(grd(b))) return (false); } } @@ -3114,7 +3103,7 @@ static bool _deadend_check_floor(const coord_def &p) continue; const coord_def a(p.x+2*i, p.y); - if (!in_bounds(a) || _is_floor(grd(a))) + if (!in_bounds(a) || feat_has_solid_floor(grd(a))) continue; for (int j = -1; j <= 1; j++) @@ -3127,7 +3116,7 @@ static bool _deadend_check_floor(const coord_def &p) continue; const coord_def c(p.x+i, p.y+j); - if (_is_floor(grd(c)) && !_is_floor(grd(b))) + if (feat_has_solid_floor(grd(c)) && !feat_has_solid_floor(grd(b))) return (false); } } @@ -3236,7 +3225,7 @@ void change_labyrinth(bool msg) // Use the adjacent floor grids as source and destination. coord_def src(c.x-1,c.y); coord_def dst(c.x+1,c.y); - if (!_is_floor(grd(src)) || !_is_floor(grd(dst))) + if (!feat_has_solid_floor(grd(src)) || !feat_has_solid_floor(grd(dst))) { src = coord_def(c.x, c.y-1); dst = coord_def(c.x, c.y+1); @@ -3375,7 +3364,7 @@ void change_labyrinth(bool msg) int floor_count = 0; coord_def new_adj(p); for (adjacent_iterator ai(c); ai; ++ai) - if (_is_floor(grd(*ai)) && one_chance_in(++floor_count)) + if (feat_has_solid_floor(grd(*ai)) && one_chance_in(++floor_count)) new_adj = *ai; if (new_adj != p && maybe_bloodify_square(new_adj)) @@ -3423,7 +3412,7 @@ void change_labyrinth(bool msg) if (!in_bounds(p)) continue; - if (_is_floor(grd(p))) + if (feat_has_solid_floor(grd(p))) { // Once a valid grid is found, move all items from the // stack onto it. diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 81adf191dd..1437238afd 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1733,11 +1733,8 @@ bool move_item_to_grid( int *const obj, const coord_def& p, bool silent ) item_def& item(mitm[ob]); - if (feat_destroys_items(grd(p))) + if (feat_destroys_item(grd(p), mitm[ob], !silenced(p) && !silent)) { - if (!silenced(p) && !silent) - mprf(MSGCH_SOUND, feat_item_destruction_message(grd(p))); - item_was_destroyed(item, NON_MONSTER); destroy_item(ob); ob = NON_ITEM; @@ -1833,11 +1830,8 @@ bool copy_item_to_grid( const item_def &item, const coord_def& p, if (quant_drop == 0) return (false); - if (feat_destroys_items(grd(p))) + if (feat_destroys_item(grd(p), item, !silenced(p) && !silent)) { - if (!silenced(p)) - mprf(MSGCH_SOUND, feat_item_destruction_message(grd(p))); - item_was_destroyed(item, NON_MONSTER); return (true); @@ -2001,11 +1995,8 @@ bool drop_item( int item_dropped, int quant_drop, bool try_offer ) mprf("You drop %s.", quant_name(you.inv[item_dropped], quant_drop, DESC_NOCAP_A).c_str()); - if (feat_destroys_items(my_grid)) - { - if (!silenced(you.pos())) - mprf(MSGCH_SOUND, feat_item_destruction_message(my_grid)); - } + if (feat_destroys_item(my_grid, you.inv[item_dropped], !silenced(you.pos()))) + ; else if (strstr(you.inv[item_dropped].inscription.c_str(), "=s") != 0) StashTrack.add_stash(); diff --git a/crawl-ref/source/l_feat.cc b/crawl-ref/source/l_feat.cc index 00529c11dc..baeaac20fd 100644 --- a/crawl-ref/source/l_feat.cc +++ b/crawl-ref/source/l_feat.cc @@ -31,10 +31,9 @@ return (1); \ } -FEATF(_feat_destroys_items, feat_destroys_items) - FEATF(_feat_is_wall, feat_is_wall) FEATF(_feat_is_solid, feat_is_solid) +FEATF(_feat_has_solid_floor, feat_has_solid_floor) FEATF(_feat_is_opaque, feat_is_opaque) FEATF(_feat_is_door, feat_is_door) FEATF(_feat_is_closed_door, feat_is_closed_door) @@ -60,9 +59,9 @@ FEATF(_feat_is_critical, is_critical_feature) const struct luaL_reg feat_dlib[] = { -{ "destroys_items", _feat_destroys_items }, { "is_wall", _feat_is_wall }, { "is_solid", _feat_is_solid }, +{ "has_solid_floor", _feat_has_solid_floor }, { "is_opaque", _feat_is_opaque }, { "is_door", _feat_is_door }, { "is_closed_door", _feat_is_closed_door }, diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc index 173d643020..68215b5fca 100644 --- a/crawl-ref/source/mon-pathfind.cc +++ b/crawl-ref/source/mon-pathfind.cc @@ -392,7 +392,7 @@ bool monster_pathfind::traversable(const coord_def p) if (mons) return mons_traversable(p); - return (!feat_is_solid(grd(p)) && !feat_destroys_items(grd(p))); + return feat_has_solid_floor(grd(p)); } // Checks whether a given monster can pass over a certain position, respecting diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 3a0c43fb0f..3845be27d2 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1175,7 +1175,6 @@ static bool _need_missile_gift() const item_def *launcher = _find_missile_launcher(best_missile_skill); return (you.piety > 80 && random2( you.piety ) > 70 - && !feat_destroys_items( grd(you.pos()) ) && one_chance_in(8) && you.skills[ best_missile_skill ] >= 8 && (launcher || best_missile_skill == SK_DARTS)); @@ -1263,9 +1262,6 @@ static void _show_pure_deck_chances() static void _give_nemelex_gift() { - if (feat_destroys_items(grd(you.pos()))) - return; - // Nemelex will give at least one gift early. if (!you.num_gifts[GOD_NEMELEX_XOBEH] && x_chance_in_y(you.piety + 1, piety_breakpoint(1)) @@ -1289,14 +1285,16 @@ static void _give_nemelex_gift() #if DEBUG_GIFTS || DEBUG_CARDS _show_pure_deck_chances(); #endif - _update_sacrifice_weights(choice); - int thing_created = items( 1, OBJ_MISCELLANY, gift_type, true, 1, MAKE_ITEM_RANDOM_RACE, 0, 0, GOD_NEMELEX_XOBEH ); + move_item_to_grid(&thing_created, you.pos(), true); + if (thing_created != NON_ITEM) { + _update_sacrifice_weights(choice); + // Piety|Common | Rare |Legendary // -------------------------------- // 0: 95.00%, 5.00%, 0.00% @@ -1329,8 +1327,6 @@ static void _give_nemelex_gift() deck.colour = deck_rarity_to_color(rarity); deck.inscription = "god gift"; - move_item_to_grid(&thing_created, you.pos()); - simple_god_message(" grants you a gift!"); more(); canned_msg(MSG_SOMETHING_APPEARS); @@ -2046,7 +2042,6 @@ static void _do_god_gift(bool prayed_for) case GOD_TROG: if (you.piety > 130 && random2(you.piety) > 120 - && !feat_destroys_items(grd(you.pos())) && one_chance_in(4)) { if (you.religion == GOD_TROG @@ -2058,7 +2053,8 @@ static void _do_god_gift(bool prayed_for) { success = acquirement(OBJ_ARMOUR, you.religion); // Okawaru charges extra for armour acquirements. - _inc_gift_timeout(30 + random2avg(15, 2)); + if (success) + _inc_gift_timeout(30 + random2avg(15, 2)); } if (success) @@ -2194,8 +2190,7 @@ static void _do_god_gift(bool prayed_for) } } - if (gift != NUM_BOOKS - && !feat_destroys_items(grd(you.pos()))) + if (gift != NUM_BOOKS) { if (gift == OBJ_RANDOM) { @@ -2216,7 +2211,7 @@ static void _do_god_gift(bool prayed_for) // reason. mark_had_book(gift); - move_item_to_grid( &thing_created, you.pos() ); + move_item_to_grid( &thing_created, you.pos(), true ); if (thing_created != NON_ITEM) { diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 7da3ee46af..9f3f03d736 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1714,13 +1714,6 @@ bool cast_portal_projectile(int pow) bool cast_apportation(int pow, const coord_def& where) { - // Protect the player from destroying the item. - if (feat_destroys_items(grd(you.pos()))) - { - mpr( "That would be silly while over this terrain!" ); - return (false); - } - if (you.trans_wall_blocking(where)) { mpr("A translucent wall is in the way."); @@ -1750,6 +1743,13 @@ bool cast_apportation(int pow, const coord_def& where) item_def& item = mitm[item_idx]; + // Protect the player from destroying the item. + if (feat_destroys_item(grd(you.pos()), item)) + { + mpr( "That would be silly while over this terrain!" ); + return (false); + } + // Mass of one unit. const int unit_mass = item_mass(item); const int max_mass = pow * 30 + random2(pow * 20); diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 9b2fe96deb..2e3ac60cc7 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -321,6 +321,12 @@ bool cell_is_solid(const coord_def &c) return (feat_is_solid(grd(c))); } +bool feat_has_solid_floor(dungeon_feature_type feat) +{ + return (!feat_is_solid(feat) && feat != DNGN_DEEP_WATER && + feat != DNGN_LAVA); +} + bool feat_is_door(dungeon_feature_type feat) { return (feat == DNGN_CLOSED_DOOR || feat == DNGN_DETECTED_SECRET_DOOR @@ -376,11 +382,6 @@ bool feat_is_watery(dungeon_feature_type feat) return (feat_is_water(feat) || feat == DNGN_FOUNTAIN_BLUE); } -bool feat_destroys_items(dungeon_feature_type feat) -{ - return (feat == DNGN_LAVA || feat == DNGN_DEEP_WATER); -} - // Returns GOD_NO_GOD if feat is not an altar, otherwise returns the // GOD_* type. god_type feat_altar_god(dungeon_feature_type feat) @@ -543,16 +544,30 @@ dungeon_feature_type grid_secret_door_appearance(const coord_def &where) : ret); } -const char *feat_item_destruction_message(dungeon_feature_type feat) +bool feat_destroys_item(dungeon_feature_type feat, const item_def &item, + bool noisy) { - return (feat == DNGN_DEEP_WATER ? "You hear a splash." : - feat == DNGN_LAVA ? "You hear a sizzling splash." - : "You hear a crunching noise."); + switch (feat) + { + case DNGN_DEEP_WATER: + if (noisy) + mprf(MSGCH_SOUND, "You hear a splash."); + return (true); + + case DNGN_LAVA: + if (noisy) + mprf(MSGCH_SOUND, "You hear a sizzling splash."); + return (true); + + default: + return (false); + } } static coord_def _dgn_find_nearest_square( const coord_def &pos, - bool (*acceptable)(const coord_def &), + void *thing, + bool (*acceptable)(const coord_def &, void *thing), bool (*traversable)(const coord_def &) = NULL) { memset(travel_point_distance, 0, sizeof(travel_distance_grid_t)); @@ -568,7 +583,7 @@ static coord_def _dgn_find_nearest_square( { const coord_def &p = *i; - if (p != pos && acceptable(p)) + if (p != pos && acceptable(p, thing)) return (p); travel_point_distance[p.x][p.y] = 1; @@ -597,16 +612,17 @@ static coord_def _dgn_find_nearest_square( return (unfound); } -static bool _item_safe_square(const coord_def &pos) +static bool _item_safe_square(const coord_def &pos, void *item) { const dungeon_feature_type feat = grd(pos); - return (feat_is_traversable(feat) && !feat_destroys_items(feat)); + return (feat_is_traversable(feat) && + !feat_destroys_item(feat, *static_cast(item))); } // Moves an item on the floor to the nearest adjacent floor-space. static bool _dgn_shift_item(const coord_def &pos, item_def &item) { - const coord_def np = _dgn_find_nearest_square(pos, _item_safe_square); + const coord_def np = _dgn_find_nearest_square(pos, &item, _item_safe_square); if (in_bounds(np) && np != pos) { int index = item.index(); @@ -622,7 +638,7 @@ bool is_critical_feature(dungeon_feature_type feat) || feat_altar_god(feat) != GOD_NO_GOD); } -static bool _is_feature_shift_target(const coord_def &pos) +static bool _is_feature_shift_target(const coord_def &pos, void*) { return (grd(pos) == DNGN_FLOOR && !dungeon_events.has_listeners_at(pos)); } @@ -634,7 +650,7 @@ static bool _dgn_shift_feature(const coord_def &pos) return (false); const coord_def dest = - _dgn_find_nearest_square(pos, _is_feature_shift_target); + _dgn_find_nearest_square(pos, NULL, _is_feature_shift_target); if (in_bounds(dest) && dest != pos) { @@ -654,27 +670,27 @@ static bool _dgn_shift_feature(const coord_def &pos) static void _dgn_check_terrain_items(const coord_def &pos, bool preserve_items) { const dungeon_feature_type feat = grd(pos); - if (feat_is_solid(feat) || feat_destroys_items(feat)) + + int item = igrd(pos); + bool did_destroy = false; + while (item != NON_ITEM) { - int item = igrd(pos); - bool did_destroy = false; - while (item != NON_ITEM) - { - const int curr = item; - item = mitm[item].link; + const int curr = item; + item = mitm[item].link; - // Game-critical item. - if (preserve_items || mitm[curr].is_critical()) - _dgn_shift_item(pos, mitm[curr]); - else - { - item_was_destroyed(mitm[curr]); - destroy_item(curr); - did_destroy = true; - } + if (!feat_is_solid(feat) && !feat_destroys_item(feat, mitm[curr])) + continue; + + // Game-critical item. + if (preserve_items || mitm[curr].is_critical()) + _dgn_shift_item(pos, mitm[curr]); + else + { + feat_destroys_item(feat, mitm[curr], true); + item_was_destroyed(mitm[curr]); + destroy_item(curr); + did_destroy = true; } - if (did_destroy && player_can_hear(pos)) - mprf(MSGCH_SOUND, feat_item_destruction_message(feat)); } } @@ -704,7 +720,7 @@ static void _dgn_check_terrain_blood(const coord_def &pos, else { if (feat_is_solid(old_feat) != feat_is_solid(new_feat) - || feat_is_water(new_feat) || feat_destroys_items(new_feat) + || feat_is_water(new_feat) || new_feat == DNGN_LAVA || is_critical_feature(new_feat)) { env.pgrid(pos) &= ~(FPROP_BLOODY); diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index f464d29929..73c5c5ee5e 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -24,6 +24,7 @@ bool cell_is_solid(const coord_def &c); bool feat_is_wall(dungeon_feature_type feat); bool feat_is_opaque(dungeon_feature_type feat); bool feat_is_solid(dungeon_feature_type feat); +bool feat_has_solid_floor(dungeon_feature_type feat); bool feat_is_door(dungeon_feature_type feat); bool feat_is_closed_door(dungeon_feature_type feat); bool feat_is_secret_door(dungeon_feature_type feat); @@ -63,9 +64,7 @@ void find_connected_range(coord_def d, dungeon_feature_type ft_min, void get_door_description(int door_size, const char** adjective, const char** noun); dungeon_feature_type grid_secret_door_appearance(const coord_def &where); dungeon_feature_type grid_appearance(const coord_def &gc); -bool feat_destroys_items(dungeon_feature_type feat); - -const char *feat_item_destruction_message( dungeon_feature_type feat ); +bool feat_destroys_item(dungeon_feature_type feat, const item_def &item, bool noisy = false); // Terrain changed under 'pos', perform necessary effects. void dungeon_terrain_changed(const coord_def &pos, diff --git a/crawl-ref/source/wiz-item.cc b/crawl-ref/source/wiz-item.cc index 1bdce290dd..56b1b9bba0 100644 --- a/crawl-ref/source/wiz-item.cc +++ b/crawl-ref/source/wiz-item.cc @@ -822,13 +822,6 @@ void wizard_list_items() //--------------------------------------------------------------- static void _debug_acquirement_stats(FILE *ostat) { - if (feat_destroys_items(grd(you.pos()))) - { - mpr("You must stand on a square which doesn't destroy items " - "in order to do this."); - return; - } - int p = get_item_slot(11); if (p == NON_ITEM) { diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 4fdb333dd4..40a19123cb 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -659,11 +659,8 @@ static void _xom_make_item(object_class_type base, int subtype, int power) items(true, base, subtype, true, power, MAKE_ITEM_RANDOM_RACE, 0, 0, GOD_XOM); - if (feat_destroys_items(grd(you.pos()))) + if (feat_destroys_item(grd(you.pos()), mitm[thing_created], !silenced(you.pos()))) { - if (!silenced(you.pos())) - mprf(MSGCH_SOUND, feat_item_destruction_message(grd(you.pos()))); - simple_god_message(" snickers.", GOD_XOM); destroy_item(thing_created, true); thing_created = NON_ITEM; @@ -2425,7 +2422,7 @@ static void _xom_zero_miscast() } } - if (!feat_destroys_items(feat) && !feat_is_solid(feat) + if (feat_has_solid_floor(feat) && inv_items.size() > 0) { int idx = inv_items[random2(inv_items.size())]; -- cgit v1.2.3-54-g00ecf From 74c535b701b7642b74b45934e78cadd7ab67a0e4 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Wed, 30 Dec 2009 03:27:21 -0800 Subject: Ignore obscured items in the UI I probably missed a few spots. --- crawl-ref/source/directn.cc | 14 +++++++------- crawl-ref/source/food.cc | 12 ++++++------ crawl-ref/source/items.cc | 4 ++-- crawl-ref/source/l_item.cc | 2 +- crawl-ref/source/mon-act.cc | 9 +++++++++ crawl-ref/source/ouch.cc | 4 ++++ crawl-ref/source/player.cc | 11 +++++++++++ crawl-ref/source/player.h | 1 + crawl-ref/source/religion.cc | 7 ++++--- crawl-ref/source/show.cc | 12 ++++-------- crawl-ref/source/showsymb.cc | 2 +- crawl-ref/source/spells4.cc | 4 ++-- crawl-ref/source/stash.cc | 8 ++++---- crawl-ref/source/stuff.cc | 4 ++-- crawl-ref/source/stuff.h | 2 +- crawl-ref/source/tilepick.cc | 4 ++-- crawl-ref/source/tilereg.cc | 2 +- crawl-ref/source/tilesdl.cc | 4 ++-- crawl-ref/source/travel.cc | 4 ++-- crawl-ref/source/tutorial.cc | 4 ++-- 20 files changed, 68 insertions(+), 46 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 047dcd3974..58aac3b22a 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -523,7 +523,7 @@ void full_describe_view() if (unknown_mimic) // It'll be on top. list_items.push_back(get_mimic_item(mon)); - const int oid = igrd(*ri); + const int oid = you.visible_igrd(*ri); if (oid == NON_ITEM) continue; @@ -1764,10 +1764,10 @@ std::string get_terse_square_desc(const coord_def &gc) else desc = mons.full_name(DESC_PLAIN, true); } - else if (igrd(gc) != NON_ITEM) + else if (you.visible_igrd(gc) != NON_ITEM) { - if (mitm[igrd(gc)].is_valid()) - desc = mitm[igrd(gc)].name(DESC_PLAIN); + if (mitm[you.visible_igrd(gc)].is_valid()) + desc = mitm[you.visible_igrd(gc)].name(DESC_PLAIN); } else desc = feature_description(gc, false, DESC_PLAIN, false); @@ -1793,7 +1793,7 @@ void get_square_desc(const coord_def &c, describe_info &inf, return; const monsters* mons = monster_at(c); - const int oid = igrd(c); + const int oid = you.visible_igrd(c); if (mons && mons->visible_to(&you)) { @@ -1836,7 +1836,7 @@ void full_describe_square(const coord_def &c) return; const monsters* mons = monster_at(c); - const int oid = igrd(c); + const int oid = you.visible_igrd(c); if (mons && mons->visible_to(&you)) { @@ -3425,7 +3425,7 @@ static void _describe_cell(const coord_def& where, bool in_range) cloud_described = true; } - int targ_item = igrd(where); + int targ_item = you.visible_igrd(where); if (targ_item != NON_ITEM) { diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index bd2db8d728..d17a4a5371 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -452,7 +452,7 @@ static bool _have_corpses_in_pack(bool remind) bool butchery(int which_corpse) { - if (igrd(you.pos()) == NON_ITEM) + if (you.visible_igrd(you.pos()) == NON_ITEM) { if (!_have_corpses_in_pack(false)) mpr("There isn't anything here!"); @@ -503,7 +503,7 @@ bool butchery(int which_corpse) int num_corpses = 0; int corpse_id = -1; bool prechosen = (which_corpse != -1); - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { if (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY) { @@ -577,7 +577,7 @@ bool butchery(int which_corpse) bool did_weap_swap = false; bool first_corpse = true; int keyin; - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { if (si->base_type != OBJ_CORPSES || si->sub_type != CORPSE_BODY) continue; @@ -790,7 +790,7 @@ bool eat_food(int slot) if (result != -2) // else skip ahead to inventory { - if (igrd(you.pos()) != NON_ITEM) + if (you.visible_igrd(you.pos()) != NON_ITEM) { result = eat_from_floor(true); if (result == 1) @@ -1186,7 +1186,7 @@ int eat_from_floor(bool skip_chunks) bool found_valid = false; std::vector food_items; - for (stack_iterator si(you.pos()); si; ++si ) + for (stack_iterator si(you.pos(), true); si; ++si ) { if (you.species == SP_VAMPIRE) { @@ -1483,7 +1483,7 @@ int prompt_eat_chunks() // First search the stash on the floor, unless levitating. if (you.flight_mode() != FL_LEVITATE) { - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { if (you.species == SP_VAMPIRE) { diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 1aaeda2dec..fe96b86d1b 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1171,7 +1171,7 @@ void pickup() return; } - int o = igrd(you.pos()); + int o = you.visible_igrd(you.pos()); const int num_nonsquelched = _count_nonsquelched_items(o); if (o == NON_ITEM) @@ -2578,7 +2578,7 @@ static void _do_autopickup() return; } - int o = igrd(you.pos()); + int o = you.visible_igrd(you.pos()); std::string pickup_warning; while (o != NON_ITEM) diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc index e8dc23a2b1..ecd343be2a 100644 --- a/crawl-ref/source/l_item.cc +++ b/crawl-ref/source/l_item.cc @@ -48,7 +48,7 @@ void lua_set_exclusive_item(const item_def *item) void lua_push_floor_items(lua_State *ls) { - lua_push_items(ls, igrd(you.pos())); + lua_push_items(ls, you.visible_igrd(you.pos())); } void lua_push_inv_items(lua_State *ls = NULL) diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index 18ad9a1b01..6aca56ffa8 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -2183,6 +2183,7 @@ static bool _monster_eat_item(monsters *monster, bool nearby) bool death_ooze_ate_good = false; bool death_ooze_ate_corpse = false; + // Jellies can swim, so don't check water for (stack_iterator si(monster->pos()); si && eaten < max_eat && hps_changed < 50; ++si) { @@ -2466,6 +2467,14 @@ static bool _handle_pickup(monsters *monster) if (monster->asleep() || monster->submerged()) return (false); + // Hack - Harpies fly over water, but we don't have a general + // system for monster igrd yet. Flying intelligent monsters + // (kenku!) would also count here. + dungeon_feature_type feat = grd(monster->pos()); + + if ((feat == DNGN_LAVA || feat == DNGN_DEEP_WATER) && !monster->flight_mode()) + return (false); + const bool nearby = mons_near(monster); int count_pickup = 0; diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 34f8bc736c..2813101bbe 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -551,6 +551,10 @@ bool expose_items_to_element(beam_type flavour, const coord_def& where, if (target_class == OBJ_UNASSIGNED) return (false); + // Beams fly *over* water and lava. + if (grd(where) == DNGN_LAVA || grd(where) == DNGN_DEEP_WATER) + return (false); + for (stack_iterator si(where); si; ++si) { if (!si->is_valid()) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index e490908d1b..564bf18de1 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5549,6 +5549,17 @@ bool player::can_swim() const return (species == SP_MERFOLK && merfolk_change_is_safe(true)); } +int player::visible_igrd(const coord_def &where) const +{ + if (grd(where) == DNGN_LAVA + || (grd(where) == DNGN_DEEP_WATER && species != SP_MERFOLK)) + { + return (NON_ITEM); + } + + return igrd(where); +} + bool player::swimming() const { return in_water() && can_swim(); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 1e5c58d47a..9c64409023 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -323,6 +323,7 @@ public: bool in_water() const; bool can_swim() const; + int visible_igrd(const coord_def&) const; bool is_levitating() const; bool cannot_speak() const; bool invisible() const; diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 3845be27d2..80b277bc67 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -2266,7 +2266,7 @@ static bool _confirm_pray_sacrifice(god_type god) return (false); } - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { if (_god_likes_item(god, *si) && (_is_risky_sacrifice(*si) @@ -3811,7 +3811,7 @@ bool ely_destroy_weapons() god_acting gdact; bool success = false; - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { item_def& item(*si); if (item.base_type != OBJ_WEAPONS @@ -4692,7 +4692,8 @@ void offer_items() int i = igrd(you.pos()); - if (!god_likes_items(you.religion) && i != NON_ITEM) + if (!god_likes_items(you.religion) && i != NON_ITEM + && you.visible_igrd(you.pos()) != NON_ITEM) { simple_god_message(" doesn't care about such mundane gifts.", you.religion); diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc index 103d00b09d..0148d92438 100644 --- a/crawl-ref/source/show.cc +++ b/crawl-ref/source/show.cc @@ -224,8 +224,8 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep) const monsters* m = monster_at(gp); if (m && mons_is_unknown_mimic(m)) eitem = &get_mimic_item(m); - else if (igrd(gp) != NON_ITEM) - eitem = &mitm[igrd(gp)]; + else if (you.visible_igrd(gp) != NON_ITEM) + eitem = &mitm[you.visible_igrd(gp)]; else return; @@ -235,10 +235,6 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep) const dungeon_feature_type feat = grd(gp); - if ((feat == DNGN_DEEP_WATER && you.species != SP_MERFOLK) - || feat == DNGN_LAVA) - return; - if (Options.feature_item_brand && is_critical_feature(feat)) ecol |= COLFLAG_FEATURE_ITEM; else if (Options.trap_item_brand && feat_is_trap(feat)) @@ -251,7 +247,7 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep) ecol = _feat_colour(gp, feat); // monster(mimic)-owned items have link = NON_ITEM+1+midx - if (eitem->link > NON_ITEM && igrd(gp) != NON_ITEM) + if (eitem->link > NON_ITEM && you.visible_igrd(gp) != NON_ITEM) ecol |= COLFLAG_ITEM_HEAP; else if (eitem->link < NON_ITEM && !crawl_state.arena) ecol |= COLFLAG_ITEM_HEAP; @@ -260,7 +256,7 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep) } #ifdef USE_TILE - int idx = igrd(gp); + int idx = you.visible_igrd(gp); if (idx != NON_ITEM) { if (feat_is_stair(feat)) diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc index 6f3c77fea6..6019065d7e 100644 --- a/crawl-ref/source/showsymb.cc +++ b/crawl-ref/source/showsymb.cc @@ -100,7 +100,7 @@ static int _get_mons_colour(const monsters *mons) col |= COLFLAG_FEATURE_ITEM; } else if (Options.heap_brand != CHATTR_NORMAL - && igrd(mons->pos()) != NON_ITEM + && you.visible_igrd(mons->pos()) != NON_ITEM && !crawl_state.arena) { col |= COLFLAG_ITEM_HEAP; diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 03dbf76e72..d4c78afc48 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1182,7 +1182,7 @@ void cast_fulsome_distillation(int /*pow*/) int corpse = -1; // Search items at the player's location for corpses. - for (stack_iterator si(you.pos()); si; ++si) + for (stack_iterator si(you.pos(), true); si; ++si) { if (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY) { @@ -1476,7 +1476,7 @@ bool cast_fragmentation(int pow, const dist& spd) goto all_done; } - for (stack_iterator si(spd.target); si; ++si) + for (stack_iterator si(spd.target, true); si; ++si) { if (si->base_type == OBJ_CORPSES) { diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 147dbc67d8..f40dc4005e 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -326,7 +326,7 @@ static bool _grid_has_mimic_item(const coord_def& pos) static bool _grid_has_perceived_item(const coord_def& pos) { - return (igrd(pos) != NON_ITEM || _grid_has_mimic_item(pos)); + return (you.visible_igrd(pos) != NON_ITEM || _grid_has_mimic_item(pos)); } static bool _grid_has_perceived_multiple_items(const coord_def& pos) @@ -336,7 +336,7 @@ static bool _grid_has_perceived_multiple_items(const coord_def& pos) if (_grid_has_mimic_item(pos)) ++count; - for (stack_iterator si(pos); si && count < 2; ++si) + for (stack_iterator si(pos, true); si && count < 2; ++si) ++count; return (count > 1); @@ -361,7 +361,7 @@ void Stash::update() items.clear(); // Now, grab all items on that square and fill our vector - for (stack_iterator si(p); si; ++si) + for (stack_iterator si(p, true); si; ++si) if (!is_filtered(*si)) add_item(*si); @@ -384,7 +384,7 @@ void Stash::update() pitem = &get_mimic_item(monster_at(p)); else { - pitem = &mitm[igrd(p)]; + pitem = &mitm[you.visible_igrd(p)]; tutorial_first_item(*pitem); } diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index ccff7125aa..9094d9b214 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -65,9 +65,9 @@ #include "tutorial.h" #include "view.h" -stack_iterator::stack_iterator(const coord_def& pos) +stack_iterator::stack_iterator(const coord_def& pos, bool accesible) { - cur_link = igrd(pos); + cur_link = accesible ? you.visible_igrd(pos) : igrd(pos); if ( cur_link != NON_ITEM ) next_link = mitm[cur_link].link; else diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index 684df4175d..8d0e288db6 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -24,7 +24,7 @@ class stack_iterator : public std::iterator { public: - explicit stack_iterator( const coord_def& pos ); + explicit stack_iterator( const coord_def& pos, bool accessible = false ); explicit stack_iterator( int start_link ); operator bool() const; diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index 723dbc0d00..8881bc867b 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -4795,7 +4795,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected) if (!mons_is_known_mimic(mon)) { // If necessary add item brand. - if (igrd(gc) != NON_ITEM) + if (you.visible_igrd(gc) != NON_ITEM) { if (foreground) t |= TILE_FLAG_S_UNDER; @@ -4815,7 +4815,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected) else if (menv[idx].holiness() == MH_PLANT) { // If necessary add item brand. - if (igrd(gc) != NON_ITEM) + if (you.visible_igrd(gc) != NON_ITEM) { if (foreground) t |= TILE_FLAG_S_UNDER; diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 4490e3a59a..65383f46b4 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -1745,7 +1745,7 @@ bool DungeonRegion::update_tip_text(std::string& tip) tip += get_class_abbrev(you.char_class); tip += ")"; - if (igrd(m_cursor[CURSOR_MOUSE]) != NON_ITEM) + if (you.visible_igrd(m_cursor[CURSOR_MOUSE]) != NON_ITEM) tip += "\n[L-Click] Pick up items (g)"; const dungeon_feature_type feat = grd(m_cursor[CURSOR_MOUSE]); diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 50dbb83f58..62ac431970 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -1550,7 +1550,7 @@ void TilesFramework::update_inventory() memset(inv_shown, 0, sizeof(inv_shown)); int num_ground = 0; - for (int i = igrd(you.pos()); i != NON_ITEM; i = mitm[i].link) + for (int i = you.visible_igrd(you.pos()); i != NON_ITEM; i = mitm[i].link) num_ground++; // If the inventory is full, show at least one row of the ground. @@ -1676,7 +1676,7 @@ void TilesFramework::update_inventory() type = (object_class_type)(find - obj_syms); } - for (int i = igrd(you.pos()); i != NON_ITEM; i = mitm[i].link) + for (int i = you.visible_igrd(you.pos()); i != NON_ITEM; i = mitm[i].link) { if ((int)inv.size() >= mx * my) break; diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 28b593d97a..296e39318a 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -550,8 +550,8 @@ inline static void _check_interesting_square(int x, int y, ed.found_item(pos, get_mimic_item(mons)); } - if (igrd(pos) != NON_ITEM) - ed.found_item( pos, mitm[ igrd(pos) ] ); + if (you.visible_igrd(pos) != NON_ITEM) + ed.found_item( pos, mitm[ you.visible_igrd(pos) ] ); } ed.found_feature( pos, grd(pos) ); diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 69aeb760a2..e0e7d53b72 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -1887,7 +1887,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc) text << "Ah, a corpse!"; else { - int i = igrd(gc); + int i = you.visible_igrd(gc); while (i != NON_ITEM) { if (mitm[i].base_type == OBJ_CORPSES) @@ -4680,7 +4680,7 @@ void tutorial_observe_cell(const coord_def& gc) else if (grd(gc) == DNGN_ENTER_PORTAL_VAULT) learned_something_new(TUT_SEEN_PORTAL, gc); - const int it = igrd(gc); + const int it = you.visible_igrd(gc); if (it != NON_ITEM) { const item_def& item(mitm[it]); -- cgit v1.2.3-54-g00ecf From 33bb370e46344d6cf54e2e9f937e7f1b2d2e83b1 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Wed, 30 Dec 2009 03:30:39 -0800 Subject: Fix four cosmetic errors in one line --- crawl-ref/source/religion.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 80b277bc67..8a20c52062 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -4853,9 +4853,9 @@ void offer_items() if (num_sacced > 0 && you.religion == GOD_KIKUBAAQUDGHA) { - simple_god_message(" torments the living!"); + simple_god_message(" torments the living!"); torment(TORMENT_KIKUBAAQUDGHA, you.pos()); - you.piety -= 8 + random2(4); // costs 8 - 12 piety + lose_piety(random_range(8, 12)); } // Explanatory messages if nothing the god likes is sacrificed. -- cgit v1.2.3-54-g00ecf