stabilize dead air camera reconciliation
All checks were successful
build / image (push) Successful in 27s
All checks were successful
build / image (push) Successful in 27s
This commit is contained in:
@@ -67,6 +67,20 @@ const baseDeadAirGame = defineMultiplayerGame<DeadAirGameContract>({
|
||||
applyInput(state, input, { playerId, emit }) {
|
||||
const player = findPlayer(state, playerId);
|
||||
if (!player || player.bot || !player.alive || state.resetTicks > 0) return;
|
||||
if (
|
||||
Math.abs(input.forward) > 0.01 ||
|
||||
Math.abs(input.strafe) > 0.01 ||
|
||||
input.fire ||
|
||||
input.sprint ||
|
||||
input.reload ||
|
||||
input.interact ||
|
||||
input.toggleFlashlight ||
|
||||
input.throwDecoy ||
|
||||
angleDifference(input.yaw, player.yaw) > 0.003 ||
|
||||
Math.abs(input.pitch - player.pitch) > 0.003
|
||||
) {
|
||||
player.engaged = true;
|
||||
}
|
||||
applyCommand(player, input);
|
||||
if (input.reload) beginReload(player);
|
||||
if (input.toggleFlashlight) player.flashlight = !player.flashlight;
|
||||
@@ -370,6 +384,7 @@ function createPlayer(id: number, bot: boolean, round: number): DeadAirAuthority
|
||||
return {
|
||||
id,
|
||||
bot,
|
||||
engaged: bot,
|
||||
alive: true,
|
||||
x: spawn.x,
|
||||
z: spawn.z,
|
||||
@@ -517,7 +532,12 @@ function fire(
|
||||
let hit: DeadAirAuthorityPlayer | null = null;
|
||||
let hitDistance = shotRange;
|
||||
for (const target of state.players) {
|
||||
if (!target.alive || target.id === shooter.id || target.bot === shooter.bot) continue;
|
||||
if (
|
||||
!target.alive ||
|
||||
target.id === shooter.id ||
|
||||
target.bot === shooter.bot ||
|
||||
(!target.bot && !target.engaged)
|
||||
) continue;
|
||||
const offsetX = target.x - shooter.x;
|
||||
const offsetZ = target.z - shooter.z;
|
||||
const forwardDistance = offsetX * directionX + offsetZ * directionZ;
|
||||
@@ -673,7 +693,7 @@ function updateWarden(
|
||||
tick: number,
|
||||
): void {
|
||||
const visibleTargets = state.players.filter(
|
||||
(target) => !target.bot && target.alive && canSeePlayer(state, warden, target),
|
||||
(target) => !target.bot && target.engaged && target.alive && canSeePlayer(state, warden, target),
|
||||
);
|
||||
visibleTargets.sort(
|
||||
(left, right) =>
|
||||
|
||||
@@ -31,6 +31,8 @@ export interface DeadAirBotState {
|
||||
export interface DeadAirAuthorityPlayer {
|
||||
id: number;
|
||||
bot: boolean;
|
||||
/** Humans remain untargetable until they produce deliberate play input. */
|
||||
engaged: boolean;
|
||||
alive: boolean;
|
||||
x: number;
|
||||
z: number;
|
||||
|
||||
Reference in New Issue
Block a user