vehicle abilities and their characteristics

This commit is contained in:
tresabhi committed 2026-11-15 21:14:09 -06:00
1 parent 79129ff3c0
commit b48a68b8de
21 files changed
+1664 -258

No files matched your search

+817 -1
View File
@@ -4,7 +4,7 @@ import {
normalizeBoundingBox,
unionBoundingBox,
} from "@blitzkit/core";
import { ShellType, TankClass } from "@blitzkit/protos";
import { ShellType, TankClass, type GunDefinition } from "@blitzkit/protos";
import type { Vector2Tuple } from "three";
import { shellSlot } from "../tankopedia/augments";
import { hullTraverseSpeed } from "../tankopedia/hullTraverseSpeed";
@@ -15,6 +15,36 @@ import {
type Characteristic,
} from "../types/characteristics";
// The reload a gun shows. An auto reloader has no single one, so it shows none
function reloadOf(gun: GunDefinition) {
const type = gun.gun_type;
if (type?.$case === "regular") return type.value.reload;
if (type?.$case === "auto_loader") return type.value.clip_reload;
return 0;
}
// The shells in a gun's clip, or none for a gun without one
function shellsPerClipOf(gun: GunDefinition) {
const type = gun.gun_type;
if (type?.$case === "auto_loader") return type.value.shell_count;
if (type?.$case === "auto_reloader") return type.value.shell_count;
return 0;
}
// The time between a clip's shells, or none for a gun without a clip
function intraClipOf(gun: GunDefinition) {
const type = gun.gun_type;
if (type?.$case === "auto_loader") return type.value.intra_clip;
if (type?.$case === "auto_reloader") return type.value.intra_clip;
return 0;
}
/**
* peek-a-boo assumes at least this many seconds between shots to account for
* peeking out, aiming, and retreating
@@ -1358,6 +1388,792 @@ export const characteristics = {
},
},
// Abilities. A tank only gets the ones it has, which is whether the
// protagonist carries the ability's script
steady_aim_system_duration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("SteadyAimSystem"),
compute({ script, augment }) {
let duration = 0;
script("protagonist", "SteadyAimSystem", (effect) => {
duration += effect.duration ?? 0;
});
augment("SAS_DURATION", (value) => {
duration += value;
});
return duration;
},
},
steady_aim_system_aiming_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("SteadyAimSystem"),
compute({ script, augment }) {
let speed = 0;
script("protagonist", "SteadyAimSystem", (effect) => {
speed += effect.aimingSpeed ?? 0;
});
augment("SAS_AIMING_SPEED", (value) => {
speed += value;
});
return speed * 100;
},
},
steady_aim_system_dispersion: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("SteadyAimSystem"),
compute({ script, augment }) {
let dispersion = 0;
script("protagonist", "SteadyAimSystem", (effect) => {
dispersion += effect.gunDispersionModifier ?? 0;
});
augment("SAS_GUN_DISPERSION", (value) => {
dispersion += value;
});
return dispersion * 100;
},
},
steady_aim_system_activation_condition: {
type: CharacteristicType.Enum,
should_render: ({ hasScript }) => hasScript("SteadyAimSystem"),
compute({ script, augment }) {
let onHit = false;
script("protagonist", "SteadyAimSystem", (effect) => {
onHit = effect.activateWithoutDamage === true;
});
augment("SAS_ALLOW_ACTIVATE_ON_HIT", (value) => {
onHit = value !== 0;
});
return onHit ? "on_hit" : "on_damage";
},
},
burst_mode_count: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("BurstMode"),
compute({ script }) {
let count = 0;
script("protagonist", "BurstMode", (effect) => {
count += effect.count ?? 0;
});
return count;
},
},
burst_mode_interval: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("BurstMode"),
compute({ script, augment }) {
let interval = 0;
script("protagonist", "BurstMode", (effect) => {
interval += effect.burstInterval ?? 0;
});
augment("BURST_MODE_INTERVAL", (value) => {
interval += value;
});
return interval;
},
},
burst_mode_penetrations: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("BurstMode"),
compute({ script, augment }) {
let penetrations = 0;
script("protagonist", "BurstMode", (effect) => {
penetrations += effect.requiredDamagingPenetrations ?? 0;
});
augment("BURST_MODE_REQUIRED_PENETRATIONS", (value) => {
penetrations += value;
});
return penetrations;
},
},
burst_mode_target_order: {
type: CharacteristicType.Enum,
should_render: ({ hasScript }) => hasScript("BurstMode"),
compute({ script, augment }) {
let order = false;
script("protagonist", "BurstMode", (effect) => {
order = effect.targetOrder === true;
});
augment("BURST_MODE_TARGET_ORDER", (value) => {
order = value !== 0;
});
return order ? "yes" : "no";
},
},
combat_frenzy_reload_bonus: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("CombatFrenzy"),
compute({ script, augment }) {
let bonus = 0;
script("protagonist", "CombatFrenzy", (effect) => {
bonus += effect.reloadSpeedBonusPerStack ?? 0;
});
augment("COMBAT_FRENZY_RELOAD_SPEED_BONUS_PER_STACK", (value) => {
bonus += value;
});
return bonus * 100;
},
},
combat_frenzy_max_stacks: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("CombatFrenzy"),
compute({ script, augment }) {
let stacks = 0;
script("protagonist", "CombatFrenzy", (effect) => {
stacks += effect.maxStacks ?? 0;
});
augment("COMBAT_FRENZY_MAX_STACKS", (value) => {
stacks += value;
});
return stacks;
},
},
combat_frenzy_keep_stacks: {
type: CharacteristicType.Enum,
should_render: ({ hasScript }) => hasScript("CombatFrenzy"),
compute({ script, augment }) {
let keep = false;
script("protagonist", "CombatFrenzy", (effect) => {
keep = effect.allowSwitchAfterKill === true;
});
augment("COMBAT_FRENZY_ALLOW_SWITCH_AFTER_KILL", (value) => {
keep = value !== 0;
});
return keep ? "yes" : "no";
},
},
external_ammo_module_clip_bonus: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ExternalAmmoModule"),
compute({ script }) {
let bonus = 0;
script("protagonist", "ExternalAmmoModule", (effect) => {
bonus += effect.clipSizeBonus ?? 0;
});
return bonus;
},
},
external_ammo_module_transformation: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ExternalAmmoModule"),
compute({ script }) {
let duration = 0;
script("protagonist", "ExternalAmmoModule", (effect) => {
duration += effect.transformationDuration ?? 0;
});
return duration;
},
},
external_ammo_module_timeout: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ExternalAmmoModule"),
compute({ script }) {
let timeout = 0;
script("protagonist", "ExternalAmmoModule", (effect) => {
timeout += effect.transformationTimeOut ?? 0;
});
return timeout;
},
},
external_ammo_module_activation_condition: {
type: CharacteristicType.Enum,
should_render: ({ hasScript }) => hasScript("ExternalAmmoModule"),
compute({ script, augment }) {
let onHit = false;
script("protagonist", "ExternalAmmoModule", (effect) => {
onHit = effect.allowNonDamagingHits === true;
});
augment("EXTERNAL_AMMO_MODULE_ALLOW_NON_DAMAGING_HITS", (value) => {
onHit = value !== 0;
});
return onHit ? "on_hit" : "on_damage";
},
},
ramming_configuration_damage_bonus: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RammingConfiguration"),
compute({ script, augment }) {
let bonus = 0;
script("protagonist", "RammingConfiguration", (effect) => {
bonus += effect.rammingDamageBonus ?? 0;
});
augment("RAMMING_CONFIGURATION_RAMMING_DAMAGE_BONUS", (value) => {
bonus += value;
});
return bonus * 100;
},
},
ramming_configuration_track_damage_bonus: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RammingConfiguration"),
compute({ script, augment }) {
let bonus = 0;
script("protagonist", "RammingConfiguration", (effect) => {
bonus += effect.rammingTrackDamageBonus ?? 0;
});
augment("RAMMING_CONFIGURATION_RAMMING_TRACK_DAMAGE_BONUS", (value) => {
bonus += value;
});
return bonus * 100;
},
},
ramming_configuration_damage_reduction: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RammingConfiguration"),
compute({ script, augment }) {
let reduction = 0;
script("protagonist", "RammingConfiguration", (effect) => {
reduction += effect.rammingDamageReduction ?? 0;
});
augment("RAMMING_CONFIGURATION_RAMMING_DAMAGE_REDUCTION", (value) => {
reduction += value;
});
return reduction * 100;
},
},
nitro_duration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script, augment }) {
let duration = 0;
script("protagonist", "RechargeableNitro", (effect) => {
duration += effect.duration ?? 0;
});
// The augment's heating duration is taken as the nitro duration
augment("RECHARGEABLE_NITRO_HEATING_DURATION", (value) => {
duration += value;
});
return duration;
},
},
nitro_cooling_duration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script, augment }) {
let duration = 0;
script("protagonist", "RechargeableNitro", (effect) => {
duration += effect.coolingDuration ?? 0;
});
augment("RECHARGEABLE_NITRO_COOLING_DURATION", (value) => {
duration += value;
});
return duration;
},
},
nitro_cooldown: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script }) {
let cooldown = 0;
script("protagonist", "RechargeableNitro", (effect) => {
cooldown += effect.cooldown ?? 0;
});
return cooldown;
},
},
nitro_engine_power: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script, characteristic }): number {
let factor = 1;
script("protagonist", "RechargeableNitro", (effect) => {
factor *= effect.enginePowerFactor ?? 1;
});
return (characteristic("engine_power") as number) * factor;
},
},
nitro_top_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script, augment, characteristic }): number {
let factor = 1;
script("protagonist", "RechargeableNitro", (effect) => {
factor *= effect.fwdSpeedLimitFactor ?? 1;
});
augment("RECHARGEABLE_NITRO_FWD_SPEED_LIMIT_FACTOR", (value) => {
factor += value;
});
return (characteristic("speed_forward") as number) * factor;
},
},
nitro_rotation_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("RechargeableNitro"),
compute({ script, augment, characteristic }): number {
let bonus = 0;
script("protagonist", "RechargeableNitro", (effect) => {
bonus += effect.rotationSpeedFactor ?? 0;
});
augment("RECHARGEABLE_NITRO_ROTATION_SPEED_FACTOR", (value) => {
bonus += value;
});
return (
(characteristic("hull_traverse_speed_medium") as number) * (1 + bonus)
);
},
},
shell_overheat_boost: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script, augment }) {
let boost = 0;
script("protagonist", "ShellOverheat", (effect) => {
boost += effect.maxBoostToMinimumAlpha ?? 0;
});
augment("SHELL_OVERHEAT_MIN_ALPHA_BOOST", (value) => {
boost += value;
});
return boost * 100;
},
},
shell_overheat_charge_time: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script, augment }) {
let time = 0;
script("protagonist", "ShellOverheat", (effect) => {
time += effect.maxChargeAccumulationTimeFromStart ?? 0;
});
augment("SHELL_OVERHEAT_CHARGE_TIME", (value) => {
time += value;
});
return time;
},
},
shell_overheat_activation_delay: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script, augment }) {
let delay = 0;
script("protagonist", "ShellOverheat", (effect) => {
delay += effect.chargeActivationDelay ?? 0;
});
augment("SHELL_OVERHEAT_ACTIVATION_DELAY", (value) => {
delay += value;
});
return delay;
},
},
shell_overheat_decay_time: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script }) {
let time = 0;
script("protagonist", "ShellOverheat", (effect) => {
time += effect.decayTimeFromMaxToZero ?? 0;
});
return time;
},
},
shell_overheat_min_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script }) {
let speed = 0;
script("protagonist", "ShellOverheat", (effect) => {
speed += effect.minSpeedForChargeAccumulation ?? 0;
});
return speed;
},
},
shell_overheat_max_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("ShellOverheat"),
compute({ script, augment }) {
let speed = 0;
script("protagonist", "ShellOverheat", (effect) => {
speed += effect.maxSpeedForChargeAccumulation ?? 0;
});
augment("SHELL_OVERHEAT_MAX_TANK_SPEED", (value) => {
speed += value;
});
return speed;
},
},
auxiliary_weapons_shots: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script }) {
let count = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
count += gun!.burst!.count;
});
return count;
},
},
auxiliary_weapons_damage: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script, augment }) {
let damage = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
damage += gun!.shells[0].armor_damage;
});
augment("AUXILLIARY_WEAPONS_GUN_DAMAGE", (value) => {
damage += value;
});
return damage;
},
},
auxiliary_weapons_penetration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script }) {
let penetration = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
penetration += gun!.shells[0].penetration!.near;
});
return penetration;
},
},
auxiliary_weapons_shell_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script }) {
let speed = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
speed += gun!.shells[0].velocity;
});
return speed;
},
},
auxiliary_weapons_interval: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script, augment }) {
let interval = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
interval += gun!.burst!.interval;
});
augment("AUXILLIARY_WEAPONS_GUN_BURST_INTERVAL", (value) => {
interval += value;
});
return interval;
},
},
auxiliary_weapons_cooldown: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("AuxilliaryWeapons"),
compute({ script, augment }) {
let cooldown = 0;
script("protagonist", "AuxilliaryWeapons", (_, gun) => {
cooldown += reloadOf(gun!);
});
augment("AUXILLIARY_WEAPONS_GUN_RELOAD_TIME", (value) => {
cooldown += value;
});
return cooldown;
},
},
unguided_rocket_count: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script }) {
let count = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
count += shellsPerClipOf(gun!);
});
return count;
},
},
unguided_rocket_damage: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script, augment }) {
let damage = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
damage += gun!.shells[0].armor_damage;
});
augment("UNGUIDED_ROCKET_DAMAGE", (value) => {
damage += value;
});
return damage;
},
},
unguided_rocket_penetration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script }) {
let penetration = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
penetration += gun!.shells[0].penetration!.near;
});
return penetration;
},
},
unguided_rocket_initial_speed: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script, augment }) {
let speed = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
speed += gun!.shells[0].velocity;
});
augment("UNGUIDED_ROCKET_INITIAL_SPEED", (value) => {
speed += value;
});
return speed;
},
},
unguided_rocket_acceleration: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script, augment }) {
// Only the unguided rocket carries an acceleration, so it always exists here
let acceleration = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
acceleration += gun!.shells[0].acceleration!;
});
augment("UNGUIDED_ROCKET_ACCELERATION", (value) => {
acceleration += value;
});
return acceleration;
},
},
unguided_rocket_max_distance: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script }) {
let distance = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
distance += gun!.shells[0].range;
});
return distance;
},
},
unguided_rocket_intra_clip: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script, augment }) {
let reload = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
reload += intraClipOf(gun!);
});
augment("UNGUIDED_ROCKET_INTERCLIP_RELOAD", (value) => {
reload += value;
});
return reload;
},
},
unguided_rocket_container_reload: {
type: CharacteristicType.Number,
should_render: ({ hasScript }) => hasScript("UnguidedRocket"),
compute({ script, augment }) {
let reload = 0;
script("protagonist", "UnguidedRocket", (_, gun) => {
reload += reloadOf(gun!);
});
augment("UNGUIDED_ROCKET_CONTAINER_RELOAD", (value) => {
reload += value;
});
return reload;
},
},
// Compute time only: what the assault shells visualizer is drawn from
_assault_distances: {
type: CharacteristicType.NumberList,
@@ -1,5 +1,6 @@
import type { CaseType } from "@blitzkit/core";
import type { GunDefinition } from "@blitzkit/protos";
import { humanBoolean } from "./characteristicsPresets";
import {
CharacteristicRanking,
type CharacteristicName,
@@ -68,6 +69,263 @@ export const characteristicsGroups: CharacteristicsGroup[] = [
// ],
// },
// Abilities, which only show on the tanks that have them
{
name: "steady_aim_system",
sortable: false,
order: [
{
name: "steady_aim_system_duration",
decimals: 1,
units: "s",
},
{
name: "steady_aim_system_aiming_speed",
decimals: 1,
units: "percentage",
},
{
name: "steady_aim_system_dispersion",
ranking: CharacteristicRanking.None,
decimals: 1,
units: "percentage",
},
{
...humanBoolean,
name: "steady_aim_system_activation_condition",
},
],
},
{
name: "burst_mode",
sortable: false,
order: [
{
name: "burst_mode_count",
decimals: 0,
},
{
name: "burst_mode_interval",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "burst_mode_penetrations",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 0,
},
{
...humanBoolean,
name: "burst_mode_target_order",
},
],
},
{
name: "combat_frenzy",
sortable: false,
order: [
{
name: "combat_frenzy_reload_bonus",
decimals: 0,
units: "percentage",
},
{
name: "combat_frenzy_max_stacks",
decimals: 0,
},
{
...humanBoolean,
name: "combat_frenzy_keep_stacks",
},
],
},
{
name: "external_ammo_module",
sortable: false,
order: [
{
name: "external_ammo_module_clip_bonus",
decimals: 0,
},
{
name: "external_ammo_module_transformation",
ranking: CharacteristicRanking.None,
decimals: 1,
units: "s",
},
{
name: "external_ammo_module_timeout",
ranking: CharacteristicRanking.None,
decimals: 1,
units: "s",
},
{
...humanBoolean,
name: "external_ammo_module_activation_condition",
},
],
},
{
name: "ramming_configuration",
sortable: false,
order: [
{
name: "ramming_configuration_damage_bonus",
decimals: 0,
units: "percentage",
},
{
name: "ramming_configuration_track_damage_bonus",
decimals: 0,
units: "percentage",
},
{
name: "ramming_configuration_damage_reduction",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 0,
units: "percentage",
},
],
},
{
name: "nitro",
sortable: false,
order: [
{
name: "nitro_duration",
decimals: 1,
units: "s",
},
{
name: "nitro_cooling_duration",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "nitro_cooldown",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "nitro_engine_power",
decimals: 0,
units: "bhp",
},
{
name: "nitro_top_speed",
decimals: 0,
units: "km_h",
},
{
name: "nitro_rotation_speed",
decimals: 1,
units: "deg_s",
},
],
},
{
name: "shell_overheat",
sortable: false,
order: [
{
name: "shell_overheat_boost",
decimals: 1,
units: "percentage",
},
{
name: "shell_overheat_charge_time",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "shell_overheat_activation_delay",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "shell_overheat_decay_time",
ranking: CharacteristicRanking.None,
decimals: 1,
units: "s",
},
{
name: "shell_overheat_min_speed",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 0,
units: "km_h",
},
{
name: "shell_overheat_max_speed",
ranking: CharacteristicRanking.None,
decimals: 0,
units: "km_h",
},
],
},
{
name: "auxiliary_weapons",
sortable: false,
order: [
{ name: "auxiliary_weapons_shots", decimals: 0 },
{ name: "auxiliary_weapons_damage", decimals: 0 },
{ name: "auxiliary_weapons_penetration", decimals: 0, units: "mm" },
{ name: "auxiliary_weapons_shell_speed", decimals: 0, units: "m_s" },
{
name: "auxiliary_weapons_interval",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 2,
units: "s",
},
{
name: "auxiliary_weapons_cooldown",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 2,
units: "s",
},
],
},
{
name: "unguided_rocket",
sortable: false,
order: [
{ name: "unguided_rocket_count", decimals: 0 },
{ name: "unguided_rocket_damage", decimals: 0 },
{ name: "unguided_rocket_penetration", decimals: 0, units: "mm" },
{ name: "unguided_rocket_initial_speed", decimals: 0, units: "m_s" },
{ name: "unguided_rocket_acceleration", decimals: 1, units: "m_s2" },
{ name: "unguided_rocket_max_distance", decimals: 0, units: "m" },
{
name: "unguided_rocket_intra_clip",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
{
name: "unguided_rocket_container_reload",
ranking: CharacteristicRanking.LowerIsBetter,
decimals: 1,
units: "s",
},
],
},
{
name: "assault_shells",
sortable: false,
@@ -0,0 +1,16 @@
import {
CharacteristicRanking,
type CharacteristicRenderConfig,
} from "../types/characteristics";
// Switches come out as "yes" or "no", or as what the game calls them
export const humanBoolean = {
// Ability values are only comparable to themselves, so nothing is ranked
ranking: CharacteristicRanking.None,
render({ output, strings }) {
return strings.tanks.characteristics.flags[
output as keyof typeof strings.tanks.characteristics.flags
];
},
} satisfies Partial<CharacteristicRenderConfig>;
@@ -5,7 +5,12 @@ import {
type TankEnvironment,
} from "@blitzkit/core";
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
import { CrewType, type TankDefinition } from "@blitzkit/protos";
import {
AbilitySource,
CrewType,
type GunDefinition,
type TankDefinition,
} from "@blitzkit/protos";
import { useMemo } from "react";
import { api } from "../api/dynamic";
import { characteristics } from "../config/characteristics";
@@ -51,6 +56,10 @@ export function computeCharacteristics(
protagonist: new Map(),
antagonist: new Map(),
};
const scriptGunMap: Record<DuelSide, Map<string, GunDefinition>> = {
protagonist: new Map(),
antagonist: new Map(),
};
function addScript(side: DuelSide, name: string, script: BlitzEffectScript) {
if (!scriptsMap[side].has(name)) {
@@ -80,6 +89,25 @@ export function computeCharacteristics(
addScript(side, script["#text"], script);
}
// A tank's vehicle abilities are hidden provisions or consumables, which
// count like any other script
for (const ability of sideTank.vehicle_abilities) {
const script =
scripts[
ability.source === AbilitySource.ABILITY_SOURCE_PROVISION
? "provisions"
: "consumables"
][ability.id];
if (script === undefined) continue;
addScript(side, script["#text"], script);
if (ability.gun !== undefined) {
scriptGunMap[side].set(script["#text"], ability.gun);
}
}
for (const index in states[side].equipment) {
const choice = states[side].equipment[index];
const id = sideEquipmentPreset.slots[index].options[choice];
@@ -140,20 +168,26 @@ export function computeCharacteristics(
// console.log(scriptsMap);
// The gun is the script's placeholder gun when it is a vehicle ability with one
function script(
side: DuelSide,
name: string,
callback: (effect: BlitzEffectScript) => void,
callback: (effect: BlitzEffectScript, gun?: GunDefinition) => void,
) {
if (!scriptsMap[side].has(name)) return;
const scripts = scriptsMap[side].get(name)!;
const gun = scriptGunMap[side].get(name);
for (const script of scripts) {
callback(script);
callback(script, gun);
}
}
function hasScript(name: string) {
return scriptsMap.protagonist.has(name);
}
const augments = augmentAttributes(tank, states.protagonist);
function augment(name: string, callback: (value: number) => void) {
@@ -179,6 +213,7 @@ export function computeCharacteristics(
characteristic,
script,
hasScript,
augment,
} satisfies CharacteristicContext;
@@ -15,8 +15,12 @@ const characteristicConfigs = new Map<
CharacteristicRenderConfig
>();
for (const { order } of characteristicsGroups) {
for (const item of order) {
for (const group of characteristicsGroups) {
// Special groups only some tanks have, so there is no other tank to rank
// them against
if (group.sortable === false) continue;
for (const item of group.order) {
if (!("name" in item)) continue;
characteristicConfigs.set(item.name, item);
}
@@ -14,7 +14,9 @@ const sortableCharacteristicTypes = new Set<CharacteristicType>([
export const sortableCharacteristics = new Set<RenderedCharacteristicName>();
for (const group of characteristicsGroups) {
if (!group.sortable) continue;
// Only groups that are explicitly unsortable are left out, which is different from undefined
// yes, it's meant to be === false and not !sortable
if (group.sortable === false) continue;
for (const config of group.order) {
if (!("name" in config)) continue;
@@ -41,7 +41,7 @@ export type Characteristic = {
export type CharacteristicScript = (
side: DuelSide,
name: string,
effect: (effect: BlitzEffectScript) => void,
effect: (effect: BlitzEffectScript, gun?: GunDefinition) => void,
) => void;
export interface CharacteristicContext {
@@ -64,10 +64,9 @@ export interface CharacteristicContext {
name: CharacteristicName,
): ReturnType<Characteristic["compute"]>;
hasScript(name: string): boolean;
script: CharacteristicScript;
// Like scripts, but for each value the installed augments give an attribute,
// named without the `ATTRIBUTE_NAME_` prefix
augment(name: string, callback: (value: number) => void): void;
}