fix for linked actors when summoning

This commit is contained in:
Mike Bloy 2026-03-09 22:23:52 -05:00
parent e9b08843b6
commit 39c114f06d
4 changed files with 30 additions and 2 deletions

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Gang up calculation was double-counting the attacker if the attacker had formation fighter.
- Fixed summons and deletions of linked tokens.
## [4.2.1]

View File

@ -1095,6 +1095,13 @@ export class ActorFolderEffect extends PowerEffect {
return doc;
}
async primaryDocForTarget(doc, target) {
const newDoc = await super.primaryDocForTarget(doc, target);
newDoc.flags[moduleName].spawnedTempTokenSceneId = target.parent.id;
newDoc.flags[moduleName].spawnedTempTokenId = target.id;
return newDoc;
}
async sideEffects() {
if (this.data.fatigue) {
for (const target of this.data.spawned) {

View File

@ -266,8 +266,22 @@ export async function powerEffectManagementHook(effect, data, userId) {
}
const isSpawned = effect.getFlag(moduleName, 'spawnedTempToken') ?? false;
if (isSpawned) {
const token = effect.parent.token;
await moduleHelpers.socket.executeAsGM(deleteToken, token.parent.id, token.id);
let token = effect.parent?.token;
let sceneId;
let tokenId;
if (token) {
sceneId = token.parent.id;
tokenId = token.id;
} else {
sceneId = effect.getFlag(moduleName, 'spawnedTempTokenSceneId');
tokenId = effect.getFlag(moduleName, 'spawnedTempTokenId');
}
function _deleteSpawnedToken(sceneId, tokenId) {
moduleHelpers.socket.executeAsGM(deleteToken, sceneId, tokenId);
}
if (sceneId && tokenId) {
setTimeout(_deleteSpawnedToken, 500, sceneId, tokenId);
}
}
const targetIds = effect.getFlag(moduleName, 'targetIds') || [];
for (const targetId of targetIds) {

View File

@ -542,6 +542,12 @@ export class SummonEidolonEffect extends BaseSummonEffect {
get modifiers() {
return super.modifiers.filter((m) => m.id === 'actorId');
}
get spawnUpdates() {
const updates = super.spawnUpdates;
delete updates.token.actorLink;
return updates;
}
}
export class SummonCompanionEffect extends SummonEidolonEffect {