let actor = this.actor;
let effect = this.effect;
let bleedingAmt;
let bleedingRoll;
let msg = ""
let damage = effect.conditionValue;
let scriptArgs = { msg, damage };
await Promise.all(actor.runScripts("preApplyCondition", { effect, data: scriptArgs }))
msg = scriptArgs.msg;
damage = scriptArgs.damage;
msg += await actor.applyBasicDamage(damage, { damageType: game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL, minimumOne: false, suppressMsg: true })
if (actor.status.wounds.value == 0 && !actor.hasCondition("unconscious")) {
await actor.addCondition("unconscious")
msg += "
" + game.i18n.format("BleedUnc", { name: actor.prototypeToken.name })
}
if (actor.hasCondition("unconscious")) {
bleedingAmt = effect.conditionValue;
bleedingRoll = (await new Roll("1d100").roll()).total;
if (bleedingRoll <= bleedingAmt * 10) {
msg += "
" + game.i18n.format("BleedFail", { name: actor.prototypeToken.name }) + " (" + game.i18n.localize("Rolled") + " " + bleedingRoll + ")";
await actor.addCondition("dead")
}
else if (bleedingRoll % 11 == 0) {
msg += "
" + game.i18n.format("BleedCrit", { name: actor.prototypeToken.name }) + " (" + game.i18n.localize("Rolled") + bleedingRoll + ")"
await actor.removeCondition("bleeding")
}
else {
msg += "
" + game.i18n.localize("BleedRoll") + ": " + bleedingRoll;
}
}
await Promise.all(actor.runScripts("applyCondition", { effect, data: { bleedingRoll } }))
if (args.suppressMessage) {
let messageData = game.wfrp4e.utility.chatDataSetup(msg);
messageData.speaker = { alias: this.effect.name }
messageData.flavor = this.effect.name;
return messageData
}
else {
return this.script.scriptMessage(msg)
}