From c4160b2fd5cc8073a62ac6cde8bbfacedaf645e0 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 16 Sep 2023 10:16:59 +0200 Subject: [PATCH] Combat tracker enhancements --- modules/pegasus-actor-sheet.js | 1 - modules/pegasus-actor.js | 31 ++++-- modules/pegasus-combat.js | 132 +++++++++++++++++--------- modules/pegasus-config.js | 7 ++ modules/pegasus-item-sheet.js | 1 + modules/pegasus-roll-dialog.js | 5 +- modules/pegasus-utility.js | 3 - styles/simple.css | 6 ++ system.json | 8 +- template.json | 1 + templates/chat-generic-result.html | 16 ++-- templates/item-effect-sheet.html | 8 +- templates/pegasus-combat-tracker.html | 15 ++- templates/roll-dialog-generic.html | 12 +-- 14 files changed, 165 insertions(+), 81 deletions(-) diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 8c60304..1ea3b38 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -38,7 +38,6 @@ export class PegasusActorSheet extends ActorSheet { cssClass: this.isEditable ? "editable" : "locked", data: actorData.system, traumaState: this.actor.getTraumaState(), - effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, specs: this.actor.getSpecs( ), config: game.system.pegasus.config, diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 3c7753b..e29aaa8 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -778,6 +778,10 @@ export class PegasusActor extends Actor { rollMode: game.settings.get("core", "rollMode"), whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')) } + this.createEmbeddedDocuments("ActiveEffect", [ + { label: 'EFFECT.StatusDaze', icon: 'icons/svg/daze.svg', flags: { core: { statusId: 'daze' } } } + ]) + if (incDec > 0) { chatData.content = `
${this.name} suffered a Stun level. 0 ) { + ui.notifications.warn("Unable to gain/use Momentum while stunned") + return + } + let momentum = duplicate(this.system.momentum) momentum.value += incDec this.update({ 'system.momentum': momentum }) @@ -1902,9 +1911,6 @@ export class PegasusActor extends Actor { let hindrancesDices = 0 if (this.type == "character" || this.type == 'npc') { - if (this.system.combat.stunlevel > 0) { - hindrancesDices += 2 - } hindrancesDices += this.system.combat.hindrancedice let overCapacity = Math.floor(this.encCurrent / this.getEncumbranceCapacity()) if (overCapacity > 0) { @@ -1924,9 +1930,6 @@ export class PegasusActor extends Actor { } } if (this.type == "vehicle") { - if (this.system.stun.value > 0) { - hindrancesDices += 2 - } if (this.isVehicleCrawling()) { hindrancesDices += 3 } @@ -2136,8 +2139,6 @@ export class PegasusActor extends Actor { rollData.noBonusDice = this.checkNoBonusDice() rollData.dicePool = [] rollData.subKey = subKey - rollData.tic1 = "NONE" - rollData.tic2 = "NONE" if (subKey == "melee-dmg" || subKey == "ranged-dmg" || subKey == "power-dmg") { rollData.isDamage = true @@ -2270,6 +2271,15 @@ export class PegasusActor extends Actor { } } } + /* -------------------------------------------- */ + getExtraTICsFromEffect() { + let effects = this.items.filter(it => it.type == "effect" && Number(it.system.extratics)>0) + let nbTics = 0 + for (let e of effects) { + nbTics += Number(it.system.extratics) + } + return nbTics + } /* -------------------------------------------- */ getLevelRemainingList() { @@ -2390,6 +2400,11 @@ export class PegasusActor extends Actor { console.log("MR ROLL", rollData) if (isInit) { rollData.title = "MR / Initiative" + rollData.nbTIC = ((this.type == "character") ? 2 : 1) + this.getExtraTICsFromEffect() + rollData.TICs = [] + for(let i=0; i { game.combat.resetNPCInitiative() }) + html.find('.select-combat-actor').click(ev => { + let combatantId = $(ev.currentTarget).data("combatant-id") + game.combat.selectActor(combatantId) + }) + } @@ -46,11 +68,11 @@ export class PegasusCombat extends Combat { /* -------------------------------------------- */ async resetNPCInitiative() { - for(let c of this.combatants) { + for (let c of this.combatants) { if (c.actor && c.actor.type == "npc") { await this.updateEmbeddedDocuments("Combatant", [{ _id: c.id, initiative: -1 }]); } - } + } } /* -------------------------------------------- */ @@ -62,6 +84,21 @@ export class PegasusCombat extends Combat { return false } + /* -------------------------------------------- */ + selectActor(combatantId) { + const combatant = game.combat.combatants.get(combatantId) + if (combatant) { + let chatData = { + user: game.user.id, + alias: combatant.actor.name, + rollMode: game.settings.get("core", "rollMode"), + whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), + content: `
${combatant.actor.name} has been nominated to act, ${combatant.actor.name} choose which TIC you wish to activate! { - let chatData = { - user: game.user.id, - alias: combatant.actor.name, - rollMode: game.settings.get("core", "rollMode"), - whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), - content: `
${combatant.actor.name} is performing ${ticData.text} { + let chatData = { + user: game.user.id, + alias: combatant.actor.name, + rollMode: game.settings.get("core", "rollMode"), + whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), + content: `
${combatant.actor.name} is performing ${ticData[num].text}All Characters have acted, All Characters who do not have Stun gain 1 Momentum!Weapon Damage Dice : {{weaponDamageDice}} {{/if}} + + {{#if (eq subKey "dmg-res")}} +
  • Damage Resistance
  • + {{/if}} + {{#if isResistance}}
  • Armor Resistance Dice : {{armor.system.resistanceDice}}
  • ADRL : {{armor.system.adrl}}
  • @@ -53,12 +58,11 @@ {{/if}} {{#if (eq subKey "dmg-res")}} -
  • Damage Resistance
  • - {{#each armorsList as |armor idx|}} - {{#if armor.applied}} -
  • ADRL: {{armor.adrl}}
  • - {{/if}} - {{/each}} + {{#each armorsList as |armor idx|}} + {{#if armor.applied}} +
  • ADRL: {{armor.adrl}}
  • + {{/if}} + {{/each}} {{/if}} {{#if power}} diff --git a/templates/item-effect-sheet.html b/templates/item-effect-sheet.html index bf58941..b7810cd 100644 --- a/templates/item-effect-sheet.html +++ b/templates/item-effect-sheet.html @@ -88,7 +88,13 @@
  • - + +
  • + +
  • +
  • diff --git a/templates/pegasus-combat-tracker.html b/templates/pegasus-combat-tracker.html index dd79f9b..8cac80d 100644 --- a/templates/pegasus-combat-tracker.html +++ b/templates/pegasus-combat-tracker.html @@ -66,7 +66,7 @@
  • {{this.name}}
    -

    {{this.name}}

    +

    {{this.name}}

    {{#if ../user.isGM}} @@ -96,10 +96,15 @@ {{/if}}
    - {{getTIC 1 this.id}} - {{#if (isCharacter this.id)}} - {{getTIC 2 this.id}} - {{/if}} + {{#each this.TICs as | tic index|}} + + {{/each}}
    diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index 3ae91ce..9aea318 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -156,16 +156,12 @@ {{/if}} {{#if isInit}} -
    - TIC 1: - -
    - {{#if (eq actorType "character")}} + {{#each TICs as |tic index|}}
    - TIC 2: - + TIC {{add index 1}}: +
    - {{/if}} + {{/each}} {{/if}}