quake2ts 0.0.416 → 0.0.418

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13973,6 +13973,33 @@ var ClientEffectSystem = class {
13973
13973
  }
13974
13974
  };
13975
13975
 
13976
+ // src/blend.ts
13977
+ var createBlendState = () => ({
13978
+ damageAlpha: 0,
13979
+ bonusAlpha: 0,
13980
+ lastFlashes: 0
13981
+ });
13982
+ var updateBlend = (state, ps, dt, damageIntensity = 0) => {
13983
+ state.damageAlpha -= dt;
13984
+ if (state.damageAlpha < 0) state.damageAlpha = 0;
13985
+ if (damageIntensity > 0) {
13986
+ state.damageAlpha = damageIntensity;
13987
+ }
13988
+ state.bonusAlpha -= dt;
13989
+ if (state.bonusAlpha < 0) state.bonusAlpha = 0;
13990
+ const flashes = ps.stats ? ps.stats[PlayerStat.STAT_FLASHES] ?? 0 : 0;
13991
+ if (flashes !== state.lastFlashes) {
13992
+ state.bonusAlpha = 0.6;
13993
+ state.lastFlashes = flashes;
13994
+ }
13995
+ if (state.bonusAlpha > 0) {
13996
+ return [1, 1, 0, state.bonusAlpha * 0.3];
13997
+ } else if (state.damageAlpha > 0) {
13998
+ return [1, 0, 0, state.damageAlpha * 0.5];
13999
+ }
14000
+ return [0, 0, 0, 0];
14001
+ };
14002
+
13976
14003
  // src/input/bindings.ts
13977
14004
  var DEFAULT_BINDINGS = [
13978
14005
  { code: "KeyW", command: "+forward" },
@@ -14667,6 +14694,9 @@ function createClient(imports) {
14667
14694
  let pauseMenuFactory;
14668
14695
  let optionsFactory;
14669
14696
  const configStrings = new ClientConfigStrings();
14697
+ const blendState = createBlendState();
14698
+ let currentBlend = [0, 0, 0, 0];
14699
+ let pendingDamage = 0;
14670
14700
  let latestFrame;
14671
14701
  let lastRenderTime = 0;
14672
14702
  let clientInAutoDemo = false;
@@ -14738,6 +14768,9 @@ function createClient(imports) {
14738
14768
  if (pos) {
14739
14769
  effectSystem.onTempEntity(type, pos, time);
14740
14770
  }
14771
+ },
14772
+ onDamage: (indicators) => {
14773
+ pendingDamage = 0.5;
14741
14774
  }
14742
14775
  });
14743
14776
  demoPlayback.setHandler(demoHandler);
@@ -15048,7 +15081,16 @@ function createClient(imports) {
15048
15081
  }
15049
15082
  }
15050
15083
  const frameTimeMs = sample.latest && sample.previous ? Math.max(0, sample.latest.timeMs - sample.previous.timeMs) : 0;
15084
+ if (frameTimeMs > 0) {
15085
+ prediction.decayError(frameTimeMs / 1e3);
15086
+ }
15051
15087
  lastView = view.sample(lastRendered, frameTimeMs);
15088
+ if (lastRendered) {
15089
+ currentBlend = updateBlend(blendState, lastRendered, frameTimeMs / 1e3, pendingDamage);
15090
+ pendingDamage = 0;
15091
+ } else {
15092
+ currentBlend = [0, 0, 0, 0];
15093
+ }
15052
15094
  const command = {};
15053
15095
  const timeSeconds = sample.nowMs / 1e3;
15054
15096
  dlightManager.update(timeSeconds);
@@ -15143,7 +15185,7 @@ function createClient(imports) {
15143
15185
  maxs: { x: 16, y: 16, z: 32 },
15144
15186
  damageAlpha: lastRendered.damageAlpha ?? 0,
15145
15187
  damageIndicators: lastRendered.damageIndicators ?? [],
15146
- blend: lastRendered.blend ?? [0, 0, 0, 0],
15188
+ blend: currentBlend,
15147
15189
  pickupIcon: lastRendered.pickupIcon,
15148
15190
  centerPrint: void 0,
15149
15191
  // Handled by CGame MessageSystem now