mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-16 02:27:54 -06:00
Add weapon range variants, lethal ranges and special ranges to comp analyzer
This commit is contained in:
@@ -136,6 +136,22 @@ export const MAX_AP = 57;
|
||||
export const MAIN_SLOT_AP = 10;
|
||||
export const SUB_SLOT_AP = 3;
|
||||
|
||||
/** Ways of shooting a main weapon that fly differently, see `Range_Variants` of the weapon params */
|
||||
export const RANGE_VARIANT_KEYS = [
|
||||
"vertical",
|
||||
"horizontal",
|
||||
"tap",
|
||||
"hold",
|
||||
"long",
|
||||
"short",
|
||||
"ground",
|
||||
"jump",
|
||||
"charged",
|
||||
"partialCharge",
|
||||
"standard",
|
||||
"turret",
|
||||
] as const;
|
||||
|
||||
/** How many active players the opponent's team has more than the user's team */
|
||||
export const TENACITY_PLAYER_DEFICITS = [1, 2, 3] as const;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
} from "~/modules/in-game-lists/types";
|
||||
import type {
|
||||
DAMAGE_TYPE,
|
||||
RANGE_VARIANT_KEYS,
|
||||
TENACITY_PLAYER_DEFICITS,
|
||||
} from "./analyzer-constants";
|
||||
import type { SPECIAL_EFFECTS } from "./core/specialEffects";
|
||||
@@ -17,7 +18,7 @@ type Overwrites = Record<
|
||||
Partial<Record<"High" | "Mid" | "Low", number>>
|
||||
>;
|
||||
|
||||
export interface BaseWeaponStats {
|
||||
export interface BaseWeaponStats extends RangeParams {
|
||||
/** Replacing default values of the ability json for this specific weapon */
|
||||
overwrites?: Overwrites;
|
||||
/** Weapon's weight class. "Light/Heavy weapon" */
|
||||
@@ -107,16 +108,42 @@ export interface BaseWeaponStats {
|
||||
/** How much ink a fully charged Splatana shot consumes? */
|
||||
InkConsumeFullCharge_ChargeParam?: number;
|
||||
|
||||
// Range parameters for shooters/blasters/sloshers/splatlings/dualies
|
||||
// Range parameters for chargers (direct distance values)
|
||||
/** Charger full charge range */
|
||||
DistanceFullCharge?: number;
|
||||
/** Charger max charge range */
|
||||
DistanceMaxCharge?: number;
|
||||
/** Charger min charge range */
|
||||
DistanceMinCharge?: number;
|
||||
|
||||
/** Which way of shooting the `Range_*` params describe, set when the weapon has `Range_Variants` */
|
||||
Range_VariantKey?: RangeVariantKey;
|
||||
/** Other ways of shooting the weapon that fly differently (a roller's horizontal swing, a charger's tap shot) */
|
||||
Range_Variants?: RangeVariantParams[];
|
||||
}
|
||||
|
||||
/** A way of shooting a main weapon with its own flight, e.g. a roller's vertical or horizontal swing */
|
||||
export type RangeVariantKey = (typeof RANGE_VARIANT_KEYS)[number];
|
||||
|
||||
export interface RangeVariantParams extends RangeParams {
|
||||
Range_VariantKey: RangeVariantKey;
|
||||
}
|
||||
|
||||
/** How a main weapon's shot flies, see comp-analyzer's `WeaponRange` */
|
||||
export interface RangeParams {
|
||||
/** Initial bullet velocity */
|
||||
Range_SpawnSpeed?: number;
|
||||
/** Upward angle the bullet is shot at, in degrees (vertical roller swings) */
|
||||
Range_SpawnAngle?: number;
|
||||
/** How far in front of the player the bullet spawns (Splatanas) */
|
||||
Range_SpawnOffsetZ?: number;
|
||||
/** Velocity cap after straight phase */
|
||||
Range_GoStraightStateEndMaxSpeed?: number;
|
||||
/** Frames in straight phase */
|
||||
Range_GoStraightToBrakeStateFrame?: number;
|
||||
/** Gravity constant (typically 0.016) */
|
||||
Range_FreeGravity?: number;
|
||||
/** Air resistance during free phase (rollers only, typically 0.1) */
|
||||
/** Air resistance during free phase (typically 0.02) */
|
||||
Range_FreeAirResist?: number;
|
||||
/** Velocity multiplier (typically 2.0) */
|
||||
Range_ZRate?: number;
|
||||
@@ -126,20 +153,16 @@ export interface BaseWeaponStats {
|
||||
Range_BrakeGravity?: number;
|
||||
/** Frames in brake phase (typically 4) */
|
||||
Range_BrakeToFreeStateFrame?: number;
|
||||
/** Max frames (Splatanas) or max bounces (Bloblobber) before projectile stops */
|
||||
/** Brake phase ends early once the bullet falls faster than this (typically -0.15) */
|
||||
Range_BrakeToFreeVelocityY?: number;
|
||||
/** Max frames (Splatanas, blasters) or max bounces (Bloblobber) before projectile stops */
|
||||
Range_BurstFrame?: number;
|
||||
/** Speed multiplier after bouncing (Bloblobber only) */
|
||||
Range_BounceAfterMaxSpeed?: number;
|
||||
|
||||
// Range parameters for chargers (direct distance values)
|
||||
/** Charger full charge range */
|
||||
DistanceFullCharge?: number;
|
||||
/** Charger max charge range */
|
||||
DistanceMaxCharge?: number;
|
||||
/** Charger min charge range */
|
||||
DistanceMinCharge?: number;
|
||||
|
||||
// Blaster specific
|
||||
/** Straight line flight distance (a charger's tap shot) */
|
||||
Range_Distance?: number;
|
||||
/** Damage by distance from the shooter (rollers, brushes) */
|
||||
Range_DistanceDamage?: DistanceDamage[];
|
||||
/** Blaster explosion radius */
|
||||
BlastRadius?: number;
|
||||
}
|
||||
@@ -212,6 +235,7 @@ export type SpecialWeaponParams = SpecialWeaponParamsObject[SpecialWeaponId] & {
|
||||
Range_BrakeAirResist?: number;
|
||||
Range_BrakeGravity?: number;
|
||||
Range_BrakeToFreeStateFrame?: number;
|
||||
Range_BrakeToFreeVelocityY?: number;
|
||||
};
|
||||
|
||||
export type ParamsJson = {
|
||||
|
||||
@@ -34,6 +34,7 @@ import type {
|
||||
AbilityPoints,
|
||||
AnalyzedBuild,
|
||||
DamageType,
|
||||
DistanceDamage,
|
||||
InkConsumeType,
|
||||
MainWeaponInkConsumptionStats,
|
||||
MainWeaponParams,
|
||||
@@ -551,7 +552,9 @@ function damages(args: StatFunctionInput): AnalyzedBuild["stats"]["damages"] {
|
||||
const value = args.mainWeaponParams[key as keyof MainWeaponParams];
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
for (const subValue of value.flat()) {
|
||||
for (const subValue of (
|
||||
value as Array<DistanceDamage | DistanceDamage[]>
|
||||
).flat()) {
|
||||
result.push({
|
||||
type,
|
||||
value: subValue.Damage / 10,
|
||||
|
||||
@@ -77,6 +77,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 1.667,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_FreeAirResist: 0.02,
|
||||
Range_ZRate: 2,
|
||||
MoveSpeed: 0.06,
|
||||
DamageParam_ValueMax: 520,
|
||||
@@ -171,6 +172,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 0.8484,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 11,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.9,
|
||||
WeaponSpeedType: "Fast",
|
||||
@@ -201,6 +203,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 0.9131,
|
||||
Range_GoStraightToBrakeStateFrame: 9,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 13,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.385,
|
||||
MoveSpeed: 0.045,
|
||||
@@ -230,6 +233,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 1.0073,
|
||||
Range_GoStraightToBrakeStateFrame: 11,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 15,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.335,
|
||||
MoveSpeed: 0.04,
|
||||
@@ -259,6 +263,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 0.92715,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 12,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 4.085,
|
||||
WeaponSpeedType: "Fast",
|
||||
@@ -289,6 +294,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 1.13305,
|
||||
Range_GoStraightToBrakeStateFrame: 11,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 15,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.335,
|
||||
MoveSpeed: 0.055,
|
||||
@@ -318,6 +324,7 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 1.3426,
|
||||
Range_GoStraightToBrakeStateFrame: 11,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 15,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.325,
|
||||
MoveSpeed: 0.05,
|
||||
@@ -347,8 +354,21 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 1.65,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_BurstFrame: 11,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 2.035,
|
||||
Range_VariantKey: "ground",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 0.92,
|
||||
Range_GoStraightStateEndMaxSpeed: 0.9,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_BurstFrame: 11,
|
||||
Range_ZRate: 2,
|
||||
BlastRadius: 3.635,
|
||||
Range_VariantKey: "jump",
|
||||
},
|
||||
],
|
||||
MoveSpeed: 0.04,
|
||||
DamageParam_ValueDirect: 1250,
|
||||
BlastParam_DistanceDamage: [
|
||||
@@ -416,6 +436,16 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "tap",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 2.4,
|
||||
Range_GoStraightStateEndMaxSpeed: 2.3032,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "hold",
|
||||
},
|
||||
],
|
||||
MoveSpeed: 0.066,
|
||||
MoveSpeedVariable: 0.072,
|
||||
DamageParam_ValueMax: 380,
|
||||
@@ -434,7 +464,46 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 6,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_SpawnAngle: 7.5,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1200,
|
||||
Distance: 4.2,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 12.43,
|
||||
},
|
||||
{
|
||||
Damage: 350,
|
||||
Distance: 14.2,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 0.8,
|
||||
Range_GoStraightToBrakeStateFrame: 6,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 4.7,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 6.7,
|
||||
},
|
||||
{
|
||||
Damage: 250,
|
||||
Distance: 8.7,
|
||||
},
|
||||
],
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Fast",
|
||||
BodyParam_Damage: 700,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMinValue: 350,
|
||||
@@ -451,7 +520,50 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 6,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_SpawnAngle: 7.5,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1500,
|
||||
Distance: 5.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 8.2,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 11.2,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 13.2,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 1.05,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1500,
|
||||
Distance: 4.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 7.2,
|
||||
},
|
||||
{
|
||||
Damage: 350,
|
||||
Distance: 10.7,
|
||||
},
|
||||
],
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
BodyParam_Damage: 1250,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMinValue: 400,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMaxValue: 1500,
|
||||
@@ -467,7 +579,54 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 9,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_SpawnAngle: 7.5,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1800,
|
||||
Distance: 8.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 14,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 19.53,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 20.6,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 1.2,
|
||||
Range_GoStraightToBrakeStateFrame: 9,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1800,
|
||||
Distance: 7.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 12.9,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 16.49,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 17.4,
|
||||
},
|
||||
],
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Slow",
|
||||
BodyParam_Damage: 1250,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMinValue: 400,
|
||||
@@ -484,7 +643,46 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 9,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_SpawnAngle: 7.5,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1500,
|
||||
Distance: 5.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 10.2,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 16.2,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 0.94,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1500,
|
||||
Distance: 4.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 7.2,
|
||||
},
|
||||
{
|
||||
Damage: 300,
|
||||
Distance: 10.96923,
|
||||
},
|
||||
],
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
BodyParam_Damage: 1250,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMinValue: 400,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMaxValue: 1500,
|
||||
@@ -501,7 +699,50 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 6,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_SpawnAngle: 7.5,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 1200,
|
||||
Distance: 5.2,
|
||||
},
|
||||
{
|
||||
Damage: 1000,
|
||||
Distance: 7.7,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 14.5,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 16,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 1.1,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 700,
|
||||
Distance: 4.2,
|
||||
},
|
||||
{
|
||||
Damage: 500,
|
||||
Distance: 6.2,
|
||||
},
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 8.2,
|
||||
},
|
||||
],
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
BodyParam_Damage: 700,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMinValue: 400,
|
||||
VerticalSwingUnitGroupParam_DamageParam_DamageMaxValue: 1200,
|
||||
@@ -515,6 +756,22 @@ export const weaponParams = {
|
||||
"1100": {
|
||||
Range_SpawnSpeed: 0.72,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 300,
|
||||
Distance: 4.3,
|
||||
},
|
||||
{
|
||||
Damage: 250,
|
||||
Distance: 6.8,
|
||||
},
|
||||
{
|
||||
Damage: 150,
|
||||
Distance: 10.3,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
WeaponSpeedType: "Fast",
|
||||
BodyParam_Damage: 200,
|
||||
@@ -527,6 +784,18 @@ export const weaponParams = {
|
||||
"1110": {
|
||||
Range_SpawnSpeed: 0.84,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 400,
|
||||
Distance: 3.3,
|
||||
},
|
||||
{
|
||||
Damage: 200,
|
||||
Distance: 14.3,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
BodyParam_Damage: 250,
|
||||
SwingUnitGroupParam_DamageParam_DamageMinValue: 200,
|
||||
@@ -538,6 +807,18 @@ export const weaponParams = {
|
||||
"1120": {
|
||||
Range_SpawnSpeed: 1.05,
|
||||
Range_GoStraightToBrakeStateFrame: 9,
|
||||
Range_FreeGravity: 0.04,
|
||||
Range_FreeAirResist: 0.1,
|
||||
Range_DistanceDamage: [
|
||||
{
|
||||
Damage: 600,
|
||||
Distance: 5,
|
||||
},
|
||||
{
|
||||
Damage: 310,
|
||||
Distance: 13,
|
||||
},
|
||||
],
|
||||
Range_ZRate: 2,
|
||||
BodyParam_Damage: 300,
|
||||
SwingUnitGroupParam_DamageParam_DamageMinValue: 310,
|
||||
@@ -550,6 +831,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 16.765,
|
||||
DistanceMaxCharge: 16.765,
|
||||
DistanceMinCharge: 9.261,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.261,
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.03,
|
||||
DamageParam_ValueFullCharge: 1400,
|
||||
DamageParam_ValueMaxCharge: 800,
|
||||
@@ -563,6 +851,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 24.037,
|
||||
DistanceMaxCharge: 24.037,
|
||||
DistanceMinCharge: 9.033,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.033,
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.02,
|
||||
DamageParam_ValueFullCharge: 1600,
|
||||
DamageParam_ValueMaxCharge: 800,
|
||||
@@ -575,6 +870,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 26.037,
|
||||
DistanceMaxCharge: 24.037,
|
||||
DistanceMinCharge: 9.033,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.033,
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.02,
|
||||
DamageParam_ValueFullCharge: 1600,
|
||||
DamageParam_ValueMaxCharge: 800,
|
||||
@@ -586,6 +888,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 29.05,
|
||||
DistanceMaxCharge: 29.05,
|
||||
DistanceMinCharge: 9.045,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.045,
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Slow",
|
||||
MoveSpeedFullCharge: 0.015,
|
||||
DamageParam_ValueFullCharge: 1800,
|
||||
@@ -600,6 +909,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 31.05,
|
||||
DistanceMaxCharge: 29.05,
|
||||
DistanceMinCharge: 9.045,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.045,
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Slow",
|
||||
MoveSpeedFullCharge: 0.015,
|
||||
DamageParam_ValueFullCharge: 1800,
|
||||
@@ -626,6 +942,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 19.804,
|
||||
DistanceMaxCharge: 18.804,
|
||||
DistanceMinCharge: 12.602,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 12.602,
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.03,
|
||||
DamageParam_ValueFullCharge: 1800,
|
||||
DamageParam_ValueMaxCharge: 1300,
|
||||
@@ -639,6 +962,13 @@ export const weaponParams = {
|
||||
DistanceFullCharge: 26.037,
|
||||
DistanceMaxCharge: 24.037,
|
||||
DistanceMinCharge: 9.033,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: 9.033,
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.068,
|
||||
DamageParam_ValueFullCharge: 680,
|
||||
DamageParam_ValueMaxCharge: 680,
|
||||
@@ -653,9 +983,11 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 2,
|
||||
Range_FreeGravity: 0.05,
|
||||
Range_FreeAirResist: 0.12,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_ZRate: 2,
|
||||
MoveSpeed: 0.04,
|
||||
DamageParam_ValueDirectMax: 700,
|
||||
@@ -668,9 +1000,11 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_FreeGravity: 0.05,
|
||||
Range_FreeAirResist: 0.12,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_ZRate: 2,
|
||||
WeaponSpeedType: "Fast",
|
||||
MoveSpeed: 0.066,
|
||||
@@ -684,9 +1018,11 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 5,
|
||||
Range_FreeGravity: 0.06,
|
||||
Range_FreeAirResist: 0.16,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
MoveSpeed: 0.07,
|
||||
DamageParam_ValueDirectMax: 760,
|
||||
DamageParam_ValueDirectMin: 520,
|
||||
@@ -699,11 +1035,13 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_FreeGravity: 0.015,
|
||||
Range_FreeAirResist: 0.01,
|
||||
Range_BrakeAirResist: 0.01,
|
||||
Range_BrakeGravity: 0.01,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_ZRate: 0.5,
|
||||
Range_BounceAfterMaxSpeed: 0.6,
|
||||
Range_BounceAfterMaxSpeed: 0.35,
|
||||
Range_BurstFrame: 3,
|
||||
MoveSpeed: 0.05,
|
||||
DamageParam_ValueDirect: 320,
|
||||
@@ -715,9 +1053,11 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_FreeGravity: 0.05,
|
||||
Range_FreeAirResist: 0.12,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_ZRate: 1,
|
||||
WeaponSpeedType: "Slow",
|
||||
MoveSpeed: 0.045,
|
||||
@@ -736,9 +1076,11 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 2,
|
||||
Range_FreeGravity: 0.05,
|
||||
Range_FreeAirResist: 0.12,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_ZRate: 2,
|
||||
MoveSpeed: 0.04,
|
||||
DamageParam_ValueDirectMax: 480,
|
||||
@@ -826,6 +1168,15 @@ export const weaponParams = {
|
||||
Range_SpawnSpeed: 2.21915,
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_VariantKey: "long",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 1.1,
|
||||
Range_GoStraightStateEndMaxSpeed: 1.027,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_VariantKey: "short",
|
||||
},
|
||||
],
|
||||
MoveSpeed: 0.086,
|
||||
MoveSpeed_Charge: 0.086,
|
||||
MoveSpeedVariable: 0.05,
|
||||
@@ -916,6 +1267,16 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "standard",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 3.2,
|
||||
Range_GoStraightStateEndMaxSpeed: 3.197,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "turret",
|
||||
},
|
||||
],
|
||||
MoveSpeed: 0.06,
|
||||
DamageParam_ValueMax: 360,
|
||||
DamageParam_ValueMin: 180,
|
||||
@@ -960,6 +1321,16 @@ export const weaponParams = {
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "standard",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 3.312,
|
||||
Range_GoStraightStateEndMaxSpeed: 2.23,
|
||||
Range_GoStraightToBrakeStateFrame: 3,
|
||||
Range_ZRate: 2,
|
||||
Range_VariantKey: "turret",
|
||||
},
|
||||
],
|
||||
MoveSpeed: 0.07,
|
||||
DamageParam_ValueMax: 255,
|
||||
DamageParam_ValueMin: 128,
|
||||
@@ -991,6 +1362,7 @@ export const weaponParams = {
|
||||
Range_SpawnSpeed: 2.4,
|
||||
Range_GoStraightStateEndMaxSpeed: 2.3135,
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_BrakeGravity: 0.07,
|
||||
Range_ZRate: 2,
|
||||
WeaponSpeedType: "Slow",
|
||||
MoveSpeed: 0.05,
|
||||
@@ -1033,7 +1405,24 @@ export const weaponParams = {
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
BlastRadius: 2.05,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 2.1,
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_FreeGravity: 0.15,
|
||||
Range_FreeAirResist: 0.24,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
BlastRadius: 2.05,
|
||||
Range_VariantKey: "partialCharge",
|
||||
},
|
||||
],
|
||||
MoveSpeedFullCharge: 0.068,
|
||||
DamageParam_ValueMax: 350,
|
||||
DamageParam_ValueMin: 300,
|
||||
@@ -1056,6 +1445,22 @@ export const weaponParams = {
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 1.45,
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_FreeGravity: 0.15,
|
||||
Range_FreeAirResist: 0.24,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_VariantKey: "partialCharge",
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Fast",
|
||||
MoveSpeedFullCharge: 0.084,
|
||||
DamageParam_ValueMax: 450,
|
||||
@@ -1074,7 +1479,24 @@ export const weaponParams = {
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
BlastRadius: 2.05,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 2.294,
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 4,
|
||||
Range_FreeGravity: 0.15,
|
||||
Range_FreeAirResist: 0.24,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
BlastRadius: 2.05,
|
||||
Range_VariantKey: "partialCharge",
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Slow",
|
||||
MoveSpeedFullCharge: 0.04,
|
||||
DamageParam_ValueMax: 350,
|
||||
@@ -1094,10 +1516,29 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 22,
|
||||
Range_FreeGravity: 0.02,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0.0027,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 0.8,
|
||||
Range_BurstFrame: 26,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 2.82,
|
||||
Range_GoStraightToBrakeStateFrame: 5,
|
||||
Range_FreeGravity: 0,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 1.4,
|
||||
Range_BurstFrame: 6,
|
||||
Range_VariantKey: "tap",
|
||||
},
|
||||
],
|
||||
MoveSpeed_Charge: 0.06,
|
||||
DamageParam_SplatanaVerticalDirect: 1400,
|
||||
DamageParam_SplatanaVertical: 700,
|
||||
@@ -1112,10 +1553,29 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 10,
|
||||
Range_FreeGravity: 0.1,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0.02,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 0.8,
|
||||
Range_BurstFrame: 14,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 3.3,
|
||||
Range_GoStraightToBrakeStateFrame: 5,
|
||||
Range_FreeGravity: 0,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 1.4,
|
||||
Range_BurstFrame: 4,
|
||||
Range_VariantKey: "tap",
|
||||
},
|
||||
],
|
||||
WeaponSpeedType: "Fast",
|
||||
MoveSpeed_Charge: 0.0945,
|
||||
DamageParam_SplatanaVerticalDirect: 1200,
|
||||
@@ -1131,10 +1591,29 @@ export const weaponParams = {
|
||||
Range_GoStraightStateEndMaxSpeed: 10,
|
||||
Range_GoStraightToBrakeStateFrame: 21,
|
||||
Range_FreeGravity: 0.1,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0.02,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 1.4,
|
||||
Range_BurstFrame: 21,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_SpawnSpeed: 2.3,
|
||||
Range_GoStraightToBrakeStateFrame: 6,
|
||||
Range_FreeGravity: 0,
|
||||
Range_FreeAirResist: 0,
|
||||
Range_BrakeAirResist: 0,
|
||||
Range_BrakeGravity: 0,
|
||||
Range_BrakeToFreeStateFrame: 0,
|
||||
Range_BrakeToFreeVelocityY: 0,
|
||||
Range_SpawnOffsetZ: 1.4,
|
||||
Range_BurstFrame: 6,
|
||||
Range_VariantKey: "tap",
|
||||
},
|
||||
],
|
||||
MoveSpeed_Charge: 0.055,
|
||||
DamageParam_SplatanaVerticalDirect: 1600,
|
||||
DamageParam_SplatanaVertical: 800,
|
||||
@@ -2372,6 +2851,7 @@ export const weaponParams = {
|
||||
Range_BrakeAirResist: 0.09,
|
||||
Range_BrakeGravity: 0.09,
|
||||
Range_BrakeToFreeStateFrame: 10,
|
||||
Range_BrakeToFreeVelocityY: -0.1,
|
||||
Range_BlastRadius: 4,
|
||||
},
|
||||
"2": {
|
||||
@@ -2618,10 +3098,14 @@ export const weaponParams = {
|
||||
},
|
||||
],
|
||||
BumpDamage: 400,
|
||||
Range_SpawnSpeed: 3.36,
|
||||
Range_GoStraightStateEndMaxSpeed: 2.232,
|
||||
Range_GoStraightToBrakeStateFrame: 7,
|
||||
Range_FreeGravity: 0.016,
|
||||
Range_SpawnSpeed: 2,
|
||||
Range_GoStraightToBrakeStateFrame: 8,
|
||||
Range_FreeGravity: 0.05,
|
||||
Range_FreeAirResist: 0.12,
|
||||
Range_BrakeAirResist: 0.1,
|
||||
Range_BrakeGravity: 0.04,
|
||||
Range_BrakeToFreeStateFrame: 1,
|
||||
Range_BrakeToFreeVelocityY: 10,
|
||||
Range_BlastRadius: 4.8,
|
||||
},
|
||||
"13": {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { RangeVariantKey } from "~/features/build-analyzer/analyzer-types";
|
||||
import type { MainWeaponId } from "~/modules/in-game-lists/types";
|
||||
import { useSearchParam } from "~/modules/search-params/hooks";
|
||||
import { compAnalyzerSearchParams } from "./comp-analyzer-search-params";
|
||||
|
||||
@@ -20,3 +22,56 @@ export function useTargetSubDefenseAp() {
|
||||
export function useTargetResAp() {
|
||||
return useSearchParam(compAnalyzerSearchParams, "res");
|
||||
}
|
||||
|
||||
/** Ways of shooting turned on in the range chart, per weapon */
|
||||
export function useRangeVariants() {
|
||||
const [entries, setEntries] = useSearchParam(
|
||||
compAnalyzerSearchParams,
|
||||
"rangeVariants",
|
||||
);
|
||||
|
||||
const enabledVariantKeys = (weaponId: MainWeaponId) =>
|
||||
entries.flatMap((entry) => {
|
||||
const [entryWeaponId, key] = entry.split("-");
|
||||
return Number(entryWeaponId) === weaponId ? [key as RangeVariantKey] : [];
|
||||
});
|
||||
|
||||
const setEnabledVariantKeys = (
|
||||
weaponId: MainWeaponId,
|
||||
keys: RangeVariantKey[],
|
||||
) => {
|
||||
setEntries([
|
||||
...entries.filter((entry) => !entry.startsWith(`${weaponId}-`)),
|
||||
...keys.map((key) => `${weaponId}-${key}`),
|
||||
]);
|
||||
};
|
||||
|
||||
return { enabledVariantKeys, setEnabledVariantKeys };
|
||||
}
|
||||
|
||||
/** Weapons left out of the range chart */
|
||||
export function useHiddenRanges() {
|
||||
const [hiddenWeaponIds, setHiddenWeaponIds] = useSearchParam(
|
||||
compAnalyzerSearchParams,
|
||||
"hiddenRanges",
|
||||
);
|
||||
|
||||
const [selectedWeaponIds] = useSelectedWeapons();
|
||||
|
||||
const toggleHidden = (weaponId: MainWeaponId) => {
|
||||
const stillSelected = hiddenWeaponIds.filter(
|
||||
(id) => id !== weaponId && selectedWeaponIds.includes(id),
|
||||
);
|
||||
setHiddenWeaponIds(
|
||||
hiddenWeaponIds.includes(weaponId)
|
||||
? stillSelected
|
||||
: [...stillSelected, weaponId],
|
||||
);
|
||||
};
|
||||
|
||||
return { hiddenWeaponIds, toggleHidden };
|
||||
}
|
||||
|
||||
export function useSpecialRanges() {
|
||||
return useSearchParam(compAnalyzerSearchParams, "specialRanges");
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ describe("compAnalyzerSearchParams", () => {
|
||||
singleCombos: [false, true],
|
||||
subDef: [0, 29, 57],
|
||||
res: [0, 57],
|
||||
rangeVariants: [[], ["1010-horizontal"], ["400-tap", "400-hold"]],
|
||||
specialRanges: [false, true],
|
||||
hiddenRanges: [[], [1010], [1010, 400]],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,5 +42,16 @@ describe("compAnalyzerSearchParams", () => {
|
||||
["abc"],
|
||||
]);
|
||||
assertDecodesToDefault(compAnalyzerSearchParams, "res", [["-1"], ["58"]]);
|
||||
assertDecodesToDefault(compAnalyzerSearchParams, "specialRanges", [["1"]]);
|
||||
});
|
||||
|
||||
test("drops malformed range variant entries", () => {
|
||||
expect(
|
||||
SearchParams.decodeParam(compAnalyzerSearchParams.shape.rangeVariants, [
|
||||
"1010-horizontal",
|
||||
"1010-sideways",
|
||||
"horizontal",
|
||||
]),
|
||||
).toEqual(["1010-horizontal"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import * as v from "valibot";
|
||||
import { MAX_AP } from "~/features/build-analyzer/analyzer-constants";
|
||||
import {
|
||||
MAX_AP,
|
||||
RANGE_VARIANT_KEYS,
|
||||
} from "~/features/build-analyzer/analyzer-constants";
|
||||
import { mainWeaponIds } from "~/modules/in-game-lists/weapon-ids";
|
||||
import * as SearchParams from "~/modules/search-params/search-params";
|
||||
import { SP } from "~/modules/search-params/search-params";
|
||||
@@ -7,6 +10,11 @@ import { numericEnum } from "~/utils/schema";
|
||||
import { MAX_WEAPONS } from "./comp-analyzer-constants";
|
||||
import type { CategorizationType } from "./comp-analyzer-types";
|
||||
|
||||
/** `<weaponId>-<variantKey>`, a way of shooting a weapon turned on in the range chart */
|
||||
const RANGE_VARIANT_ENTRY_REGEX = new RegExp(
|
||||
`^\\d{1,4}-(${RANGE_VARIANT_KEYS.join("|")})$`,
|
||||
);
|
||||
|
||||
const CATEGORIZATION_TYPES = [
|
||||
"category",
|
||||
"sub",
|
||||
@@ -26,6 +34,15 @@ export const compAnalyzerSearchParams = SearchParams.define({
|
||||
},
|
||||
),
|
||||
singleCombos: SP.param(v.boolean(), { default: false, loader: false }),
|
||||
rangeVariants: SP.param(
|
||||
v.array(v.pipe(v.string(), v.regex(RANGE_VARIANT_ENTRY_REGEX))),
|
||||
{ default: [], loader: false },
|
||||
),
|
||||
specialRanges: SP.param(v.boolean(), { default: false, loader: false }),
|
||||
hiddenRanges: SP.param(
|
||||
v.pipe(v.array(numericEnum(mainWeaponIds)), v.maxLength(MAX_WEAPONS)),
|
||||
{ default: [], loader: false },
|
||||
),
|
||||
subDef: SP.param(
|
||||
v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(MAX_AP)),
|
||||
{
|
||||
|
||||
@@ -88,8 +88,10 @@
|
||||
|
||||
.weaponLegendItem {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--s-1);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.weaponLegendColor {
|
||||
@@ -110,3 +112,111 @@
|
||||
height: auto;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
.variantChip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s-1);
|
||||
padding: var(--s-0-5) var(--s-2);
|
||||
background: var(--color-bg-higher);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-field);
|
||||
font-size: var(--font-xs);
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&:hover {
|
||||
background: var(--color-bg-high);
|
||||
}
|
||||
}
|
||||
|
||||
.variantChipHidden {
|
||||
background: transparent;
|
||||
border-style: dashed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.variantLine {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lethalRange {
|
||||
font-size: var(--font-xs);
|
||||
color: var(--color-text-high);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.specialRangesToggleRow {
|
||||
display: flex;
|
||||
padding-block-start: var(--s-2);
|
||||
border-block-start: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.specialRanges {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--s-1);
|
||||
}
|
||||
|
||||
.specialRangeRow {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.specialRangeIcon {
|
||||
position: absolute;
|
||||
inset-inline-start: 0;
|
||||
}
|
||||
|
||||
.specialRangeTrack {
|
||||
position: relative;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.specialRangeBar {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
inset-inline-start: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-inline: var(--s-1);
|
||||
border-radius: var(--radius-field);
|
||||
font-size: var(--font-xs);
|
||||
font-weight: var(--weight-semi);
|
||||
color: black;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.specialRangeBlast {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
border-radius: var(--radius-field);
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.weaponLegendItemHidden > :not(.visibilityToggle) {
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.visibilityToggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s-0-5);
|
||||
padding: var(--s-0-5);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--radius-field);
|
||||
color: var(--color-text-high);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: var(--color-bg-high);
|
||||
}
|
||||
|
||||
&[aria-pressed="false"] img {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import clsx from "clsx";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { WeaponImage } from "~/components/Image";
|
||||
import { SendouSwitch } from "~/components/elements/Switch";
|
||||
import { SpecialWeaponImage, WeaponImage } from "~/components/Image";
|
||||
import type { RangeVariantKey } from "~/features/build-analyzer/analyzer-types";
|
||||
import type { MainWeaponId } from "~/modules/in-game-lists/types";
|
||||
import {
|
||||
useHiddenRanges,
|
||||
useRangeVariants,
|
||||
useSpecialRanges,
|
||||
} from "../comp-analyzer-hooks";
|
||||
import * as SpecialWeaponRange from "../core/SpecialWeaponRange";
|
||||
import * as WeaponRange from "../core/WeaponRange";
|
||||
import styles from "./RangeVisualization.module.css";
|
||||
|
||||
@@ -12,6 +22,15 @@ const BENCHMARK_COLORS = [
|
||||
"rgba(100, 100, 120, 0.5)",
|
||||
] as const;
|
||||
|
||||
const CHART_WIDTH = 600;
|
||||
const CHART_HEIGHT = 240;
|
||||
const CHART_PADDING = { top: 20, right: 60, bottom: 30, left: 50 };
|
||||
const CHART_INNER_WIDTH =
|
||||
CHART_WIDTH - CHART_PADDING.left - CHART_PADDING.right;
|
||||
const MAX_RANGE = 32;
|
||||
|
||||
const ALTERNATE_VARIANT_DASH = "6,4";
|
||||
|
||||
interface RangeVisualizationProps {
|
||||
weaponIds: MainWeaponId[];
|
||||
}
|
||||
@@ -19,20 +38,24 @@ interface RangeVisualizationProps {
|
||||
export function RangeVisualization({ weaponIds }: RangeVisualizationProps) {
|
||||
const { t } = useTranslation(["analyzer", "weapons"]);
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
const { enabledVariantKeys, setEnabledVariantKeys } = useRangeVariants();
|
||||
const [showSpecialRanges, setShowSpecialRanges] = useSpecialRanges();
|
||||
const { hiddenWeaponIds, toggleHidden } = useHiddenRanges();
|
||||
|
||||
const weaponsWithRange = WeaponRange.ofWeapons(weaponIds);
|
||||
const weaponsWithRange = WeaponRange.ofWeapons(weaponIds, enabledVariantKeys);
|
||||
const shownWeapons = weaponsWithRange.filter(
|
||||
(weapon) => !hiddenWeaponIds.includes(weapon.weaponId),
|
||||
);
|
||||
const benchmarkTrajectories = WeaponRange.benchmarkTrajectories();
|
||||
|
||||
if (weaponsWithRange.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const maxRange = 32;
|
||||
|
||||
const allYValues: number[] = [];
|
||||
for (const weapon of weaponsWithRange) {
|
||||
if (weapon.trajectory) {
|
||||
for (const point of weapon.trajectory) {
|
||||
for (const weapon of shownWeapons) {
|
||||
for (const variant of weapon.variants) {
|
||||
for (const point of variant.trajectory ?? []) {
|
||||
if (point.y >= 0) {
|
||||
allYValues.push(point.y);
|
||||
}
|
||||
@@ -40,8 +63,15 @@ export function RangeVisualization({ weaponIds }: RangeVisualizationProps) {
|
||||
}
|
||||
}
|
||||
|
||||
const minY = 0;
|
||||
const maxY = Math.max(...allYValues, 2);
|
||||
const handleToggleVariant = (
|
||||
weapon: WeaponRange.WeaponWithRange,
|
||||
key: RangeVariantKey,
|
||||
) => {
|
||||
const nextKeys = WeaponRange.toggleVariant(weapon, key);
|
||||
if (!nextKeys) return;
|
||||
|
||||
setEnabledVariantKeys(weapon.weaponId, nextKeys);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.container} data-testid="range-visualization">
|
||||
@@ -68,99 +98,242 @@ export function RangeVisualization({ weaponIds }: RangeVisualizationProps) {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<TrajectoryChart
|
||||
weapons={weaponsWithRange}
|
||||
benchmarkTrajectories={benchmarkTrajectories}
|
||||
maxRange={maxRange}
|
||||
minY={minY}
|
||||
maxY={maxY}
|
||||
/>
|
||||
<div className={styles.chartContainer}>
|
||||
<WeaponLegend
|
||||
weapons={weaponsWithRange}
|
||||
hiddenWeaponIds={hiddenWeaponIds}
|
||||
onToggleVariant={handleToggleVariant}
|
||||
onToggleHidden={toggleHidden}
|
||||
/>
|
||||
<TrajectoryChart
|
||||
weapons={shownWeapons}
|
||||
benchmarkTrajectories={benchmarkTrajectories}
|
||||
maxY={Math.max(...allYValues, 2)}
|
||||
/>
|
||||
<div className={styles.specialRangesToggleRow}>
|
||||
<SendouSwitch
|
||||
isSelected={showSpecialRanges}
|
||||
onChange={setShowSpecialRanges}
|
||||
data-testid="special-ranges-switch"
|
||||
>
|
||||
{t("analyzer:comp.specialRanges")}
|
||||
</SendouSwitch>
|
||||
</div>
|
||||
{showSpecialRanges ? (
|
||||
<SpecialRangeRows weaponIds={weaponIds} />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WeaponLegend({
|
||||
weapons,
|
||||
hiddenWeaponIds,
|
||||
onToggleVariant,
|
||||
onToggleHidden,
|
||||
}: {
|
||||
weapons: WeaponRange.WeaponWithRange[];
|
||||
hiddenWeaponIds: MainWeaponId[];
|
||||
onToggleVariant: (
|
||||
weapon: WeaponRange.WeaponWithRange,
|
||||
key: RangeVariantKey,
|
||||
) => void;
|
||||
onToggleHidden: (weaponId: MainWeaponId) => void;
|
||||
}) {
|
||||
const { t } = useTranslation(["analyzer"]);
|
||||
|
||||
return (
|
||||
<div className={styles.weaponLegend}>
|
||||
{weapons.map((weapon) => {
|
||||
const color = SLOT_COLORS[weapon.slot % SLOT_COLORS.length];
|
||||
const isHidden = hiddenWeaponIds.includes(weapon.weaponId);
|
||||
const visibilityToggle = (
|
||||
<VisibilityToggle
|
||||
weaponId={weapon.weaponId}
|
||||
isHidden={isHidden}
|
||||
onToggle={() => onToggleHidden(weapon.weaponId)}
|
||||
/>
|
||||
);
|
||||
|
||||
if (weapon.allVariantKeys.length === 0) {
|
||||
const [variant] = weapon.variants;
|
||||
return (
|
||||
<div
|
||||
key={`${weapon.weaponId}-${weapon.slot}`}
|
||||
className={clsx(styles.weaponLegendItem, {
|
||||
[styles.weaponLegendItemHidden]: isHidden,
|
||||
})}
|
||||
>
|
||||
{visibilityToggle}
|
||||
<span
|
||||
className={styles.weaponLegendColor}
|
||||
style={{ backgroundColor: color }}
|
||||
/>
|
||||
<span className={styles.weaponLegendRange}>
|
||||
{variant.range.toFixed(1)}
|
||||
</span>
|
||||
<LethalRangeLabel lethal={variant.lethal} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const allVariants = WeaponRange.variantsOf(weapon.weaponId);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={`${weapon.weaponId}-${weapon.slot}`}
|
||||
className={clsx(styles.weaponLegendItem, {
|
||||
[styles.weaponLegendItemHidden]: isHidden,
|
||||
})}
|
||||
>
|
||||
{visibilityToggle}
|
||||
{allVariants.map((variant) => {
|
||||
if (variant.key === null) return null;
|
||||
const key = variant.key;
|
||||
const isShown = weapon.variants.some(
|
||||
(shown) => shown.key === key,
|
||||
);
|
||||
|
||||
return (
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
className={clsx(styles.variantChip, {
|
||||
[styles.variantChipHidden]: !isShown,
|
||||
})}
|
||||
aria-pressed={isShown}
|
||||
disabled={isHidden}
|
||||
onClick={() => onToggleVariant(weapon, key)}
|
||||
data-testid={`range-variant-${key}`}
|
||||
>
|
||||
<VariantLineSample
|
||||
color={color}
|
||||
isDefault={variant.isDefault}
|
||||
/>
|
||||
<span>{t(`analyzer:comp.rangeVariant.${key}`)}</span>
|
||||
<span className={styles.weaponLegendRange}>
|
||||
{variant.range.toFixed(1)}
|
||||
</span>
|
||||
<LethalRangeLabel lethal={variant.lethal} />
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function VisibilityToggle({
|
||||
weaponId,
|
||||
isHidden,
|
||||
onToggle,
|
||||
}: {
|
||||
weaponId: MainWeaponId;
|
||||
isHidden: boolean;
|
||||
onToggle: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation(["analyzer", "weapons"]);
|
||||
const weaponName = t(`weapons:MAIN_${weaponId}`);
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.visibilityToggle}
|
||||
aria-pressed={!isHidden}
|
||||
aria-label={
|
||||
isHidden
|
||||
? t("analyzer:comp.showInRangeChart", { weapon: weaponName })
|
||||
: t("analyzer:comp.hideFromRangeChart", { weapon: weaponName })
|
||||
}
|
||||
onClick={onToggle}
|
||||
data-testid={`range-visibility-${weaponId}`}
|
||||
>
|
||||
<WeaponImage weaponSplId={weaponId} variant="build" size={24} />
|
||||
{isHidden ? <EyeOff size={14} /> : <Eye size={14} />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function VariantLineSample({
|
||||
color,
|
||||
isDefault,
|
||||
}: {
|
||||
color: string;
|
||||
isDefault: boolean;
|
||||
}) {
|
||||
return (
|
||||
<svg width={16} height={4} aria-hidden className={styles.variantLine}>
|
||||
<line
|
||||
x1={0}
|
||||
y1={2}
|
||||
x2={16}
|
||||
y2={2}
|
||||
stroke={color}
|
||||
strokeWidth={3}
|
||||
strokeDasharray={isDefault ? undefined : "4,3"}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function LethalRangeLabel({
|
||||
lethal,
|
||||
}: {
|
||||
lethal: WeaponRange.LethalRange | undefined;
|
||||
}) {
|
||||
const { t } = useTranslation(["analyzer"]);
|
||||
|
||||
if (!lethal) return null;
|
||||
|
||||
return (
|
||||
<span className={styles.lethalRange}>
|
||||
{t("analyzer:comp.lethalRange", {
|
||||
shots: lethal.shots,
|
||||
distance: lethal.distance.toFixed(1),
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface TrajectoryChartProps {
|
||||
weapons: WeaponRange.WeaponWithRange[];
|
||||
benchmarkTrajectories: Array<{
|
||||
id: MainWeaponId;
|
||||
range: number;
|
||||
trajectory?: WeaponRange.TrajectoryPoint[];
|
||||
}>;
|
||||
maxRange: number;
|
||||
minY: number;
|
||||
benchmarkTrajectories: WeaponRange.BenchmarkTrajectory[];
|
||||
maxY: number;
|
||||
}
|
||||
|
||||
function TrajectoryChart({
|
||||
weapons,
|
||||
benchmarkTrajectories,
|
||||
maxRange,
|
||||
minY,
|
||||
maxY,
|
||||
}: TrajectoryChartProps) {
|
||||
const chartWidth = 600;
|
||||
const chartHeight = 200;
|
||||
const padding = { top: 20, right: 60, bottom: 30, left: 50 };
|
||||
const innerWidth = chartWidth - padding.left - padding.right;
|
||||
const innerHeight = chartHeight - padding.top - padding.bottom;
|
||||
const minY = 0;
|
||||
const innerHeight = CHART_HEIGHT - CHART_PADDING.top - CHART_PADDING.bottom;
|
||||
|
||||
const xScale = (z: number) => (z / maxRange) * innerWidth;
|
||||
const xScale = (z: number) => (z / MAX_RANGE) * CHART_INNER_WIDTH;
|
||||
const yScale = (y: number) =>
|
||||
innerHeight - ((y - minY) / (maxY - minY)) * innerHeight;
|
||||
|
||||
// where the trajectory hits the ground (lastPoint may be below it or mid-air); blasts happen there
|
||||
const getGroundIntersection = (
|
||||
trajectory: WeaponRange.TrajectoryPoint[],
|
||||
): WeaponRange.TrajectoryPoint | null => {
|
||||
for (let i = 0; i < trajectory.length; i++) {
|
||||
const point = trajectory[i];
|
||||
if (point.y < 0) {
|
||||
const prevPoint = trajectory[i - 1];
|
||||
if (prevPoint && prevPoint.y >= 0) {
|
||||
const t = prevPoint.y / (prevPoint.y - point.y);
|
||||
const groundZ = prevPoint.z + t * (point.z - prevPoint.z);
|
||||
return { z: groundZ, y: 0 };
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
const lastPoint = trajectory[trajectory.length - 1];
|
||||
return lastPoint && lastPoint.y >= 0 ? lastPoint : null;
|
||||
};
|
||||
|
||||
const trajectoryToPath = (
|
||||
trajectory: WeaponRange.TrajectoryPoint[],
|
||||
): string => {
|
||||
if (trajectory.length === 0) return "";
|
||||
const points = clampToGround(trajectory).map(
|
||||
(p) => `${xScale(p.z)},${yScale(p.y)}`,
|
||||
);
|
||||
if (points.length === 0) return "";
|
||||
|
||||
const clampedPoints: WeaponRange.TrajectoryPoint[] = [];
|
||||
for (const point of trajectory) {
|
||||
if (point.y >= 0) {
|
||||
clampedPoints.push(point);
|
||||
} else {
|
||||
const prevPoint = clampedPoints[clampedPoints.length - 1];
|
||||
if (prevPoint && prevPoint.y > 0) {
|
||||
const t = prevPoint.y / (prevPoint.y - point.y);
|
||||
const groundZ = prevPoint.z + t * (point.z - prevPoint.z);
|
||||
clampedPoints.push({ z: groundZ, y: 0 });
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clampedPoints.length === 0) return "";
|
||||
|
||||
const points = clampedPoints.map((p) => `${xScale(p.z)},${yScale(p.y)}`);
|
||||
return `M ${points.join(" L ")}`;
|
||||
};
|
||||
|
||||
const groundY = yScale(0);
|
||||
|
||||
const xTicks: number[] = [];
|
||||
const xStep = Math.ceil(maxRange / 5);
|
||||
for (let x = 0; x <= maxRange; x += xStep) {
|
||||
const xStep = Math.ceil(MAX_RANGE / 5);
|
||||
for (let x = 0; x <= MAX_RANGE; x += xStep) {
|
||||
xTicks.push(x);
|
||||
}
|
||||
|
||||
@@ -170,174 +343,265 @@ function TrajectoryChart({
|
||||
yTicks.push(y);
|
||||
}
|
||||
|
||||
const shownVariants = weapons.flatMap((weapon) =>
|
||||
weapon.variants.map((variant) => ({
|
||||
id: `${weapon.weaponId}-${weapon.slot}-${variant.key}`,
|
||||
color: SLOT_COLORS[weapon.slot % SLOT_COLORS.length],
|
||||
variant,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.chartContainer}>
|
||||
<div className={styles.weaponLegend}>
|
||||
{weapons.map((weapon) => {
|
||||
const color = SLOT_COLORS[weapon.slot % SLOT_COLORS.length];
|
||||
<svg
|
||||
viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}
|
||||
className={styles.chart}
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
>
|
||||
<g transform={`translate(${CHART_PADDING.left}, ${CHART_PADDING.top})`}>
|
||||
{xTicks.map((tick) => (
|
||||
<line
|
||||
key={`x-grid-${tick}`}
|
||||
x1={xScale(tick)}
|
||||
y1={0}
|
||||
x2={xScale(tick)}
|
||||
y2={innerHeight}
|
||||
stroke="var(--color-border)"
|
||||
strokeWidth={0.5}
|
||||
/>
|
||||
))}
|
||||
{yTicks.map((tick) => (
|
||||
<line
|
||||
key={`y-grid-${tick}`}
|
||||
x1={0}
|
||||
y1={yScale(tick)}
|
||||
x2={CHART_INNER_WIDTH}
|
||||
y2={yScale(tick)}
|
||||
stroke="var(--color-border)"
|
||||
strokeWidth={0.5}
|
||||
/>
|
||||
))}
|
||||
|
||||
<line
|
||||
x1={0}
|
||||
y1={groundY}
|
||||
x2={CHART_INNER_WIDTH}
|
||||
y2={groundY}
|
||||
stroke="var(--color-text-high)"
|
||||
strokeWidth={1}
|
||||
/>
|
||||
|
||||
{benchmarkTrajectories.map((benchmark, index) => {
|
||||
const x = xScale(benchmark.range);
|
||||
return (
|
||||
<div
|
||||
key={`${weapon.weaponId}-${weapon.slot}`}
|
||||
className={styles.weaponLegendItem}
|
||||
>
|
||||
<WeaponImage
|
||||
weaponSplId={weapon.weaponId}
|
||||
variant="build"
|
||||
size={24}
|
||||
/>
|
||||
<span
|
||||
className={styles.weaponLegendColor}
|
||||
style={{ backgroundColor: color }}
|
||||
/>
|
||||
<span className={styles.weaponLegendRange}>
|
||||
{weapon.range.toFixed(1)}
|
||||
</span>
|
||||
</div>
|
||||
<line
|
||||
key={benchmark.id}
|
||||
x1={x}
|
||||
y1={0}
|
||||
x2={x}
|
||||
y2={innerHeight}
|
||||
stroke={BENCHMARK_COLORS[index % BENCHMARK_COLORS.length]}
|
||||
strokeWidth={2}
|
||||
strokeDasharray="4,4"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<svg
|
||||
viewBox={`0 0 ${chartWidth} ${chartHeight}`}
|
||||
className={styles.chart}
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
>
|
||||
<g transform={`translate(${padding.left}, ${padding.top})`}>
|
||||
{/* Grid lines */}
|
||||
{xTicks.map((tick) => (
|
||||
<line
|
||||
key={`x-grid-${tick}`}
|
||||
x1={xScale(tick)}
|
||||
y1={0}
|
||||
x2={xScale(tick)}
|
||||
y2={innerHeight}
|
||||
stroke="var(--color-border)"
|
||||
strokeWidth={0.5}
|
||||
|
||||
{shownVariants.map(({ id, color, variant }) => {
|
||||
if (!variant.trajectory) return null;
|
||||
return (
|
||||
<path
|
||||
key={id}
|
||||
d={trajectoryToPath(variant.trajectory)}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={2.5}
|
||||
strokeDasharray={
|
||||
variant.isDefault ? undefined : ALTERNATE_VARIANT_DASH
|
||||
}
|
||||
/>
|
||||
))}
|
||||
{yTicks.map((tick) => (
|
||||
<line
|
||||
key={`y-grid-${tick}`}
|
||||
x1={0}
|
||||
y1={yScale(tick)}
|
||||
x2={innerWidth}
|
||||
y2={yScale(tick)}
|
||||
stroke="var(--color-border)"
|
||||
strokeWidth={0.5}
|
||||
);
|
||||
})}
|
||||
|
||||
{shownVariants.map(({ id, color, variant }) => {
|
||||
if (!variant.blastRadius || !variant.trajectory) return null;
|
||||
const blastPoint = clampToGround(variant.trajectory).at(-1);
|
||||
if (!blastPoint) return null;
|
||||
return (
|
||||
<circle
|
||||
key={`blast-${id}`}
|
||||
cx={xScale(blastPoint.z)}
|
||||
cy={yScale(blastPoint.y)}
|
||||
r={xScale(variant.blastRadius)}
|
||||
fill={`${color}33`}
|
||||
stroke={color}
|
||||
strokeWidth={1}
|
||||
strokeDasharray={
|
||||
variant.isDefault ? undefined : ALTERNATE_VARIANT_DASH
|
||||
}
|
||||
/>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Ground line (y=0) */}
|
||||
<line
|
||||
x1={0}
|
||||
y1={groundY}
|
||||
x2={innerWidth}
|
||||
y2={groundY}
|
||||
stroke="var(--color-text-high)"
|
||||
strokeWidth={1}
|
||||
/>
|
||||
{shownVariants.map(({ id, color, variant }) => {
|
||||
if (!variant.lethal || !variant.trajectory) return null;
|
||||
const markerY = heightAt(variant.trajectory, variant.lethal.distance);
|
||||
if (markerY === null) return null;
|
||||
return (
|
||||
<circle
|
||||
key={`lethal-${id}`}
|
||||
cx={xScale(variant.lethal.distance)}
|
||||
cy={yScale(markerY)}
|
||||
r={4}
|
||||
fill={color}
|
||||
stroke="var(--color-bg)"
|
||||
strokeWidth={1.5}
|
||||
data-testid="lethal-range-marker"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Benchmark vertical lines */}
|
||||
{benchmarkTrajectories.map((benchmark, index) => {
|
||||
const x = xScale(benchmark.range);
|
||||
return (
|
||||
<line
|
||||
key={benchmark.id}
|
||||
x1={x}
|
||||
y1={0}
|
||||
x2={x}
|
||||
y2={innerHeight}
|
||||
stroke={BENCHMARK_COLORS[index % BENCHMARK_COLORS.length]}
|
||||
strokeWidth={2}
|
||||
strokeDasharray="4,4"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Weapon trajectories */}
|
||||
{weapons.map((weapon) => {
|
||||
if (!weapon.trajectory) return null;
|
||||
const color = SLOT_COLORS[weapon.slot % SLOT_COLORS.length];
|
||||
return (
|
||||
<path
|
||||
key={`${weapon.weaponId}-${weapon.slot}`}
|
||||
d={trajectoryToPath(weapon.trajectory)}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={2.5}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Blast radius circles */}
|
||||
{weapons.map((weapon) => {
|
||||
if (!weapon.blastRadius || !weapon.trajectory) return null;
|
||||
const groundPoint = getGroundIntersection(weapon.trajectory);
|
||||
if (!groundPoint) return null;
|
||||
const color = SLOT_COLORS[weapon.slot % SLOT_COLORS.length];
|
||||
const radiusPixels = xScale(weapon.blastRadius);
|
||||
return (
|
||||
<circle
|
||||
key={`blast-${weapon.weaponId}-${weapon.slot}`}
|
||||
cx={xScale(groundPoint.z)}
|
||||
cy={yScale(0)}
|
||||
r={radiusPixels}
|
||||
fill={`${color}33`}
|
||||
stroke={color}
|
||||
strokeWidth={1}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* X axis labels */}
|
||||
{xTicks.map((tick) => (
|
||||
<text
|
||||
key={`x-label-${tick}`}
|
||||
x={xScale(tick)}
|
||||
y={innerHeight + 15}
|
||||
textAnchor="middle"
|
||||
fontSize={10}
|
||||
fill="var(--color-text-high)"
|
||||
>
|
||||
{tick}
|
||||
</text>
|
||||
))}
|
||||
|
||||
{/* Y axis labels */}
|
||||
{yTicks.map((tick) => (
|
||||
<text
|
||||
key={`y-label-${tick}`}
|
||||
x={-8}
|
||||
y={yScale(tick) + 3}
|
||||
textAnchor="end"
|
||||
fontSize={10}
|
||||
fill="var(--color-text-high)"
|
||||
>
|
||||
{tick}
|
||||
</text>
|
||||
))}
|
||||
|
||||
{/* Axis labels */}
|
||||
{xTicks.map((tick) => (
|
||||
<text
|
||||
x={innerWidth / 2}
|
||||
y={innerHeight + 25}
|
||||
key={`x-label-${tick}`}
|
||||
x={xScale(tick)}
|
||||
y={innerHeight + 15}
|
||||
textAnchor="middle"
|
||||
fontSize={11}
|
||||
fontSize={10}
|
||||
fill="var(--color-text-high)"
|
||||
>
|
||||
z
|
||||
{tick}
|
||||
</text>
|
||||
))}
|
||||
|
||||
{yTicks.map((tick) => (
|
||||
<text
|
||||
x={-25}
|
||||
y={innerHeight / 2}
|
||||
textAnchor="middle"
|
||||
fontSize={11}
|
||||
key={`y-label-${tick}`}
|
||||
x={-8}
|
||||
y={yScale(tick) + 3}
|
||||
textAnchor="end"
|
||||
fontSize={10}
|
||||
fill="var(--color-text-high)"
|
||||
transform={`rotate(-90, -25, ${innerHeight / 2})`}
|
||||
>
|
||||
y
|
||||
{tick}
|
||||
</text>
|
||||
</g>
|
||||
</svg>
|
||||
))}
|
||||
|
||||
<text
|
||||
x={CHART_INNER_WIDTH / 2}
|
||||
y={innerHeight + 25}
|
||||
textAnchor="middle"
|
||||
fontSize={11}
|
||||
fill="var(--color-text-high)"
|
||||
>
|
||||
z
|
||||
</text>
|
||||
<text
|
||||
x={-25}
|
||||
y={innerHeight / 2}
|
||||
textAnchor="middle"
|
||||
fontSize={11}
|
||||
fill="var(--color-text-high)"
|
||||
transform={`rotate(-90, -25, ${innerHeight / 2})`}
|
||||
>
|
||||
y
|
||||
</text>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Special ranges of the comp as bars on the same x scale as the trajectory chart above them */
|
||||
function SpecialRangeRows({ weaponIds }: { weaponIds: MainWeaponId[] }) {
|
||||
const rows = SpecialWeaponRange.ofWeapons(weaponIds);
|
||||
|
||||
if (rows.length === 0) return null;
|
||||
|
||||
const trackStyle = {
|
||||
marginInlineStart: `${(CHART_PADDING.left / CHART_WIDTH) * 100}%`,
|
||||
width: `${(CHART_INNER_WIDTH / CHART_WIDTH) * 100}%`,
|
||||
};
|
||||
const percentageOfTrack = (distance: number) =>
|
||||
`${(Math.min(distance, MAX_RANGE) / MAX_RANGE) * 100}%`;
|
||||
|
||||
return (
|
||||
<div className={styles.specialRanges} data-testid="special-ranges">
|
||||
{rows.map((row) => {
|
||||
const color = SLOT_COLORS[row.slot % SLOT_COLORS.length];
|
||||
return (
|
||||
<div key={row.slot} className={styles.specialRangeRow}>
|
||||
<SpecialWeaponImage
|
||||
specialWeaponId={row.specialWeaponId}
|
||||
size={24}
|
||||
className={styles.specialRangeIcon}
|
||||
/>
|
||||
<div className={styles.specialRangeTrack} style={trackStyle}>
|
||||
<span
|
||||
className={styles.specialRangeBar}
|
||||
style={{
|
||||
width: percentageOfTrack(row.range),
|
||||
backgroundColor: color,
|
||||
}}
|
||||
>
|
||||
{row.range.toFixed(1)}
|
||||
{row.blastRadius ? ` + ${row.blastRadius.toFixed(1)}` : ""}
|
||||
</span>
|
||||
{row.blastRadius ? (
|
||||
<span
|
||||
className={styles.specialRangeBlast}
|
||||
style={{
|
||||
insetInlineStart: percentageOfTrack(row.range),
|
||||
width: percentageOfTrack(row.blastRadius),
|
||||
backgroundColor: color,
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The trajectory up to where it reaches the ground (or its last point mid-air) */
|
||||
function clampToGround(
|
||||
trajectory: WeaponRange.TrajectoryPoint[],
|
||||
): WeaponRange.TrajectoryPoint[] {
|
||||
const clampedPoints: WeaponRange.TrajectoryPoint[] = [];
|
||||
for (const point of trajectory) {
|
||||
if (point.y >= 0) {
|
||||
clampedPoints.push(point);
|
||||
continue;
|
||||
}
|
||||
|
||||
const prevPoint = clampedPoints.at(-1);
|
||||
if (prevPoint && prevPoint.y > 0) {
|
||||
const t = prevPoint.y / (prevPoint.y - point.y);
|
||||
clampedPoints.push({
|
||||
z: prevPoint.z + t * (point.z - prevPoint.z),
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return clampedPoints;
|
||||
}
|
||||
|
||||
function heightAt(
|
||||
trajectory: WeaponRange.TrajectoryPoint[],
|
||||
z: number,
|
||||
): number | null {
|
||||
const points = clampToGround(trajectory);
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
const prevPoint = points[i - 1];
|
||||
const point = points[i];
|
||||
if (z < prevPoint.z || z > point.z) continue;
|
||||
|
||||
const t =
|
||||
point.z === prevPoint.z ? 0 : (z - prevPoint.z) / (point.z - prevPoint.z);
|
||||
return prevPoint.y + t * (point.y - prevPoint.y);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { SpecialWeaponId } from "~/modules/in-game-lists/types";
|
||||
import {
|
||||
BIG_BUBBLER_ID,
|
||||
BOOYAH_BOMB_ID,
|
||||
@@ -18,6 +19,17 @@ describe("SpecialWeaponRange.ofSpecial", () => {
|
||||
expect(result?.range).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// "Calculating weapon range (11.1.0 ver.)" community sheet
|
||||
test.each([
|
||||
{ why: "Trizooka", id: TRIZOOKA_ID, expected: 22.55 },
|
||||
{ why: "Crab Tank cannon", id: CRAB_TANK_ID, expected: 24.66 },
|
||||
] satisfies Array<{ why: string; id: SpecialWeaponId; expected: number }>)(
|
||||
"matches the community range sheet: $why",
|
||||
({ id, expected }) => {
|
||||
expect(SpecialWeaponRange.ofSpecial(id)?.range).toBeCloseTo(expected, 1);
|
||||
},
|
||||
);
|
||||
|
||||
test("Crab Tank reaches further than Trizooka", () => {
|
||||
const crab = SpecialWeaponRange.ofSpecial(CRAB_TANK_ID);
|
||||
const trizooka = SpecialWeaponRange.ofSpecial(TRIZOOKA_ID);
|
||||
@@ -55,3 +67,14 @@ describe("SpecialWeaponRange.ofSpecial", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("SpecialWeaponRange.ofWeapons", () => {
|
||||
test("keeps the comp slot of each special with a range and leaves the rest out", () => {
|
||||
// Splat Roller (Big Bubbler), Squeezer (Trizooka)
|
||||
const specials = SpecialWeaponRange.ofWeapons([1010, 400]);
|
||||
|
||||
expect(
|
||||
specials.map(({ slot, specialWeaponId }) => ({ slot, specialWeaponId })),
|
||||
).toEqual([{ slot: 1, specialWeaponId: TRIZOOKA_ID }]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
* specials carry a radius in their params.
|
||||
*/
|
||||
|
||||
import { specialWeaponParams } from "~/features/build-analyzer/core/utils";
|
||||
import type { SpecialWeaponId } from "~/modules/in-game-lists/types";
|
||||
import {
|
||||
mainWeaponParams,
|
||||
specialWeaponParams,
|
||||
} from "~/features/build-analyzer/core/utils";
|
||||
import type {
|
||||
MainWeaponId,
|
||||
SpecialWeaponId,
|
||||
} from "~/modules/in-game-lists/types";
|
||||
import { specialWeaponIds } from "~/modules/in-game-lists/weapon-ids";
|
||||
import * as WeaponRange from "./WeaponRange";
|
||||
|
||||
const DEFAULT_BRAKE_AIR_RESIST = 0.36;
|
||||
const DEFAULT_BRAKE_GRAVITY = 0.07;
|
||||
const DEFAULT_BRAKE_TO_FREE_FRAME = 4;
|
||||
const DEFAULT_FREE_GRAVITY = 0.016;
|
||||
const DEFAULT_FREE_AIR_RESIST = 0;
|
||||
|
||||
/** Range of a special: how far its projectile flies, or the radius of its area. */
|
||||
export interface SpecialWeaponRangeResult {
|
||||
/** In game distance units. */
|
||||
@@ -45,23 +45,11 @@ export function ofSpecial(
|
||||
};
|
||||
}
|
||||
|
||||
if (params.Range_SpawnSpeed === undefined) return null;
|
||||
|
||||
const trajectoryParams: WeaponRange.TrajectoryParams = {
|
||||
spawnSpeed: params.Range_SpawnSpeed,
|
||||
goStraightStateEndMaxSpeed:
|
||||
params.Range_GoStraightStateEndMaxSpeed ?? params.Range_SpawnSpeed,
|
||||
goStraightToBrakeStateFrame: params.Range_GoStraightToBrakeStateFrame ?? 4,
|
||||
freeGravity: params.Range_FreeGravity ?? DEFAULT_FREE_GRAVITY,
|
||||
freeAirResist: params.Range_FreeAirResist ?? DEFAULT_FREE_AIR_RESIST,
|
||||
brakeAirResist: params.Range_BrakeAirResist ?? DEFAULT_BRAKE_AIR_RESIST,
|
||||
brakeGravity: params.Range_BrakeGravity ?? DEFAULT_BRAKE_GRAVITY,
|
||||
brakeToFreeFrame:
|
||||
params.Range_BrakeToFreeStateFrame ?? DEFAULT_BRAKE_TO_FREE_FRAME,
|
||||
};
|
||||
const flightParams = WeaponRange.trajectoryParams(params);
|
||||
if (!flightParams) return null;
|
||||
|
||||
const range = WeaponRange.groundRange(
|
||||
WeaponRange.simulateTrajectory(trajectoryParams),
|
||||
WeaponRange.simulateTrajectory(flightParams),
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -76,6 +64,21 @@ export interface SpecialWeaponWithRange extends SpecialWeaponRangeResult {
|
||||
specialWeaponId: SpecialWeaponId;
|
||||
}
|
||||
|
||||
/** The special of a comp's weapon with its range. */
|
||||
export interface CompSpecialWithRange extends SpecialWeaponWithRange {
|
||||
/** Position of the weapon in the comp */
|
||||
slot: number;
|
||||
}
|
||||
|
||||
/** Ranges of the specials of a comp's weapons in comp order, the ones without a range to draw left out. */
|
||||
export function ofWeapons(weaponIds: MainWeaponId[]): CompSpecialWithRange[] {
|
||||
return weaponIds.flatMap((weaponId, slot) => {
|
||||
const { specialWeaponId } = mainWeaponParams(weaponId);
|
||||
const result = ofSpecial(specialWeaponId);
|
||||
return result ? [{ slot, specialWeaponId, ...result }] : [];
|
||||
});
|
||||
}
|
||||
|
||||
/** Every special with a range to draw, widest first. */
|
||||
export function allSpecials(): SpecialWeaponWithRange[] {
|
||||
return specialWeaponIds
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { RangeVariantKey } from "~/features/build-analyzer/analyzer-types";
|
||||
import type { MainWeaponId } from "~/modules/in-game-lists/types";
|
||||
import * as WeaponRange from "./WeaponRange";
|
||||
|
||||
@@ -11,6 +12,41 @@ const RANGE_COMPARISONS: [MainWeaponId, MainWeaponId][] = [
|
||||
[2070, 7010], // Snipewriter 5H > Tri-Stringer
|
||||
];
|
||||
|
||||
// "Calculating weapon range (11.1.0 ver.)" community sheet, rows whose params didn't change since
|
||||
const SHEET_RANGES: Array<{
|
||||
weaponId: MainWeaponId;
|
||||
key: RangeVariantKey | null;
|
||||
expected: number;
|
||||
why: string;
|
||||
}> = [
|
||||
{ weaponId: 40, key: null, expected: 11.93, why: "Splattershot" },
|
||||
{ weaponId: 210, key: null, expected: 9.86, why: "Blaster bursts mid-air" },
|
||||
{ weaponId: 250, key: null, expected: 17.39, why: "Rapid Blaster Pro" },
|
||||
{ weaponId: 260, key: "jump", expected: 7.77, why: "S-BLAST jump shot" },
|
||||
{ weaponId: 400, key: "hold", expected: 11.63, why: "Squeezer hold" },
|
||||
{ weaponId: 1010, key: "horizontal", expected: 9.27, why: "Splat Roller" },
|
||||
{ weaponId: 1030, key: "horizontal", expected: 8.3, why: "Flingza Roller" },
|
||||
{ weaponId: 2060, key: "tap", expected: 12.6, why: "Goo Tuber tap" },
|
||||
{ weaponId: 3000, key: null, expected: 11.15, why: "Slosher air resist" },
|
||||
{ weaponId: 3040, key: null, expected: 17.39, why: "Explosher" },
|
||||
{ weaponId: 4030, key: "short", expected: 10.77, why: "Ballpoint short" },
|
||||
{ weaponId: 5020, key: "turret", expected: 15.75, why: "Glooga turret" },
|
||||
{ weaponId: 5050, key: "turret", expected: 14.22, why: "Douser turret" },
|
||||
{
|
||||
weaponId: 7010,
|
||||
key: "partialCharge",
|
||||
expected: 13.83,
|
||||
why: "Tri-Stringer",
|
||||
},
|
||||
{
|
||||
weaponId: 8020,
|
||||
key: "charged",
|
||||
expected: 16.1,
|
||||
why: "Decavitator charged, spawn offset",
|
||||
},
|
||||
{ weaponId: 8020, key: "tap", expected: 15.2, why: "Decavitator tap" },
|
||||
];
|
||||
|
||||
describe("WeaponRange.ofWeapons", () => {
|
||||
test("keeps a separate slot for each copy of a duplicated weapon", () => {
|
||||
const weapons = WeaponRange.ofWeapons([40, 40, 70]);
|
||||
@@ -24,7 +60,176 @@ describe("WeaponRange.ofWeapons", () => {
|
||||
const [longer] = WeaponRange.ofWeapons([longerId]);
|
||||
const [shorter] = WeaponRange.ofWeapons([shorterId]);
|
||||
|
||||
expect(longer.range).toBeGreaterThan(shorter.range);
|
||||
expect(longer.variants[0].range).toBeGreaterThan(
|
||||
shorter.variants[0].range,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test("shows only the default variant when none are enabled", () => {
|
||||
const [roller] = WeaponRange.ofWeapons([1010]);
|
||||
|
||||
expect(roller.variants.map((variant) => variant.key)).toEqual(["vertical"]);
|
||||
expect(roller.allVariantKeys).toEqual(["vertical", "horizontal"]);
|
||||
});
|
||||
|
||||
test("shows the enabled variants in the weapon's own order", () => {
|
||||
const [roller] = WeaponRange.ofWeapons([1010], () => [
|
||||
"horizontal",
|
||||
"vertical",
|
||||
]);
|
||||
|
||||
expect(roller.variants.map((variant) => variant.key)).toEqual([
|
||||
"vertical",
|
||||
"horizontal",
|
||||
]);
|
||||
});
|
||||
|
||||
test("weapons with one way of shooting have no variant keys", () => {
|
||||
const [splattershot] = WeaponRange.ofWeapons([40]);
|
||||
|
||||
expect(splattershot.allVariantKeys).toEqual([]);
|
||||
expect(splattershot.variants[0].key).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("WeaponRange.variantsOf", () => {
|
||||
test.each(SHEET_RANGES)(
|
||||
"matches the community range sheet: $why",
|
||||
({ weaponId, key, expected }) => {
|
||||
const variant = WeaponRange.variantsOf(weaponId).find(
|
||||
(candidate) => key === null || candidate.key === key,
|
||||
);
|
||||
|
||||
expect(variant?.range).toBeCloseTo(expected, 1);
|
||||
},
|
||||
);
|
||||
|
||||
test("Splatana shots spawn in front of the player at shooting height", () => {
|
||||
const [charged, tap] = WeaponRange.variantsOf(8000);
|
||||
|
||||
expect(charged.trajectory?.[0]).toEqual({ z: 0.8, y: 1 });
|
||||
expect(tap.trajectory?.[0]).toEqual({ z: 1.4, y: 1 });
|
||||
});
|
||||
|
||||
test("vertical roller flicks are launched upwards", () => {
|
||||
const [vertical] = WeaponRange.variantsOf(1010);
|
||||
const highestPoint = Math.max(
|
||||
...(vertical.trajectory ?? []).map((point) => point.y),
|
||||
);
|
||||
|
||||
expect(highestPoint).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
test("rollers carry their one-shot distance per swing", () => {
|
||||
const [vertical, horizontal] = WeaponRange.variantsOf(1010);
|
||||
|
||||
expect(vertical.lethal).toEqual({ shots: 1, distance: 8.2 });
|
||||
expect(horizontal.lethal).toEqual({ shots: 1, distance: 7.2 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("WeaponRange.lethalRange", () => {
|
||||
test.each([
|
||||
{
|
||||
why: "ends where damage drops below one-shot",
|
||||
points: [
|
||||
{ Damage: 1500, Distance: 5.2 },
|
||||
{ Damage: 1000, Distance: 8.2 },
|
||||
{ Damage: 500, Distance: 11.2 },
|
||||
],
|
||||
expected: { shots: 1, distance: 8.2 },
|
||||
},
|
||||
{
|
||||
why: "interpolates between points",
|
||||
points: [
|
||||
{ Damage: 400, Distance: 3.3 },
|
||||
{ Damage: 200, Distance: 14.3 },
|
||||
],
|
||||
expected: { shots: 3, distance: 3.3 + (11 * (400 - 1000 / 3)) / 200 },
|
||||
},
|
||||
{
|
||||
why: "is null when damage never drops a breakpoint",
|
||||
points: [
|
||||
{ Damage: 600, Distance: 5 },
|
||||
{ Damage: 500, Distance: 13 },
|
||||
],
|
||||
expected: null,
|
||||
},
|
||||
])("$why", ({ points, expected }) => {
|
||||
const result = WeaponRange.lethalRange(points);
|
||||
|
||||
if (expected === null) {
|
||||
expect(result).toBeNull();
|
||||
} else {
|
||||
expect(result?.shots).toBe(expected.shots);
|
||||
expect(result?.distance).toBeCloseTo(expected.distance);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("WeaponRange.simulateTrajectory", () => {
|
||||
const params: WeaponRange.TrajectoryParams = {
|
||||
spawnSpeed: 1,
|
||||
spawnAngle: 0,
|
||||
spawnOffsetZ: 0,
|
||||
goStraightStateEndMaxSpeed: 1,
|
||||
goStraightToBrakeStateFrame: 2,
|
||||
freeGravity: 0.016,
|
||||
freeAirResist: 0.02,
|
||||
brakeAirResist: 0.09,
|
||||
brakeGravity: 0.09,
|
||||
brakeToFreeFrame: 10,
|
||||
brakeToFreeVelocityY: -0.15,
|
||||
};
|
||||
|
||||
test("ends the brake phase once the shot falls faster than brakeToFreeVelocityY", () => {
|
||||
const earlyFree = WeaponRange.groundRange(
|
||||
WeaponRange.simulateTrajectory({ ...params, brakeToFreeVelocityY: -0.1 }),
|
||||
);
|
||||
const fullBrake = WeaponRange.groundRange(
|
||||
WeaponRange.simulateTrajectory({ ...params, brakeToFreeVelocityY: -99 }),
|
||||
);
|
||||
|
||||
expect(earlyFree).toBeGreaterThan(fullBrake);
|
||||
});
|
||||
});
|
||||
|
||||
describe("WeaponRange.toggleVariant", () => {
|
||||
const roller = (enabled: RangeVariantKey[]) =>
|
||||
WeaponRange.ofWeapons([1010], () => enabled)[0];
|
||||
|
||||
test.each([
|
||||
{
|
||||
why: "turning on an alternative keeps the default",
|
||||
enabled: [],
|
||||
key: "horizontal",
|
||||
expected: ["vertical", "horizontal"],
|
||||
},
|
||||
{
|
||||
why: "back to only the default is stored as nothing",
|
||||
enabled: ["vertical", "horizontal"],
|
||||
key: "horizontal",
|
||||
expected: [],
|
||||
},
|
||||
{
|
||||
why: "the default can be hidden while an alternative shows",
|
||||
enabled: ["vertical", "horizontal"],
|
||||
key: "vertical",
|
||||
expected: ["horizontal"],
|
||||
},
|
||||
{
|
||||
why: "the last shown variant can't be hidden",
|
||||
enabled: ["horizontal"],
|
||||
key: "horizontal",
|
||||
expected: null,
|
||||
},
|
||||
] satisfies Array<{
|
||||
why: string;
|
||||
enabled: RangeVariantKey[];
|
||||
key: RangeVariantKey;
|
||||
expected: RangeVariantKey[] | null;
|
||||
}>)("$why", ({ enabled, key, expected }) => {
|
||||
expect(WeaponRange.toggleVariant(roller(enabled), key)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* How far main weapons shoot: a frame by frame simulation of a shot's flight (straight, braking,
|
||||
* then falling) from the weapon's params, chargers reaching their full charge distance in a line.
|
||||
* then falling) from the weapon's params, chargers reaching their charge distance in a line.
|
||||
* Distances are in game units, measured from a player standing on flat ground.
|
||||
*/
|
||||
|
||||
import type {
|
||||
DistanceDamage,
|
||||
RangeParams,
|
||||
RangeVariantKey,
|
||||
} from "~/features/build-analyzer/analyzer-types";
|
||||
import { mainWeaponParams } from "~/features/build-analyzer/core/utils";
|
||||
import type { MainWeaponId } from "~/modules/in-game-lists/types";
|
||||
import { weaponCategories } from "~/modules/in-game-lists/weapon-ids";
|
||||
@@ -11,6 +16,10 @@ import { weaponCategories } from "~/modules/in-game-lists/weapon-ids";
|
||||
/** Flight params of a shot, `Range_*` of the weapon's params with the game's defaults filled in. */
|
||||
export interface TrajectoryParams {
|
||||
spawnSpeed: number;
|
||||
/** Upward angle of the shot in degrees */
|
||||
spawnAngle: number;
|
||||
/** How far in front of the player the shot spawns */
|
||||
spawnOffsetZ: number;
|
||||
goStraightStateEndMaxSpeed: number;
|
||||
goStraightToBrakeStateFrame: number;
|
||||
freeGravity: number;
|
||||
@@ -18,6 +27,7 @@ export interface TrajectoryParams {
|
||||
brakeAirResist: number;
|
||||
brakeGravity: number;
|
||||
brakeToFreeFrame: number;
|
||||
brakeToFreeVelocityY: number;
|
||||
burstFrame?: number;
|
||||
bounceAfterMaxSpeed?: number;
|
||||
}
|
||||
@@ -28,11 +38,16 @@ export interface TrajectoryPoint {
|
||||
y: number;
|
||||
}
|
||||
|
||||
const DEFAULT_GO_STRAIGHT_TO_BRAKE_STATE_FRAME = 4;
|
||||
const DEFAULT_BRAKE_AIR_RESIST = 0.36;
|
||||
const DEFAULT_BRAKE_GRAVITY = 0.07;
|
||||
const DEFAULT_BRAKE_TO_FREE_FRAME = 4;
|
||||
const DEFAULT_BRAKE_TO_FREE_VELOCITY_Y = -0.15;
|
||||
const DEFAULT_FREE_GRAVITY = 0.016;
|
||||
const DEFAULT_FREE_AIR_RESIST = 0;
|
||||
const DEFAULT_FREE_AIR_RESIST = 0.02;
|
||||
|
||||
/** Damage (in tenths of HP) it takes to splat a player */
|
||||
const SPLAT_DAMAGE = 1000;
|
||||
|
||||
function getWeaponCategoryName(weaponId: MainWeaponId): string | undefined {
|
||||
for (const category of weaponCategories) {
|
||||
@@ -64,15 +79,46 @@ function bouncingRange(trajectory: TrajectoryPoint[]): number {
|
||||
return lastPoint?.z ?? 0;
|
||||
}
|
||||
|
||||
/** Flight params of `Range_*` params with the game's defaults filled in, `null` when they have no speed. */
|
||||
export function trajectoryParams(
|
||||
params: Omit<RangeParams, "Range_DistanceDamage">,
|
||||
): TrajectoryParams | null {
|
||||
if (params.Range_SpawnSpeed === undefined) return null;
|
||||
|
||||
return {
|
||||
spawnSpeed: params.Range_SpawnSpeed,
|
||||
spawnAngle: params.Range_SpawnAngle ?? 0,
|
||||
spawnOffsetZ: params.Range_SpawnOffsetZ ?? 0,
|
||||
goStraightStateEndMaxSpeed:
|
||||
params.Range_GoStraightStateEndMaxSpeed ?? params.Range_SpawnSpeed,
|
||||
goStraightToBrakeStateFrame:
|
||||
params.Range_GoStraightToBrakeStateFrame ??
|
||||
DEFAULT_GO_STRAIGHT_TO_BRAKE_STATE_FRAME,
|
||||
freeGravity: params.Range_FreeGravity ?? DEFAULT_FREE_GRAVITY,
|
||||
freeAirResist: params.Range_FreeAirResist ?? DEFAULT_FREE_AIR_RESIST,
|
||||
brakeAirResist: params.Range_BrakeAirResist ?? DEFAULT_BRAKE_AIR_RESIST,
|
||||
brakeGravity: params.Range_BrakeGravity ?? DEFAULT_BRAKE_GRAVITY,
|
||||
brakeToFreeFrame:
|
||||
params.Range_BrakeToFreeStateFrame ?? DEFAULT_BRAKE_TO_FREE_FRAME,
|
||||
brakeToFreeVelocityY:
|
||||
params.Range_BrakeToFreeVelocityY ?? DEFAULT_BRAKE_TO_FREE_VELOCITY_Y,
|
||||
burstFrame: params.Range_BurstFrame,
|
||||
bounceAfterMaxSpeed: params.Range_BounceAfterMaxSpeed,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The shot's position on every frame until it lands, bursts or stops. Bouncing shots
|
||||
* (`bounceAfterMaxSpeed` set) bounce `burstFrame` times instead of landing.
|
||||
* The shot's position on every frame until it lands, bursts or stops. The brake phase ends early once
|
||||
* the shot falls faster than `brakeToFreeVelocityY`. Bouncing shots (`bounceAfterMaxSpeed` set)
|
||||
* bounce `burstFrame` times instead of landing.
|
||||
*/
|
||||
export function simulateTrajectory(
|
||||
params: TrajectoryParams,
|
||||
): TrajectoryPoint[] {
|
||||
const {
|
||||
spawnSpeed,
|
||||
spawnAngle,
|
||||
spawnOffsetZ,
|
||||
goStraightStateEndMaxSpeed,
|
||||
goStraightToBrakeStateFrame,
|
||||
freeGravity,
|
||||
@@ -80,6 +126,7 @@ export function simulateTrajectory(
|
||||
brakeAirResist,
|
||||
brakeGravity,
|
||||
brakeToFreeFrame,
|
||||
brakeToFreeVelocityY,
|
||||
burstFrame,
|
||||
bounceAfterMaxSpeed,
|
||||
} = params;
|
||||
@@ -90,10 +137,11 @@ export function simulateTrajectory(
|
||||
const maxFrames = isBouncing ? 300 : (burstFrame ?? 300);
|
||||
|
||||
const points: TrajectoryPoint[] = [];
|
||||
let z = 0;
|
||||
const angleRadians = (spawnAngle * Math.PI) / 180;
|
||||
let z = spawnOffsetZ;
|
||||
let y = PLAYER_HEIGHT;
|
||||
let vz = spawnSpeed;
|
||||
let vy = 0;
|
||||
let vz = spawnSpeed * Math.cos(angleRadians);
|
||||
let vy = spawnSpeed * Math.sin(angleRadians);
|
||||
let frame = 0;
|
||||
let bounceCount = 0;
|
||||
|
||||
@@ -101,11 +149,16 @@ export function simulateTrajectory(
|
||||
|
||||
while (frame < goStraightToBrakeStateFrame && frame < maxFrames) {
|
||||
z += vz;
|
||||
y += vy;
|
||||
points.push({ z, y });
|
||||
frame++;
|
||||
}
|
||||
|
||||
vz = Math.min(vz, goStraightStateEndMaxSpeed);
|
||||
const speed = Math.hypot(vz, vy);
|
||||
if (speed > goStraightStateEndMaxSpeed) {
|
||||
vz *= goStraightStateEndMaxSpeed / speed;
|
||||
vy *= goStraightStateEndMaxSpeed / speed;
|
||||
}
|
||||
|
||||
for (let i = 0; i < brakeToFreeFrame && frame < maxFrames; i++) {
|
||||
vz *= 1 - brakeAirResist;
|
||||
@@ -128,6 +181,8 @@ export function simulateTrajectory(
|
||||
return points;
|
||||
}
|
||||
}
|
||||
|
||||
if (vy < brakeToFreeVelocityY) break;
|
||||
}
|
||||
|
||||
while (frame < maxFrames) {
|
||||
@@ -167,56 +222,111 @@ export function simulateTrajectory(
|
||||
return points;
|
||||
}
|
||||
|
||||
/** How many hits splat at point blank and up to which distance that many still do. */
|
||||
export interface LethalRange {
|
||||
shots: number;
|
||||
distance: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lethal range of damage falling off linearly between `distanceDamage` points (rollers, brushes),
|
||||
* `null` when the weapon splats in the same number of hits at every distance.
|
||||
*/
|
||||
export function lethalRange(
|
||||
distanceDamage: DistanceDamage[],
|
||||
): LethalRange | null {
|
||||
const [closest] = distanceDamage;
|
||||
if (!closest || closest.Damage <= 0) return null;
|
||||
|
||||
const shots = Math.ceil(SPLAT_DAMAGE / closest.Damage);
|
||||
const threshold = SPLAT_DAMAGE / shots;
|
||||
|
||||
for (let i = 1; i < distanceDamage.length; i++) {
|
||||
const near = distanceDamage[i - 1];
|
||||
const far = distanceDamage[i];
|
||||
if (far.Damage >= threshold) continue;
|
||||
|
||||
const t = (near.Damage - threshold) / (near.Damage - far.Damage);
|
||||
return {
|
||||
shots,
|
||||
distance: near.Distance + t * (far.Distance - near.Distance),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Range of a main weapon, `unsupported` for weapons the model can't simulate. */
|
||||
export interface WeaponRangeResult {
|
||||
range: number;
|
||||
blastRadius?: number;
|
||||
rangeType: "calculated" | "direct" | "unsupported";
|
||||
trajectory?: TrajectoryPoint[];
|
||||
lethal?: LethalRange;
|
||||
}
|
||||
|
||||
/** Range of a main weapon with the trajectory it was measured from. */
|
||||
/** One way of shooting a weapon with its range, `key` `null` for weapons that only have one. */
|
||||
export interface WeaponRangeVariant extends WeaponRangeResult {
|
||||
key: RangeVariantKey | null;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
/** Range of a main weapon's default way of shooting with the trajectory it was measured from. */
|
||||
export function ofMainWeapon(weaponId: MainWeaponId): WeaponRangeResult {
|
||||
return variantsOf(weaponId)[0];
|
||||
}
|
||||
|
||||
/** Every way of shooting a main weapon (a roller's vertical and horizontal swing…), the default first. */
|
||||
export function variantsOf(weaponId: MainWeaponId): WeaponRangeVariant[] {
|
||||
const category = getWeaponCategoryName(weaponId);
|
||||
|
||||
if (!category) {
|
||||
return { range: 0, rangeType: "unsupported" };
|
||||
return [{ key: null, isDefault: true, range: 0, rangeType: "unsupported" }];
|
||||
}
|
||||
|
||||
const params = mainWeaponParams(weaponId);
|
||||
const defaultRangeParams: RangeParams =
|
||||
category === "CHARGERS" && params.DistanceFullCharge !== undefined
|
||||
? { Range_Distance: params.DistanceFullCharge }
|
||||
: params;
|
||||
|
||||
if (category === "CHARGERS" && params.DistanceFullCharge !== undefined) {
|
||||
const range = params.DistanceFullCharge;
|
||||
return [
|
||||
{
|
||||
key: params.Range_VariantKey ?? null,
|
||||
isDefault: true,
|
||||
...rangeOf(defaultRangeParams),
|
||||
},
|
||||
...(params.Range_Variants ?? []).map((variant) => ({
|
||||
key: variant.Range_VariantKey,
|
||||
isDefault: false,
|
||||
...rangeOf(variant),
|
||||
})),
|
||||
];
|
||||
}
|
||||
|
||||
function rangeOf(params: RangeParams): WeaponRangeResult {
|
||||
const lethal = params.Range_DistanceDamage
|
||||
? (lethalRange(params.Range_DistanceDamage) ?? undefined)
|
||||
: undefined;
|
||||
|
||||
if (params.Range_Distance !== undefined) {
|
||||
return {
|
||||
range,
|
||||
range: params.Range_Distance,
|
||||
rangeType: "direct",
|
||||
trajectory: [
|
||||
{ z: 0, y: PLAYER_HEIGHT },
|
||||
{ z: range, y: PLAYER_HEIGHT },
|
||||
{ z: params.Range_Distance, y: PLAYER_HEIGHT },
|
||||
],
|
||||
lethal,
|
||||
};
|
||||
}
|
||||
|
||||
if (params.Range_SpawnSpeed === undefined) {
|
||||
const flightParams = trajectoryParams(params);
|
||||
if (!flightParams) {
|
||||
return { range: 0, rangeType: "unsupported" };
|
||||
}
|
||||
|
||||
const trajectoryParams: TrajectoryParams = {
|
||||
spawnSpeed: params.Range_SpawnSpeed,
|
||||
goStraightStateEndMaxSpeed:
|
||||
params.Range_GoStraightStateEndMaxSpeed ?? params.Range_SpawnSpeed,
|
||||
goStraightToBrakeStateFrame: params.Range_GoStraightToBrakeStateFrame ?? 4,
|
||||
freeGravity: params.Range_FreeGravity ?? DEFAULT_FREE_GRAVITY,
|
||||
freeAirResist: params.Range_FreeAirResist ?? DEFAULT_FREE_AIR_RESIST,
|
||||
brakeAirResist: params.Range_BrakeAirResist ?? DEFAULT_BRAKE_AIR_RESIST,
|
||||
brakeGravity: params.Range_BrakeGravity ?? DEFAULT_BRAKE_GRAVITY,
|
||||
brakeToFreeFrame:
|
||||
params.Range_BrakeToFreeStateFrame ?? DEFAULT_BRAKE_TO_FREE_FRAME,
|
||||
burstFrame: params.Range_BurstFrame,
|
||||
bounceAfterMaxSpeed: params.Range_BounceAfterMaxSpeed,
|
||||
};
|
||||
|
||||
const trajectory = simulateTrajectory(trajectoryParams);
|
||||
const trajectory = simulateTrajectory(flightParams);
|
||||
const range =
|
||||
params.Range_BounceAfterMaxSpeed !== undefined
|
||||
? bouncingRange(trajectory)
|
||||
@@ -227,32 +337,76 @@ export function ofMainWeapon(weaponId: MainWeaponId): WeaponRangeResult {
|
||||
blastRadius: params.BlastRadius,
|
||||
rangeType: "calculated",
|
||||
trajectory,
|
||||
lethal,
|
||||
};
|
||||
}
|
||||
|
||||
/** A comp's weapon with its range. */
|
||||
/** A comp's weapon with the ways of shooting it that are shown. */
|
||||
export interface WeaponWithRange {
|
||||
weaponId: MainWeaponId;
|
||||
/** Position in the comp, kept through the filtering so duplicates stay apart */
|
||||
slot: number;
|
||||
range: number;
|
||||
blastRadius?: number;
|
||||
rangeType: "calculated" | "direct" | "unsupported";
|
||||
trajectory?: TrajectoryPoint[];
|
||||
/** Shown ways of shooting, default first when it is one of them */
|
||||
variants: WeaponRangeVariant[];
|
||||
/** Every way of shooting the weapon has, empty when it has only one */
|
||||
allVariantKeys: RangeVariantKey[];
|
||||
}
|
||||
|
||||
/** Ranges of a comp's weapons, the ones the model can't simulate left out. */
|
||||
export function ofWeapons(weaponIds: MainWeaponId[]): WeaponWithRange[] {
|
||||
return weaponIds
|
||||
.map((weaponId, slot) => {
|
||||
const result = ofMainWeapon(weaponId);
|
||||
return {
|
||||
/**
|
||||
* Ranges of a comp's weapons, the ones the model can't simulate left out. `enabledVariantKeys` picks
|
||||
* which ways of shooting a weapon are shown, its default when it returns none it has.
|
||||
*/
|
||||
export function ofWeapons(
|
||||
weaponIds: MainWeaponId[],
|
||||
enabledVariantKeys: (weaponId: MainWeaponId) => RangeVariantKey[] = () => [],
|
||||
): WeaponWithRange[] {
|
||||
return weaponIds.flatMap((weaponId, slot) => {
|
||||
const all = variantsOf(weaponId).filter(
|
||||
(variant) => variant.rangeType !== "unsupported",
|
||||
);
|
||||
if (all.length === 0) return [];
|
||||
|
||||
const enabledKeys = enabledVariantKeys(weaponId);
|
||||
const enabled = all.filter(
|
||||
(variant) => variant.key !== null && enabledKeys.includes(variant.key),
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
weaponId,
|
||||
slot,
|
||||
...result,
|
||||
};
|
||||
})
|
||||
.filter((w) => w.rangeType !== "unsupported");
|
||||
variants: enabled.length > 0 ? enabled : [all[0]],
|
||||
allVariantKeys: all.flatMap((variant) =>
|
||||
variant.key !== null ? [variant.key] : [],
|
||||
),
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ways of shooting a comp's weapon to show after toggling `key`: empty when only the default is left,
|
||||
* `null` when the toggle would hide every one of them.
|
||||
*/
|
||||
export function toggleVariant(
|
||||
weapon: WeaponWithRange,
|
||||
key: RangeVariantKey,
|
||||
): RangeVariantKey[] | null {
|
||||
const shownKeys = weapon.variants.flatMap((variant) =>
|
||||
variant.key !== null ? [variant.key] : [],
|
||||
);
|
||||
const nextKeys = weapon.allVariantKeys.filter((variantKey) =>
|
||||
variantKey === key
|
||||
? !shownKeys.includes(variantKey)
|
||||
: shownKeys.includes(variantKey),
|
||||
);
|
||||
|
||||
if (nextKeys.length === 0) return null;
|
||||
if (nextKeys.length === 1 && nextKeys[0] === weapon.allVariantKeys[0]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return nextKeys;
|
||||
}
|
||||
|
||||
/** Weapons drawn under every comp's ranges for scale: Splattershot and Snipewriter 5H. */
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.selectedWeaponsColumn {
|
||||
width: 100%;
|
||||
max-width: 40rem;
|
||||
margin-inline: auto;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import clsx from "clsx";
|
||||
import { HardDriveDownload } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -20,8 +21,11 @@ import { metaTags, ogPageImage } from "../../../utils/remix";
|
||||
import { MAX_WEAPONS } from "../comp-analyzer-constants";
|
||||
import {
|
||||
useCategorization,
|
||||
useHiddenRanges,
|
||||
useRangeVariants,
|
||||
useSelectedWeapons,
|
||||
useSingleWeaponCombos,
|
||||
useSpecialRanges,
|
||||
useTargetSubDefenseAp,
|
||||
} from "../comp-analyzer-hooks";
|
||||
import { DamageComboList } from "../components/DamageComboBar";
|
||||
@@ -30,6 +34,7 @@ import { SelectedWeapons } from "../components/SelectedWeapons";
|
||||
import { WeaponCategories } from "../components/WeaponCategories";
|
||||
import { WeaponGrid } from "../components/WeaponGrid";
|
||||
import * as DamageCombos from "../core/DamageCombos";
|
||||
import styles from "./comp-analyzer.module.css";
|
||||
|
||||
export const meta: MetaFunction = (args) => {
|
||||
return metaTags({
|
||||
@@ -95,23 +100,25 @@ function CompAnalyzerPage() {
|
||||
};
|
||||
|
||||
return (
|
||||
<Main className="stack lg">
|
||||
<SelectedWeapons
|
||||
selectedWeaponIds={selectedWeaponIds}
|
||||
onRemove={handleRemoveWeapon}
|
||||
onReorder={setSelectedWeaponIds}
|
||||
/>
|
||||
<div className="stack horizontal justify-end">
|
||||
{selectedWeaponIds.length >= MAX_WEAPONS ? (
|
||||
<CompExportDialog
|
||||
weaponIds={selectedWeaponIds}
|
||||
excludedDamageKeys={excludedDamageKeys}
|
||||
/>
|
||||
) : (
|
||||
<SendouPopover trigger={<ExportButton />}>
|
||||
{t("analyzer:comp.exportHint", { max: MAX_WEAPONS })}
|
||||
</SendouPopover>
|
||||
)}
|
||||
<Main bigger className="stack lg">
|
||||
<div className={clsx(styles.selectedWeaponsColumn, "stack lg")}>
|
||||
<SelectedWeapons
|
||||
selectedWeaponIds={selectedWeaponIds}
|
||||
onRemove={handleRemoveWeapon}
|
||||
onReorder={setSelectedWeaponIds}
|
||||
/>
|
||||
<div className="stack horizontal justify-end">
|
||||
{selectedWeaponIds.length >= MAX_WEAPONS ? (
|
||||
<CompExportDialog
|
||||
weaponIds={selectedWeaponIds}
|
||||
excludedDamageKeys={excludedDamageKeys}
|
||||
/>
|
||||
) : (
|
||||
<SendouPopover trigger={<ExportButton />}>
|
||||
{t("analyzer:comp.exportHint", { max: MAX_WEAPONS })}
|
||||
</SendouPopover>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<WeaponCategories selectedWeaponIds={selectedWeaponIds} />
|
||||
<WeaponGrid
|
||||
@@ -191,6 +198,9 @@ function CompGraphicWithCombos({
|
||||
}) {
|
||||
const [singleWeaponCombos] = useSingleWeaponCombos();
|
||||
const [targetSubDefenseAp] = useTargetSubDefenseAp();
|
||||
const { enabledVariantKeys } = useRangeVariants();
|
||||
const { hiddenWeaponIds } = useHiddenRanges();
|
||||
const [showSpecialRanges] = useSpecialRanges();
|
||||
|
||||
const combos = DamageCombos.calculate(
|
||||
weaponIds,
|
||||
@@ -207,6 +217,9 @@ function CompGraphicWithCombos({
|
||||
title={title}
|
||||
showRanges={showRanges}
|
||||
showCombos={showCombos}
|
||||
enabledVariantKeys={enabledVariantKeys}
|
||||
hiddenRangeWeaponIds={hiddenWeaponIds}
|
||||
showSpecialRanges={showSpecialRanges}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
.rangeBarAlternate {
|
||||
background-image: repeating-linear-gradient(
|
||||
-45deg,
|
||||
transparent 0,
|
||||
transparent 4px,
|
||||
oklch(0% 0 0 / 0.25) 4px,
|
||||
oklch(0% 0 0 / 0.25) 8px
|
||||
);
|
||||
}
|
||||
|
||||
.rangeLabel {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
inset-inline-start: var(--s-1-5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: var(--font-2xs);
|
||||
font-weight: var(--weight-bold);
|
||||
line-height: 1;
|
||||
color: oklch(20% 0 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rangeLethalTick {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
z-index: 1;
|
||||
width: 0;
|
||||
border-left: 2px solid oklch(20% 0 0 / 0.75);
|
||||
}
|
||||
|
||||
.rangeIconSpacer {
|
||||
width: 28px;
|
||||
}
|
||||
|
||||
.rangeBlast {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
SubWeaponImage,
|
||||
WeaponImage,
|
||||
} from "~/components/Image";
|
||||
import type { RangeVariantKey } from "~/features/build-analyzer/analyzer-types";
|
||||
import { mainWeaponParams } from "~/features/build-analyzer/core/utils";
|
||||
import {
|
||||
LETHAL_DAMAGE,
|
||||
@@ -16,6 +17,7 @@ import type {
|
||||
DamageCombo,
|
||||
DamageSegment,
|
||||
} from "~/features/comp-analyzer/comp-analyzer-types";
|
||||
import * as SpecialWeaponRange from "~/features/comp-analyzer/core/SpecialWeaponRange";
|
||||
import * as WeaponRange from "~/features/comp-analyzer/core/WeaponRange";
|
||||
import type { MainWeaponId } from "~/modules/in-game-lists/types";
|
||||
import { COMP_ANALYZER_URL, navIconUrl } from "~/utils/urls";
|
||||
@@ -40,6 +42,9 @@ export function CompGraphic({
|
||||
title,
|
||||
showRanges = true,
|
||||
showCombos = true,
|
||||
enabledVariantKeys,
|
||||
hiddenRangeWeaponIds = [],
|
||||
showSpecialRanges = false,
|
||||
}: {
|
||||
weaponIds: MainWeaponId[];
|
||||
/** Without a title the whole header is left out */
|
||||
@@ -48,10 +53,21 @@ export function CompGraphic({
|
||||
combos: DamageCombo[];
|
||||
showRanges?: boolean;
|
||||
showCombos?: boolean;
|
||||
/** Ways of shooting each weapon drawn in the range chart, its default when none */
|
||||
enabledVariantKeys?: (weaponId: MainWeaponId) => RangeVariantKey[];
|
||||
/** Weapons left out of the range chart */
|
||||
hiddenRangeWeaponIds?: MainWeaponId[];
|
||||
showSpecialRanges?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation(["analyzer"]);
|
||||
|
||||
const weaponsWithRange = WeaponRange.ofWeapons(weaponIds);
|
||||
const weaponsWithRange = WeaponRange.ofWeapons(
|
||||
weaponIds,
|
||||
enabledVariantKeys,
|
||||
).filter((weapon) => !hiddenRangeWeaponIds.includes(weapon.weaponId));
|
||||
const specialRanges = showSpecialRanges
|
||||
? SpecialWeaponRange.ofWeapons(weaponIds)
|
||||
: [];
|
||||
const topCombos = combos.slice(0, MAX_COMBOS);
|
||||
|
||||
return (
|
||||
@@ -78,12 +94,15 @@ export function CompGraphic({
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{showRanges && weaponsWithRange.length > 0 ? (
|
||||
{showRanges && weaponsWithRange.length + specialRanges.length > 0 ? (
|
||||
<>
|
||||
<GraphicSectionDivider>
|
||||
{t("analyzer:comp.weaponRanges")}
|
||||
</GraphicSectionDivider>
|
||||
<RangeChart weapons={weaponsWithRange} />
|
||||
<RangeChart
|
||||
weapons={weaponsWithRange}
|
||||
specialRanges={specialRanges}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
{showCombos && topCombos.length > 0 ? (
|
||||
@@ -146,52 +165,111 @@ function WeaponRow({
|
||||
|
||||
function RangeChart({
|
||||
weapons,
|
||||
specialRanges,
|
||||
}: {
|
||||
weapons: Array<{
|
||||
weaponId: MainWeaponId;
|
||||
range: number;
|
||||
blastRadius?: number;
|
||||
slot: number;
|
||||
}>;
|
||||
weapons: WeaponRange.WeaponWithRange[];
|
||||
specialRanges: SpecialWeaponRange.CompSpecialWithRange[];
|
||||
}) {
|
||||
const { t } = useTranslation(["analyzer"]);
|
||||
|
||||
return (
|
||||
<div className={styles.rangeChart}>
|
||||
{weapons.map((weapon) => (
|
||||
<div
|
||||
key={`${weapon.weaponId}-${weapon.slot}`}
|
||||
className={styles.rangeRow}
|
||||
>
|
||||
<WeaponImage
|
||||
weaponSplId={weapon.weaponId}
|
||||
variant="build"
|
||||
{weapons.flatMap((weapon) =>
|
||||
weapon.variants.map((variant, index) => (
|
||||
<div
|
||||
key={`${weapon.weaponId}-${weapon.slot}-${variant.key}`}
|
||||
className={styles.rangeRow}
|
||||
>
|
||||
{index === 0 ? (
|
||||
<WeaponImage
|
||||
weaponSplId={weapon.weaponId}
|
||||
variant="build"
|
||||
size={28}
|
||||
/>
|
||||
) : (
|
||||
<div className={styles.rangeIconSpacer} />
|
||||
)}
|
||||
<RangeTrack
|
||||
slot={weapon.slot}
|
||||
range={variant.range}
|
||||
blastRadius={variant.blastRadius}
|
||||
lethalDistance={variant.lethal?.distance}
|
||||
isAlternate={!variant.isDefault}
|
||||
label={
|
||||
variant.key && weapon.allVariantKeys.length > 0
|
||||
? t(`analyzer:comp.rangeVariant.${variant.key}`)
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<div className={styles.rangeValue}>{variant.range.toFixed(1)}</div>
|
||||
</div>
|
||||
)),
|
||||
)}
|
||||
{specialRanges.map((special) => (
|
||||
<div key={`special-${special.slot}`} className={styles.rangeRow}>
|
||||
<SpecialWeaponImage
|
||||
specialWeaponId={special.specialWeaponId}
|
||||
size={28}
|
||||
/>
|
||||
<div className={styles.rangeTrack}>
|
||||
<div
|
||||
className={clsx(styles.rangeBar, styles.slot, {
|
||||
[styles.rangeBarWithBlast]: Boolean(weapon.blastRadius),
|
||||
})}
|
||||
data-slot={weapon.slot}
|
||||
style={{ width: rangePercentage(weapon.range) }}
|
||||
/>
|
||||
{weapon.blastRadius ? (
|
||||
<div
|
||||
className={clsx(styles.rangeBlast, styles.slot)}
|
||||
data-slot={weapon.slot}
|
||||
style={{
|
||||
left: rangePercentage(weapon.range),
|
||||
width: rangePercentage(weapon.blastRadius),
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={styles.rangeValue}>{weapon.range.toFixed(1)}</div>
|
||||
<RangeTrack
|
||||
slot={special.slot}
|
||||
range={special.range}
|
||||
blastRadius={special.blastRadius}
|
||||
/>
|
||||
<div className={styles.rangeValue}>{special.range.toFixed(1)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RangeTrack({
|
||||
slot,
|
||||
range,
|
||||
blastRadius,
|
||||
lethalDistance,
|
||||
isAlternate = false,
|
||||
label,
|
||||
}: {
|
||||
slot: number;
|
||||
range: number;
|
||||
blastRadius?: number;
|
||||
lethalDistance?: number;
|
||||
isAlternate?: boolean;
|
||||
label?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={styles.rangeTrack}>
|
||||
<div
|
||||
className={clsx(styles.rangeBar, styles.slot, {
|
||||
[styles.rangeBarWithBlast]: Boolean(blastRadius),
|
||||
[styles.rangeBarAlternate]: isAlternate,
|
||||
})}
|
||||
data-slot={slot}
|
||||
style={{ width: rangePercentage(range) }}
|
||||
>
|
||||
{label ? <span className={styles.rangeLabel}>{label}</span> : null}
|
||||
</div>
|
||||
{blastRadius ? (
|
||||
<div
|
||||
className={clsx(styles.rangeBlast, styles.slot)}
|
||||
data-slot={slot}
|
||||
style={{
|
||||
left: rangePercentage(range),
|
||||
width: rangePercentage(blastRadius),
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{lethalDistance ? (
|
||||
<div
|
||||
className={styles.rangeLethalTick}
|
||||
style={{ left: rangePercentage(lethalDistance) }}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ComboRow({ combo }: { combo: DamageCombo }) {
|
||||
const { t } = useTranslation(["analyzer"]);
|
||||
|
||||
|
||||
11
changelog/2026-10-28-comp-analyzer-range-variants.md
Normal file
11
changelog/2026-10-28-comp-analyzer-range-variants.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
navItem: comp-analyzer
|
||||
type: feature
|
||||
---
|
||||
Comp analyzer range chart shows more than max range
|
||||
|
||||
- Toggle other ways of shooting a weapon: roller and Splatana swings, Squeezer hold, Ballpoint short range, S-BLAST jump shots, charger taps, stringer partial charges and dualie turrets
|
||||
- Rollers and brushes mark how far they still splat in their fewest hits
|
||||
- Show the ranges of the comp's special weapons
|
||||
- Hide a weapon from the range chart by clicking its icon
|
||||
- Wider page and a taller range chart, so overlapping trajectories are easier to tell apart
|
||||
5
changelog/2026-10-28-weapon-range-accuracy.md
Normal file
5
changelog/2026-10-28-weapon-range-accuracy.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
navItem: [comp-analyzer, plans]
|
||||
type: bug
|
||||
---
|
||||
More accurate weapon ranges: sloshers and brushes no longer reach too far, blaster shots burst mid-air, vertical roller flicks fly further, Trizooka reaches further and Crab Tank shows its cannon range
|
||||
@@ -212,6 +212,22 @@
|
||||
"comp.enemySubDef": "Enemy Sub Defense Up",
|
||||
"comp.weaponRanges": "Weapon Ranges",
|
||||
"comp.damageCombos": "Damage Combos",
|
||||
"comp.specialRanges": "Special ranges",
|
||||
"comp.hideFromRangeChart": "Hide {{weapon}} from the range chart",
|
||||
"comp.showInRangeChart": "Show {{weapon}} in the range chart",
|
||||
"comp.lethalRange": "{{shots}}-shot ≤ {{distance}}",
|
||||
"comp.rangeVariant.vertical": "Vertical",
|
||||
"comp.rangeVariant.horizontal": "Horizontal",
|
||||
"comp.rangeVariant.tap": "Tap",
|
||||
"comp.rangeVariant.hold": "Hold",
|
||||
"comp.rangeVariant.long": "Long",
|
||||
"comp.rangeVariant.short": "Short",
|
||||
"comp.rangeVariant.ground": "Ground",
|
||||
"comp.rangeVariant.jump": "Jump",
|
||||
"comp.rangeVariant.charged": "Charged",
|
||||
"comp.rangeVariant.partialCharge": "Partial charge",
|
||||
"comp.rangeVariant.standard": "Standard",
|
||||
"comp.rangeVariant.turret": "Turret",
|
||||
"comp.subRoles": "Sub weapon roles",
|
||||
"comp.specialRoles": "Special weapon roles",
|
||||
"comp.subCategory.LETHAL": "One-hit",
|
||||
|
||||
@@ -6,8 +6,10 @@ import { fileURLToPath } from "node:url";
|
||||
import * as v from "valibot";
|
||||
import type {
|
||||
BaseWeaponStats,
|
||||
DistanceDamage,
|
||||
MainWeaponParams,
|
||||
ParamsJson,
|
||||
RangeParams,
|
||||
SubWeaponParams,
|
||||
WeaponKit,
|
||||
} from "~/features/build-analyzer/analyzer-types";
|
||||
@@ -256,7 +258,15 @@ function getWeaponCategoryName(weaponId: number): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function extractRangeParams(weapon: MainWeapon, params: any) {
|
||||
function extractRangeParams(
|
||||
weapon: MainWeapon,
|
||||
params: any,
|
||||
): RangeParams &
|
||||
Pick<BaseWeaponStats, "Range_VariantKey" | "Range_Variants"> &
|
||||
Pick<
|
||||
BaseWeaponStats,
|
||||
"DistanceFullCharge" | "DistanceMaxCharge" | "DistanceMinCharge"
|
||||
> {
|
||||
const category = getWeaponCategoryName(weapon.Id);
|
||||
const isBrella = category === "BRELLAS";
|
||||
const isSlosher = category === "SLOSHERS";
|
||||
@@ -265,14 +275,31 @@ function extractRangeParams(weapon: MainWeapon, params: any) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const zRate = params.spl__SpawnBulletAdditionMovePlayerParam?.ZRate;
|
||||
const isCharger = params.MoveParam?.$type === "spl__BulletChargerMoveParam";
|
||||
|
||||
if (isCharger) {
|
||||
return {
|
||||
const chargeDistances = {
|
||||
DistanceFullCharge: params.MoveParam?.DistanceFullCharge,
|
||||
DistanceMaxCharge: params.MoveParam?.DistanceMaxCharge,
|
||||
DistanceMinCharge: params.MoveParam?.DistanceMinCharge,
|
||||
};
|
||||
if (
|
||||
chargeDistances.DistanceMinCharge === chargeDistances.DistanceFullCharge
|
||||
) {
|
||||
return chargeDistances;
|
||||
}
|
||||
|
||||
return {
|
||||
...chargeDistances,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
Range_VariantKey: "tap",
|
||||
Range_Distance: chargeDistances.DistanceMinCharge,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (isSlosher) {
|
||||
@@ -284,59 +311,89 @@ function extractRangeParams(weapon: MainWeapon, params: any) {
|
||||
: best,
|
||||
units?.[0],
|
||||
);
|
||||
const moveParam = unitForRange?.MoveParam;
|
||||
const isBloblobber = weapon.Id === 3030 || weapon.Id === 3031;
|
||||
const bounceAfterMaxSpeed = params.BounceGroupParam?.BounceParam?.find(
|
||||
(bounceParam: any) => bounceParam.BounceAfterMaxSpeed !== undefined,
|
||||
)?.BounceAfterMaxSpeed;
|
||||
return {
|
||||
Range_SpawnSpeed: unitForRange?.SpawnSpeedGround,
|
||||
Range_GoStraightStateEndMaxSpeed: moveParam?.GoStraightStateEndMaxSpeed,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_FreeGravity: moveParam?.FreeGravity,
|
||||
Range_BrakeAirResist: moveParam?.BrakeAirResist,
|
||||
Range_BrakeGravity: moveParam?.BrakeGravity,
|
||||
Range_BrakeToFreeStateFrame: moveParam?.BrakeToFreeStateFrame,
|
||||
Range_ZRate: params.spl__SpawnBulletAdditionMovePlayerParam?.ZRate,
|
||||
Range_BounceAfterMaxSpeed: isBloblobber ? 0.6 : undefined,
|
||||
Range_BurstFrame: isBloblobber ? 3 : undefined,
|
||||
...rangeParamsFromMoveParam(
|
||||
unitForRange?.MoveParam,
|
||||
unitForRange?.SpawnSpeedGround,
|
||||
),
|
||||
Range_ZRate: zRate,
|
||||
Range_BounceAfterMaxSpeed: isBloblobber ? bounceAfterMaxSpeed : undefined,
|
||||
Range_BurstFrame: isBloblobber ? BLOBLOBBER_BOUNCES : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
const isRoller = category === "ROLLERS";
|
||||
if (isRoller) {
|
||||
const unit = params.VerticalSwingUnitGroupParam?.Unit?.[0];
|
||||
const moveParam = unit?.UnitParam?.MoveParam;
|
||||
const verticalUnit = params.VerticalSwingUnitGroupParam?.Unit?.[0];
|
||||
const horizontalUnit = params.WideSwingUnitGroupParam?.Unit?.[0];
|
||||
return {
|
||||
Range_SpawnSpeed: unit?.SpawnSpeedBase,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_FreeGravity: moveParam?.FreeGravity,
|
||||
Range_FreeAirResist: moveParam?.FreeAirResist,
|
||||
Range_ZRate: params.spl__SpawnBulletAdditionMovePlayerParam?.ZRate,
|
||||
...rangeParamsFromMoveParam(
|
||||
verticalUnit?.UnitParam?.MoveParam,
|
||||
verticalUnit?.SpawnSpeedBase,
|
||||
),
|
||||
Range_SpawnAngle: verticalUnit?.SpawnRotateXDegreeBase,
|
||||
Range_DistanceDamage: distanceDamageCurve(
|
||||
params.VerticalSwingUnitGroupParam?.DamageParam?.Inside,
|
||||
),
|
||||
Range_ZRate: zRate,
|
||||
Range_VariantKey: "vertical",
|
||||
Range_Variants: [
|
||||
{
|
||||
...rangeParamsFromMoveParam(
|
||||
horizontalUnit?.UnitParam?.MoveParam,
|
||||
horizontalUnit?.SpawnSpeedBase,
|
||||
),
|
||||
Range_DistanceDamage: distanceDamageCurve(
|
||||
params.WideSwingUnitGroupParam?.DamageParam?.Inside,
|
||||
),
|
||||
Range_VariantKey: "horizontal",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const isBrush = category === "BRUSHES";
|
||||
if (isBrush) {
|
||||
const unit = params.SwingUnitGroupParam?.Unit?.[0];
|
||||
const moveParam = unit?.UnitParam?.MoveParam;
|
||||
return {
|
||||
Range_SpawnSpeed: unit?.SpawnSpeedBase,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_ZRate: params.spl__SpawnBulletAdditionMovePlayerParam?.ZRate,
|
||||
...rangeParamsFromMoveParam(
|
||||
unit?.UnitParam?.MoveParam,
|
||||
unit?.SpawnSpeedBase,
|
||||
),
|
||||
Range_DistanceDamage: distanceDamageCurve(
|
||||
params.SwingUnitGroupParam?.DamageParam?.Inside,
|
||||
),
|
||||
Range_ZRate: zRate,
|
||||
};
|
||||
}
|
||||
|
||||
const isSplatana = category === "SPLATANAS";
|
||||
if (isSplatana) {
|
||||
const bulletParam = params.BulletSaberVerticalParam;
|
||||
const moveParam = bulletParam?.MoveParam;
|
||||
return {
|
||||
Range_SpawnSpeed: moveParam?.SpawnSpeed,
|
||||
Range_GoStraightStateEndMaxSpeed: moveParam?.GoStraightStateEndMaxSpeed,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_FreeGravity: moveParam?.FreeGravity,
|
||||
Range_BrakeAirResist: moveParam?.BrakeAirResist,
|
||||
Range_BrakeGravity: moveParam?.BrakeGravity,
|
||||
Range_BrakeToFreeStateFrame: moveParam?.BrakeToFreeStateFrame,
|
||||
const swingParam = params.spl__WeaponSaberParam?.SwingParam;
|
||||
const splatanaRangeParams = (bulletParam: any, shotBulletOffset: any) => ({
|
||||
...rangeParamsFromMoveParam(bulletParam?.MoveParam),
|
||||
Range_SpawnOffsetZ: shotBulletOffset?.Z,
|
||||
Range_BurstFrame: bulletParam?.BurstParam?.BurstFrame,
|
||||
});
|
||||
return {
|
||||
...splatanaRangeParams(
|
||||
params.BulletSaberVerticalParam,
|
||||
swingParam?.ShotBulletOffset_Vertical,
|
||||
),
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
...splatanaRangeParams(
|
||||
params.BulletSaberHorizontalParam,
|
||||
swingParam?.ShotBulletOffset_R,
|
||||
),
|
||||
Range_VariantKey: "tap",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -350,50 +407,172 @@ function extractRangeParams(weapon: MainWeapon, params: any) {
|
||||
? undefined
|
||||
: bulletParam?.DetonationParam?.BlastParam?.DistanceDamage?.[0]?.Distance;
|
||||
return {
|
||||
Range_SpawnSpeed: moveParam?.SpawnSpeedMax,
|
||||
Range_GoStraightStateEndMaxSpeed: moveParam?.GoStraightStateEndMaxSpeed,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_FreeGravity: moveParam?.FreeGravity,
|
||||
Range_FreeAirResist: moveParam?.FreeAirResist,
|
||||
Range_BrakeAirResist: moveParam?.BrakeAirResist,
|
||||
Range_BrakeGravity: moveParam?.BrakeGravity,
|
||||
Range_BrakeToFreeStateFrame: moveParam?.BrakeToFreeStateFrame,
|
||||
...rangeParamsFromMoveParam(moveParam, moveParam?.SpawnSpeedMax),
|
||||
BlastRadius: blastRadius,
|
||||
Range_VariantKey: "charged",
|
||||
Range_Variants: [
|
||||
{
|
||||
...rangeParamsFromMoveParam(moveParam, moveParam?.SpawnSpeedMid),
|
||||
BlastRadius: blastRadius,
|
||||
Range_VariantKey: "partialCharge",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const isSplatling = category === "SPLATLINGS";
|
||||
if (isSplatling) {
|
||||
const isBallpoint = weapon.Id === 4030 || weapon.Id === 4031;
|
||||
const moveParam = isBallpoint ? params.VariableMoveParam : params.MoveParam;
|
||||
const splatlingRangeParams = (moveParam: any) =>
|
||||
rangeParamsFromMoveParam(
|
||||
moveParam,
|
||||
moveParam?.SpawnSpeedFirstLastAndSecond,
|
||||
);
|
||||
if (isBallpoint) {
|
||||
return {
|
||||
...splatlingRangeParams(params.VariableMoveParam),
|
||||
Range_VariantKey: "long",
|
||||
Range_Variants: [
|
||||
{
|
||||
...splatlingRangeParams(params.MoveParam),
|
||||
Range_VariantKey: "short",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
return splatlingRangeParams(params.MoveParam);
|
||||
}
|
||||
|
||||
if (isBrella) {
|
||||
return {
|
||||
Range_SpawnSpeed: isBallpoint
|
||||
? moveParam?.SpawnSpeed
|
||||
: moveParam?.SpawnSpeedFirstLastAndSecond,
|
||||
Range_GoStraightStateEndMaxSpeed: moveParam?.GoStraightStateEndMaxSpeed,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
...rangeParamsFromMoveParam(
|
||||
params.spl__BulletShelterShotgunParam?.GroupParams?.[0]?.MoveParam,
|
||||
),
|
||||
Range_ZRate: zRate,
|
||||
};
|
||||
}
|
||||
|
||||
const isBlaster = params.BlastParam?.DistanceDamage !== undefined;
|
||||
const blastRadius = isBlaster
|
||||
? params.BlastParam?.DistanceDamage?.[1]?.Distance
|
||||
: undefined;
|
||||
if (isBlaster) {
|
||||
const blasterRangeParams = (
|
||||
moveParam: any,
|
||||
burstParam: any,
|
||||
blastParam: any,
|
||||
) => ({
|
||||
...rangeParamsFromMoveParam(moveParam),
|
||||
Range_BurstFrame:
|
||||
burstParam?.BurstFrame ?? params.WeaponParam?.ShotGuideFrame,
|
||||
Range_ZRate: zRate,
|
||||
BlastRadius: blastParam?.DistanceDamage?.[1]?.Distance,
|
||||
});
|
||||
const groundRangeParams = blasterRangeParams(
|
||||
params.MoveParam,
|
||||
params.BlasterBurstParam,
|
||||
params.BlastParam,
|
||||
);
|
||||
if (!params.MoveJumpParam) return groundRangeParams;
|
||||
|
||||
const moveParam = isBrella
|
||||
? params.spl__BulletShelterShotgunParam?.GroupParams?.[0]?.MoveParam
|
||||
: params.MoveParam;
|
||||
return {
|
||||
...groundRangeParams,
|
||||
Range_VariantKey: "ground",
|
||||
Range_Variants: [
|
||||
{
|
||||
...blasterRangeParams(
|
||||
params.MoveJumpParam,
|
||||
params.BlasterBurstJumpParam,
|
||||
params.BlastJumpParam,
|
||||
),
|
||||
Range_VariantKey: "jump",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const shooterRangeParams = (moveParam: any) => ({
|
||||
...rangeParamsFromMoveParam(moveParam),
|
||||
Range_ZRate: zRate,
|
||||
});
|
||||
|
||||
if (params.MoveLapOverParam) {
|
||||
return {
|
||||
...shooterRangeParams(params.MoveParam),
|
||||
Range_VariantKey: "standard",
|
||||
Range_Variants: [
|
||||
{
|
||||
...shooterRangeParams(params.MoveLapOverParam),
|
||||
Range_VariantKey: "turret",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (params.VariableMoveParam) {
|
||||
return {
|
||||
...shooterRangeParams(params.MoveParam),
|
||||
Range_VariantKey: "tap",
|
||||
Range_Variants: [
|
||||
{
|
||||
...shooterRangeParams(params.VariableMoveParam),
|
||||
Range_VariantKey: "hold",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return shooterRangeParams(params.MoveParam);
|
||||
}
|
||||
|
||||
// how many times a Bloblobber bubble bounces before bursting, not in the params
|
||||
const BLOBLOBBER_BOUNCES = 3;
|
||||
|
||||
function rangeParamsFromMoveParam(
|
||||
moveParam: any,
|
||||
spawnSpeed: number | undefined = moveParam?.SpawnSpeed,
|
||||
): RangeParams {
|
||||
return {
|
||||
Range_SpawnSpeed: moveParam?.SpawnSpeed,
|
||||
Range_SpawnSpeed: spawnSpeed,
|
||||
Range_GoStraightStateEndMaxSpeed: moveParam?.GoStraightStateEndMaxSpeed,
|
||||
Range_GoStraightToBrakeStateFrame: moveParam?.GoStraightToBrakeStateFrame,
|
||||
Range_FreeGravity: moveParam?.FreeGravity,
|
||||
Range_ZRate: params.spl__SpawnBulletAdditionMovePlayerParam?.ZRate,
|
||||
BlastRadius: blastRadius,
|
||||
Range_FreeAirResist: moveParam?.FreeAirResist,
|
||||
Range_BrakeAirResist: moveParam?.BrakeAirResist,
|
||||
Range_BrakeGravity: moveParam?.BrakeGravity,
|
||||
Range_BrakeToFreeStateFrame: moveParam?.BrakeToFreeStateFrame,
|
||||
Range_BrakeToFreeVelocityY: moveParam?.BrakeToFreeVelocityY,
|
||||
};
|
||||
}
|
||||
|
||||
// roller & brush ink damage falls off linearly between these distances
|
||||
function distanceDamageCurve(damageParam: any): DistanceDamage[] | undefined {
|
||||
if (!damageParam) return undefined;
|
||||
|
||||
const points: DistanceDamage[] = [
|
||||
{
|
||||
Damage: damageParam.DamageMaxValue,
|
||||
Distance: damageParam.DamageMaxDistance,
|
||||
},
|
||||
{
|
||||
Damage: damageParam.DamageHighValue,
|
||||
Distance: damageParam.DamageHighDistance,
|
||||
},
|
||||
{
|
||||
Damage: damageParam.DamageLowValue,
|
||||
Distance: damageParam.DamageLowDistance,
|
||||
},
|
||||
{
|
||||
Damage: damageParam.DamageMinValue,
|
||||
Distance: damageParam.DamageMinDistance,
|
||||
},
|
||||
];
|
||||
|
||||
return points.filter(
|
||||
(point, i) =>
|
||||
i === 0 ||
|
||||
point.Damage !== points[i - 1].Damage ||
|
||||
point.Distance !== points[i - 1].Distance,
|
||||
);
|
||||
}
|
||||
|
||||
function parametersToMainWeaponResult(
|
||||
weapon: MainWeapon,
|
||||
params: any,
|
||||
@@ -720,6 +899,8 @@ const BOOYAH_BOMB_FLY_DISTANCE = 27;
|
||||
const SUPER_CHUMP_FLY_DISTANCE = 30;
|
||||
const TRIPLE_INKSTRIKE_FLY_DISTANCE = 28;
|
||||
const ULTRA_STAMP_FLY_DISTANCE = 24;
|
||||
// not in the params, value from the "Calculating weapon range" community sheet
|
||||
const CRAB_TANK_CANNON_SPAWN_SPEED = 2;
|
||||
|
||||
// Range circles for the map planner (see app/features/comp-analyzer/core/SpecialWeaponRange.ts):
|
||||
// travel distance plus blast, or a single effect radius. Global (Tenta Missiles, Killer Wail), placed/utility
|
||||
@@ -740,6 +921,7 @@ function specialWeaponRangeParams(
|
||||
Range_BrakeAirResist: moveParam?.BrakeAirResist,
|
||||
Range_BrakeGravity: moveParam?.BrakeGravity,
|
||||
Range_BrakeToFreeStateFrame: moveParam?.BrakeToFreeStateFrame,
|
||||
Range_BrakeToFreeVelocityY: moveParam?.BrakeToFreeVelocityY,
|
||||
});
|
||||
|
||||
switch (specialWeapon.__RowId) {
|
||||
@@ -753,9 +935,10 @@ function specialWeaponRangeParams(
|
||||
Range_Distance: rawParams.MoveParam?.Distance,
|
||||
Range_BlastRadius: outerBlastDistance(rawParams.BlastParam),
|
||||
};
|
||||
case "SpChariot": // Crab Tank (rapid gun reach)
|
||||
case "SpChariot": // Crab Tank (cannon shot)
|
||||
return {
|
||||
...trajectoryFromMoveParam(rawParams.ShooterMoveParam),
|
||||
...trajectoryFromMoveParam(rawParams.CannonParam?.MoveParam),
|
||||
Range_SpawnSpeed: CRAB_TANK_CANNON_SPAWN_SPEED,
|
||||
Range_BlastRadius: outerBlastDistance(
|
||||
rawParams.CannonParam?.BlastParam,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user