mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02: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(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'france') return;
|
||||
if (nation !== 'china') return;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function buildTankModels() {
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'france') return;
|
||||
if (nation !== 'china') return;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
|
||||
@@ -41,7 +41,7 @@ export function ArmorMesh({
|
||||
baseMaterial={MeshStandardMaterial}
|
||||
transparent
|
||||
silent
|
||||
// depthWrite={false}
|
||||
depthWrite={false}
|
||||
uniforms={{
|
||||
thickness: { value: thickness },
|
||||
penetration: { value: penetration },
|
||||
|
||||
@@ -11,34 +11,31 @@ uniform bool spaced;
|
||||
void main() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
||||
float cosAngle = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(cosAngle);
|
||||
float dotProduct = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(dotProduct);
|
||||
|
||||
float penetrationChance = 0.0;
|
||||
bool twoCaliberRule = caliber > 2.0 * thickness;
|
||||
float penetrationChance = -1.0;
|
||||
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) {
|
||||
// no auto-ricochet, resume checks
|
||||
if (threeCaliberRule) {
|
||||
if (!threeCaliberRule && angle >= ricochet) {
|
||||
// auto ricochet angle and three caliber rule not met
|
||||
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;
|
||||
} 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
|
||||
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() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
||||
float cosAngle = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(cosAngle);
|
||||
float dotProduct = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(dotProduct);
|
||||
|
||||
float penetrationChance = 0.0;
|
||||
bool twoCaliberRule = caliber > 2.0 * thickness;
|
||||
float penetrationChance = -1.0;
|
||||
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) {
|
||||
// no auto-ricochet, resume checks
|
||||
if (threeCaliberRule) {
|
||||
if (!threeCaliberRule && angle >= ricochet) {
|
||||
// auto ricochet angle and three caliber rule not met
|
||||
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;
|
||||
} 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
|
||||
penetrationChance = 1.0 - (penetrationDifference + maxRandomPenetrationBuff) / (2.0 * maxRandomPenetrationBuff);
|
||||
}
|
||||
penetrationChance = 1.0 - (penetrationDifference + penetrationRandomRadius) / (2.0 * penetrationRandomRadius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,18 +58,24 @@ interface GunDefinitionAutoReloader {
|
||||
interClip: number;
|
||||
count: number;
|
||||
}
|
||||
export interface ShellDefinition {
|
||||
export type ShellDefinition = {
|
||||
id: number;
|
||||
name: string;
|
||||
speed: number;
|
||||
damage: { armor: number; devices: number };
|
||||
caliber: number;
|
||||
normalization: number;
|
||||
ricochet: number;
|
||||
type: ShellType;
|
||||
icon: string;
|
||||
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'), {
|
||||
cache: 'no-cache',
|
||||
|
||||
Reference in new issue
Block a user