Review initiative

This commit is contained in:
LeRatierBretonnien 2023-05-01 18:50:32 +02:00
parent 59ee6684ab
commit 268ac0a25a
8 changed files with 36 additions and 17 deletions

View File

@ -156,6 +156,7 @@
"BOL.ui.armorAgiMalus": "Rüschtung+Schild-Malus (Geschick)", "BOL.ui.armorAgiMalus": "Rüschtung+Schild-Malus (Geschick)",
"BOL.ui.armorInitMalus": "Rüstungsmalus (Init)", "BOL.ui.armorInitMalus": "Rüstungsmalus (Init)",
"BOL.ui.attackValue": "Angriffswert", "BOL.ui.attackValue": "Angriffswert",
"BOL.ui.initMalus": "Init malus",
"BOL.featureCategory.origins": "Herkünfte", "BOL.featureCategory.origins": "Herkünfte",
"BOL.featureCategory.races": "Rassen", "BOL.featureCategory.races": "Rassen",

View File

@ -154,6 +154,7 @@
"BOL.ui.armorInitMalus": "Armor Modifier (Init)", "BOL.ui.armorInitMalus": "Armor Modifier (Init)",
"BOL.ui.attackValue": "Attack Value", "BOL.ui.attackValue": "Attack Value",
"BOL.ui.weaponbonus": "Cette arme bénéficie déja d'un Dé de Bonus (Arme Favorite prise en compte, par exemple)", "BOL.ui.weaponbonus": "Cette arme bénéficie déja d'un Dé de Bonus (Arme Favorite prise en compte, par exemple)",
"BOL.ui.initMalus": "Init malus",
"BOL.featureCategory.origins": "Origins", "BOL.featureCategory.origins": "Origins",
"BOL.featureCategory.races": "Races", "BOL.featureCategory.races": "Races",

View File

@ -132,6 +132,7 @@
"BOL.ui.concentrate": "Concentration à maintenir ?", "BOL.ui.concentrate": "Concentration à maintenir ?",
"BOL.ui.aggressive": "Sort aggressif ?", "BOL.ui.aggressive": "Sort aggressif ?",
"BOL.ui.registerInit": "Enregistrer comme Init. de combat", "BOL.ui.registerInit": "Enregistrer comme Init. de combat",
"BOL.ui.initMalus": "Malus d'initiative",
"BOL.ui.magicnewrules": "Règles supplémentaires (cf. supplément fan-made Sorcellerie!)", "BOL.ui.magicnewrules": "Règles supplémentaires (cf. supplément fan-made Sorcellerie!)",
"BOL.ui.isSorcerer": "Carrière de Sorcier ?", "BOL.ui.isSorcerer": "Carrière de Sorcier ?",

View File

@ -48,7 +48,13 @@ export class BoLActor extends Actor {
} }
return false return false
} }
/* -------------------------------------------- */
getInitiativeMalus() {
if ( this.type === 'encounter' && (this.chartype == "adversary" || this.chartype == "tough")) {
return this.system.aptitudes.init.value
}
return 0
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getBougette() { getBougette() {
if (this.type == "character") { if (this.type == "character") {
@ -871,17 +877,17 @@ export class BoLActor extends Actor {
/*-------------------------------------------- */ /*-------------------------------------------- */
getInitiativeRank(rollData = undefined, isCombat = false, combatData) { getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
if (!rollData) {
rollData = this.getFlag("world", "last-initiative")
}
let fvttInit = 4 // Pietaille par defaut let fvttInit = 4 // Pietaille par defaut
if (this.type == 'character') { if (this.type == 'character') {
fvttInit = 5 fvttInit = 5
fvttInit = -1
if (!rollData) { if (!rollData) {
if (isCombat) { if (isCombat) {
if (game.user.isGM ) { if (game.user.isGM ) {
game.socket.emit("system.bol", { name: "msg_request_init_roll", data: { actorId: this.id, combatData : combatData } }) if (this.hasPlayerOwner) {
game.socket.emit("system.bol", { name: "msg_request_init_roll", data: { actorId: this.id, combatData } })
} else {
BoLRoll.aptitudeCheck(this, "init", undefined, combatData);
}
} }
} }
} else { } else {

View File

@ -584,7 +584,8 @@ export class BoLRoll {
} }
let diceData = BoLUtility.getDiceData() let diceData = BoLUtility.getDiceData()
const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus + rollData.effectModifier let malusInit = rollData.combatData?.malusInit || 0
const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus + rollData.effectModifier - malusInit
const formula = (isMalus) ? rollData.nbDice + "d" + diceData.diceFormula + "kl2 + " + modifiers : rollData.nbDice + "d" + diceData.diceFormula + "kh2 + " + modifiers const formula = (isMalus) ? rollData.nbDice + "d" + diceData.diceFormula + "kl2 + " + modifiers : rollData.nbDice + "d" + diceData.diceFormula + "kh2 + " + modifiers
rollData.formula = formula rollData.formula = formula
rollData.modifiers = modifiers rollData.modifiers = modifiers
@ -647,10 +648,11 @@ export class BoLDefaultRoll {
this.rollData.reroll = actor.heroReroll() this.rollData.reroll = actor.heroReroll()
} }
if (this.rollData.registerInit) { if (this.rollData.registerInit) {
actor.registerInit(this.rollData) await actor.registerInit(this.rollData)
this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData) this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData)
if (this.rollData.combatData) { // If combatData present if (this.rollData.combatData) { // If combatData present
let combat = game.combats.get(this.rollData.combatData.combatId) let combat = game.combats.get(this.rollData.combatData.combatId)
console.log("SET INIT!!!!!", this.rollData.initiativeRank)
combat.setInitiative(this.rollData.combatData.combatantId, this.rollData.initiativeRank) combat.setInitiative(this.rollData.combatData.combatantId, this.rollData.initiativeRank)
} }
} }

View File

@ -20,12 +20,15 @@ export class BoLCombatManager extends Combat {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions); console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
// Structure input data // Structure input data
ids = typeof ids === "string" ? [ids] : ids; ids = typeof ids === "string" ? [ids] : ids;
//const currentId = this.combatant.id; // Get initiative malus from tough/adversary
let malusInit = 0
for (let combatant of this.combatants) {
malusInit = Math.max(malusInit, combatant.actor.getInitiativeMalus())
}
// calculate initiative // calculate initiative
for (let cId = 0; cId < ids.length; cId++) { for (let cId = 0; cId < ids.length; cId++) {
const combatant = this.combatants.get(ids[cId]) const combatant = this.combatants.get(ids[cId])
let fvttInit = combatant.actor.getInitiativeRank(false, true, { combatId: this.id, combatantId: combatant.id }) let fvttInit = combatant.actor.getInitiativeRank(false, true, { combatId: this.id, combatantId: combatant.id, malusInit })
fvttInit += (cId / 100) fvttInit += (cId / 100)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]); await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
} }
@ -64,7 +67,7 @@ export class BoLCombatManager extends Combat {
return super.startCombat() return super.startCombat()
} }
/************************************************************************************/ /*-***********************************************************************************/
_onDelete() { _onDelete() {
if (game.user.isGM) { if (game.user.isGM) {
let combatants = this.combatants.contents let combatants = this.combatants.contents

View File

@ -14,7 +14,7 @@
], ],
"url": "https://www.uberwald.me/gitea/public/bol", "url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"version": "10.5.15", "version": "10.5.16",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10" "verified": "10"
@ -202,7 +202,7 @@
], ],
"socket": true, "socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.15.zip", "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.16.zip",
"background": "systems/bol/ui/page_accueil.webp", "background": "systems/bol/ui/page_accueil.webp",
"gridDistance": 1.5, "gridDistance": 1.5,
"gridUnits": "m", "gridUnits": "m",

View File

@ -22,8 +22,13 @@
<input class="field-value" type="checkbox" name="register-init" id="register-init" checked /> <input class="field-value" type="checkbox" name="register-init" id="register-init" checked />
</label> </label>
</div> </div>
</div> </div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.initMalus'}}</label>
</div>
<div class="flex1 center cell">{{combatData.malusInit}}</div>
</div>
{{/if}} {{/if}}
{{> "systems/bol/templates/dialogs/career-roll-part.hbs"}} {{> "systems/bol/templates/dialogs/career-roll-part.hbs"}}