implement knockback mechanics and adjust attack detection for OrcMON

This commit is contained in:
2025-12-15 18:11:57 +01:00
parent 1343b18753
commit 6be9927752
2 changed files with 38 additions and 4 deletions

View File

@@ -52,8 +52,40 @@ public class Player extends Entity {
public void update() {
if(life > maxLife) life = maxLife;
// ATTACKING
if(attacking) {
if(knockback) {
collisionOn = false;
panel.collisionH.checkTile(this);
panel.collisionH.checkObject(this, false);
panel.collisionH.checkEntity(this, panel.npc[panel.currentMap.getIndex()]);
// panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
if(collisionOn) {
knockbackCount = 0;
knockback = false;
speed = defaultSpeed;
invincibleCounting();
return;
}
switch(knockbackDirection) {
case UP -> worldY -= speed;
case DOWN -> worldY += speed;
case LEFT -> worldX -= speed;
case RIGHT -> worldX += speed;
}
knockbackCount++;
if(knockbackCount != 10) {
invincibleCounting();
return;
}
knockback = false;
knockbackCount = 0;
speed = defaultSpeed;
invincibleCounting();
return;
} else if(attacking) {
attacking();
invincibleCounting();
return;
@@ -62,6 +94,7 @@ public class Player extends Entity {
// BLOCKING
if(keyH.CTLKeyPressed) {
guarding = true;
transparent = false;
invincibleCounting();
return;
}
@@ -144,6 +177,7 @@ public class Player extends Entity {
if(life <= 0) {
panel.gameState = GameState.GAMEOVER;
invincibleCount = 0;
panel.ui.commandNum = -1;
panel.stopMusic();
panel.playSE(12);

View File

@@ -42,7 +42,7 @@ public class OrcMON extends Entity {
if(!onPath) checkStartChasing(panel.player, 10 ,100); else followPlayer();
checkStopChasing(panel.player, 15, 100);
setRandomDirection();
if(!attacking) checkAttack(30, panel.tileSize*4, panel.tileSize);
if(!attacking) checkAttack(50, panel.tileSize*4, panel.tileSize);
}
public void damageReaction() {
actionLock = 0;