diff options
author | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2011-04-14 22:56:46 +0200 |
---|---|---|
committer | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2011-04-14 23:02:06 +0200 |
commit | 6c2e1adc9375f3e35bad96cb5a89be0d90a22229 (patch) | |
tree | 5300df35b16d23a5fca40ff1f070ebd7191f38ba /crawl-ref/source/dgn-shoals.cc | |
parent | 2dd1d7d8588d7df09bb604bbce65a5c8480551df (diff) | |
download | crawl-ref-6c2e1adc9375f3e35bad96cb5a89be0d90a22229.tar.gz crawl-ref-6c2e1adc9375f3e35bad96cb5a89be0d90a22229.zip |
Fix #781: handle throwing nets correctly in the Shoals tides.
First, there a 10% chance of a net simply being washed away (as in,
the item is moved by the tide even if the trapped critter isn't).
If this happens, clean up the net properly.
Second, whenever a monster (or the player) that happens to be caught
in a net is shifted by the tides, move the net with it and *don't*
clear the trapping status.
Diffstat (limited to 'crawl-ref/source/dgn-shoals.cc')
-rw-r--r-- | crawl-ref/source/dgn-shoals.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 59fe46bd5d..24f913e552 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -22,6 +22,7 @@ #include "mon-util.h" #include "random.h" #include "terrain.h" +#include "traps.h" #include "view.h" #include <algorithm> @@ -231,7 +232,9 @@ static std::vector<coord_def> _shoals_water_depth_change_points() coord_def c(*ri); if (grd(c) == DNGN_DEEP_WATER && dgn_has_adjacent_feat(c, DNGN_SHALLOW_WATER)) + { points.push_back(c); + } } return points; } @@ -628,7 +631,9 @@ static std::vector<coord_def> _shoals_windshadows(grid_bool &windy) if (!windy(p) && grd(p) == DNGN_FLOOR && (dgn_has_adjacent_feat(p, DNGN_STONE_WALL) || dgn_has_adjacent_feat(p, DNGN_ROCK_WALL))) + { wind_shadows.push_back(p); + } } return wind_shadows; } @@ -780,6 +785,26 @@ static coord_def _shoals_escape_place_from(coord_def bad_place, return chosen; } +static void _clear_net_trapping_status(coord_def c) +{ + actor *victim = actor_at(c); + if (!victim) + return; + + if (victim->atype() == ACT_MONSTER) + { + monster* mvictim = victim->as_monster(); + if (you.can_see(mvictim)) + mprf("The net is swept off %s.", mvictim->name(DESC_NOCAP_THE).c_str()); + mons_clear_trapping_net(mvictim); + } + else + { + mpr("The tide washes the net away!"); + clear_trapping_net(); + } +} + static bool _shoals_tide_sweep_items_clear(coord_def c) { int link = igrd(c); @@ -792,13 +817,20 @@ static bool _shoals_tide_sweep_items_clear(coord_def c) // item clear here, let dungeon_terrain_changed teleport the item // to the nearest safe square. item_def &item(*si); + // Let the tide break up stacks if (!item_is_rune(item) && coinflip()) continue; + if (item_is_stationary(item) && !one_chance_in(5)) + continue; + const coord_def target(_shoals_escape_place_from(c, NULL, &item)); if (!target.origin()) { + if (item_is_stationary(item)) + _clear_net_trapping_status(c); + int id = si.link(); move_item_to_grid(&id, target); } @@ -831,7 +863,14 @@ static bool _shoals_tide_sweep_actors_clear(coord_def c) if (evacuation_point.origin()) return false; - victim->move_to_pos(evacuation_point); + bool clear_net = false; + if (victim->caught()) + { + int net = get_trapping_net(c); + if (net != NON_ITEM) + clear_net = !move_item_to_grid(&net, evacuation_point); + } + victim->move_to_pos(evacuation_point, clear_net); return true; } |