From 41b09b956b9a592d283efb86832295f013f3f741 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 12 Apr 2022 00:17:26 +0200 Subject: [PATCH] Fix async rolls --- compendium/wfrp4e-core.criticals.json | 6 +++--- compendium/wfrp4e-core.prayers.json | 4 ++-- compendium/wfrp4e-core.spells.json | 4 ++-- compendium/wfrp4e-core.traits.json | 4 ++-- module.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compendium/wfrp4e-core.criticals.json b/compendium/wfrp4e-core.criticals.json index e34ca25..b358e4e 100644 --- a/compendium/wfrp4e-core.criticals.json +++ b/compendium/wfrp4e-core.criticals.json @@ -557,7 +557,7 @@ "effectApplication": "actor", "effectTrigger": "oneTime", "preventDuplicateEffects": false, - "script": "fromUuid(\"Compendium.wfrp4e-core.injuries.fBcZhOBn8IpoVqQ1\").then(injury => {\n let teeth = new Roll(\"1d10\").roll().total\n ChatMessage.create({content : `${this.actor.data.token.name} a perdu ${teeth} dents`, speaker : {alias: this.effect.label}})\ninjury.location.value = `${teeth} ${injury.location.value}`\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury.data)\n})" + "script": "fromUuid(\"Compendium.wfrp4e-core.injuries.fBcZhOBn8IpoVqQ1\").then(injury => {\n let teeth = new Roll(\"1d10\").roll({async: false}).total\n ChatMessage.create({content : `${this.actor.data.token.name} a perdu ${teeth} dents`, speaker : {alias: this.effect.label}})\ninjury.location.value = `${teeth} ${injury.location.value}`\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury.data)\n})" } }, "icon": "modules/wfrp4e-core/icons/injuries/head.png", @@ -930,7 +930,7 @@ "wfrp4e": { "effectApplication": "actor", "effectTrigger": "oneTime", - "script": "args.actor.addCondition(\"stunned\", new Roll(\"1d10\").roll().total)" + "script": "args.actor.addCondition(\"stunned\", new Roll(\"1d10\").roll({async: false}).total)" } }, "icon": "modules/wfrp4e-core/icons/injuries/head.png", @@ -2640,7 +2640,7 @@ "effectApplication": "actor", "effectTrigger": "oneTime", "preventDuplicateEffects": false, - "script": "fromUuid(\"Compendium.wfrp4e-core.injuries.fBcZhOBn8IpoVqQ1\").then(injury => {\n let teeth = new Roll(\"1d10\").roll().total\n ChatMessage.create({content : `${this.actor.data.token.name} loses ${teeth} teeth`, speaker : {alias: this.effect.label}})\ninjury.location.value = `${teeth} ${injury.location.value}`\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury.data)\n})\n\nfromUuid(\"Compendium.wfrp4e-core.injuries.rkJA1DlK51QuRlJy\").then(injury => {\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury)\n})\n\nfromUuid(\"Compendium.wfrp4e-core.injuries.hCadFsTRvLN9faaY\").then(injury => {\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury)\n})\n\n\nif (args.actor.isOwner)\n args.actor.setupSkill(\"Résistance\").then(setupData => {\n args.actor.basicTest(setupData).then(test => \n {\n if (test.result.outcome == \"failure\")\n args.actor.addCondition(\"unconscious\")\n })\n })" + "script": "fromUuid(\"Compendium.wfrp4e-core.injuries.fBcZhOBn8IpoVqQ1\").then(injury => {\n let teeth = new Roll(\"1d10\").roll({async: false}).total\n ChatMessage.create({content : `${this.actor.data.token.name} loses ${teeth} teeth`, speaker : {alias: this.effect.label}})\ninjury.location.value = `${teeth} ${injury.location.value}`\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury.data)\n})\n\nfromUuid(\"Compendium.wfrp4e-core.injuries.rkJA1DlK51QuRlJy\").then(injury => {\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury)\n})\n\nfromUuid(\"Compendium.wfrp4e-core.injuries.hCadFsTRvLN9faaY\").then(injury => {\n args.actor.createEmbeddedEntity(\"OwnedItem\", injury)\n})\n\n\nif (args.actor.isOwner)\n args.actor.setupSkill(\"Résistance\").then(setupData => {\n args.actor.basicTest(setupData).then(test => \n {\n if (test.result.outcome == \"failure\")\n args.actor.addCondition(\"unconscious\")\n })\n })" } }, "icon": "modules/wfrp4e-core/icons/injuries/head.png", diff --git a/compendium/wfrp4e-core.prayers.json b/compendium/wfrp4e-core.prayers.json index 02f421d..b3e3aa4 100644 --- a/compendium/wfrp4e-core.prayers.json +++ b/compendium/wfrp4e-core.prayers.json @@ -698,7 +698,7 @@ "wfrp4e": { "effectApplication": "apply", "effectTrigger": "oneTime", - "script": "if (args.actor.has(\"Mort-vivant\"))\n{\n let damage = (await new Roll(\"1d10\")).roll().total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n}" + "script": "if (args.actor.has(\"Mort-vivant\"))\n{\n let damage = (await new Roll(\"1d10\")).roll({async: false}).total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n}" } }, "icon": "modules/wfrp4e-core/icons/prayers/miracles.png", @@ -1142,7 +1142,7 @@ "wfrp4e": { "effectApplication": "apply", "effectTrigger": "oneTime", - "script": "let damage = (await new Roll(\"1d10\")).roll().total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n\nif (args.actor.has(\"Mort-vivant\") || args.actor.data.has(\"Démoniaque\"))\n{\n args.actor.addCondition(\"ablaze\")\n}" + "script": "let damage = (await new Roll(\"1d10\")).roll({async: false}).total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n\nif (args.actor.has(\"Mort-vivant\") || args.actor.data.has(\"Démoniaque\"))\n{\n args.actor.addCondition(\"ablaze\")\n}" } }, "icon": "modules/wfrp4e-core/icons/prayers/miracles.png", diff --git a/compendium/wfrp4e-core.spells.json b/compendium/wfrp4e-core.spells.json index 37ccb54..1c8aca7 100644 --- a/compendium/wfrp4e-core.spells.json +++ b/compendium/wfrp4e-core.spells.json @@ -2148,7 +2148,7 @@ "effectApplication": "apply", "effectTrigger": "oneTime", "preventDuplicateEffects": false, - "script": "let roll = new Roll(\"1d10\").roll()\nroll.toMessage({flavor: \"Wounds Healed\", speaker : {alias : args.actor.name}})\n\nlet wounds = duplicate(args.actor.status.wounds);\n\nwounds.value += roll.total;\n\nif (wounds.value > wounds.max)\n wounds.value = wounds.max;\n\nargs.actor.update({\"data.status.wounds\" : wounds})\n\nlet bleeding = args.actor.hasCondition(\"bleeding\")\nif (bleeding)\n args.actor.removeCondition(\"bleeding\", bleeding.flags.wfrp4e.value)" + "script": "let roll = new Roll(\"1d10\").roll({async: false})\nroll.toMessage({flavor: \"Wounds Healed\", speaker : {alias : args.actor.name}})\n\nlet wounds = duplicate(args.actor.status.wounds);\n\nwounds.value += roll.total;\n\nif (wounds.value > wounds.max)\n wounds.value = wounds.max;\n\nargs.actor.update({\"data.status.wounds\" : wounds})\n\nlet bleeding = args.actor.hasCondition(\"bleeding\")\nif (bleeding)\n args.actor.removeCondition(\"bleeding\", bleeding.flags.wfrp4e.value)" } }, "icon": "modules/wfrp4e-core/icons/spells/cauterise.png", @@ -8058,7 +8058,7 @@ "effectApplication": "apply", "effectTrigger": "endRound", "preventDuplicateEffects": false, - "script": "let chatData = {content: \"\", whisper: ChatMessage.getWhisperRecipients(\"GM\")}\n\nlet wounds = this.actor.status.wounds\nlet regen = new Roll(\"1d10\").roll().total\n\nif (wounds.value >= wounds.max)\n return\n\nif (wounds.value > 0)\n{\n wounds.value += regen\n if (wounds.value > wounds.max) \n wounds.value = wounds.max\n chatData.content += `${this.actor.name} regains ${regen} Wounds.`\n \n if (regen == 10)\n chatData.content += `
Additionally, they regenerate a Critical Wound.`\n}\nelse if (regen >= 8)\n{\n chatData.content += `${this.actor.name} rolled a ${regen} and regains 1 Wound.`\n wounds.value += 1\n if (regen == 10)\n chatData.content += `
Additionally, they regenerate a Critical Wound.`\n}\nelse\n{\n chatData.content += `${this.actor.name} Regenerate roll of ${regen} - No effect.`\n}\n\nthis.actor.update({\"data.status.wounds\" : wounds})\nChatMessage.create(chatData)" + "script": "let chatData = {content: \"\", whisper: ChatMessage.getWhisperRecipients(\"GM\")}\n\nlet wounds = this.actor.status.wounds\nlet regen = new Roll(\"1d10\").roll({async: false}).total\n\nif (wounds.value >= wounds.max)\n return\n\nif (wounds.value > 0)\n{\n wounds.value += regen\n if (wounds.value > wounds.max) \n wounds.value = wounds.max\n chatData.content += `${this.actor.name} regains ${regen} Wounds.`\n \n if (regen == 10)\n chatData.content += `
Additionally, they regenerate a Critical Wound.`\n}\nelse if (regen >= 8)\n{\n chatData.content += `${this.actor.name} rolled a ${regen} and regains 1 Wound.`\n wounds.value += 1\n if (regen == 10)\n chatData.content += `
Additionally, they regenerate a Critical Wound.`\n}\nelse\n{\n chatData.content += `${this.actor.name} Regenerate roll of ${regen} - No effect.`\n}\n\nthis.actor.update({\"data.status.wounds\" : wounds})\nChatMessage.create(chatData)" } }, "icon": "modules/wfrp4e-core/icons/spells/regenerate.png", diff --git a/compendium/wfrp4e-core.traits.json b/compendium/wfrp4e-core.traits.json index 615cfb8..d29ea0d 100644 --- a/compendium/wfrp4e-core.traits.json +++ b/compendium/wfrp4e-core.traits.json @@ -416,7 +416,7 @@ "effectTrigger": "oneTime", "preventDuplicateEffects": false, "effectApplication": "apply", - "script": "let damage = new Roll(\"1d10\").roll().total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n\nargs.actor.addCondition(\"deafened\", 3)\n\nargs.actor.setupSkill(\"Résistance\", {absolute : {difficulty: \"average\" }, context : {failure: \"Subit un Etat Brisé\", success : \"Evite un Etat Brisé\"}}).then(setupData => {\n args.actor.basicTest(setupData).then(test => {\n if (test.result.outcome == \"failure\")\n args.actor.addCondition(\"broken\")\n })\n})" + "script": "let damage = new Roll(\"1d10\").roll({async: false}).total\n args.actor.applyBasicDamage(damage, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL})\n\nargs.actor.addCondition(\"deafened\", 3)\n\nargs.actor.setupSkill(\"Résistance\", {absolute : {difficulty: \"average\" }, context : {failure: \"Subit un Etat Brisé\", success : \"Evite un Etat Brisé\"}}).then(setupData => {\n args.actor.basicTest(setupData).then(test => {\n if (test.result.outcome == \"failure\")\n args.actor.addCondition(\"broken\")\n })\n})" } }, "transfer": true, @@ -641,7 +641,7 @@ "wfrp4e": { "effectTrigger": "endRound", "preventDuplicateEffects": true, - "script": "let chatData = {content: \"\", whisper: ChatMessage.getWhisperRecipients(\"GM\")}\n\nlet wounds = duplicate(this.actor.status.wounds)\nlet regen = new Roll(\"1d10\").roll().total\n\nif (wounds.value >= wounds.max)\n return\n\nif (wounds.value > 0)\n{\n wounds.value += regen\n if (wounds.value > wounds.max) \n wounds.value = wounds.max\n chatData.content += `${this.actor.name}<\/b> récupère ${regen} Blessures.`\n \n if (regen == 10)\n chatData.content += `
De plus, il récupère d'une Blessure Critique.`\n}\nelse if (regen >= 8)\n{\n chatData.content += `${this.actor.name}<\/b> a réussi un ${regen} et récupère 1 Blessure.`\n wounds.value += 1\n if (regen == 10)\n chatData.content += `
De plus, il récupère d'une Blessure Critique.`\n}\nelse\n{\n chatData.content += `${this.actor.name}<\/b> Jet de Régénration de ${regen} - Aucun effet.`\n}\n\nthis.actor.update({\"data.status.wounds\" : wounds})\nChatMessage.create(chatData)", + "script": "let chatData = {content: \"\", whisper: ChatMessage.getWhisperRecipients(\"GM\")}\n\nlet wounds = duplicate(this.actor.status.wounds)\nlet regen = new Roll(\"1d10\").roll({async: false}).total\n\nif (wounds.value >= wounds.max)\n return\n\nif (wounds.value > 0)\n{\n wounds.value += regen\n if (wounds.value > wounds.max) \n wounds.value = wounds.max\n chatData.content += `${this.actor.name}<\/b> récupère ${regen} Blessures.`\n \n if (regen == 10)\n chatData.content += `
De plus, il récupère d'une Blessure Critique.`\n}\nelse if (regen >= 8)\n{\n chatData.content += `${this.actor.name}<\/b> a réussi un ${regen} et récupère 1 Blessure.`\n wounds.value += 1\n if (regen == 10)\n chatData.content += `
De plus, il récupère d'une Blessure Critique.`\n}\nelse\n{\n chatData.content += `${this.actor.name}<\/b> Jet de Régénration de ${regen} - Aucun effet.`\n}\n\nthis.actor.update({\"data.status.wounds\" : wounds})\nChatMessage.create(chatData)", "effectApplication": "actor" } }, diff --git a/module.json b/module.json index 4f045f6..4bed971 100644 --- a/module.json +++ b/module.json @@ -5,7 +5,7 @@ "authors": [ {"name":"LeRatierBretonnien" }], "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-wh4-lang-fr-fr", "flags": {}, - "version": "5.2.3", + "version": "5.2.4", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [],