spawn multiple tokens improvement

This commit is contained in:
Mike Bloy 2026-03-23 19:08:08 -05:00
parent 93767cd0bb
commit 08bbb6de87
2 changed files with 24 additions and 15 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Changed how summon powers spawn multiple tokens.
## [4.2.3]
### Changed

View File

@ -45,25 +45,28 @@ export class BaseSummonEffect extends ActorFolderEffect {
}
async spawn() {
const location = await Sequencer.Crosshair.show({
distance: this.targetTokenDoc.height / 2,
texture: this.targetTokenDoc.texture.src,
snap: {
position: CONST.GRID_SNAPPING_MODES.VERTEX | CONST.GRID_SNAPPING_MODES.CENTER,
},
label: { text: this.targetTokenDoc.name },
});
const tokenDocs = [];
const spawned = [];
for (let i = 0; i < this.summonCount; i++) {
tokenDocs[i] = this.targetTokenDoc.clone({
x: location.token.x + i * 5,
y: location.token.y + i * 5,
let label = this.targetTokenDoc.name;
if (this.summonCount > 1) {
label = `${this.targetTokenDoc.name} #${i + 1}`;
}
const location = await Sequencer.Crosshair.show({
distance: this.targetTokenDoc.height / 2,
texture: this.targetTokenDoc.texture.src,
snap: {
position: CONST.GRID_SNAPPING_MODES.VERTEX | CONST.GRID_SNAPPING_MODES.CENTER,
},
label: { text: label },
});
const tokenDoc = this.targetTokenDoc.clone({
x: location.token.x,
y: location.token.y,
elevation: this.source.elevation,
});
const spawn = await this.source.scene.createEmbeddedDocuments('Token', [tokenDoc]);
spawned.push(...spawn);
}
log('token docs', tokenDocs);
const spawned = await this.source.scene.createEmbeddedDocuments('Token', tokenDocs);
log('Spawned', spawned);
return spawned;
}