@adatechnology/game-crowd 0.3.0 → 0.4.0

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.
package/dist/index.js CHANGED
@@ -433,6 +433,7 @@ function createBalance(ctx) {
433
433
  // src/physics/blast.ts
434
434
  import { blastShove } from "@adatechnology/game-contracts";
435
435
  var CENTRE_HEIGHT = 1;
436
+ var SHELTERED = 0.5;
436
437
  var DISMEMBER_SHARE = 0.5;
437
438
  var LIMB_CHANCE = 0.5;
438
439
  var STUN_BASE = 0.45;
@@ -471,22 +472,23 @@ function createBlasts(ctx, hooks) {
471
472
  emitBlood(tally, i);
472
473
  ctx.deferKill(i);
473
474
  };
474
- const hurt = (i, blast, distance, index) => {
475
- const falloff = (1 - distance / blast.radius) ** 2;
475
+ const hurt = (i, blast, distance, index, reach = 1) => {
476
+ const falloff = (1 - distance / blast.radius) ** 2 * reach;
476
477
  const amount = blast.energy / 1e3 * options.pointsPerKilojoule * falloff;
477
478
  const draw = (salt) => () => unit(store.identity[i], ctx.step, salt);
478
479
  if (ctx.damage(i, { region: 1, amount, distance, cut: falloff }, draw(SALT.JAW + index)).died) return true;
479
480
  const region = Math.floor(unit(store.identity[i], ctx.step, SALT.REGION + index) * 6);
480
481
  return ctx.damage(i, { region, amount: amount / 2, distance, cut: falloff }, draw(SALT.JAW + 8 + index)).died;
481
482
  };
482
- const shoveOf = (i, blasts) => {
483
+ const shoveOf = (i, blasts, reaches) => {
483
484
  const position = [store.x[i], store.y[i] + CENTRE_HEIGHT * store.height[i], store.z[i]];
484
485
  let vx = 0;
485
486
  let vy = 0;
486
487
  let vz = 0;
487
488
  let falloff = 0;
488
- for (const blast of blasts) {
489
- const shove = blastShove({ point: blast.point, energy: blast.energy, radius: blast.radius }, { position, mass: store.mass[i] }, options.shove);
489
+ for (let b = 0; b < blasts.length; b++) {
490
+ const blast = blasts[b];
491
+ const shove = blastShove({ point: blast.point, energy: blast.energy, radius: blast.radius, reach: reaches?.[b] ?? 1 }, { position, mass: store.mass[i] }, options.shove);
490
492
  if (!shove) continue;
491
493
  vx += shove.speed * shove.direction[0];
492
494
  vy += shove.speed * shove.direction[1];
@@ -521,16 +523,19 @@ function createBlasts(ctx, hooks) {
521
523
  };
522
524
  const affect = (i, blasts, tallies, candidates) => {
523
525
  let dead = store.hp[i] <= 0;
526
+ const reaches = blasts.map(
527
+ (blast) => blast.reach && distanceTo(i, blast) <= blast.radius ? blast.reach([store.x[i], store.y[i] + CENTRE_HEIGHT * store.height[i], store.z[i]]) : 1
528
+ );
524
529
  for (let b = 0; b < blasts.length && !dead; b++) {
525
530
  const blast = blasts[b];
526
531
  const distance = distanceTo(i, blast);
527
532
  if (distance > blast.radius) continue;
528
533
  tallies[b].reached++;
529
- if (blast.lethalRadius !== void 0 && distance < blast.lethalRadius) kill(i, blast, distance, tallies[b]);
530
- else if (hurt(i, blast, distance, b)) tallies[b].killed++;
534
+ if (blast.lethalRadius !== void 0 && distance < blast.lethalRadius && reaches[b] >= SHELTERED) kill(i, blast, distance, tallies[b]);
535
+ else if (hurt(i, blast, distance, b, reaches[b])) tallies[b].killed++;
531
536
  dead = store.hp[i] <= 0 || dead;
532
537
  }
533
- const shove = shoveOf(i, blasts);
538
+ const shove = shoveOf(i, blasts, reaches);
534
539
  if (shove) applyShove(i, shove, candidates, tallies, blasts);
535
540
  };
536
541
  const resolve = () => {