Skip to content

Commit

Permalink
The return of randomized energy (when pursuing the player).
Browse files Browse the repository at this point in the history
Randomized energy (essentially monsters having a random choice between
0.9/1.0/1.1 move delay) was removed in c209556. It had two main problems
- the first was that it felt surprising and 'unfair' when an ogre two
steps away suddenly moved and hit the player on the same turn, and the
second was that it incentivized running away from an adjacent monster
until random energy made a space between the two of you (usually only
taking 0-2 hits in the process).

This commit re-implements randomized energy, but only when the monster
is pursuing the player (replacing the experimental swiftness on pursuit).
This hopefully addresses the first issue with randomized energy, since
an ogre will only be able to move + attack if the player was adjacent to it
and just moved away - essentially an attack of opportunity.

The second issue will be addressed by bringing back attacks of opportunity
in a separate commit, making running away from an adjacent monster far
more deadly.

The hope is that randomized energy will help smooth out some of the sharp
edges on attacks of opportunity - we'll try it out.
  • Loading branch information
elliptic committed Aug 18, 2023
1 parent 967258e commit e438bbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
24 changes: 8 additions & 16 deletions crawl-ref/source/mon-act.cc
Expand Up @@ -3025,21 +3025,20 @@ static bool _monster_swaps_places(monster* mon, const coord_def& delta)
return false;
}

static void _maybe_pursue_quickly(monster &mons, coord_def orig_pos)
static void _maybe_randomize_energy(monster &mons, coord_def orig_pos)
{
if (!mons.alive() // barbs!
|| !crawl_state.potential_pursuers.count(&mons)
|| mons.wont_attack()
|| mons_is_confused(mons, true)
|| mons_is_fleeing(mons)
|| !mons.can_see(you)
|| mons.has_ench(ENCH_PURSUING))
|| !mons.can_see(you))
{
return;
}


// Only trigger swiftness for monsters moving toward you, not doing tricky
// Only randomize energy for monsters moving toward you, not doing tricky
// M_MAINTAIN_RANGE nonsense or wandering around a lake or what have you.
if (grid_distance(mons.pos(), you.pos()) > grid_distance(orig_pos, you.pos()))
return;
Expand All @@ -3049,15 +3048,8 @@ static void _maybe_pursue_quickly(monster &mons, coord_def orig_pos)
if (!foe || !foe->is_player())
return;

if (you.can_see(mons))
{
const string msg = make_stringf(
" puts on a burst of speed as %s %s you!",
mons.pronoun(PRONOUN_SUBJECTIVE).c_str(),
conjugate_verb("pursue", mons.pronoun_plurality()).c_str());
simple_monster_message(mons, msg.c_str());
}
mons.add_ench(ENCH_PURSUING);
// Randomize energy.
mons.speed_increment += random2(3) - 1;
}

static bool _do_move_monster(monster& mons, const coord_def& delta)
Expand Down Expand Up @@ -3186,11 +3178,11 @@ static bool _do_move_monster(monster& mons, const coord_def& delta)

_handle_manticore_barbs(mons);

// Turn on the gas before we use up move energy, so that pillar-dancing
// players can maybe get bapped if they get unlucky.
_maybe_pursue_quickly(mons, orig_pos);
_swim_or_move_energy(mons);

// Randomize move energy for monsters pursuing the player.
_maybe_randomize_energy(mons, orig_pos);

return true;
}

Expand Down
4 changes: 1 addition & 3 deletions crawl-ref/source/movement.cc
Expand Up @@ -227,9 +227,7 @@ static void _mark_potential_pursuers(coord_def new_pos)
const coord_def orig_pos = you.pos();
for (radius_iterator ri(you.pos(), LOS_NO_TRANS); ri; ++ri)
{
if (!one_chance_in(10))
continue;
// Only trigger swiftness for monsters you're moving away from.
// Only randomize energy for monsters you're moving away from.
if (grid_distance(new_pos, *ri) <= grid_distance(orig_pos, *ri))
continue;
monster* mon = monster_at(*ri);
Expand Down

0 comments on commit e438bbe

Please sign in to comment.