From 0b099e0472745b852572ac18638dabcac95d27b0 Mon Sep 17 00:00:00 2001 From: harrider <22509508+harrider@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:47:23 -0400 Subject: [PATCH 1/4] Update monster.js Added missing condition to prevent movementPoints from decrementing while the monster was moving. Previously if you increased the movementPoints value, it would still only move 1 position, but the movementPoints value would decrement each update frame until it reached 0. --- chapter-4/example-2-first-monster/monster.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter-4/example-2-first-monster/monster.js b/chapter-4/example-2-first-monster/monster.js index ade636d..e7b02d4 100644 --- a/chapter-4/example-2-first-monster/monster.js +++ b/chapter-4/example-2-first-monster/monster.js @@ -17,7 +17,7 @@ export default class BasicMonster { let oldX = this.x let oldY = this.y - if (this.movementPoints > 0) { + if (this.movementPoints > 0 && !this.moving) { // https://github.com/qiao/PathFinding.js let pX = dungeon.player.x let pY = dungeon.player.y @@ -36,4 +36,4 @@ export default class BasicMonster { over() { return this.movementPoints == 0 && !this.moving } -} \ No newline at end of file +} From 947852525abc97c6aa6d42e22c2d10a98b67bf4a Mon Sep 17 00:00:00 2001 From: harrider <22509508+harrider@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:49:13 -0400 Subject: [PATCH 2/4] Update monster.js Added missing condition to prevent movementPoints from decrementing while the monster was moving. Previously if you increased the movementPoints value, it would still only move 1 position, but the movementPoints value would decrement each update frame until it reached 0. --- chapter-4/example-3-basic-combat/monster.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter-4/example-3-basic-combat/monster.js b/chapter-4/example-3-basic-combat/monster.js index 313629d..9dd7c5e 100644 --- a/chapter-4/example-3-basic-combat/monster.js +++ b/chapter-4/example-3-basic-combat/monster.js @@ -32,7 +32,7 @@ export default class BasicMonster { let finder = new PF.AStarFinder() let path = finder.findPath(oldX, oldY, pX, pY, grid) - if (this.movementPoints > 0) { + if (this.movementPoints > 0 && !this.moving) { if (path.length > 2) { dungeon.moveEntityTo(this, path[1][0], path[1][1]) } @@ -56,4 +56,4 @@ export default class BasicMonster { onDestroy() { console.log(`${this.name} was killed`) } -} \ No newline at end of file +} From d1db18d711276d5cda90ba26b47383323e5f3e64 Mon Sep 17 00:00:00 2001 From: harrider <22509508+harrider@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:50:26 -0400 Subject: [PATCH 3/4] Update monster.js Added "moving" attribute to constructor --- chapter-4/example-2-first-monster/monster.js | 1 + 1 file changed, 1 insertion(+) diff --git a/chapter-4/example-2-first-monster/monster.js b/chapter-4/example-2-first-monster/monster.js index e7b02d4..f5a0868 100644 --- a/chapter-4/example-2-first-monster/monster.js +++ b/chapter-4/example-2-first-monster/monster.js @@ -6,6 +6,7 @@ export default class BasicMonster { this.x = x this.y = y this.tile = 26 + this.moving = false dungeon.initializeEntity(this) } From 4e33c4b32fefe511a7447608880665187627766b Mon Sep 17 00:00:00 2001 From: harrider <22509508+harrider@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:50:56 -0400 Subject: [PATCH 4/4] Update monster.js Added "moving" attribute to constructor --- chapter-4/example-3-basic-combat/monster.js | 1 + 1 file changed, 1 insertion(+) diff --git a/chapter-4/example-3-basic-combat/monster.js b/chapter-4/example-3-basic-combat/monster.js index 9dd7c5e..b4f20d2 100644 --- a/chapter-4/example-3-basic-combat/monster.js +++ b/chapter-4/example-3-basic-combat/monster.js @@ -9,6 +9,7 @@ export default class BasicMonster { this.x = x this.y = y this.tile = 26 + this.moving = false dungeon.initializeEntity(this) }