mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 11:39:51 +01:00
fix: 3 caliber auto ricochet
This commit is contained in:
1 parent
99123b733d
commit
5044a5be48
6 files changed
+52
-52
No files matched your search
@@ -20,7 +20,7 @@ export async function buildTankArmors() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
if (nation !== 'france') return;
|
if (nation !== 'china') return;
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function buildTankModels() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
if (nation !== 'france') return;
|
if (nation !== 'china') return;
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function ArmorMesh({
|
|||||||
baseMaterial={MeshStandardMaterial}
|
baseMaterial={MeshStandardMaterial}
|
||||||
transparent
|
transparent
|
||||||
silent
|
silent
|
||||||
// depthWrite={false}
|
depthWrite={false}
|
||||||
uniforms={{
|
uniforms={{
|
||||||
thickness: { value: thickness },
|
thickness: { value: thickness },
|
||||||
penetration: { value: penetration },
|
penetration: { value: penetration },
|
||||||
|
|||||||
@@ -11,34 +11,31 @@ uniform bool spaced;
|
|||||||
void main() {
|
void main() {
|
||||||
vec3 normalizedNormal = normalize(vNormal);
|
vec3 normalizedNormal = normalize(vNormal);
|
||||||
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
||||||
float cosAngle = dot(normalizedNormal, -normalizedViewPosition);
|
float dotProduct = dot(normalizedNormal, -normalizedViewPosition);
|
||||||
float angle = acos(cosAngle);
|
float angle = acos(dotProduct);
|
||||||
|
|
||||||
float penetrationChance = 0.0;
|
float penetrationChance = -1.0;
|
||||||
bool twoCaliberRule = caliber > 2.0 * thickness;
|
|
||||||
bool threeCaliberRule = caliber > 3.0 * thickness;
|
bool threeCaliberRule = caliber > 3.0 * thickness;
|
||||||
float finalNormalization = twoCaliberRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization;
|
|
||||||
float finalPenetration = penetration;
|
|
||||||
float effectiveArmor = thickness / cos(angle - finalNormalization);
|
|
||||||
|
|
||||||
if (angle < ricochet) {
|
if (!threeCaliberRule && angle >= ricochet) {
|
||||||
// no auto-ricochet, resume checks
|
// auto ricochet angle and three caliber rule not met
|
||||||
if (threeCaliberRule) {
|
penetrationChance = 0.0;
|
||||||
|
} else {
|
||||||
|
bool twoCaliberRule = caliber > 2.0 * thickness;
|
||||||
|
float finalNormalization = twoCaliberRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization;
|
||||||
|
float effectiveArmor = thickness / cos(angle - finalNormalization);
|
||||||
|
float penetrationRandomRadius = penetration * 0.05;
|
||||||
|
float penetrationDifference = effectiveArmor - penetration;
|
||||||
|
|
||||||
|
if (penetrationDifference > penetrationRandomRadius) {
|
||||||
|
// even with a +5% buff, can't penetrate
|
||||||
|
penetrationChance = 0.0;
|
||||||
|
} else if (penetrationDifference < -penetrationRandomRadius) {
|
||||||
|
// event with a -5% nerf, can penetrate
|
||||||
penetrationChance = 1.0;
|
penetrationChance = 1.0;
|
||||||
} else {
|
} else {
|
||||||
float maxRandomPenetrationBuff = finalPenetration * 0.05;
|
|
||||||
float penetrationDifference = effectiveArmor - finalPenetration;
|
|
||||||
|
|
||||||
if (penetrationDifference > maxRandomPenetrationBuff) {
|
|
||||||
// even with a +5% buff, can't penetrate
|
|
||||||
penetrationChance = 0.0;
|
|
||||||
} else if (penetrationDifference < -maxRandomPenetrationBuff) {
|
|
||||||
// event with a -5% nerf, can penetrate
|
|
||||||
penetrationChance = 1.0;
|
|
||||||
} else {
|
|
||||||
// penetration gradiant
|
// penetration gradiant
|
||||||
penetrationChance = 1.0 - (penetrationDifference + maxRandomPenetrationBuff) / (2.0 * maxRandomPenetrationBuff);
|
penetrationChance = 1.0 - (penetrationDifference + penetrationRandomRadius) / (2.0 * penetrationRandomRadius);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,34 +10,31 @@ uniform float normalization;
|
|||||||
void main() {
|
void main() {
|
||||||
vec3 normalizedNormal = normalize(vNormal);
|
vec3 normalizedNormal = normalize(vNormal);
|
||||||
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
||||||
float cosAngle = dot(normalizedNormal, -normalizedViewPosition);
|
float dotProduct = dot(normalizedNormal, -normalizedViewPosition);
|
||||||
float angle = acos(cosAngle);
|
float angle = acos(dotProduct);
|
||||||
|
|
||||||
float penetrationChance = 0.0;
|
float penetrationChance = -1.0;
|
||||||
bool twoCaliberRule = caliber > 2.0 * thickness;
|
|
||||||
bool threeCaliberRule = caliber > 3.0 * thickness;
|
bool threeCaliberRule = caliber > 3.0 * thickness;
|
||||||
float finalNormalization = twoCaliberRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization;
|
|
||||||
float finalPenetration = penetration;
|
|
||||||
float effectiveArmor = thickness / cos(angle - finalNormalization);
|
|
||||||
|
|
||||||
if (angle < ricochet) {
|
if (!threeCaliberRule && angle >= ricochet) {
|
||||||
// no auto-ricochet, resume checks
|
// auto ricochet angle and three caliber rule not met
|
||||||
if (threeCaliberRule) {
|
penetrationChance = 0.0;
|
||||||
|
} else {
|
||||||
|
bool twoCaliberRule = caliber > 2.0 * thickness;
|
||||||
|
float finalNormalization = twoCaliberRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization;
|
||||||
|
float effectiveArmor = thickness / cos(angle - finalNormalization);
|
||||||
|
float penetrationRandomRadius = penetration * 0.05;
|
||||||
|
float penetrationDifference = effectiveArmor - penetration;
|
||||||
|
|
||||||
|
if (penetrationDifference > penetrationRandomRadius) {
|
||||||
|
// even with a +5% buff, can't penetrate
|
||||||
|
penetrationChance = 0.0;
|
||||||
|
} else if (penetrationDifference < -penetrationRandomRadius) {
|
||||||
|
// event with a -5% nerf, can penetrate
|
||||||
penetrationChance = 1.0;
|
penetrationChance = 1.0;
|
||||||
} else {
|
} else {
|
||||||
float maxRandomPenetrationBuff = finalPenetration * 0.05;
|
|
||||||
float penetrationDifference = effectiveArmor - finalPenetration;
|
|
||||||
|
|
||||||
if (penetrationDifference > maxRandomPenetrationBuff) {
|
|
||||||
// even with a +5% buff, can't penetrate
|
|
||||||
penetrationChance = 0.0;
|
|
||||||
} else if (penetrationDifference < -maxRandomPenetrationBuff) {
|
|
||||||
// event with a -5% nerf, can penetrate
|
|
||||||
penetrationChance = 1.0;
|
|
||||||
} else {
|
|
||||||
// penetration gradiant
|
// penetration gradiant
|
||||||
penetrationChance = 1.0 - (penetrationDifference + maxRandomPenetrationBuff) / (2.0 * maxRandomPenetrationBuff);
|
penetrationChance = 1.0 - (penetrationDifference + penetrationRandomRadius) / (2.0 * penetrationRandomRadius);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,18 +58,24 @@ interface GunDefinitionAutoReloader {
|
|||||||
interClip: number;
|
interClip: number;
|
||||||
count: number;
|
count: number;
|
||||||
}
|
}
|
||||||
export interface ShellDefinition {
|
export type ShellDefinition = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
speed: number;
|
speed: number;
|
||||||
damage: { armor: number; devices: number };
|
damage: { armor: number; devices: number };
|
||||||
caliber: number;
|
caliber: number;
|
||||||
normalization: number;
|
|
||||||
ricochet: number;
|
|
||||||
type: ShellType;
|
|
||||||
icon: string;
|
icon: string;
|
||||||
penetration: number | Vector2Tuple;
|
penetration: number | Vector2Tuple;
|
||||||
}
|
} & (
|
||||||
|
| {
|
||||||
|
type: Omit<ShellType, 'hc' | 'he'>;
|
||||||
|
normalization: number;
|
||||||
|
ricochet: number;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: Omit<ShellType, 'ap' | 'ap_cr'>;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const tankDefinitions = fetch(asset('definitions/tanks.json'), {
|
export const tankDefinitions = fetch(asset('definitions/tanks.json'), {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
|
|||||||
Reference in new issue
Block a user