Permalink
Browse files

Bug 732411: Fix a rare case where a mob stuck on top of a player woul…

…d slow the game down
  • Loading branch information...
sork committed Mar 26, 2012
1 parent 749fc5a commit 5c10b3a0a0f5b2c54da6d29115bd9f04116a68ae
Showing with 15 additions and 8 deletions.
  1. +15 −8 client/js/game.js
View
@@ -1150,15 +1150,22 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
});
entity.onRequestPath(function(x, y) {
- var ignored = [entity]; // Always ignore self
-
+ var ignored = [entity], // Always ignore self
+ ignoreTarget = function(target) {
+ ignored.push(target);
+
+ // also ignore other attackers of the target entity
+ target.forEachAttacker(function(attacker) {
+ ignored.push(attacker);
+ });
+ };
+
if(entity.hasTarget()) {
- ignored.push(entity.target);
-
- // also ignore other attackers of the target entity
- entity.target.forEachAttacker(function(attacker) {
- ignored.push(attacker);
- });
+ ignoreTarget(entity.target);
+ } else if(entity.previousTarget) {
+ // If repositioning before attacking again, ignore previous target
+ // See: tryMovingToADifferentTile()
+ ignoreTarget(entity.previousTarget);
}
return self.findPath(entity, x, y, ignored);

0 comments on commit 5c10b3a

Please sign in to comment.