shape change part 3
This commit is contained in:
parent
8aac513792
commit
5c9556471e
@ -1,4 +1,4 @@
|
|||||||
import { moduleName } from '../globals.js';
|
import { log, moduleName } from '../globals.js';
|
||||||
import { ActorFolderEffect } from './basePowers.js';
|
import { ActorFolderEffect } from './basePowers.js';
|
||||||
|
|
||||||
export class ShapeChangeEffect extends ActorFolderEffect {
|
export class ShapeChangeEffect extends ActorFolderEffect {
|
||||||
@ -99,7 +99,7 @@ export class ShapeChangeEffect extends ActorFolderEffect {
|
|||||||
}
|
}
|
||||||
this.data.tokenUpdates = {
|
this.data.tokenUpdates = {
|
||||||
flags: {
|
flags: {
|
||||||
[moduleName]: { 'shapeChange.srcTokenId': this.target.id },
|
[moduleName]: { 'shapeChange.srcTokenUuid': this.target.document.uuid },
|
||||||
},
|
},
|
||||||
actorLink: false,
|
actorLink: false,
|
||||||
name: `${this.target.name} (${this.targetActor.prototypeToken.name} form)`,
|
name: `${this.target.name} (${this.targetActor.prototypeToken.name} form)`,
|
||||||
@ -113,24 +113,33 @@ export class ShapeChangeEffect extends ActorFolderEffect {
|
|||||||
Item: {},
|
Item: {},
|
||||||
};
|
};
|
||||||
for (const effect of this.target.actor.effects) {
|
for (const effect of this.target.actor.effects) {
|
||||||
const doc = await this.target.actor.getEmbeddedDocument('ActiveEffect', effect.id);
|
const doc = deepClone(await this.target.actor.getEmbeddedDocument('ActiveEffect', effect.id));
|
||||||
this.data.embeddedUpdates.ActiveEffect[effect.name] = doc;
|
this.data.embeddedUpdates.ActiveEffect[effect.name] = doc;
|
||||||
}
|
}
|
||||||
for (const item of this.target.actor.items.filter(
|
for (const item of this.target.actor.items.filter(
|
||||||
(i) =>
|
(i) =>
|
||||||
(i.type === 'skill' && ['smarts', 'spirit'].includes(i.system.attribute)) ||
|
(i.type === 'skill' && ['smarts', 'spirit'].includes(i.system.attribute)) ||
|
||||||
['power', 'edge', 'hindrance', 'action'].includes(i.type),
|
['edge', 'hindrance', 'action'].includes(i.type),
|
||||||
)) {
|
)) {
|
||||||
const doc = await this.target.actor.getEmbeddedDocument('Item', item.id);
|
const doc = deepClone(await this.target.actor.getEmbeddedDocument('Item', item.id));
|
||||||
|
if (doc.type === 'power' && doc?.system?.choiceSets?.length > 0 && !doc.system.choiceSets[0].choice) {
|
||||||
|
doc.system.choiceSets[0].choice = 1;
|
||||||
|
}
|
||||||
this.data.embeddedUpdates.Item[item.name] = doc;
|
this.data.embeddedUpdates.Item[item.name] = doc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async spawn() {
|
async spawn() {
|
||||||
|
const target = this.target.document;
|
||||||
|
const size = target.parent.dimensions.size;
|
||||||
|
const protoWidth = this.targetActor.prototypeToken.width;
|
||||||
|
const protoHeight = this.targetActor.prototypeToken.height;
|
||||||
this.targetTokenDoc.updateSource({
|
this.targetTokenDoc.updateSource({
|
||||||
x: this.target.x,
|
x: target.x - ((protoWidth - target.width) * size) / 2,
|
||||||
y: this.target.y,
|
y: target.y - ((protoHeight - target.height) * size) / 2,
|
||||||
elevation: this.target.elevation,
|
elevation: target.elevation,
|
||||||
|
hidden: target.hidden,
|
||||||
|
alpha: target.alpha,
|
||||||
});
|
});
|
||||||
return this.source.scene.createEmbeddedDocuments('Token', [this.targetTokenDoc]);
|
return this.source.scene.createEmbeddedDocuments('Token', [this.targetTokenDoc]);
|
||||||
}
|
}
|
||||||
@ -175,8 +184,21 @@ export class ShapeChangeEffect extends ActorFolderEffect {
|
|||||||
return updates;
|
return updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sideEffects() {
|
||||||
|
// await this.target.document.update({
|
||||||
|
// hidden: true,
|
||||||
|
// alpha: 0.1,
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
get description() {
|
get description() {
|
||||||
let desc = super.description;
|
let desc = super.description;
|
||||||
|
desc += `<p>The caster ${this.data.transform === 'none' ? 'transforms' : 'causes the target to transform'}
|
||||||
|
into a <em>${this.targetActor.name}</em>.</p>`;
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shapeChangeTokenDeleteHandler(token, options, userId) {
|
||||||
|
log('TOKEN DELETED |', token, options, userId);
|
||||||
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { requestTokenRoll, addActiveEffectsToToken, deleteActiveEffectsFromToken
|
|||||||
import { preDamageRollModifiers, preTraitRollModifiers } from './rollHelpers.js';
|
import { preDamageRollModifiers, preTraitRollModifiers } from './rollHelpers.js';
|
||||||
import { log, moduleHelpers } from './globals.js';
|
import { log, moduleHelpers } from './globals.js';
|
||||||
import { powerEffectManagementHook, visualActiveEffectPowerButtons } from './powers/powers.js';
|
import { powerEffectManagementHook, visualActiveEffectPowerButtons } from './powers/powers.js';
|
||||||
|
import { shapeChangeTokenDeleteHandler } from './powers/shapeChange.js';
|
||||||
|
|
||||||
// Initialize module
|
// Initialize module
|
||||||
Hooks.once('init', async () => {
|
Hooks.once('init', async () => {
|
||||||
@ -44,6 +45,7 @@ Hooks.on('swadePreRollAttribute', preTraitRollModifiers);
|
|||||||
Hooks.on('swadePreRollSkill', preTraitRollModifiers);
|
Hooks.on('swadePreRollSkill', preTraitRollModifiers);
|
||||||
Hooks.on('swadeRollDamage', preDamageRollModifiers);
|
Hooks.on('swadeRollDamage', preDamageRollModifiers);
|
||||||
Hooks.on('deleteActiveEffect', powerEffectManagementHook);
|
Hooks.on('deleteActiveEffect', powerEffectManagementHook);
|
||||||
|
Hooks.on('deleteToken', shapeChangeTokenDeleteHandler);
|
||||||
Hooks.on('visual-active-effects.createEffectButtons', visualActiveEffectPowerButtons);
|
Hooks.on('visual-active-effects.createEffectButtons', visualActiveEffectPowerButtons);
|
||||||
Hooks.on('visual-active-effects.createEffectButtons', SwadeVAEbuttons);
|
Hooks.on('visual-active-effects.createEffectButtons', SwadeVAEbuttons);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user