@waica/behaviors 0.12.0 → 0.13.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/health.d.ts CHANGED
@@ -45,6 +45,10 @@ export declare class Health extends Component {
45
45
  label: string;
46
46
  ref: 'stat';
47
47
  };
48
+ hurtSound: {
49
+ label: string;
50
+ ref: 'sound';
51
+ };
48
52
  };
49
53
  static transient: string[];
50
54
  max: number;
@@ -55,6 +59,8 @@ export declare class Health extends Component {
55
59
  * publishes nothing: the stat is the project's to declare.
56
60
  */
57
61
  stat: string;
62
+ /** Sound played at this entity's position on every accepted hit. Empty plays nothing (CA-12). */
63
+ hurtSound: string;
58
64
  /** Health left; 0 is dead. Filled in from max on ready. */
59
65
  current: number;
60
66
  /** Whoever dealt the last accepted hit, for the state that reacts to it. */
package/dist/health.js CHANGED
@@ -47,6 +47,7 @@ export class Health extends Component {
47
47
  max: { label: 'Max health', min: 1, max: 20, step: 1 },
48
48
  invulnerability: { label: 'Invulnerability', min: 0, max: 5, step: 0.1 },
49
49
  stat: { label: 'Stat', ref: 'stat' },
50
+ hurtSound: { label: 'Hurt sound', ref: 'sound' },
50
51
  };
51
52
  static transient = [
52
53
  'current',
@@ -64,6 +65,8 @@ export class Health extends Component {
64
65
  * publishes nothing: the stat is the project's to declare.
65
66
  */
66
67
  stat = '';
68
+ /** Sound played at this entity's position on every accepted hit. Empty plays nothing (CA-12). */
69
+ hurtSound = '';
67
70
  /** Health left; 0 is dead. Filled in from max on ready. */
68
71
  current = 0;
69
72
  /** Whoever dealt the last accepted hit, for the state that reacts to it. */
@@ -158,6 +161,8 @@ export class Health extends Component {
158
161
  current: this.current,
159
162
  source,
160
163
  });
164
+ if (this.hurtSound)
165
+ this.game.audio.play(this.hurtSound, { at: this.entity });
161
166
  this.invulnerable = this.invulnerability;
162
167
  this.blinkClock = 0;
163
168
  if (this.current === 0) {
@@ -29,12 +29,18 @@ export declare class MeleeAttack extends Component {
29
29
  max: number;
30
30
  step: number;
31
31
  };
32
+ swingSound: {
33
+ label: string;
34
+ ref: 'sound';
35
+ };
32
36
  };
33
37
  damage: number;
34
38
  /** How far in front of the attacker the blow reaches, in world units. */
35
39
  range: number;
36
40
  /** How wide the blow is, across the facing. */
37
41
  width: number;
42
+ /** Sound played on every swing. Empty plays nothing (CA-12). */
43
+ swingSound: string;
38
44
  /**
39
45
  * Lands one blow along `facing`: every other living entity with a Hitbox
40
46
  * and a Health inside the strike area takes `damage` once, with this
@@ -16,12 +16,15 @@ export class MeleeAttack extends Component {
16
16
  damage: { label: 'Damage', min: 0, max: 20, step: 1 },
17
17
  range: { label: 'Range', min: 0.5, max: 5, step: 0.5 },
18
18
  width: { label: 'Width', min: 0.5, max: 5, step: 0.5 },
19
+ swingSound: { label: 'Swing sound', ref: 'sound' },
19
20
  };
20
21
  damage = 1;
21
22
  /** How far in front of the attacker the blow reaches, in world units. */
22
23
  range = 1;
23
24
  /** How wide the blow is, across the facing. */
24
25
  width = 1;
26
+ /** Sound played on every swing. Empty plays nothing (CA-12). */
27
+ swingSound = '';
25
28
  /**
26
29
  * Lands one blow along `facing`: every other living entity with a Hitbox
27
30
  * and a Health inside the strike area takes `damage` once, with this
@@ -33,6 +36,11 @@ export class MeleeAttack extends Component {
33
36
  const direction = logicalDirection(facing, this.game.projection);
34
37
  if (!direction)
35
38
  return [];
39
+ // Positional like Health's hurtSound (CA-8): an off-camera NPC's swing
40
+ // should attenuate and pan like the hit it causes, not play flat and
41
+ // dead-centre while the damage it lands sounds correctly placed.
42
+ if (this.swingSound)
43
+ this.game.audio.play(this.swingSound, { at: this.entity });
36
44
  const area = this.strikeArea(direction.x, direction.y);
37
45
  const struck = [];
38
46
  // A copy: a target with no death-handling graph is destroyed on the spot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waica/behaviors",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Waica built-in behaviors — the curated game-feel library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,6 +19,6 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@waica/engine": "^0.12.0"
22
+ "@waica/engine": "^0.13.0"
23
23
  }
24
24
  }