develop WIP with working havoc
This commit is contained in:
parent
f4495df534
commit
5002134e2c
13
module.json
13
module.json
@ -15,6 +15,7 @@
|
||||
"esmodules": [
|
||||
"scripts/module.js"
|
||||
],
|
||||
"socket": true,
|
||||
"packs": [
|
||||
{
|
||||
"name": "module-docs",
|
||||
@ -54,22 +55,22 @@
|
||||
"label": "SWADE MB Helper Actors",
|
||||
"path": "packs/helper-actors",
|
||||
"type": "Actor",
|
||||
"system": "swade",
|
||||
"ownership": {
|
||||
"PLAYER": "OBSERVER",
|
||||
"ASSISTANT": "OWNER"
|
||||
},
|
||||
"system": "swade"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "swade-mb-gear",
|
||||
"label": "SWADE MB Gear",
|
||||
"path": "packs/gear",
|
||||
"type": "Item",
|
||||
"system": "swade",
|
||||
"ownership": {
|
||||
"PLAYER": "OBSERVER",
|
||||
"ASSISTANT": "OWNER"
|
||||
},
|
||||
"system": "swade"
|
||||
}
|
||||
}
|
||||
],
|
||||
"packFolders": [
|
||||
@ -106,6 +107,10 @@
|
||||
"compatibility": {
|
||||
"verified": "1.16.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "socketlib",
|
||||
"type": "module"
|
||||
}
|
||||
],
|
||||
"recommends": [
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { api } from './api.js'
|
||||
import { shapeChangeOnDismiss } from './powerEffects.js'
|
||||
import { log } from './shim.js'
|
||||
import { havocResult, shapeChangeOnDismiss } from './powerEffects.js'
|
||||
import { log, shim } from './shim.js'
|
||||
|
||||
const moduleName = 'swade-mb-helpers'
|
||||
|
||||
@ -17,6 +17,13 @@ Hooks.on('setup', api.registerFunctions)
|
||||
|
||||
Hooks.on('ready', () => {
|
||||
_checkModule('warpgate')
|
||||
_checkModule('socketlib')
|
||||
log('Initialized SWADE MB Helpers')
|
||||
warpgate.event.watch(warpgate.EVENT.DISMISS, shapeChangeOnDismiss)
|
||||
})
|
||||
|
||||
Hooks.on('socketlib.ready', () => {
|
||||
const socket = socketlib.registerModule('swade-mb-helpers')
|
||||
socket.register('havocResult', havocResult)
|
||||
shim._socket = socket
|
||||
})
|
||||
|
||||
@ -545,6 +545,27 @@ class EntangleEffect extends TargetedPowerEffect {
|
||||
}
|
||||
}
|
||||
|
||||
class HavocEffect extends TargetedPowerEffect {
|
||||
get name () {
|
||||
return 'Havoc'
|
||||
}
|
||||
|
||||
get baseDurationRounds () {
|
||||
return 1
|
||||
}
|
||||
|
||||
async prepResult () {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
}
|
||||
|
||||
async applyResult () {
|
||||
await super.applyResult()
|
||||
for (const target of this.targets) {
|
||||
await havocResult(target.id, this.raise)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IntangibilityEffect extends TargetedPowerEffect {
|
||||
get name () {
|
||||
return 'Intangility'
|
||||
@ -1349,6 +1370,7 @@ const PowerClasses = {
|
||||
'detectconceal-aracana': DetectConcealArcanaEffect,
|
||||
disguise: DisguiseEffect,
|
||||
entangle: EntangleEffect,
|
||||
havoc: HavocEffect,
|
||||
intangibility: IntangibilityEffect,
|
||||
invisibility: InvisibilityEffect,
|
||||
'lower trait': BoostLowerTraitEffect,
|
||||
@ -1419,3 +1441,30 @@ export async function shapeChangeOnDismiss (data) {
|
||||
await token.update(update)
|
||||
}
|
||||
}
|
||||
|
||||
export async function havocResult (tokenId, isRaise) {
|
||||
const token = shim.canvas.tokens.get(tokenId)
|
||||
if (!token) {
|
||||
log('Unable to find token with id ', tokenId)
|
||||
return
|
||||
}
|
||||
const owner = shim.warpgateUtil.firstOwner(token.document)
|
||||
if (owner !== shim.user) {
|
||||
shim.socket.executeAsUser(havocResult, owner.id, tokenId, isRaise)
|
||||
return
|
||||
}
|
||||
const effect = shim.getStatus('SWADE.Distr', 'Distracted')
|
||||
await shim.applyActiveEffects(token, [effect])
|
||||
log(`apply ${effect.label} to ${token.document.name}, raise: ${isRaise}`)
|
||||
const opts = {
|
||||
flavour: 'Resist Havoc',
|
||||
additionalMods: []
|
||||
}
|
||||
if (isRaise) {
|
||||
opts.additionalMods.push({ label: 'vs. Raise', value: -2 })
|
||||
}
|
||||
if (token.actor.effects.find(e => e.name === 'Flying')) {
|
||||
opts.additionalMods.push({ label: 'Flying', value: -2 })
|
||||
}
|
||||
token.actor.rollAttribute('strength', opts)
|
||||
}
|
||||
|
||||
@ -21,6 +21,10 @@ export class shim {
|
||||
return Actor
|
||||
}
|
||||
|
||||
static get canvas () {
|
||||
return game.canvas
|
||||
}
|
||||
|
||||
static get folders () {
|
||||
return game.folders
|
||||
}
|
||||
@ -49,6 +53,12 @@ export class shim {
|
||||
return game.scenes
|
||||
}
|
||||
|
||||
static _socket = null
|
||||
|
||||
static get socket () {
|
||||
return shim._socket
|
||||
}
|
||||
|
||||
static mergeObject (...args) {
|
||||
return mergeObject(...args)
|
||||
}
|
||||
@ -114,6 +124,10 @@ export class shim {
|
||||
return warpgate.spawnAt(...args)
|
||||
}
|
||||
|
||||
static get warpgateUtil () {
|
||||
return warpgate.util
|
||||
}
|
||||
|
||||
static getActorFolderByPath (path) {
|
||||
const names = path.split('/')
|
||||
if (names[0] === '') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user