All files / src/lib/events eventWeaponAttack.js

0% Statements 0/10
0% Branches 0/5
0% Functions 0/1
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70                                                                                                                                           
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_WEAPON_ATTACK";
const groups = ["EVENT_GROUP_ACTOR"];
 
const fields = [
  {
    key: "spriteSheetId",
    type: "sprite",
    label: l10n("FIELD_SPRITE_SHEET"),
    defaultValue: "LAST_SPRITE",
  },
  {
    key: "actorId",
    type: "actor",
    label: l10n("FIELD_SOURCE"),
    defaultValue: "$self$",
    width: "50%",
  },
  {
    key: "offset",
    type: "number",
    label: l10n("FIELD_OFFSET"),
    defaultValue: 10,
    min: 0,
    max: 64,
    width: "50%",
  },
  {
    key: "collisionGroup",
    label: l10n("FIELD_COLLISION_GROUP"),
    type: "collisionMask",
    width: "50%",
    includePlayer: false,
    defaultValue: "3",
  },
  {
    key: "collisionMask",
    label: l10n("FIELD_COLLIDE_WITH"),
    type: "collisionMask",
    width: "50%",
    includePlayer: true,
    defaultValue: ["1"],
  },
];
 
const compile = (input, helpers) => {
  const { weaponAttack, actorSetActive } = helpers;
  const offset =
    input.offset === "" || input.offset === undefined || input.offset === null
      ? 10
      : input.offset;
  actorSetActive(input.actorId);
  weaponAttack(
    input.spriteSheetId,
    offset,
    input.collisionGroup,
    input.collisionMask
  );
};
 
module.exports = {
  id,
  deprecated: true,
  groups,
  fields,
  compile,
  waitUntilAfterInitFade: true,
};