Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@
"DL.SettingDSNColourDie": "Enable dice colouring",
"DL.SettingDSNHint": "Colourize the Dice So Nice! boons/banes dice. Select d3 die numerals (Arabic/Roman) on Demon Lord theme.",
"DL.SettingDSNLabel": "Dice So Nice! Settings",
"DL.SettingDamageScrollText": "Enable Scroll Text for Damage/Health",
"DL.SettingDamageScrollTextHint": "When checked, scrolling text appears above tokens about damage/heal value.",
"DL.SettingEnableQuickDraw": "Enable one-click draw for rolltables.",
"DL.SettingEnableQuickDrawHint": "Draw directly form sidebar, compendia or sheets (right-click).",
"DL.SettingFinesseAutoSelect": "Finesse weapon attack attribute auto select",
Expand Down
5 changes: 2 additions & 3 deletions src/module/active-effects/afflictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,10 @@ export class DLAfflictions {
effectsDataList.push(_buildBaseAffliction('grabbed', 'systems/demonlord/assets/icons/effects/grabbed.svg'))

// Horrified
const baneValue = game.settings.get('demonlord', 'optionalRuleBaneValue') ? -2 : -3
effectsDataList.push(
_buildBaseAffliction('horrified', 'systems/demonlord/assets/icons/effects/horrified.svg', [
addEffect('system.bonuses.challenge.boons.all', baneValue, effectPriority),
addEffect('system.bonuses.attack.boons.all', baneValue, effectPriority),
addEffect('system.bonuses.challenge.boons.all', -3, effectPriority),
addEffect('system.bonuses.attack.boons.all', -3, effectPriority),
]),
)

Expand Down
20 changes: 13 additions & 7 deletions src/module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,11 @@ getTargetAttackBane(target) {

for (let effect of this.appliedEffects) {
const specialDuration = foundry.utils.getProperty(effect, `flags.${game.system.id}.specialDuration`)
if (specialDuration === 'NextD20Roll' || specialDuration === 'NextChallengeRoll') await effect?.delete()
const doNotAnimate = foundry.utils.getProperty(effect, `flags.${game.system.id}.doNotAnimate`) === undefined ? false: true
if (specialDuration === 'NextD20Roll' || specialDuration === 'NextChallengeRoll') {
if (doNotAnimate) await effect?.delete({animate: false})
else await effect?.delete()
}
}

return challengeRoll
Expand Down Expand Up @@ -1066,6 +1070,7 @@ getTargetAttackBane(target) {
flags: {
demonlord: {
specialDuration: 'NextChallengeRoll',
doNotAnimate: true,
},
},
})
Expand Down Expand Up @@ -1101,13 +1106,13 @@ getTargetAttackBane(target) {
}, ],
flags: {
demonlord: {
specialDuration: 'NextChallengeRoll',
specialDuration: 'NextChallengeRoll', animate: false
},
},
})

await ActiveEffect.create(willChallengeRollBanesEffect, {
parent: actor,
parent: actor, animate: false
})
}
}
Expand All @@ -1128,12 +1133,13 @@ getTargetAttackBane(target) {
flags: {
demonlord: {
specialDuration: 'NextChallengeRoll',
doNotAnimate : true,
},
},
})

await ActiveEffect.create(darkMagicSpellsKnownEffect, {
parent: actor,
parent: actor, animate: false
})
}
}
Expand Down Expand Up @@ -1219,7 +1225,7 @@ getTargetAttackBane(target) {

if (validTargetArray.length >= 4 && !isStunned)
await ActiveEffect.create(fourAndMoreEffect, {
parent: actor,
parent: actor, animate: false
})

const isFrightened = actor.effects.find(e => e.statuses?.has('frightened')) === undefined ? false : true
Expand Down Expand Up @@ -1349,7 +1355,7 @@ getTargetAttackBane(target) {
})

await ActiveEffect.create(seesFrighteningSource, {
parent: actor,
parent: actor, animate: false
})
}

Expand Down Expand Up @@ -1539,7 +1545,7 @@ getTargetAttackBane(target) {
})

await ActiveEffect.create(seesFrighteningSource, {
parent: actor,
parent: actor, animate: false
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/module/actor/sheets/base-actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ export default class DLBaseActorSheet extends HandlebarsApplicationMixin(ActorSh
const affliction = CONFIG.statusEffects.find(a => a.id === afflictionId)
if (!affliction) return false
affliction['statuses'] = [affliction.id]

if (affliction.id === "horrified")
{
affliction.description = game.settings.get('demonlord', 'optionalRuleBaneValue') ? affliction.description.replace('3','2') : affliction.description = affliction.description.replace('2','3')
game.settings.get('demonlord', 'optionalRuleBaneValue') ? Object.keys(affliction.changes).forEach(function(value){ affliction.changes[value].value = -2 }) : Object.keys(affliction.changes).forEach(function(value){ affliction.changes[value].value = -3 })
}

await ActiveEffect.create(affliction, { parent: this.actor })
const targets = tokenManager.targets
switch (afflictionId) {
Expand Down
6 changes: 3 additions & 3 deletions src/module/chat/roll-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export async function postCustomTextToChat(actor, roll, options, attribute = {})
data['targetValue'] = targetNumber
data['failureText'] =
roll.total >= targetNumber
? game.i18n.localize('DL.YouCannotBeEffectedUntilYouCompleteARest')
? game.i18n.localize('DL.YouCannotBeAffectedUntilYouCompleteARest')
: game.i18n.format('DL.BecomeFrightenedForRounds', { round: `${durationRollFormulaText}` })
data['actionEffects'] = buildAttributeEffectsMessage(actor, attribute, 0, 0)
data['resultText'] =
Expand All @@ -530,7 +530,7 @@ export async function postCustomTextToChat(actor, roll, options, attribute = {})
if (options.legacyMode) {
data['failureText'] =
roll.total >= targetNumber
? game.i18n.localize('DL.YouCannotBeEffectedUntilYouCompleteARest')
? game.i18n.localize('DL.YouCannotBeAffectedUntilYouCompleteARest')
: isMad
? game.i18n.format('DL.GainedInsanityAndGoMad', { insanity: 1 })
: game.i18n.format('DL.GainedInsanity', { insanity: 1 })
Expand Down Expand Up @@ -592,7 +592,7 @@ export async function postCustomTextToChat(actor, roll, options, attribute = {})
if (options.legacyMode) {
data['failureText'] =
roll.total >= targetNumber
? game.i18n.format('DL.YouCannotBeEffectedUntilYouCompleteARest')
? game.i18n.format('DL.YouCannotBeAffectedUntilYouCompleteARest')
: game.i18n.format('DL.GainedInsanity', { insanity: `${insanityRollFormulaText}` })
} else {
data['failureText'] =
Expand Down
37 changes: 35 additions & 2 deletions src/module/demonlord.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,43 @@ Hooks.on('createToken', async _tokenDocument => {
return 0
})

Hooks.on('updateActor', async (actor, updateData) => {
Hooks.on("preUpdateActor", (actor, updateData, options) => {
options['demonlord'] = {
oldHealth: actor.system.characteristics.health.value
}
})

Hooks.on('updateActor', async (actor, updateData, options) => {
if (!game.ready || !actor.isOwner) return
if (Object.keys(updateData).equals(['_id'])) return

if (actor && updateData && options?.action == 'update' && options?.diff && game.settings.get('demonlord', 'damageScrollText')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have expected this to be part of Foundry! Nice work.

const oldHealth = options['demonlord'].oldHealth
const flatChanges = foundry.utils.flattenObject(updateData)
for (const [key, value] of Object.entries(flatChanges)) {
if (key === 'system.characteristics.health.value') {
/**
* Modified version of the awesome https://github.com/foundryvtt/dnd5e/blob/5.3.x/module/documents/actor/actor.mjs
* Big thanks to Andrew Clayton
*/
const tokens = actor.isToken ? [actor.token] : actor.getActiveTokens(true, true)
if (!tokens.length) return
const diff = value - oldHealth
for (const token of tokens) {
if (!token.object?.visible || token.isSecret) continue;
const t = token.object
canvas.interface.createScrollingText(t.center, diff * -1, {
duration: 1000,
fontSize: 28 + 20 * (Math.clamp(Math.abs(diff) / actor.system.characteristics.health.max, 0, 1)),
fill: diff > 0 ? "#a22223" : "#1b8f23",
direction: diff > 0 ? CONST.TEXT_ANCHOR_POINTS.BOTTOM : CONST.TEXT_ANCHOR_POINTS.TOP,
stroke: 0x000000,
strokeThickness: 4,
jitter: 0.25
})
}
}
}
}

if (game.combat) {
let token = actor.token || game.combats?.viewed?.combatants.find(c => c.actor?.id == actor.id)?.token
Expand Down
8 changes: 8 additions & 0 deletions src/module/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,4 +963,12 @@ export const registerSettings = function () {
type: Boolean,
config: true
})
game.settings.register('demonlord', 'damageScrollText', {
name: game.i18n.localize('DL.SettingDamageScrollText'),
hint: game.i18n.localize('DL.SettingDamageScrollTextHint'),
default: true,
scope: 'world',
type: Boolean,
config: true,
})
}
8 changes: 8 additions & 0 deletions src/module/utils/handlebars-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ export function registerHandlebarsHelpers() {
return ( game.settings.get('demonlord', 'optionalRuleHide2025FHTraits') && !game.settings.get('demonlord', 'optionalRuleTraitMode2025') && ([game.i18n.localize('DL.CreatureHorrifying').toLowerCase(), game.i18n.localize('DL.CreatureFrightening').toLowerCase()].find(x => x === a.toLowerCase()) !== undefined))
})

Handlebars.registerHelper('dlGetAfflictionToolTip', function (tooltip) {
if (tooltip === 'DL.AfflictionsHorrified')
return game.settings.get('demonlord', 'optionalRuleBaneValue')
? game.i18n.localize('DL.AfflictionsHorrified').replace('3', '2')
: game.i18n.localize('DL.AfflictionsHorrified').replace('2', '3')
else return game.i18n.localize(tooltip)
})

Handlebars.registerHelper('enrichHTMLUnrolled', async (x) => await TextEditor.enrichHTML(x, { unrolled: true }))
Handlebars.registerHelper('lookupAttributeModifier', (attributeName, actorData) =>
actorData?.system?.attributes[attributeName.toLowerCase()]?.modifier
Expand Down
5 changes: 3 additions & 2 deletions src/templates/actor/tabs/afflictions.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="tab demonlord-v2-tab scrollable {{cssClass}}" data-group="primary" data-tab="afflictions">
{{#*inline "dlAffliction"}}
<div class="item-group-affliction checkable {{#if value}}selected{{/if}} {{#if immune}}locked{{/if}}" style="width: auto; margin: 2px; position: relative;" {{#if
tooltip}}data-tippy-affliction="{{localize tooltip}}" {{/if}}>
<div class="item-group-affliction checkable {{#if value}}selected{{/if}} {{#if immune}}locked{{/if}}" style="width: auto; margin: 2px; position: relative;"
{{#if tooltip}}data-tippy-affliction="{{dlGetAfflictionToolTip tooltip}}" {{/if}}>
<input type="checkbox" id="data.afflictions.{{name}}" data-name="{{name}}" {{checked value}} />
<i class="icon-{{name}} themed-icon"></i>
<span class="sep"></span>
Expand Down Expand Up @@ -77,4 +77,5 @@
<span style="margin-left: 4px; text-align: center; width: 100%">{{localize "DL.ModsDisableAfflictions"}}</span>
</div>
</div>

</div>