add spiritual weapon summon
This commit is contained in:
@@ -1378,6 +1378,110 @@ class SummonAllyEffect extends SummonEffect {
|
||||
}
|
||||
}
|
||||
|
||||
class SpiritualWeaponEffect extends SummonEffect {
|
||||
get name () {
|
||||
return 'Spiritual Weapon'
|
||||
}
|
||||
|
||||
async prepMenu () {
|
||||
await super.prepMenu()
|
||||
this.menuData.buttons = [
|
||||
this.menuData.buttons[0],
|
||||
{ label: 'Apply with Raise', value: 'raise' },
|
||||
this.menuData.buttons[1]
|
||||
]
|
||||
this.menuData.inputs.pop()
|
||||
this.menuData.inputs.pop()
|
||||
this.menuData.inputs[this.menuData.inputs.length - 1].label = 'Weapon to summon'
|
||||
const arcaneSkills = this.token.actor.items
|
||||
.filter(i => i.type === 'skill').filter(s => (
|
||||
s.system.swid === 'faith' ||
|
||||
s.system.swid === 'spellcasting' ||
|
||||
s.system.swid === 'performance')).map(s => {
|
||||
return {
|
||||
value: s.system.swid,
|
||||
html: s.name
|
||||
}
|
||||
})
|
||||
this.menuData.inputs.push(
|
||||
{ type: 'select', label: 'Arcane Skill', options: arcaneSkills }
|
||||
)
|
||||
}
|
||||
|
||||
async prepResult () {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.actorId = this.inputs[this.inputIndex]
|
||||
this.arcaneSkillSwid = this.inputs[this.inputIndex + 1]
|
||||
this.actor = shim.actors.get(this.actorId)
|
||||
this.icon = 'icons/weapons/hammers/hammer-double-glowing-yellow.webp'
|
||||
this.protoDoc = await this.actor.getTokenDocument()
|
||||
this.spawnOptions = {
|
||||
controllingActor: this.token.actor,
|
||||
duplicates: 1,
|
||||
updateOpts: {
|
||||
embedded: {
|
||||
Item: { renderSheet: null }
|
||||
}
|
||||
},
|
||||
crosshairs: {
|
||||
icon: this.icon,
|
||||
label: `Summon ${this.actor.name}`,
|
||||
drawOutline: true,
|
||||
rememberControlled: true
|
||||
}
|
||||
}
|
||||
this.spawnMutation = {
|
||||
actor: {
|
||||
name: `${this.token.name}'s ${this.actor.name}`,
|
||||
system: {
|
||||
wildcard: this.token.actor.system.wildcard,
|
||||
attributes: {
|
||||
spirit: {
|
||||
die: {
|
||||
sides: this.token.actor.system.attributes.spirit.die.sides,
|
||||
modifier: this.token.actor.system.attributes.spirit.die.modifier
|
||||
},
|
||||
'wild-die': {
|
||||
sides: this.token.actor.system.attributes.spirit['wild-die'].sides
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
token: {
|
||||
actorLink: false,
|
||||
name: `${this.token.name}'s ${this.protoDoc.name}`,
|
||||
disposition: this.token.document.disposition,
|
||||
sight: { enabled: false }
|
||||
},
|
||||
embedded: { ActiveEffect: {}, Item: {} }
|
||||
}
|
||||
const weaponItemId = this.actor.items.find(i =>
|
||||
i.type === 'weapon' && i.system.swid === 'spiritual-weapon').id
|
||||
const weaponDoc = this.actor.getEmbeddedDocument('Item', weaponItemId).clone()
|
||||
const arcaneSkill = this.token.actor.items.find(i => i.type === 'skill' && i.system.swid === this.arcaneSkillSwid)
|
||||
const arcaneDoc = this.token.actor.getEmbeddedDocument('Item', arcaneSkill.id).clone()
|
||||
this.spawnMutation.embedded.Item[weaponDoc.name] = {
|
||||
system: {
|
||||
damage: '@spi+d4',
|
||||
actions: {
|
||||
trait: arcaneDoc.name
|
||||
}
|
||||
}
|
||||
}
|
||||
// weaponDoc.system.actions.trait = arcaneDoc.name
|
||||
if (this.raise) {
|
||||
this.spawnMutation.embedded.Item[weaponDoc.name].system.damage = '@spi+d6'
|
||||
// weaponDoc.system.damage = '@spi+d6'
|
||||
}
|
||||
this.spawnMutation.embedded.Item[arcaneDoc.name] = arcaneDoc
|
||||
// this.spawnMutation.embedded.Item[weaponDoc.name] = weaponDoc
|
||||
for (const effectDocument of this.effectDocs) {
|
||||
this.spawnMutation.embedded.ActiveEffect[effectDocument.name] = effectDocument
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SummonAnimalEffect extends SummonEffect {
|
||||
get name () {
|
||||
return 'Summon Animal'
|
||||
@@ -1597,6 +1701,7 @@ const PowerClasses = {
|
||||
slothspeed: SlothSpeedEffect,
|
||||
smite: SmiteEffect,
|
||||
speed: SlothSpeedEffect,
|
||||
'spiritual-weapon': SpiritualWeaponEffect,
|
||||
'summon ally': SummonAllyEffect,
|
||||
'summon-ally': SummonAllyEffect,
|
||||
'summon animal': SummonAnimalEffect,
|
||||
|
||||
@@ -73,12 +73,12 @@ export async function preDamageRollModifiers (actor, item, roll, modifiers, opti
|
||||
const target = targets[0]
|
||||
_addArcaneModifiers(target, modifiers)
|
||||
const weaknesses = target.actor.items.filter(
|
||||
i => i.type === 'ability' && i.system.swid.toLowerCase().includes('weakness'))
|
||||
i => i.type === 'ability' && i.system.swid.toLowerCase().includes('environmental-weakness'))
|
||||
if (weaknesses.length > 0) {
|
||||
modifiers.push(...weaknesses.map(i => { return { label: i.name, value: '+4', ignore: true } }))
|
||||
}
|
||||
const resistances = target.actor.items.filter(
|
||||
i => i.type === 'ability' && i.system.swid.toLowerCase().includes('resistance'))
|
||||
i => i.type === 'ability' && i.system.swid.toLowerCase().includes('environmental-resistance'))
|
||||
if (resistances.length > 0) {
|
||||
modifiers.push(...resistances.map(i => { return { label: i.name, value: '-4', ignore: true } }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user