Improved logic

This commit is contained in:
WBHarry 2026-06-30 13:02:04 +02:00
parent 7fac6e8e82
commit 8c2b114a04
2 changed files with 8 additions and 6 deletions

View file

@ -44,7 +44,7 @@ export default class DHSummonField extends fields.ArrayField {
const actor = await getWorldActor(await foundry.utils.fromUuid(summon.actorUUID));
/* Extending summon data in memory so it's available in actionField.toChat. Think it's harmless, but ugly. Could maybe find a better way. */
summon.actor = actor;
summon.actor = actor.toObject();
const countNumber = Number.parseInt(count);
for (let i = 0; i < countNumber; i++) {

View file

@ -893,13 +893,15 @@ export function shouldUseHopeFearAutomation(options = { gmAsPlayer: true }) {
export async function getWorldActor(baseActor) {
if (baseActor.inCompendium) {
const worldActorCopy =
game.actors.find(x => x._stats.compendiumSource === baseActor.uuid && x.name === baseActor.name);
const worldActorCopy = game.actors.find(x =>
x._stats.compendiumSource === baseActor.uuid &&
(!x.prototypeToken.actorLink || x.name === baseActor.name)
);
if (worldActorCopy)
return worldActorCopy.toObject();
return worldActorCopy;
const baseActorData = baseActor.toObject();
const baseActorData = baseActor;
return await game.system.api.documents.DhpActor.create({
...baseActorData,
_stats: {
@ -909,5 +911,5 @@ export async function getWorldActor(baseActor) {
});
}
return baseActor.toObject();
return baseActor;
}