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/), 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). 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] ## [4.2.3]
### Changed ### Changed

View File

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