Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 738395: Characters should never get stuck if diagonally adjacent …

…to their target
  • Loading branch information...
commit c8d5679f01cb0ceeee5551baf24bd6e196eaded1 1 parent 3f97029
Franck Lecollinet sork authored
Showing with 16 additions and 0 deletions.
  1. +4 −0 client/js/entity.js
  2. +12 −0 client/js/game.js
4 client/js/entity.js
View
@@ -211,6 +211,10 @@ define(function() {
return result;
},
+ isDiagonallyAdjacent: function(entity) {
+ return this.isAdjacent(entity) && !this.isAdjacentNonDiagonal(entity);
+ },
+
forEachAdjacentNonDiagonalPosition: function(callback) {
callback(this.gridX - 1, this.gridY, Types.Orientations.LEFT);
callback(this.gridX, this.gridY - 1, Types.Orientations.UP);
12 client/js/game.js
View
@@ -2032,7 +2032,12 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
if(character.canAttack(time)) {
if(!isMoving) { // don't hit target if moving to a different tile.
+ if(character.hasTarget() && character.getOrientationTo(character.target) !== character.orientation) {
+ character.lookAtTarget();
+ }
+
character.hit();
+
if(character.id === this.playerId) {
this.client.sendHit(character.target);
}
@@ -2045,6 +2050,13 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
this.client.sendHurt(character);
}
}
+ } else {
+ if(character.hasTarget()
+ && character.isDiagonallyAdjacent(character.target)
+ && character.target instanceof Player
+ && !character.target.isMoving()) {
+ character.follow(character.target);
+ }
}
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.