foundryvtt-wh4-lang-fr-fr/reference_scripts/rly9iBUy8EX7NhQT.js

27 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2024-06-06 21:09:27 +02:00
if (game.user.targets.size !== 1)
return ui.notifications.warn("You must target exactly one Boat.");
const target = game.user.targets.first();
const vehicle = target.actor;
if (!(vehicle.system instanceof VehicleModel))
return ui.notifications.warn("You can only Constrict a Boat");
if (vehicle.size > 3)
return ui.notifications.warn("You can only Constrict vessels of Size Large or smaller");
const turns = Math.ceil(vehicle.system.details.length.value / 10);
const mainEffect = this.item.effects.contents[0];
const effectData = mainEffect.toObject();
effectData.statuses = [effectData.name.slugify()];
foundry.utils.setProperty(effectData, "flags.wfrp4e.target", target.id);
foundry.utils.setProperty(effectData, "flags.wfrp4e.turns", turns);
await this.actor.applyEffect({effectData: [effectData]});
const speaker = ChatMessage.getSpeaker({actor: this.actor});
this.script.scriptMessage(`<b>${speaker.alias}</b> started wrapping itself around the <b>${target.name}</b> and will be able to start crushing it after ${turns} turns.`);