[Fix] Beastform Effect Size Issue (#1368)

* Fixed so beastform effects handle actors being smaller than 1

* .
This commit is contained in:
WBHarry 2025-12-06 21:08:08 +01:00 committed by GitHub
parent 6d8d773a26
commit c3cb9121af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 2 deletions

View file

@ -19,8 +19,8 @@ export default class BeastformEffect extends BaseEffect {
base64: false
}),
tokenSize: new fields.SchemaField({
height: new fields.NumberField({ integer: true, nullable: true }),
width: new fields.NumberField({ integer: true, nullable: true })
height: new fields.NumberField({ integer: false, nullable: true }),
width: new fields.NumberField({ integer: false, nullable: true })
})
}),
advantageOn: new fields.ArrayField(new fields.StringField()),
@ -29,6 +29,14 @@ export default class BeastformEffect extends BaseEffect {
};
}
/** @inheritDoc */
static migrateData(source) {
if (!source.characterTokenData.tokenSize.height) source.characterTokenData.tokenSize.height = 1;
if (!source.characterTokenData.tokenSize.width) source.characterTokenData.tokenSize.width = 1;
return super.migrateData(source);
}
async _onCreate(_data, _options, userId) {
if (userId !== game.user.id) return;

View file

@ -877,4 +877,32 @@ export default class DhpActor extends Actor {
return acc;
}, []);
}
/* Temporarily copying the foundry method to add a fix to a bug with scenes
https://discord.com/channels/170995199584108546/1296292044011995136/1446693077443149856
*/
getDependentTokens({ scenes, linked = false } = {}) {
if (this.isToken && !scenes) return [this.token];
if (scenes) scenes = Array.isArray(scenes) ? scenes : [scenes];
else scenes = Array.from(this._dependentTokens.keys());
/* Code to filter out nonexistant scenes */
scenes = scenes.filter(scene => game.scenes.some(x => x.id === scene.id));
if (this.isToken) {
const parent = this.token.parent;
return scenes.includes(parent) ? [this.token] : [];
}
const allTokens = [];
for (const scene of scenes) {
if (!scene) continue;
const tokens = this._dependentTokens.get(scene);
for (const token of tokens ?? []) {
if (!linked || token.actorLink) allTokens.push(token);
}
}
return allTokens;
}
}