Tweak retrieving world actor (#2052)

This commit is contained in:
Carlos Fernandez 2026-07-01 18:48:07 -04:00 committed by GitHub
parent 489f62a379
commit d36c141d36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -893,13 +893,12 @@ export function shouldUseHopeFearAutomation(options = { gmAsPlayer: true }) {
export async function getWorldActor(baseActor) { export async function getWorldActor(baseActor) {
if (baseActor.inCompendium) { if (baseActor.inCompendium) {
const worldActorCopy = game.actors.find(x => const worldActorCandidates = game.actors.filter(x =>
x._stats.compendiumSource === baseActor.uuid && x._stats.compendiumSource === baseActor.uuid &&
(!x.prototypeToken.actorLink || x.name === baseActor.name) x.prototypeToken.actorLink === baseActor.prototypeToken.actorLink
); );
const worldActorCopy = worldActorCandidates.find(a => a.name === baseActor.name) ?? worldActorCandidates[0];
if (worldActorCopy) if (worldActorCopy) return worldActorCopy;
return worldActorCopy;
const baseActorData = baseActor; const baseActorData = baseActor;
return await game.system.api.documents.DhpActor.create({ return await game.system.api.documents.DhpActor.create({