Skip to content

Commit 3743c99

Browse files
committed
equipment toggle, sounds, etcetera
1 parent 3d87b60 commit 3743c99

6 files changed

Lines changed: 69 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Added
1414

15+
- `atLocation`, `radius`, `constrainedByWalls`, `volume`, and `duration` support for sound effects.
16+
- `equipment:[state]` roll options for `toggle` animations. Use them wisely.
1517
- `templateAsOrigin` preset option for `ranged` animations. Allows to have the template to be the source of the animation, as opposed to the owner token. Allows for template animations detached from token location.
1618

1719
### Changed
1820

21+
- The Sounds Database to use a two-digit indexes (01, 02, 03, etc.)
1922
- Inner Radiance Torrent (P) to use `templateAsOrigin`.
2023

2124
### Fixed

animations/spells.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@
145145
}
146146
}
147147
]
148-
}
148+
}

src/assets/soundDb.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1+
// Start from 01
2+
13
const p = 'modules/pf2e-graphics/assets/library'
24
const database = {
35
lightning_bolt: {
46
impact: {
5-
0: `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact A.wav`,
6-
1: `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact B.wav`,
7-
2: `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact C.wav`,
7+
'01': `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact A.wav`,
8+
'02': `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact B.wav`,
9+
'03': `${p}/sounds/ovani-sounds/Magic/Shock/Lightning Bolt Impact C.wav`,
810
},
911
},
1012
bow: {
11-
0: `${p}/sounds/gamedev-market/BowWhistleShot1.wav`,
12-
1: `${p}/sounds/gamedev-market/BowWhistleShot2.wav`,
13-
2: `${p}/sounds/gamedev-market/BowWhistleShot3.wav`,
14-
3: `${p}/sounds/gamedev-market/BowWhistleShot4.wav`,
15-
4: `${p}/sounds/gamedev-market/BowWhistleShot5.wav`,
16-
5: `${p}/sounds/gamedev-market/BowWhistleShot6.wav`,
17-
6: `${p}/sounds/gamedev-market/BowWhistleShot7.wav`,
13+
'01': `${p}/sounds/gamedev-market/BowWhistleShot1.wav`,
14+
'02': `${p}/sounds/gamedev-market/BowWhistleShot2.wav`,
15+
'03': `${p}/sounds/gamedev-market/BowWhistleShot3.wav`,
16+
'04': `${p}/sounds/gamedev-market/BowWhistleShot4.wav`,
17+
'05': `${p}/sounds/gamedev-market/BowWhistleShot5.wav`,
18+
'06': `${p}/sounds/gamedev-market/BowWhistleShot6.wav`,
19+
'07': `${p}/sounds/gamedev-market/BowWhistleShot7.wav`,
1820
},
1921
crossbow: {
20-
0: `${p}/sounds/gamedev-market/Crossbow Shot A.wav`,
21-
1: `${p}/sounds/gamedev-market/Crossbow Shot B.wav`,
22-
2: `${p}/sounds/gamedev-market/Crossbow Shot C.wav`,
23-
3: `${p}/sounds/gamedev-market/Crossbow Shot D.wav`,
22+
'01': `${p}/sounds/gamedev-market/Crossbow Shot A.wav`,
23+
'02': `${p}/sounds/gamedev-market/Crossbow Shot B.wav`,
24+
'03': `${p}/sounds/gamedev-market/Crossbow Shot C.wav`,
25+
'04': `${p}/sounds/gamedev-market/Crossbow Shot D.wav`,
2426
},
2527
}
2628

src/storage/AnimCore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ErrorMsg, dedupeStrings, dev, devMessage, findTokenByActor, getPlayerOwners, log, mergeObjectsConcatArrays, nonNullable } from 'src/utils.ts'
2-
import type { Entries, TokenOrDoc } from 'src/extensions'
2+
import type { TokenOrDoc } from 'src/extensions'
33
import { settings } from 'src/settings'
44
import { type PresetKeys, presets } from './presets'
55

src/storage/presets.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,20 @@ export const helpers = {
123123

124124
return seq
125125
},
126-
genericSoundFunction(seq: SoundSection, _item: ItemPF2e, _target: Target, options: SoundConfig) {
126+
genericSoundFunction(seq: SoundSection, _item: ItemPF2e, target: Target, options: SoundConfig) {
127127
seq.file(options?.file)
128+
129+
if (options?.atLocation)
130+
seq.atLocation(target, options.atLocation)
131+
if (options?.radius)
132+
seq.radius(options.radius)
133+
if (options?.constrainedByWalls)
134+
seq.constrainedByWalls(options.constrainedByWalls)
135+
if (options?.volume)
136+
seq.volume(options.volume)
137+
if (options?.duration)
138+
seq.duration(options.duration)
139+
128140
return seq
129141
},
130142
}
@@ -136,12 +148,17 @@ type presetOptions<T> =
136148

137149
interface rangedOptions {
138150
bounce: { file: string, sound: SoundConfig }
139-
templateAsOrigin: true
151+
templateAsOrigin: boolean
140152
}
141153

142154
interface SoundConfig {
143155
file: string
144156
waitUntilFinished: number
157+
atLocation: Parameters<SoundSection['atLocation']>[1]
158+
radius: number
159+
volume: number
160+
duration: number
161+
constrainedByWalls: boolean
145162
}
146163

147164
export interface EffectOptions<T extends PresetKeys> {

src/triggers/toggle.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
import { devMessage } from 'src/utils'
22

3+
function check(i: ItemPF2e, o: { _id: string, system: any }) {
4+
const result = {
5+
bool: false,
6+
options: [] as string[],
7+
}
8+
9+
if (i.system.rules.length) {
10+
result.bool = true
11+
}
12+
13+
if (o?.system?.equipped?.carryType || o?.system?.equipped?.handsHeld) {
14+
result.bool = true
15+
// @ts-expect-error These do exist.
16+
if (Number(i.handsHeld) === Number(i.hands.replace('+', ''))) {
17+
result.options.push(`equipment:wielded`)
18+
} else {
19+
result.options.push(`equipment:${o.system.equipped.carryType}`)
20+
}
21+
}
22+
23+
return result
24+
}
25+
326
function trifectaFunc(item: ItemPF2e, _options: { _id: string, system: Partial<ItemPF2e['system']> }, _id: ItemPF2e['id']) {
4-
if (!item.actor || !item.system.rules.length) return
27+
const { bool, options: newOptions } = check(item, _options)
28+
// If there is no actor, don't.
29+
// If there are no rules AND no special changes, don't. || If there are either rules or special changes, continue.
30+
if (!item.actor || !bool) return
531

632
const deliverable = {
7-
rollOptions: [...item.getRollOptions(), ...item.actor.getRollOptions()].sort(),
33+
rollOptions: [...item.getRollOptions(), ...item.actor.getRollOptions(), ...newOptions],
834
trigger: 'toggle' as const,
935
actor: item.actor,
1036
item,
1137
}
1238

13-
devMessage('Toggle Hook Data', deliverable, _options)
39+
devMessage('Toggle Hook Data', deliverable, _options, newOptions)
1440
window.pf2eGraphics.AnimCore.findAndAnimate(deliverable)
1541
}
1642

0 commit comments

Comments
 (0)