feat: Introduce throwable flares and player flashlight overload, enabling monster stunning/teleportation, and remove debug dot.

This commit is contained in:
2026-01-03 11:24:26 +00:00
parent d588433d8a
commit a74ccd1f6d
7 changed files with 222 additions and 62 deletions

View File

@@ -13,16 +13,18 @@ export class Monster {
this.scene.add(this.mesh);
// AI State
this.state = 'PATROL'; // PATROL, CHASE, JUMPSCARE
this.speed = 1.5;
this.chaseSpeed = 3.5;
this.state = 'PATROL'; // PATROL, CHASE, JUMPSCARE, STUNNED
this.target = null;
this.patrolSpeed = 1.5; // Renamed from 'speed'
this.chaseSpeed = 4.5; // Increased from 3.5
this.stunTimer = 0;
this.position = new THREE.Vector3(15, 0, 15);
this.mesh.position.copy(this.position);
this.targetNode = new THREE.Vector3();
this.setNewPatrolTarget();
this.detectionRange = 12;
this.detectionRange = 15; // Increased from 12
this.catchRange = 1.5;
this.fov = Math.PI / 1.5; // Wide view
@@ -161,6 +163,22 @@ export class Monster {
update(dt) {
if (!this.player) return;
if (this.state === 'STUNNED') {
this.stunTimer -= dt;
// Retreat while stunned
const retreatDir = new THREE.Vector3().subVectors(this.mesh.position, this.player.camera.position).normalize();
retreatDir.y = 0;
this.mesh.position.add(retreatDir.multiplyScalar(this.patrolSpeed * dt));
if (this.stunTimer <= 0) {
this.state = 'PATROL';
this.setNewPatrolTarget();
}
this.updateAnimation(dt);
this.updateAudio(dt);
return;
}
const isSafe = this.isPlayerSafe();
const playerPos = this.player.camera.position.clone();
playerPos.y = 0;
@@ -178,7 +196,7 @@ export class Monster {
// Move towards target
const dir = new THREE.Vector3().subVectors(this.targetNode, monsterPos).normalize();
this.mesh.position.add(dir.multiplyScalar(this.speed * dt));
this.mesh.position.add(dir.multiplyScalar(this.patrolSpeed * dt));
// Rotation
const targetRotation = Math.atan2(dir.x, dir.z);
@@ -391,4 +409,13 @@ export class Monster {
window.location.reload();
}, 1500);
}
onOverload(playerPosition) {
const dist = this.mesh.position.distanceTo(playerPosition);
if (dist < 12) { // Within overload range
this.state = 'STUNNED';
this.stunTimer = 4.0; // 4 seconds of retreat/stun
window.log('CRITICAL: ENTITY_SENSORS_OVERLOADED - RETREATING');
}
}
}