Carrrièes, stat patch et log

This commit is contained in:
2022-01-30 09:18:49 +01:00
parent 222842d2e6
commit e3c9213969
7 changed files with 96 additions and 102 deletions

View File

@ -140,36 +140,38 @@ export class WH4FRPatchConfig {
this.patch_subspecies();
this.patch_career();
game.wfrp4e.config.conditionScripts = {
"ablaze": async function (actor) {
/*game.wfrp4e.config.conditionScripts = {
"ablaze" : async function (actor) {
let effect = actor.hasCondition("ablaze")
let value = effect.conditionValue;
let leastProtectedLoc;
let leastProtectedValue = 999;
for (let loc in actor.status.armour) {
if (actor.status.armour[loc].value != undefined && actor.status.armour[loc].value < leastProtectedValue) {
leastProtectedLoc = loc;
leastProtectedValue = actor.status.armour[loc].value;
}
for (let loc in actor.status.armour)
{
if (actor.status.armour[loc].value != undefined && actor.status.armour[loc].value < leastProtectedValue)
{
leastProtectedLoc = loc;
leastProtectedValue = actor.status.armour[loc].value;
}
}
let rollString = `1d10 + ${value - 1}`
let roll = new Roll(`${rollString} - ${leastProtectedValue || 0}`).roll();
let msg = `<h2>En Flammes</h2><b>Formule</b>: ${rollString}<br><b>Lancer</b>: ${roll.terms.map(i => i.total).splice(0, 3).join(" ")}` // Don't show AP in the roll formula
actor.runEffects("preApplyCondition", { effect, data: { msg, roll, rollString } })
let roll = await new Roll(`${rollString} - ${leastProtectedValue || 0}`).roll();
let msg = `<h2>${game.i18n.localize("WFRP4E.ConditionName.Ablaze")}</h2><b>${game.i18n.localize("Formula")}</b>: ${rollString}<br><b>${game.i18n.localize("Roll")}</b>: ${roll.terms.map(i => i.total).splice(0, 3).join(" ")}` // Don't show AP in the roll formula
actor.runEffects("preApplyCondition", {effect, data : {msg, roll, rollString}})
value = effect.conditionValue;
let damageMsg = (`<br>` + await actor.applyBasicDamage(roll.total, { damageType: game.wfrp4e.config.DAMAGE_TYPE.IGNORE_AP, suppressMsg: true })).split("")
damageMsg.splice(damageMsg.length - 1, 1) // Removes the parentheses and adds + AP amount.
msg += damageMsg.join("").concat(` + ${leastProtectedValue} AP)`)
let damageMsg = (`<br>` + await actor.applyBasicDamage(roll.total, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_AP, suppressMsg : true})).split("")
damageMsg.splice(damageMsg.length-1, 1) // Removes the parentheses and adds + AP amount.
msg += damageMsg.join("").concat(` + ${leastProtectedValue} ${game.i18n.localize("AP")})`)
let messageData = game.wfrp4e.utility.chatDataSetup(msg);
messageData.speaker = { alias: actor.data.token.name }
actor.runEffects("applyCondition", { effect, data: { messageData } })
messageData.speaker = {alias: actor.data.token.name}
actor.runEffects("applyCondition", {effect, data : {messageData}})
return messageData
},
"poisoned": async function (actor) {
"poisoned": async function (actor) {
let effect = actor.hasCondition("poisoned")
let msg = `<h2>Empoisonné</h2>`
@ -217,7 +219,7 @@ export class WH4FRPatchConfig {
actor.runEffects("applyCondition", { effect, data: { messageData, bleedingRoll } })
return messageData
}
}
}*/
game.wfrp4e.config.statusEffects = [
{
@ -239,9 +241,9 @@ export class WH4FRPatchConfig {
wfrp4e: {
"trigger": "endRound",
"effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')",
"script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1
}
}
}
},
@ -280,7 +282,7 @@ export class WH4FRPatchConfig {
wfrp4e: {
"trigger": "endRound",
"effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')",
"script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1
}
}
@ -308,8 +310,8 @@ export class WH4FRPatchConfig {
flags: {
wfrp4e: {
"effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')",
"value": 1
"script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value" : 1
}
}
},
@ -321,14 +323,14 @@ export class WH4FRPatchConfig {
wfrp4e: {
"trigger": "endRound",
"effectTrigger": "dialogChoice",
"effectData": {
"description": "Tests relatifs à la vue",
"modifier": "-10 * this.flags.wfrp4e.value"
"effectData" : {
"description" : "Tests related to sight",
"modifier" : "-10 * this.flags.wfrp4e.value"
},
"value": 1,
"secondaryEffect": {
"effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 10 * getProperty(this.effect, 'flags.wfrp4e.value')",
"secondaryEffect" :{
"effectTrigger": "targetPrefillDialog",
"script": "if (args.item && args.item.attackType=='melee') args.prefillModifiers.modifier += 10 * this.effect.conditionValue",
}
}
}
@ -340,7 +342,7 @@ export class WH4FRPatchConfig {
flags: {
wfrp4e: {
"effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')",
"script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1
}
}
@ -352,14 +354,14 @@ export class WH4FRPatchConfig {
flags: {
wfrp4e: {
"effectTrigger": "dialogChoice",
"effectData": {
"description": "Tout les tests relatifs au mouvement",
"modifier": "-20"
"effectData" : {
"description" : "Tests related to movement of any kind",
"modifier" : "-20"
},
"value": null,
"secondaryEffect": {
"effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 20",
"secondaryEffect" :{
"effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 20",
}
}
}
@ -371,16 +373,16 @@ export class WH4FRPatchConfig {
flags: {
wfrp4e: {
"effectTrigger": "dialogChoice",
"effectData": {
"description": "Tests affectés ",
"slBonus": "-1"
"effectData" : {
"description" : "Tests to affect",
"slBonus" : "-1"
},
"script": `
if (this.flags.wfrp4e.fearName)
this.flags.wfrp4e.effectData.description += " " + this.flags.wfrp4e.fearName
else
this.flags.wfrp4e.effectData.description += " la source de la Peur"
`,
"script" : `
if (this.flags.wfrp4e.fearName)
this.flags.wfrp4e.effectData.description += " " + this.flags.wfrp4e.fearName
else
this.flags.wfrp4e.effectData.description += " the source of fear"
`,
"value": null
}
}
@ -392,9 +394,9 @@ export class WH4FRPatchConfig {
flags: {
wfrp4e: {
"value": null,
"secondaryEffect": {
"effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 20",
"secondaryEffect" :{
"effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 20",
}
}
}

View File

@ -34,7 +34,7 @@ import WFRP_Utility from "/systems/wfrp4e/modules/system/utility-wfrp4e.js";
import "./xregexp-all.js";
const us_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const carac_val = '(?<m>[0-9-]+)\\s+(?<ws>[0-9-]+)\\s+(?<bs>[0-9-]+)\\s+(?<s>[0-9-]+)\\s+(?<t>[0-9-]+)\\s+(?<i>[0-9-]+)\\s+(?<ag>[0-9-]+)\\s+(?<dex>[0-9-]+)\\s+(?<int>[0-9-]+)\\s+(?<wp>[0-9-]+)\\s+(?<fel>[0-9-]+)\\s+(?<w>[0-9-\*]+)';
const carac_val = '(?<m>[0-9\\-]+)\\s+(?<ws>[0-9\\-]+)\\s+(?<bs>[0-9\\-]+)\\s+(?<s>[0-9\\-]+)\\s+(?<t>[0-9\\-]+)\\s+(?<i>[0-9\\-]+)\\s+(?<ag>[0-9\\-]+)\\s+(?<dex>[0-9\\-]+)\\s+(?<int>[0-9\\-]+)\\s+(?<wp>[0-9\\-]+)\\s+(?<fel>[0-9\\-]+)\\s+(?<w>[0-9\\-\*]+)';
const name_val = '(?<name>[a-zA-Z\\s\\-,]*)[\\s\\r\\na-zA-Z]*(?<tiers>.*|[\\(\\)a-z0-9]+)';
let sectionData = [
{ name: "trait", toFind: "Traits\\s*:", secondParse: '(?<name>[a-z\\s]*)[\\s\\+]*(?<value>.*|[\\+0-9]+)', index: -1 },
@ -164,6 +164,9 @@ function __patchName ( name) {
export default async function statParserFR(statString, type = "npc") {
let model = duplicate(game.system.model.Actor[type]);
// Patch wront/strange carac value before processing
statString = statString.replace(/ /g, " 0")
let reg1 = XRegExp(us_carac, 'gi');
let res = reg1.test(statString);
if (res) { //stat block identified go on
@ -196,7 +199,8 @@ export default async function statParserFR(statString, type = "npc") {
let resCarac = XRegExp.exec(statString, reg2); // resr contains all carac found
// Setup carac
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"]; // Auto patch
//console.log("CARAC", resCarac)
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"] // Auto patch
model.details.move.value = Number(resCarac["m"]);
for (let key in model.characteristics) {
if (resCarac[key] === '-') resCarac[key] = 0;