develop #34

Merged
mike merged 14 commits from develop into main 2023-09-26 03:39:21 +00:00
2 changed files with 105 additions and 9 deletions
Showing only changes of commit e26f0c8fd6 - Show all commits

View File

@ -542,18 +542,29 @@ class ProtectionEffect extends TargetedPowerEffect {
}
class ShapeChangeEffect extends TargetedPowerEffect {
get actorFolderBase () {
return 'Morphables'
}
get tempActorFolder () {
return `${this.actorFolderBase}/Changed`
}
get actorFolder () {
return `${this.actorFolderBase}/${this.name}`
}
get name () {
return 'Shape Change'
}
get baseDurationRounds () {
if (this.increasedDuration ?? false) {
return 50
}
return 5
}
get actorFolder () {
return 'Shape Change'
}
async prepFolders () {
const folders = []
const folderNames = [
@ -620,6 +631,87 @@ class ShapeChangeEffect extends TargetedPowerEffect {
}
])
}
async prepResult () {
this.raise = (this.buttons === 'raise')
this.actorId = (this.inputs[this.inputIndex])
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)
this.protoDoc = await this.actor.getTokenDocument()
this.spawnOptions = {
controllingActor: this.targets[0].actor,
duplicates: 1,
crosshairs: {
rememberControlled: true
}
}
const effectChanges = []
if (this.raise) {
for (const stat of ['vigor', 'strength']) {
effectChanges.push({
key: `system.attributes.${stat}.die.sides`,
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
value: '+2',
priority: 0
})
}
}
this.effectDocs.push(
shim.createEffectDocument(
this.icon,
`Shape Change into ${this.protoDoc.name}`,
this.durationRounds, effectChanges)
)
this.spawnMutation = {
actor: {
name: `${this.targets[0].actor.name} (${this.actor.name} form)`,
system: {
attributes: {
smarts: { die: targetActor.system.attributes.smarts.die },
spirit: { die: targetActor.system.attributes.spirit.die }
},
wildcard: targetActor.system.wildcard
}
},
token: {
actorLink: false,
name: `${this.targets[0].name} (${this.protoDoc.name} form) `
},
embedded: { ActiveEffect: {}, Item: {} }
}
for (const doc of this.effectDocs) {
this.spawnMutation.embedded.ActiveEffect[doc.name] = doc
}
for (const doc of this.targets[0].actor.effects) {
this.spawnMutation.embedded.ActiveEffect[doc.name] = this.targets[0].actor.getEmbeddedDocument('ActiveEffect', doc.id)
}
for (const item of targetActor.items) {
if (item.type === 'skill' && ['smarts', 'spirit'].includes(item.system.attribute)) {
const doc = await this.targets[0].actor.getEmbeddedDocument('Item', item.id)
this.spawnMutation.embedded.Item[item.name] = doc
}
if (['power', 'edge', 'hindrance', 'action'].includes(item.type)) {
const doc = await this.targets[0].actor.getEmbeddedDocument('Item', item.id)
this.spawnMutation.embedded.Item[item.name] = doc
}
}
}
async applyResult () {
log('protoDoc', this.protoDoc)
log('spawnOptions', this.spawnOptions)
log('spawnMutation', this.spawnMutation)
await shim.warpgateSpawnAt(
this.targets[0].center,
this.protoDoc,
this.spawnMutation,
{},
this.spawnOptions
)
}
}
class SmiteEffect extends TargetedPowerEffect {
@ -864,6 +956,9 @@ class SummonEffect extends PowerEffect {
async applyResult () {
await this.prepAdditional()
log('protoDoc', this.protoDoc)
log('spawnOptions', this.spawnOptions)
log('spawnMutation', this.spawnMutation)
await shim.warpgateSpawn(this.protoDoc, this.spawnMutation, {}, this.spawnOptions)
}
}
@ -946,7 +1041,7 @@ class SummonAllyEffect extends SummonEffect {
}
const edge = template.items.getName(inputs[i])
if (edge) {
const doc = template.getEmbeddedDocument('Item', edge.id)
const doc = await template.getEmbeddedDocument('Item', edge.id)
this.spawnMutation.embedded.Item[edge.name] = doc
}
}
@ -960,7 +1055,6 @@ class SummonAllyEffect extends SummonEffect {
for (const item of template.items) {
const doc = await template.getEmbeddedDocument('Item', item.id)
this.spawnMutation.embedded.Item[item.name] = doc
log(`Added ${item.name} to spawn mutation`)
}
}
@ -972,12 +1066,10 @@ class SummonAllyEffect extends SummonEffect {
for (const item of template.items) {
const doc = await template.getEmbeddedDocument('Item', item.id)
this.spawnMutation.embedded.Item[item.name] = doc
log(`Added ${item.name} to spawn mutation`)
}
for (const effect of template.effects.values()) {
const doc = shim.ActiveEffect.fromSource(effect)
this.spawnMutation.embedded.ActiveEffect[effect.name] = doc
log(`Added ${effect.name} to spawn mutation`)
}
}
@ -1012,7 +1104,7 @@ class SummonAllyEffect extends SummonEffect {
this.spawnOptions.crosshairs.icon = this.icon
for (const mirrorItem of mirrorActor.items) {
this.spawnMutation.embedded.Item[mirrorItem.name] =
mirrorActor.getEmbeddedDocument('Item', mirrorItem.id)
await mirrorActor.getEmbeddedDocument('Item', mirrorItem.id)
}
this.spawnMutation.embedded.Item['Summon Ally'] = CONST.WARPGATE.DELETE
const effectChanges = []

View File

@ -106,6 +106,10 @@ export class shim {
return warpgate.spawn(...args)
}
static warpgateSpawnAt (...args) {
return warpgate.spawnAt(...args)
}
static getActorFolderByPath (path) {
const names = path.split('/')
if (names[0] === '') {