Skip to content

CombatTracker, ChatCard, Fear Roll and localization fixes#307

Merged
ClipplerBlood merged 14 commits intoXacus:masterfrom
sasquach45932:master
Apr 9, 2026
Merged

CombatTracker, ChatCard, Fear Roll and localization fixes#307
ClipplerBlood merged 14 commits intoXacus:masterfrom
sasquach45932:master

Conversation

@sasquach45932
Copy link
Copy Markdown
Contributor

Thanks for pt-br transaltion to @nafeels !

@sasquach45932
Copy link
Copy Markdown
Contributor Author

image image image image image

@sasquach45932
Copy link
Copy Markdown
Contributor Author

Item macro

PrePass PostPass Description
preRollAttack postRollAttack Weapon
preRollTalent postRollTalent Talent/Special Attack
preRollSpell postRollSpell Spell
preRollItem postRollItem Inventory Item/Trait/Special Action, End Of The Round (*)
preRollItem postRollItem End Of The Round (**)

Global parameters: item, speaker, actor, token, character

Pass specific parameters:

Pass Parameters
preRollAttack attackAttribute, defenseAttribute, targetActorUuid
postRollTalent attackRoll, targetNumber, successfullHit ,plus20, targetActorUuid
preRollTalent targetActorUuid (*)
postRollTalent attackRoll, targetNumber, successfullHit ,plus20, targetActorUuid
preRollSpell attackAttribute, defenseAttribute, targetActorUuid
postRollSpell attackRoll, targetNumber, successfullHit ,plus20, targetActorUuid
preRollItem targetActorUuid (*)
postRollItem targetActorUuid (*)
preRollItem attackAttribute, defenseAttribute, targetActorUuid (*)
postRollItem attackRoll, targetNumber, successfullHit ,plus20, targetActorUuid (**)

(*) - Does not have attack attribute
(**) - Has attack attribute

Example Weapon macro.

In case of successful hit, it applies the Blinded affliction on the target for 1 round. If the total of the attack roll was 20 or higher and exceeds the score of the attribute or characteristic by 5 or more, the Blinded affliction duration is 3 rounds.

if (args.pass === 'postRollAttack' && args.successfullHit) {
    const targetActor = fromUuidSync(args.targetActorUuid)
    const blindedEffect = foundry.utils.deepClone(CONFIG.statusEffects.find(e => e.id === 'blinded'))
    blindedEffect['statuses'] = blindedEffect.id
    blindedEffect.duration.rounds = args.plus20 ? 3 : 1

    await ActiveEffect.create(blindedEffect, {
        parent: targetActor,
    })
}

Copy link
Copy Markdown
Contributor

@juanferrer juanferrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few questions/suggestions.

Comment thread src/module/utils/handlebars-helpers.js Outdated
else return game.i18n.localize(tooltip)
})

Handlebars.registerHelper('dlLocalize', function (groupName, str) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should change the name to improve clarity, as it's building the localization string and handling special cases.

Comment thread src/module/actor/actor.js Outdated
// Get attacker attribute and defender attribute name
let attackAttribute = item.system.action?.attack?.toLowerCase()
const defenseAttribute = item.system.action?.against?.toLowerCase()
if (game.settings.get('demonlord', 'enableItemMacro')) await item.executeDLMacro({},{pass : 'preRollAttack', attackAttribute : attackAttribute, defenseAttribute: defenseAttribute, targetActorUuid: defender?.uuid})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should get the value once to avoid querying the settings so many times.

const itemMacroEnabled = game.settings.get('demonlord', 'enableItemMacro')

and reuse

Comment thread src/module/chat/effect-messages.js Outdated
Comment on lines +161 to +179
@@ -168,13 +168,42 @@ export function buildAttackEffectsMessage(attacker, defender, item, attackAttrib
: defender?.system.horrifying
? game.i18n.localize('DL.CreatureHorrifying')
: ''
else
creatureType =
defender?.system.frightening && defender?.system.horrifying
? game.i18n.localize('DL.CreatureHorrifying') + '/' + game.i18n.localize('DL.CreatureFrightening')
: defender?.system.frightening
? game.i18n.localize('DL.CreatureFrightening')
: defender?.system.horrifying
? game.i18n.localize('DL.CreatureHorrifying')
: ''
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand the code, it's basically the following:

  • If we're in traitMode2025, it only matters if it's horrifying
  • Otherwise, we add the relevant string for frightening/horrifying

Nested ternary operators get too complex too quickly. It can be simplified like this:

let creatureType = ''
const isFrightening = defender?.system.frightening
const isHorrifying = defender?.system.horrifying
const isTraitMode2025 = game.settings.get('demonlord', 'optionalRuleTraitMode2025')

if (isHorrifying && isTraitMode2025) {
  creatureType = game.i18n.localize('DL.CreatureHorrifying')
} else if (isFrightening || isHorrifying) {
  creatureType = isHorrifying ? game.i18n.localize('DL.CreatureHorrifying') : game.i18n.localize('DL.CreatureFrightening')
}

I removed the frightening AND horrifying case, as a creature can't be frightening and horrifying, the strongest state wins (i.e. horrifying).

Copy link
Copy Markdown
Contributor

@juanferrer juanferrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ClipplerBlood ClipplerBlood merged commit e4bc2e3 into Xacus:master Apr 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants