foundryvtt-wh4-lang-fr-fr/scripts/groEX1wJ9l00PkDF.js

73 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2024-06-06 22:07:28 +02:00
let turns = this.effect.getFlag("wfrp4e", "turns");
if (turns <= 0) return;
turns--;
const speaker = ChatMessage.getSpeaker({actor: this.actor});
const targetId = this.effect.getFlag("wfrp4e", "target");
const target = canvas.scene.tokens.get(targetId);
if (turns > 0) {
this.effect.setFlag("wfrp4e", "turns", turns);
2024-10-08 20:52:09 +02:00
return this.script.message(`<p><b>${speaker.alias}</b> continue de s'enrouler autour <b>${target.name}</b>. Il pourra commencer à écraser dans ${turns} tours.</p>`);
2024-06-06 22:07:28 +02:00
}
if (this.actor.items.find(i => i.type === "extendedTest" && i.name === this.effect.name)) {
2024-10-08 20:52:09 +02:00
this.script.message(`<p><b>${speaker.alias}</b> peut reprenre son écrasement <b>${target.name}</b> avec le Test Etendu.</p>`);
2024-06-06 22:07:28 +02:00
return;
}
const extendedTestData = {
name: this.effect.name,
type: "extendedTest",
img: this.effect.img,
system: {
SL: {
current: 0,
target: target.actor.system.status.wounds.value
},
test: {
2024-10-08 20:52:09 +02:00
value: 'Strength'
2024-06-06 22:07:28 +02:00
},
completion: {
value: "remove"
},
difficulty: {
value: "challenging"
}
}
};
const extendedTests = await this.actor.createEmbeddedDocuments("Item", [extendedTestData], {fromEffect: this.effect.id});
const extendedTest = extendedTests[0];
2024-10-08 20:52:09 +02:00
this.script.message(`<p><b>${speaker.alias}</b> a fini de s'enrouler autour de <b>${target.name}</b>. Il peut maintenant écraser via le Test Etendu @UUID[${extendedTest.uuid}].</p>`);
2024-06-06 22:07:28 +02:00
let effect = {
name: extendedTest.name,
2024-10-08 20:52:09 +02:00
img: extendedTest.img,
system: {
transferData : {
2024-06-06 22:07:28 +02:00
type: "document",
documentType: "Item"
},
scriptData: [
{
label: extendedTest.name,
script: `
let id = this.item.flags.wfrp4e.fromEffect;
let effect = this.actor.effects.find(e => e.id === id);
const speaker = ChatMessage.getSpeaker({actor: this.actor});
const targetId = effect.getFlag("wfrp4e", "target");
const target = canvas.scene.tokens.get(targetId);
2024-10-08 20:52:09 +02:00
this.script.message(\`<p><b>${speaker.alias}</b> écrase <b>${target.name}</b>. Le bateau et broyé, réduit à une masse de déchets flottants.</p>\`);
2024-06-06 22:07:28 +02:00
await effect.delete();
`,
trigger: "deleteEffect"
}
]
}
}
await extendedTests[0].createEmbeddedDocuments("ActiveEffect", [effect]);