Skip to content

Commit

Permalink
Remember the centre of Gravitas when its target dies.
Browse files Browse the repository at this point in the history
On most parts of the map, if one attractee collided with and killed the
target, further attactees wouldn't be moved, because the dead target was
too far away.  That's a bit weird because, notionally, they're all being
attracted at the same time.

Even worse, if we happened to be close to (0,0), the remaining monsters
would be sucked to the northwest, where the spirits of the departed
reside.
  • Loading branch information
neilmoore committed Oct 23, 2015
1 parent 245b47f commit e0d96ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crawl-ref/source/spl-transloc.cc
Expand Up @@ -1002,19 +1002,20 @@ void attract_actor(const actor* agent, actor* victim, const coord_def pos,
bool fatal_attraction(actor *victim, actor *agent, int pow)
{
bool affected = false;
for (actor_near_iterator ai(victim->pos(), LOS_NO_TRANS); ai; ++ai)
const auto pos = victim->pos(); // in case it dies
for (actor_near_iterator ai(pos, LOS_NO_TRANS); ai; ++ai)
{
if (*ai == victim || *ai == agent || ai->is_stationary())
continue;

const int range = (victim->pos() - ai->pos()).rdist();
const int range = (pos - ai->pos()).rdist();
const int strength =
min(4, (pow / 10) / (range*range));
if (strength <= 0)
continue;

affected = true;
attract_actor(agent, *ai, victim->pos(), pow, strength);
attract_actor(agent, *ai, pos, pow, strength);
}

return affected;
Expand Down

0 comments on commit e0d96ed

Please sign in to comment.