spawn multiple tokens improvement
This commit is contained in:
parent
93767cd0bb
commit
08bbb6de87
@ -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
|
||||
|
||||
@ -45,25 +45,28 @@ export class BaseSummonEffect extends ActorFolderEffect {
|
||||
}
|
||||
|
||||
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({
|
||||
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 },
|
||||
label: { text: label },
|
||||
});
|
||||
const tokenDocs = [];
|
||||
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,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user