Skip to content

Commit

Permalink
Fix sneaking. Prevent sneaking in Level 10 for a guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz committed May 10, 2022
1 parent 6c170a5 commit 5f5265c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion assets/maps/level10.json
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,8 @@
"skill": 3,
"colors": 6,
"type": "guard",
"direction": 1
"direction": 1,
"sneak": false
},
{
"room": 14,
Expand Down
5 changes: 0 additions & 5 deletions src/Enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ PrinceJS.Enemy = function (game, level, location, direction, room, skill, color,
this.strikeTimer = 0;
this.lookBelow = false;
this.startFight = false;
this.sneakUp = true;

this.health = PrinceJS.Enemy.EXTRA_STRENGTH[skill] + PrinceJS.Enemy.STRENGTH[this.level.number];

Expand Down Expand Up @@ -388,10 +387,6 @@ PrinceJS.Enemy.prototype.setInactive = function () {
}
};

PrinceJS.Enemy.prototype.setSneakUp = function (state) {
this.sneakUp = state;
};

PrinceJS.Enemy.prototype.checkBarrier = function () {
if (!this.alive || this.charName === "shadow") {
return;
Expand Down
9 changes: 7 additions & 2 deletions src/Fighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ PrinceJS.Fighter = function (game, level, location, direction, room, key, animKe
this.alive = true;
this.swordDrawn = false;
this.blocked = false;
this.sneakUp = true;

this.onInitLife = new Phaser.Signal();
this.onDamageLife = new Phaser.Signal();
Expand Down Expand Up @@ -241,7 +242,7 @@ PrinceJS.Fighter.prototype.checkFight = function () {
this.x > 0 &&
this.opponent.x > 0 &&
Math.abs(this.x - this.opponent.x) >= 20 &&
!this.opponent.sneaks()
!(this.sneakUp && this.opponent.sneaks())
) {
this.turn();
}
Expand Down Expand Up @@ -938,6 +939,10 @@ PrinceJS.Fighter.prototype.updateSplash = function () {
}
};

PrinceJS.Fighter.prototype.setSneakUp = function (state) {
this.sneakUp = state;
};

PrinceJS.Fighter.prototype.checkButton = function () {
if (this.charFcheck) {
let tile = this.level.getTileAt(this.charBlockX, this.charBlockY, this.room);
Expand Down Expand Up @@ -1321,7 +1326,7 @@ PrinceJS.Fighter.prototype.moveL = function (extended = true) {
};

PrinceJS.Fighter.prototype.sneaks = function () {
return ["stoop", "stand", "standup", "turn", "jumphanglong", "hang", "hangdrop", "climbup", "climbdown", "testfoot"].includes(this.action) || this.action.startsWith("step");
return ["stoop", "stand", "standup", "turn", "jumpbackhang", "jumphanglong", "hang", "hangdrop", "climbup", "climbdown", "testfoot"].includes(this.action) || this.action.startsWith("step");
};

PrinceJS.Fighter.prototype.getCharBounds = function () {
Expand Down

0 comments on commit 5f5265c

Please sign in to comment.