Changement cacul init

This commit is contained in:
sladecraven 2021-01-13 11:35:36 +01:00
parent 8c7ddc6f65
commit a8b38cc5b8
2 changed files with 29 additions and 19 deletions

View File

@ -59,7 +59,7 @@ const _patch_initiative = () => {
competence = duplicate(competenceItem); competence = duplicate(competenceItem);
} }
} }
rollFormula = RdDUtility.calculInitiative(competence.data.niveau, competence.data.carac_value); rollFormula = "2+( ("+RdDUtility.calculInitiative(competence.data.niveau, competence.data.carac_value)+")/100)";
} else { } else {
for (const item of c.actor.data.items) { for (const item of c.actor.data.items) {
if (item.type == "arme" && item.data.equipe) { if (item.type == "arme" && item.data.equipe) {
@ -68,13 +68,13 @@ const _patch_initiative = () => {
} }
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence; let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName); competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName);
rollFormula = RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value); rollFormula = "2+( ("+RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value) + ")/100)";
} }
} }
//console.log("Combatat", c); //console.log("Combatat", c);
const roll = this._getInitiativeRoll(c, rollFormula); const roll = this._getInitiativeRoll(c, rollFormula);
if (roll.total <= 0) roll.total = 1; if (roll.total <= 0) roll.total = 0.00;
//console.log("Compute init for", armeCombat, competence, rollFormula, roll.total); console.log("Compute init for", rollFormula, roll.total);
await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total }); await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total });
// Send a chat message // Send a chat message
@ -178,8 +178,8 @@ Hooks.once("init", async function () {
/* -------------------------------------------- */ /* -------------------------------------------- */
// Set an initiative formula for the system // Set an initiative formula for the system
CONFIG.Combat.initiative = { CONFIG.Combat.initiative = {
formula: "1d20", formula: "1+(1d6/10)",
decimals: 0 decimals: 2
}; };
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -649,32 +649,42 @@ export class RdDUtility {
static rollInitiativeCompetence(combatantId, arme) { static rollInitiativeCompetence(combatantId, arme) {
const combatant = game.combat.getCombatant(combatantId); const combatant = game.combat.getCombatant(combatantId);
const actor = combatant.actor; const actor = combatant.actor;
if (arme.name == "Autre action") { let initOffset = 0;
game.combat.rollInitiative(combatantId, "1d6"); let caracForInit = 0;
let compNiveau = 0;
if ( actor.getSurprise() == "totale") {
initOffset = -1; // To force 0
} else if ( actor.getSurprise() == "demi") {
initOffset = 0;
} else if (arme.name == "Autre action") {
initOffset = 2;
} else if (arme.name == "Draconic") { } else if (arme.name == "Draconic") {
game.combat.rollInitiative(combatantId, "1d6+200"); initOffset = 7;
} else { } else {
let initOffset = 0; initOffset = 2; // Melée = 3.XX
let caracForInit = 0;
let competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence); let competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence);
compNiveau = competence.data.niveau;
if (actor.data.type == 'creature' || actor.data.type == 'entite') { if (actor.data.type == 'creature' || actor.data.type == 'entite') {
caracForInit = competence.data.carac_value; caracForInit = competence.data.carac_value;
} else { } else {
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value; caracForInit = actor.data.data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
initOffset = 40; initOffset = 4;
} }
if (competence.data.categorie == "tir") { // Offset de principe pour les armes de jet if (competence.data.categorie == "tir") { // Offset de principe pour les armes de jet
initOffset = 80; initOffset = 5;
}
if (competence.data.categorie == "melee") { // Offset de principe pour les armes de jet
initOffset = 3;
} }
} }
initOffset -= actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages
let rollFormula = RdDUtility.calculInitiative(competence.data.niveau, caracForInit) + "+" + initOffset;
game.combat.rollInitiative(combatantId, rollFormula);
} }
let malus = actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages
let rollFormula = initOffset + "+ ( (" + RdDUtility.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";
game.combat.rollInitiative(combatantId, rollFormula);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */