From a1bb1577c0b2a549975eb53d43dff15b40f769ff Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sun, 24 Sep 2023 22:14:35 -0500 Subject: [PATCH] working shape change (needs warpgate update) --- scripts/powerEffects.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/powerEffects.js b/scripts/powerEffects.js index 8b3e044..6d21fcd 100644 --- a/scripts/powerEffects.js +++ b/scripts/powerEffects.js @@ -638,11 +638,18 @@ class ShapeChangeEffect extends TargetedPowerEffect { this.increasedDuration = (!!this.inputs[this.inputIndex + 1]) this.actor = shim.actors.get(this.actorId) this.icon = this.targets[0].document.texture.src - const targetActor = shim.actors.get(this.targets[0].actor.id) + const targetActor = this.targets[0].actor this.protoDoc = await this.actor.getTokenDocument() this.spawnOptions = { controllingActor: this.targets[0].actor, duplicates: 1, + updateOpts: { + embedded: { + Item: { + renderSheet: null + } + } + }, crosshairs: { rememberControlled: true } @@ -678,7 +685,9 @@ class ShapeChangeEffect extends TargetedPowerEffect { }, token: { actorLink: false, - name: `${this.targets[0].name} (${this.protoDoc.name} form) ` + name: `${this.targets[0].name} (${this.protoDoc.name} form) `, + elevation: this.targets[0].document.elevation, + disposition: this.targets[0].document.disposition }, embedded: { ActiveEffect: {}, Item: {} } } @@ -704,13 +713,18 @@ class ShapeChangeEffect extends TargetedPowerEffect { log('protoDoc', this.protoDoc) log('spawnOptions', this.spawnOptions) log('spawnMutation', this.spawnMutation) - await shim.warpgateSpawnAt( + const newTokenId = (await shim.warpgateSpawnAt( this.targets[0].center, this.protoDoc, this.spawnMutation, {}, this.spawnOptions - ) + ))[0] + if (!this.targets[0].document.hidden) { + await this.targets[0].toggleVisibility() + } + await this.targets[0].document.setFlag('swade-mb-helpers', 'shapeChange.to', newTokenId) + await this.targets[0].document.update({ x: 0, y: 0 }) } } @@ -866,6 +880,13 @@ class SummonEffect extends PowerEffect { this.spawnOptions = { controllingActor: this.token.actor, duplicates: this.number, + updateOpts: { + embedded: { + Item: { + renderSheet: null + } + } + }, crosshairs: { icon: this.icon, label: `Summon ${this.actor.name}`,