From 2b34863b53e3532d2a18cabecad7d3f15341b040 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com>
Date: Mon, 27 May 2024 20:42:48 -0500
Subject: [PATCH] fix: ricochet angle
---
.../Armor/components/ShotDisplay.tsx | 34 ++++++++++++++-----
.../SpacedArmorSceneComponent/index.tsx | 5 ++-
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/components/Armor/components/ShotDisplay.tsx b/src/components/Armor/components/ShotDisplay.tsx
index 39f3522c7..e7b13b752 100644
--- a/src/components/Armor/components/ShotDisplay.tsx
+++ b/src/components/Armor/components/ShotDisplay.tsx
@@ -7,6 +7,7 @@ import { radToDeg } from 'three/src/math/MathUtils';
import { J_HAT } from '../../../constants/axis';
import {
ShotLayer,
+ ShotLayerNonExternal,
ShotStatus,
useTankopediaTemporary,
} from '../../../stores/tankopedia';
@@ -43,7 +44,7 @@ const shotStatusColors: Record<
};
const LENGTH_INFINITY = 4;
-const TRACER_THICK = 1 / 64;
+const TRACER_THICK = 1 / 32;
const TRACER_THIN = TRACER_THICK / 2;
function LayerEntry({
@@ -146,7 +147,7 @@ export function ShotDisplay() {
if (!outTracer.current) return;
outTracer.current.scale.set(1, 1 - 2 * Math.abs(t2 - 0.5), 1);
- outTracer.current.position.set(0, t2 * inLength, 0);
+ outTracer.current.position.set(0, t2 * outLength, 0);
});
if (!shot) return null;
@@ -156,6 +157,12 @@ export function ShotDisplay() {
if (layer.type === null) return accumulator + layer.distance;
return accumulator;
}, 0) + LENGTH_INFINITY;
+ const outLength =
+ shot.out && shot.out.layers.length > 0
+ ? (shot.in.layers.at(-1) as ShotLayerNonExternal).point.distanceTo(
+ (shot.out.layers.at(-1) as ShotLayerNonExternal).point,
+ )
+ : LENGTH_INFINITY;
const inLast = shot.in.layers.findLast((layer) => layer.type !== null)!;
return (
@@ -282,7 +289,13 @@ export function ShotDisplay() {
: shotStatusColors[layer.status];
return (
-
+
{layerIndex}
@@ -315,21 +328,24 @@ export function ShotDisplay() {
-
+
-
+
-
+
)}
diff --git a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx
index 0c15881ed..5e9e83f80 100644
--- a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx
+++ b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx
@@ -83,6 +83,7 @@ export function SpacedArmorSceneComponent({
point: Vector3,
intersections: Intersection[],
allowRicochet: boolean,
+ remainingPenetrationInput?: number,
) {
const { antagonist, protagonist } = useDuel.getState();
const shell = antagonist!.shell;
@@ -138,7 +139,7 @@ export function SpacedArmorSceneComponent({
}
}
- let remainingPenetration = penetration;
+ let remainingPenetration = remainingPenetrationInput ?? penetration;
let index = 0;
for (const intersection of noDuplicateIntersections) {
const layer = intersection.object.userData;
@@ -314,6 +315,7 @@ export function SpacedArmorSceneComponent({
lastLayer.point,
ricochetIntersections,
false,
+ remainingPenetration,
);
shot.in.status = 'ricochet';
@@ -327,6 +329,7 @@ export function SpacedArmorSceneComponent({
} else {
shot.damage = outShot.damage;
shot.out = outShot.in;
+ shot.out.surfaceNormal = ricochetNormal;
}
}
}