Added support for adversary actor sizes

This commit is contained in:
WBHarry 2025-12-15 19:58:23 +01:00
parent 9b4249b100
commit d38b924cad
15 changed files with 180 additions and 5 deletions

View file

@ -41,7 +41,8 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
settingSheet: null,
hasResistances: true,
hasAttribution: false,
hasLimitedView: true
hasLimitedView: true,
usesSize: true
};
}
@ -76,6 +77,13 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
'DAGGERHEART.GENERAL.DamageResistance.magicalReduction'
)
});
if (this.metadata.usesSize)
schema.size = new fields.StringField({
required: true,
nullable: false,
choices: CONFIG.DH.ACTOR.tokenSize,
initial: CONFIG.DH.ACTOR.tokenSize.medium.id
});
return schema;
}
@ -138,6 +146,14 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
options.scrollingTextData = textData;
}
if (!this.parent.isToken && changes.system?.size) {
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
this.parent.prototypeToken.update({
width: tokenSizes[changes.system.size],
height: tokenSizes[changes.system.size]
});
}
if (changes.system?.resources) {
const defeatedSettings = game.settings.get(
CONFIG.DH.id,