Fix initiative 0.8.x
This commit is contained in:
parent
a7b228afe3
commit
6fc8906d67
@ -75,36 +75,36 @@ export class RdDCombatManager extends Combat {
|
|||||||
const currentId = this.combatant._id;
|
const currentId = this.combatant._id;
|
||||||
// calculate initiative
|
// calculate initiative
|
||||||
for (let cId = 0; cId < ids.length; cId++) {
|
for (let cId = 0; cId < ids.length; cId++) {
|
||||||
const c = this.getCombatant(ids[cId]);
|
const combatant = this.getCombatant(ids[cId]);
|
||||||
//if (!c) return results;
|
//if (!c) return results;
|
||||||
|
|
||||||
let rollFormula = formula; // Init per default
|
let rollFormula = formula; // Init per default
|
||||||
if (!rollFormula) {
|
if (!rollFormula) {
|
||||||
let armeCombat, competence;
|
let armeCombat, competence;
|
||||||
if (c.actor.data.type == 'creature' || c.actor.data.type == 'entite') {
|
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
||||||
for (const competenceItemData of c.actor.data.items) {
|
for (const competenceItemData of combatant.actor.data.items) {
|
||||||
if (competenceItemData.data.iscombat) {
|
if (competenceItemData.data.iscombat) {
|
||||||
competence = duplicate(competenceItemData);
|
competence = duplicate(competenceItemData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)";
|
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)";
|
||||||
} else {
|
} else {
|
||||||
for (const itemData of c.actor.data.items) {
|
for (const itemData of combatant.actor.data.items) {
|
||||||
if (itemData.type == "arme" && itemData.data.equipe) {
|
if (itemData.type == "arme" && itemData.data.equipe) {
|
||||||
armeCombat = duplicate(itemData);
|
armeCombat = duplicate(itemData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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(combatant.actor.data.items, compName);
|
||||||
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
|
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
|
||||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, Misc.data(c.actor).data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)";
|
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, Misc.data(combatant.actor).data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("Combatat", c);
|
//console.log("Combatat", c);
|
||||||
const roll = super._getInitiativeRoll(c, rollFormula);
|
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||||
if (roll.total <= 0) roll.total = 0.00;
|
if (roll.total <= 0) roll.total = 0.00;
|
||||||
console.log("Compute init for", rollFormula, roll.total);
|
console.log("Compute init for", rollFormula, roll.total);
|
||||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: c._id, initiative: roll.total }]);
|
await this.updateEmbeddedDocuments("Combatant", [{ _id: combatant._id, initiative: roll.total }]);
|
||||||
|
|
||||||
// Send a chat message
|
// Send a chat message
|
||||||
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
|
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
|
||||||
@ -112,12 +112,12 @@ export class RdDCombatManager extends Combat {
|
|||||||
{
|
{
|
||||||
speaker: {
|
speaker: {
|
||||||
scene: canvas.scene._id,
|
scene: canvas.scene._id,
|
||||||
actor: c.actor ? c.actor._id : null,
|
actor: combatant.actor ? combatant.actor._id : null,
|
||||||
token: c.token._id,
|
token: combatant.token._id,
|
||||||
alias: c.token.name,
|
alias: combatant.token.name,
|
||||||
sound: CONFIG.sounds.dice,
|
sound: CONFIG.sounds.dice,
|
||||||
},
|
},
|
||||||
flavor: `${c.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})
|
flavor: `${combatant.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})
|
||||||
<br>
|
<br>
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
@ -266,7 +266,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
let initOffset = 0;
|
let initOffset = 0;
|
||||||
let caracForInit = 0;
|
let caracForInit = 0;
|
||||||
let compNiveau = 0;
|
let compNiveau = 0;
|
||||||
let competence = { name: "Aucune" };
|
let compData = { name: "Aucune" };
|
||||||
if (combatant.actor.getSurprise() == "totale") {
|
if (combatant.actor.getSurprise() == "totale") {
|
||||||
initOffset = -1; // To force 0
|
initOffset = -1; // To force 0
|
||||||
initInfo = "Surprise Totale"
|
initInfo = "Surprise Totale"
|
||||||
@ -281,24 +281,24 @@ export class RdDCombatManager extends Combat {
|
|||||||
initInfo = "Draconic"
|
initInfo = "Draconic"
|
||||||
} else {
|
} else {
|
||||||
initOffset = 3; // Melée = 3.XX
|
initOffset = 3; // Melée = 3.XX
|
||||||
competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence);
|
compData = Misc.data(RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence));
|
||||||
compNiveau = competence.data.niveau;
|
compNiveau = compData.data.niveau;
|
||||||
initInfo = arme.name + " / " + arme.data.competence;
|
initInfo = arme.name + " / " + arme.data.competence;
|
||||||
|
|
||||||
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
||||||
caracForInit = competence.data.carac_value;
|
caracForInit = compData.data.carac_value;
|
||||||
if (competence.data.categorie == "lancer") {
|
if (compData.data.categorie == "lancer") {
|
||||||
initOffset = 5;
|
initOffset = 5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
caracForInit = Misc.data(combatant.actor).data.carac[competence.data.defaut_carac].value;
|
caracForInit = Misc.data(combatant.actor).data.carac[compData.data.defaut_carac].value;
|
||||||
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
|
if (compData.data.categorie == "lancer") { // Offset de principe pour les armes de jet
|
||||||
initOffset = 4;
|
initOffset = 4;
|
||||||
}
|
}
|
||||||
if (competence.data.categorie == "tir") { // Offset de principe pour les armes de jet
|
if (compData.data.categorie == "tir") { // Offset de principe pour les armes de jet
|
||||||
initOffset = 5;
|
initOffset = 5;
|
||||||
}
|
}
|
||||||
if (competence.data.categorie == "melee") { // Offset de principe pour les armes de jet
|
if (compData.data.categorie == "melee") { // Offset de principe pour les armes de jet
|
||||||
initOffset = 3;
|
initOffset = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user