If dead, disable rotations
This commit is contained in:
parent
6f4e6a4f30
commit
1eed104790
@ -20,6 +20,10 @@ let frameCounter = 0;
|
|||||||
let fpsStartTime = 0;
|
let fpsStartTime = 0;
|
||||||
let currentFps = 0;
|
let currentFps = 0;
|
||||||
|
|
||||||
|
let temporarilyDisableRotation = false;
|
||||||
|
let rotationDisabledUntilRespawn = false;
|
||||||
|
let lastKnownPositions = {};
|
||||||
|
|
||||||
let focusedPlayerYaw = 0;
|
let focusedPlayerYaw = 0;
|
||||||
let focusedPlayerName = "YOU";
|
let focusedPlayerName = "YOU";
|
||||||
let focusedPlayerPos = null;
|
let focusedPlayerPos = null;
|
||||||
@ -147,7 +151,11 @@ function renderFrame() {
|
|||||||
ctx.font = "16px Arial";
|
ctx.font = "16px Arial";
|
||||||
ctx.textAlign = "left";
|
ctx.textAlign = "left";
|
||||||
ctx.fillStyle = "#00FF00";
|
ctx.fillStyle = "#00FF00";
|
||||||
ctx.fillText(`${currentFps} FPS | ${freq} Hz | Ping: ${Math.round(pingTracker.getAveragePing())}ms`, 10, 20);
|
let rotationStatus = "Active";
|
||||||
|
if (temporarilyDisableRotation) rotationStatus = "Manually Disabled";
|
||||||
|
else if (rotationDisabledUntilRespawn) rotationStatus = "Disabled (Death)";
|
||||||
|
|
||||||
|
ctx.fillText(`${currentFps} FPS | ${freq} Hz | Ping: ${Math.round(pingTracker.getAveragePing())}ms | Rotation: ${rotationStatus}`, 10, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +165,7 @@ function processPlayerPositions() {
|
|||||||
localPlayerPos = null;
|
localPlayerPos = null;
|
||||||
focusedPlayerPos = null;
|
focusedPlayerPos = null;
|
||||||
focusedPlayerYaw = 0;
|
focusedPlayerYaw = 0;
|
||||||
|
let oldPlayerList = { ...playerList };
|
||||||
playerList = {};
|
playerList = {};
|
||||||
|
|
||||||
entityData.forEach(data => {
|
entityData.forEach(data => {
|
||||||
@ -170,20 +179,38 @@ function processPlayerPositions() {
|
|||||||
pos: player.pos,
|
pos: player.pos,
|
||||||
yaw: player.yaw
|
yaw: player.yaw
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lastKnownPositions["YOU"] = player.pos;
|
||||||
} else {
|
} else {
|
||||||
playerList[player.playerName] = {
|
playerList[player.playerName] = {
|
||||||
pos: player.pos,
|
pos: player.pos,
|
||||||
yaw: player.yaw
|
yaw: player.yaw
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lastKnownPositions[player.playerName] = player.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.playerName === focusedPlayerName ||
|
if (player.playerName === focusedPlayerName ||
|
||||||
(focusedPlayerName === "YOU" && player.playerType === "Local")) {
|
(focusedPlayerName === "YOU" && player.playerType === "Local")) {
|
||||||
focusedPlayerPos = player.pos;
|
focusedPlayerPos = player.pos;
|
||||||
focusedPlayerYaw = player.yaw;
|
focusedPlayerYaw = player.yaw;
|
||||||
|
|
||||||
|
if (rotationDisabledUntilRespawn) {
|
||||||
|
console.log("[radarflow] Player respawned, re-enabling rotation");
|
||||||
|
rotationDisabledUntilRespawn = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (focusedPlayerPos === null) {
|
||||||
|
if (oldPlayerList[focusedPlayerName] && oldPlayerList[focusedPlayerName].pos) {
|
||||||
|
console.log("[radarflow] Focused player disappeared, disabling rotation until respawn");
|
||||||
|
rotationDisabledUntilRespawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[radarflow] Focused player: ${focusedPlayerName}, Position: ${focusedPlayerPos ? 'Found' : 'Not found'}, Rotation disabled: ${temporarilyDisableRotation || rotationDisabledUntilRespawn}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawImage() {
|
function drawImage() {
|
||||||
@ -191,7 +218,12 @@ function drawImage() {
|
|||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
|
|
||||||
if (rotateMap && focusedPlayerPos) {
|
const shouldRotate = rotateMap &&
|
||||||
|
focusedPlayerPos &&
|
||||||
|
!temporarilyDisableRotation &&
|
||||||
|
!rotationDisabledUntilRespawn;
|
||||||
|
|
||||||
|
if (shouldRotate) {
|
||||||
ctx.translate(canvas.width / 2, canvas.height / 2);
|
ctx.translate(canvas.width / 2, canvas.height / 2);
|
||||||
ctx.rotate(degreesToRadians(focusedPlayerYaw + 270));
|
ctx.rotate(degreesToRadians(focusedPlayerYaw + 270));
|
||||||
ctx.translate(-canvas.width / 2, -canvas.height / 2);
|
ctx.translate(-canvas.width / 2, -canvas.height / 2);
|
||||||
@ -382,9 +414,24 @@ function updatePlayerDropdown() {
|
|||||||
function changePlayerFocus() {
|
function changePlayerFocus() {
|
||||||
const dropdown = document.getElementById('playerSelect');
|
const dropdown = document.getElementById('playerSelect');
|
||||||
focusedPlayerName = dropdown.value === "local" ? "YOU" : dropdown.value;
|
focusedPlayerName = dropdown.value === "local" ? "YOU" : dropdown.value;
|
||||||
|
rotationDisabledUntilRespawn = false;
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addRotationHelpText() {
|
||||||
|
const settingsHolder = document.querySelector('#settingsHolder .settings');
|
||||||
|
if (!settingsHolder) return;
|
||||||
|
|
||||||
|
const helpText = document.createElement('div');
|
||||||
|
helpText.className = 'help-text';
|
||||||
|
helpText.style.marginTop = '10px';
|
||||||
|
helpText.style.fontSize = '12px';
|
||||||
|
helpText.style.color = '#aaa';
|
||||||
|
helpText.innerHTML = 'Press <strong>R</strong> key to toggle rotation temporarily';
|
||||||
|
|
||||||
|
settingsHolder.appendChild(helpText);
|
||||||
|
}
|
||||||
|
|
||||||
function mapCoordinates(coordinates) {
|
function mapCoordinates(coordinates) {
|
||||||
if (!map || !coordinates) {
|
if (!map || !coordinates) {
|
||||||
return { x: 0, y: 0 };
|
return { x: 0, y: 0 };
|
||||||
@ -445,7 +492,12 @@ function mapAndTransformCoordinates(pos) {
|
|||||||
mapPos.y = mapPos.y * canvasHeight / imageHeight;
|
mapPos.y = mapPos.y * canvasHeight / imageHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotateMap && typeof focusedPlayerYaw === 'number') {
|
const shouldRotate = rotateMap &&
|
||||||
|
typeof focusedPlayerYaw === 'number' &&
|
||||||
|
!temporarilyDisableRotation &&
|
||||||
|
!rotationDisabledUntilRespawn;
|
||||||
|
|
||||||
|
if (shouldRotate) {
|
||||||
const canvasCenter = { x: canvasWidth / 2, y: canvasHeight / 2 };
|
const canvasCenter = { x: canvasWidth / 2, y: canvasHeight / 2 };
|
||||||
const rotationYaw = focusedPlayerName === "YOU" ? localYaw : focusedPlayerYaw;
|
const rotationYaw = focusedPlayerName === "YOU" ? localYaw : focusedPlayerYaw;
|
||||||
const angle = rotationYaw + 270;
|
const angle = rotationYaw + 270;
|
||||||
@ -625,7 +677,12 @@ function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, i
|
|||||||
(focusedPlayerName === "YOU" && playerType === "Local");
|
(focusedPlayerName === "YOU" && playerType === "Local");
|
||||||
|
|
||||||
let adjustedYaw = yaw;
|
let adjustedYaw = yaw;
|
||||||
if (rotateMap) {
|
|
||||||
|
const shouldAdjustRotation = rotateMap &&
|
||||||
|
!temporarilyDisableRotation &&
|
||||||
|
!rotationDisabledUntilRespawn;
|
||||||
|
|
||||||
|
if (shouldAdjustRotation) {
|
||||||
if (isFocusedPlayer) {
|
if (isFocusedPlayer) {
|
||||||
adjustedYaw = 90;
|
adjustedYaw = 90;
|
||||||
} else {
|
} else {
|
||||||
@ -962,4 +1019,5 @@ addEventListener("DOMContentLoaded", () => {
|
|||||||
} else {
|
} else {
|
||||||
console.error("[radarflow] Canvas element not found");
|
console.error("[radarflow] Canvas element not found");
|
||||||
}
|
}
|
||||||
|
addRotationHelpText();
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user