feat: camo

This commit is contained in:
TrèsAbhi committed 2025-12-24 20:30:19 -06:00
1 parent 7281b9fed0
commit 010303a818
4 files changed
+43 -25

No files matched your search

@@ -1,3 +1,4 @@
import { TankClass } from "@blitzkit/core";
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component"; import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
import { import {
ShellUpgrageSingleChange_AttributeName, ShellUpgrageSingleChange_AttributeName,
@@ -344,33 +345,38 @@ export const characteristics = {
); );
}, },
camouflage_still({ attribute }) { class({ tank }) {
return attribute( return tank.tank_class;
},
camouflage({ attribute, characteristic, attributeSafe, state }) {
const tankClass = characteristic("class");
const base = attribute(
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_STILL TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_STILL
); );
}, const moving =
tankClass === TankClass.LIGHT
camouflage_moving({ attribute }) { ? 0
return attribute( : attribute(
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_MOVING TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_MOVING
); );
}, const shooting = attribute(
camouflage_shooting_still({ attribute }) {
return attribute(
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FACTOR_AT_SHOT TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FACTOR_AT_SHOT
); );
},
camouflage_shooting_moving() { if (
return -Infinity;
},
camouflage_on_fire({ attributeSafe }) {
return (
attributeSafe( attributeSafe(
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FIRE_PENALTY TankAttributeChange_AttributeName.ATTRIBUTE_NAME_CONCEALMENT_FIRE_PENALTY
) ?? -Infinity )
) {
throw new Error("Fire penalty implemented! Code it in!!");
}
return (
100 *
base *
(1 + moving * state.speed) *
(state.isShooting ? shooting : 1)
); );
}, },
@@ -85,11 +85,7 @@ export const characteristicsOrder: CharacteristicsOrder = [
{ toy: "view_range" }, { toy: "view_range" },
{ name: "camouflage_still", units: "%" }, { name: "camouflage", decimals: 0, units: "%" },
{ name: "camouflage_moving", units: "%" },
{ name: "camouflage_shooting_still", units: "%" },
{ name: "camouflage_shooting_moving", units: "%" },
{ name: "camouflage_on_fire", units: "%" },
{ name: "height", units: "m" }, { name: "height", units: "m" },
{ name: "length", units: "m" }, { name: "length", units: "m" },
@@ -13,4 +13,5 @@ export interface TankState {
isShooting: boolean; isShooting: boolean;
isGunDamaged: boolean; isGunDamaged: boolean;
terrainHardness: TerrainHardness; terrainHardness: TerrainHardness;
isCaughtOnFire: boolean;
} }
@@ -166,6 +166,21 @@ function Content({ id }: { id: string }) {
<br /> <br />
<div>
<span>isCaughtOnFire</span>
<input
type="checkbox"
value={`${protagonist.isCaughtOnFire}`}
onChange={(event) => {
Tankopedia.mutate((draft) => {
draft.protagonist.isCaughtOnFire = event.target.checked;
});
}}
/>
</div>
<br />
{characteristicsOrder.map(({ group, order }) => ( {characteristicsOrder.map(({ group, order }) => (
<> <>
<h2 key={group}>{group}</h2> <h2 key={group}>{group}</h2>