113 lines
3.7 KiB
JavaScript
113 lines
3.7 KiB
JavaScript
/* globals ColorAdjustmentsSamplerShader */
|
|
/* globals socketlib */
|
|
/* globals VisionMode */
|
|
/* globals warpgate */
|
|
import { api } from './api.js'
|
|
import { requestTokenRoll } from './helpers.js'
|
|
import { preDamageRollModifiers, preTraitRollModifiers } from './rollHelpers.js'
|
|
import { shapeChangeOnDismiss } from './powerEffects.js'
|
|
import { log, moduleHelpers } from './globals.js'
|
|
import { powerEffectManagementHook } from './powers.js'
|
|
|
|
function _checkModule (name) {
|
|
if (!game.modules.get(name)?.active && game.user.isGM) {
|
|
let action = 'install and activate'
|
|
if (game.modules.get(name)) action = 'activate'
|
|
ui.notifications.error(
|
|
`SWADE MB Helpers requires the ${name} module. Please ${action} it.`)
|
|
}
|
|
}
|
|
|
|
Hooks.on('setup', api.registerFunctions)
|
|
|
|
Hooks.on('init', () => {
|
|
log('INIT VISION')
|
|
CONFIG.Canvas.visionModes.basic = new VisionMode({
|
|
id: 'basic',
|
|
label: 'VISION.ModeBasicVision',
|
|
canvas: {
|
|
shader: ColorAdjustmentsSamplerShader,
|
|
uniforms: { contrast: 0, saturation: -0.85, brightness: -1.0 }
|
|
},
|
|
lighting: {
|
|
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED }
|
|
},
|
|
vision: {
|
|
darkness: { adaptive: false },
|
|
defaults: { attenuation: 0, contrast: 0, saturation: -0.85, brightness: -1.0 },
|
|
preferred: true
|
|
}
|
|
})
|
|
CONFIG.Canvas.visionModes.darkvision = new VisionMode({
|
|
id: 'darkvision',
|
|
label: 'VISION.ModeDarkvision',
|
|
canvas: {
|
|
shader: ColorAdjustmentsSamplerShader,
|
|
uniforms: { contrast: 0, saturation: 0, brightness: 0.75, tint: [0.8, 0.8, 1.0] }
|
|
},
|
|
lighting: {
|
|
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED },
|
|
levels: {
|
|
[VisionMode.LIGHTING_LEVELS.DIM]: VisionMode.LIGHTING_LEVELS.BRIGHT
|
|
}
|
|
},
|
|
vision: {
|
|
darkness: { adaptive: false },
|
|
defaults: { attenuation: 0.1, contrast: 0, saturation: 0, brightness: 0.75 },
|
|
preferred: false
|
|
}
|
|
})
|
|
CONFIG.Canvas.visionModes.lowlight = new VisionMode({
|
|
id: 'lowlight',
|
|
label: 'Low Light Vision',
|
|
canvas: {
|
|
shader: ColorAdjustmentsSamplerShader,
|
|
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 }
|
|
},
|
|
lighting: {
|
|
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED }
|
|
},
|
|
vision: {
|
|
darkness: { adaptive: false },
|
|
defaults: { attenuation: 0.1, contrast: 0, saturation: -0.5, brightness: -0.2 },
|
|
preferred: false
|
|
}
|
|
})
|
|
CONFIG.Canvas.visionModes.blindsense = new VisionMode({
|
|
id: 'blindsense',
|
|
label: 'Blindsense',
|
|
canvas: {
|
|
shader: ColorAdjustmentsSamplerShader,
|
|
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 }
|
|
},
|
|
lighting: {
|
|
background: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED },
|
|
coloration: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED },
|
|
illumination: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED }
|
|
},
|
|
vision: {
|
|
darkness: { adaptive: false },
|
|
defaults: { attenuation: 0.3, contrast: -0.5, saturation: 0.75, brightness: 0.5 },
|
|
preferred: false
|
|
}
|
|
})
|
|
})
|
|
|
|
Hooks.on('swadePreRollAttribute', preTraitRollModifiers)
|
|
Hooks.on('swadePreRollSkill', preTraitRollModifiers)
|
|
Hooks.on('swadeRollDamage', preDamageRollModifiers)
|
|
Hooks.on('deleteActiveEffect', powerEffectManagementHook)
|
|
|
|
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('requestTokenRoll', requestTokenRoll)
|
|
moduleHelpers._socket = _socket
|
|
})
|