summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-22 15:58:36 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-04-22 15:58:36 +0000
commit13abff271666dcc566102311c3b9d237ea04f933 (patch)
tree499b2bb9a9f91a7b201f8e0102dc2befa5bcb057 /crawl-ref/source/effects.cc
parent5c8009179acad07659f28a6995438b72a7a6c183 (diff)
downloadcrawl-ref-13abff271666dcc566102311c3b9d237ea04f933.tar.gz
crawl-ref-13abff271666dcc566102311c3b9d237ea04f933.zip
* Tweak Xom's ideas about what makes a funny or boring death.
* Add another option (*sigh*) covering whether W=T and P=R. (Defaults to false.) * Various spacing and comment fixes. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9675 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc85
1 files changed, 46 insertions, 39 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index ef29b00b7b..5e75380c3a 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -874,7 +874,7 @@ typedef FixedVector<int, max_has_value> has_vector;
static armour_type _acquirement_armour_subtype()
{
// Increasing the representation of the non-body armour
- // slots here to make up for the fact that there's one
+ // slots here to make up for the fact that there's only
// one type of item for most of them. -- bwr
//
// NUM_ARMOURS is body armour and handled below
@@ -1314,8 +1314,8 @@ static int _find_acquirement_subtype(object_class_type class_wanted,
return (type_wanted);
}
-// The weight of a spell is defined as the average of all disciplines'
-// skill levels minus the doubled spell level.
+// The weight of a spell takes into account its disciplines' skill levels
+// and the spell difficulty.
static int _spell_weight(spell_type spell)
{
ASSERT(spell != SPELL_NO_SPELL);
@@ -1330,12 +1330,13 @@ static int _spell_weight(spell_type spell)
{
int skill = you.skills[spell_type2skill(disc)];
- weight += skill + 1;
+ weight += skill;
count++;
}
}
ASSERT(count > 0);
+ // Particularly difficult spells _reduce_ the overall weight.
int leveldiff = 5 - spell_difficulty(spell);
return std::max(0, 2 * weight/count + leveldiff);
@@ -1416,14 +1417,14 @@ static bool _do_book_acquirement(item_def &book, int agent)
if (i == SK_SPELLCASTING && weight >= 1)
weight--;
- // Count magic skills double to bias against manuals
- // for magic users.
if (i >= SK_SPELLCASTING && i <= SK_POISON_MAGIC)
magic_weights += weight;
else
other_weights += weight;
}
+ // Count magic skills double to bias against manuals
+ // for magic users.
if (x_chance_in_y(other_weights, 2*magic_weights + other_weights))
{
choice = BOOK_MANUAL;
@@ -1510,7 +1511,7 @@ static bool _do_book_acquirement(item_def &book, int agent)
int w = (skill < 12) ? skill + 3
: std::max(0, 25 - skill);
- // If we don't know any magic skills, make non-magic skills
+ // If we don't have any magic skills, make non-magic skills
// more likely.
if (!knows_magic && (i < SK_SPELLCASTING || i > SK_POISON_MAGIC))
w *= 2;
@@ -2476,14 +2477,21 @@ static bool _grid_is_flanked_by_walls(const coord_def &p)
// are flanked by walls on both sides, and if so, the grids following that
// also have to be floor flanked by walls.
//
-// c.d
+// czd
// a.b -> if (a, b == walls) then (c, d == walls) or return (false)
// #X#
// .
+//
+// Grid z may be floor or wall, either way we have a corridor of at least
+// length 2.
static bool _deadend_check_wall(const coord_def &p)
{
+ // The grids to the left and right of p are walls. (We already know that
+ // they are symmetric, so only need to check one side. We also know that
+ // the other direction, here up/down must then be non-walls.)
if (grid_is_wall(grd[p.x-1][p.y]))
{
+ // Run the check twice, once in either direction.
for (int i = -1; i <= 1; i++)
{
if (i == 0)
@@ -2503,7 +2511,7 @@ static bool _deadend_check_wall(const coord_def &p)
}
}
}
- else
+ else // The grids above and below p are walls.
{
for (int i = -1; i <= 1; i++)
{
@@ -2531,8 +2539,9 @@ static bool _deadend_check_wall(const coord_def &p)
// Similar to the above, checks whether turning a wall grid into floor
// would create a short "dead-end" of only 1 grid.
//
-// In the example below, X would create dead-ends at positions a and b,
-// but both Y and Z avoid this, and the resulting mini-mazes looks better.
+// In the example below, X would create miniature dead-ends at positions
+// a and b, but both Y and Z avoid this, and the resulting mini-mazes
+// look much better.
//
// ######## (A) ######## (B) ######## (C) ########
// #.....#. #....a#. #.....#. #.....#.
@@ -2640,6 +2649,7 @@ void change_labyrinth(bool msg)
if (testbits(env.map(*ri).property, FPROP_VAULT))
continue;
+ // Make sure we don't accidentally create "ugly" dead-ends.
if (_grid_is_flanked_by_walls(*ri) && _deadend_check_floor(*ri))
targets.push_back(*ri);
}
@@ -2694,7 +2704,7 @@ void change_labyrinth(bool msg)
{
const coord_def c(targets[count]);
// Maybe not valid anymore...
- if (!_grid_is_flanked_by_walls(c))
+ if (!grid_is_wall(grd(c)) || !_grid_is_flanked_by_walls(c))
continue;
// Use the adjacent floor grids as source and destination.
@@ -2736,9 +2746,15 @@ void change_labyrinth(bool msg)
for (unsigned int i = 0; i < path.size(); i++)
{
const coord_def p(path[i]);
+ // The point must be inside the changed area.
if (p.x < c1.x || p.x > c2.x || p.y < c1.y || p.y > c2.y)
continue;
+ // Only replace plain floor.
+ if (grd(p) != DNGN_FLOOR)
+ continue;
+
+ // Don't change any grids we remember.
if (is_terrain_seen(p.x, p.y))
continue;
@@ -2771,11 +2787,12 @@ void change_labyrinth(bool msg)
(int) old_grid, c.x, c.y, (int) grd(p), p.x, p.y);
}
#ifdef WIZARD
+ // Highlight the switched grids.
env.map(c).property |= FPROP_HIGHLIGHT;
env.map(p).property |= FPROP_HIGHLIGHT;
#endif
- // Shift blood some most of the time.
+ // Shift blood some of the time.
if (is_bloodcovered(c))
{
if (one_chance_in(4))
@@ -2786,18 +2803,17 @@ void change_labyrinth(bool msg)
if (grid_is_wall(grd(*ai)) && one_chance_in(++wall_count))
old_adj = *ai;
- if (old_adj != c)
+ if (old_adj != c && !is_bloodcovered(old_adj))
{
- if (!is_bloodcovered(old_adj))
- env.map(old_adj).property |= FPROP_BLOODY;
+ env.map(old_adj).property |= FPROP_BLOODY;
env.map(c).property &= (~FPROP_BLOODY);
}
}
}
else if (one_chance_in(500))
{
- // Sometimes (rarely) add blood randomly, accumulating with time...
- env.map(p).property |= FPROP_BLOODY;
+ // Rarely add blood randomly, accumulating with time...
+ env.map(c).property |= FPROP_BLOODY;
}
// Rather than use old_grid directly, replace with an adjacent
@@ -2839,10 +2855,9 @@ void change_labyrinth(bool msg)
if (_is_floor(grd(*ai)) && one_chance_in(++floor_count))
new_adj = *ai;
- if (new_adj != p)
+ if (new_adj != p && !is_bloodcovered(new_adj))
{
- if (!is_bloodcovered(new_adj))
- env.map(new_adj).property |= FPROP_BLOODY;
+ env.map(new_adj).property |= FPROP_BLOODY;
env.map(p).property &= (~FPROP_BLOODY);
}
}
@@ -2861,7 +2876,7 @@ void change_labyrinth(bool msg)
dirs.push_back(coord_def( 0,-1));
dirs.push_back(coord_def( 1,-1));
dirs.push_back(coord_def(-1, 0));
-// dirs.push_back(coord_def( 0, 0));
+
dirs.push_back(coord_def( 1, 0));
dirs.push_back(coord_def(-1, 1));
dirs.push_back(coord_def( 0, 1));
@@ -2979,13 +2994,13 @@ static void _rot_inventory_food(long time_delta)
if (you.inv[i].base_type == OBJ_POTIONS)
{
- // also handles messaging
+ // Also handles messaging.
if (maybe_coagulate_blood_potions_inv(you.inv[i]))
burden_changed_by_rot = true;
continue;
}
- // food item timed out -> make it disappear
+ // Food item timed out -> make it disappear.
if ((time_delta / 20) >= you.inv[i].special)
{
if (you.inv[i].base_type == OBJ_FOOD)
@@ -2998,17 +3013,9 @@ static void _rot_inventory_food(long time_delta)
continue;
}
- if (you.inv[i].sub_type == CORPSE_SKELETON)
- {
- if (you.equip[EQ_WEAPON] == i)
- unwield_item();
-
- destroy_item(you.inv[i]);
- burden_changed_by_rot = true;
- continue;
- }
-
- if (!mons_skeleton(you.inv[i].plus))
+ // The item is of type carrion.
+ if (you.inv[i].sub_type == CORPSE_SKELETON
+ || !mons_skeleton(you.inv[i].plus))
{
if (you.equip[EQ_WEAPON] == i)
unwield_item();
@@ -3024,7 +3031,7 @@ static void _rot_inventory_food(long time_delta)
continue;
}
- // if it hasn't disappeared, reduce the rotting timer
+ // If it hasn't disappeared, reduce the rotting timer.
you.inv[i].special -= (time_delta / 20);
if (food_is_rotten(you.inv[i])
@@ -3137,10 +3144,10 @@ void handle_time(long time_delta)
// Slow heal mutation. Applied last.
// Each level reduces your stat recovery by one third.
- if (player_mutation_level(MUT_SLOW_HEALING) > 0)
+ if (player_mutation_level(MUT_SLOW_HEALING) > 0
+ && x_chance_in_y(player_mutation_level(MUT_SLOW_HEALING), 3))
{
- if (x_chance_in_y(player_mutation_level(MUT_SLOW_HEALING), 3))
- recovery = false;
+ recovery = false;
}
if (recovery)