Review initiative
This commit is contained in:
@ -48,7 +48,13 @@ export class BoLActor extends Actor {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeMalus() {
|
||||
if ( this.type === 'encounter' && (this.chartype == "adversary" || this.chartype == "tough")) {
|
||||
return this.system.aptitudes.init.value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getBougette() {
|
||||
if (this.type == "character") {
|
||||
@ -871,17 +877,17 @@ export class BoLActor extends Actor {
|
||||
|
||||
/*-------------------------------------------- */
|
||||
getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
|
||||
if (!rollData) {
|
||||
rollData = this.getFlag("world", "last-initiative")
|
||||
}
|
||||
let fvttInit = 4 // Pietaille par defaut
|
||||
if (this.type == 'character') {
|
||||
fvttInit = 5
|
||||
fvttInit = -1
|
||||
if (!rollData) {
|
||||
if (isCombat) {
|
||||
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 {
|
||||
|
@ -584,7 +584,8 @@ export class BoLRoll {
|
||||
}
|
||||
|
||||
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
|
||||
rollData.formula = formula
|
||||
rollData.modifiers = modifiers
|
||||
@ -647,10 +648,11 @@ export class BoLDefaultRoll {
|
||||
this.rollData.reroll = actor.heroReroll()
|
||||
}
|
||||
if (this.rollData.registerInit) {
|
||||
actor.registerInit(this.rollData)
|
||||
await actor.registerInit(this.rollData)
|
||||
this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData)
|
||||
if (this.rollData.combatData) { // If combatData present
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,15 @@ export class BoLCombatManager extends Combat {
|
||||
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
|
||||
// Structure input data
|
||||
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
|
||||
for (let cId = 0; cId < ids.length; cId++) {
|
||||
for (let cId = 0; cId < ids.length; 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)
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
|
||||
}
|
||||
@ -64,7 +67,7 @@ export class BoLCombatManager extends Combat {
|
||||
return super.startCombat()
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
/*-***********************************************************************************/
|
||||
_onDelete() {
|
||||
if (game.user.isGM) {
|
||||
let combatants = this.combatants.contents
|
||||
|
Reference in New Issue
Block a user