@wildshard/kit 0.0.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/GUIDE.md +221 -0
  2. package/content/abilities/bite.json +24 -0
  3. package/content/abilities/charge.json +25 -0
  4. package/content/abilities/claw.json +24 -0
  5. package/content/abilities/slam.json +24 -0
  6. package/content/abilities/swing.json +25 -0
  7. package/content/animated/bear/pbr/black-blaze.glb +0 -0
  8. package/content/animated/bear/pbr/black-blaze.json +1 -0
  9. package/content/animated/bear/pbr/black-old.glb +0 -0
  10. package/content/animated/bear/pbr/black-old.json +1 -0
  11. package/content/animated/bear/pbr/black.glb +0 -0
  12. package/content/animated/bear/pbr/black.json +1 -0
  13. package/content/animated/bear/pbr/brown-old.glb +0 -0
  14. package/content/animated/bear/pbr/brown-old.json +1 -0
  15. package/content/animated/bear/pbr/brown.glb +0 -0
  16. package/content/animated/bear/pbr/brown.json +1 -0
  17. package/content/animated/bear/toon/black-blaze.glb +0 -0
  18. package/content/animated/bear/toon/black-blaze.json +1 -0
  19. package/content/animated/bear/toon/black-old.glb +0 -0
  20. package/content/animated/bear/toon/black-old.json +1 -0
  21. package/content/animated/bear/toon/black.glb +0 -0
  22. package/content/animated/bear/toon/black.json +1 -0
  23. package/content/animated/bear/toon/brown-old.glb +0 -0
  24. package/content/animated/bear/toon/brown-old.json +1 -0
  25. package/content/animated/bear/toon/brown.glb +0 -0
  26. package/content/animated/bear/toon/brown.json +1 -0
  27. package/content/animated/boar/pbr/big.glb +0 -0
  28. package/content/animated/boar/pbr/big.json +1 -0
  29. package/content/animated/boar/pbr/black.glb +0 -0
  30. package/content/animated/boar/pbr/black.json +1 -0
  31. package/content/animated/boar/pbr/boar.glb +0 -0
  32. package/content/animated/boar/pbr/boar.json +1 -0
  33. package/content/animated/boar/pbr/ironhide.glb +0 -0
  34. package/content/animated/boar/pbr/ironhide.json +1 -0
  35. package/content/animated/boar/pbr/scarback.glb +0 -0
  36. package/content/animated/boar/pbr/scarback.json +1 -0
  37. package/content/animated/boar/pbr/sow.glb +0 -0
  38. package/content/animated/boar/pbr/sow.json +1 -0
  39. package/content/animated/boar/toon/big.glb +0 -0
  40. package/content/animated/boar/toon/big.json +1 -0
  41. package/content/animated/boar/toon/black.glb +0 -0
  42. package/content/animated/boar/toon/black.json +1 -0
  43. package/content/animated/boar/toon/boar.glb +0 -0
  44. package/content/animated/boar/toon/boar.json +1 -0
  45. package/content/animated/boar/toon/ironhide.glb +0 -0
  46. package/content/animated/boar/toon/ironhide.json +1 -0
  47. package/content/animated/boar/toon/scarback.glb +0 -0
  48. package/content/animated/boar/toon/scarback.json +1 -0
  49. package/content/animated/boar/toon/sow.glb +0 -0
  50. package/content/animated/boar/toon/sow.json +1 -0
  51. package/content/animated/catalogue.json +1 -0
  52. package/content/bodies/biped.json +5 -0
  53. package/content/bodies/quadruped.json +5 -0
  54. package/content/clips/quadruped.json +1 -0
  55. package/content/creatures/bear/look.json +199 -0
  56. package/content/creatures/bear/pbr/black-blaze.glb +0 -0
  57. package/content/creatures/bear/pbr/black-old.glb +0 -0
  58. package/content/creatures/bear/pbr/black.glb +0 -0
  59. package/content/creatures/bear/pbr/brown-old.glb +0 -0
  60. package/content/creatures/bear/pbr/brown.glb +0 -0
  61. package/content/creatures/bear/toon/black-blaze.glb +0 -0
  62. package/content/creatures/bear/toon/black-old.glb +0 -0
  63. package/content/creatures/bear/toon/black.glb +0 -0
  64. package/content/creatures/bear/toon/brown-old.glb +0 -0
  65. package/content/creatures/bear/toon/brown.glb +0 -0
  66. package/content/creatures/bear.json +257 -0
  67. package/content/creatures/boar/look.json +184 -0
  68. package/content/creatures/boar/pbr/big.glb +0 -0
  69. package/content/creatures/boar/pbr/black.glb +0 -0
  70. package/content/creatures/boar/pbr/boar.glb +0 -0
  71. package/content/creatures/boar/pbr/ironhide.glb +0 -0
  72. package/content/creatures/boar/pbr/scarback.glb +0 -0
  73. package/content/creatures/boar/pbr/sow.glb +0 -0
  74. package/content/creatures/boar/toon/big.glb +0 -0
  75. package/content/creatures/boar/toon/black.glb +0 -0
  76. package/content/creatures/boar/toon/boar.glb +0 -0
  77. package/content/creatures/boar/toon/ironhide.glb +0 -0
  78. package/content/creatures/boar/toon/scarback.glb +0 -0
  79. package/content/creatures/boar/toon/sow.glb +0 -0
  80. package/content/creatures/boar.json +275 -0
  81. package/content/creatures/bodies.json +4754 -0
  82. package/content/harvest-items.json +98 -0
  83. package/content/harvest.json +31 -0
  84. package/content/journal-icons/antlers.png +0 -0
  85. package/content/journal-icons/bear.png +0 -0
  86. package/content/journal-icons/boar.png +0 -0
  87. package/content/journal-icons/deer.png +0 -0
  88. package/content/journal-icons/elk.png +0 -0
  89. package/content/journal-icons/ghost.png +0 -0
  90. package/content/journal-icons/ironhide.png +0 -0
  91. package/content/journal-icons.json +9 -0
  92. package/content/shared/pickupCatalogue.json +1008 -0
  93. package/content/shared/starterBow.json +21 -0
  94. package/content/species/bear.json +144 -0
  95. package/content/species/boar.json +147 -0
  96. package/content/sword-debris.json +7 -0
  97. package/content/temperaments.json +519 -0
  98. package/content/tuning/bear.json +43 -0
  99. package/content/tuning/boar.json +32 -0
  100. package/content/tuning/deer.json +32 -0
  101. package/content/tuning/pursue.json +12 -0
  102. package/package.json +57 -4
  103. package/src/abilities.ts +85 -0
  104. package/src/body.ts +25 -0
  105. package/src/clips.ts +139 -0
  106. package/src/creatures.ts +76 -0
  107. package/src/geometry/arms.ts +725 -0
  108. package/src/geometry/bear.ts +521 -0
  109. package/src/geometry/boar.ts +604 -0
  110. package/src/geometry/bowProfile.ts +34 -0
  111. package/src/geometry/export.ts +101 -0
  112. package/src/geometry/meleeProfile.ts +261 -0
  113. package/src/geometry/nativeInteractionFacts.ts +7 -0
  114. package/src/geometry/nativeLooks.ts +54 -0
  115. package/src/geometry/riderArms.ts +215 -0
  116. package/src/geometry/sharedSpecs.ts +26 -0
  117. package/src/geometry/species.ts +768 -0
  118. package/src/geometry/specimenCatalogue.ts +80 -0
  119. package/src/geometry/starterCombat.ts +194 -0
  120. package/src/geometry/starterGlyphs.ts +12 -0
  121. package/src/geometry/starterMeleeProfile.ts +134 -0
  122. package/src/geometry/starterMoves.ts +172 -0
  123. package/src/index.ts +26 -0
  124. package/src/legacyCombat.ts +25 -0
  125. package/src/legacyHarvest.ts +104 -0
  126. package/src/legacyJournalIcons.ts +10 -0
  127. package/src/legacySpecies.ts +127 -0
  128. package/src/temperament.ts +97 -0
  129. package/README.md +0 -3
@@ -0,0 +1,80 @@
1
+ import {
2
+ nameBlob,
3
+ type NamedBlob,
4
+ type BlobOptions,
5
+ } from '@wildshard/sdk/blobs'
6
+ import { namedJsonSchema } from '@wildshard/sdk/formatJsonSchema'
7
+ import { encodeCanonicalJson } from '@wildshard/sdk/immutable'
8
+ import {
9
+ PickupCatalogueSchema,
10
+ SpecimenBookSchema,
11
+ type PickupCatalogueRows,
12
+ type SpecimenBookRows,
13
+ type SpecimenModelMetadataRows,
14
+ } from '@wildshard/shard-format/specimenCatalogue'
15
+ import { parse, object, array, string, unknown } from 'valibot'
16
+
17
+ import pickupRows from '../../content/shared/pickupCatalogue.json' with { type: 'json' }
18
+
19
+ /** Admit fresh shared pickup metadata for an offline recipe, without installing runtime models or loading geometry. */
20
+ export function sharedPickupCatalogue(): PickupCatalogueRows {
21
+ return parse(PickupCatalogueSchema, pickupRows)
22
+ }
23
+
24
+ /** A build-time catalogue: admitted rows and metadata, without runtime registration or model construction. */
25
+ export interface AuthoredSpecimenCatalogue {
26
+ readonly book: SpecimenBookRows
27
+ readonly model: (key: string) => SpecimenModelMetadataRows
28
+ }
29
+
30
+ /** Admit a complete specimen book once; model lookups retain its ordered authored metadata. */
31
+ export function defineSpecimenCatalogue(
32
+ input: unknown,
33
+ ): AuthoredSpecimenCatalogue {
34
+ const book = parse(SpecimenBookSchema, input),
35
+ models = new Map<string, SpecimenModelMetadataRows>()
36
+ for (const row of book.rows) {
37
+ if (models.has(row.key))
38
+ throw new Error(`Duplicate authored specimen ${row.key}`)
39
+ models.set(row.key, row.model)
40
+ }
41
+ return {
42
+ book,
43
+ model(key) {
44
+ const model = models.get(key)
45
+ if (model === undefined)
46
+ throw new Error(`Missing authored specimen ${key}`)
47
+ return model
48
+ },
49
+ }
50
+ }
51
+
52
+ /** Emit admitted book data with its defining schema and caller-owned tier/dependencies. */
53
+ export function nameSpecimenBook(
54
+ name: string,
55
+ input: unknown,
56
+ options: Pick<BlobOptions, 'tier' | 'dependencies'> = {},
57
+ ): NamedBlob {
58
+ const book = defineSpecimenCatalogue(input).book
59
+ return nameBlob(
60
+ name,
61
+ 'json',
62
+ new TextEncoder().encode(encodeCanonicalJson(book)),
63
+ {
64
+ ...options,
65
+ jsonSchema: namedJsonSchema(SpecimenBookSchema, { provenance: true }),
66
+ },
67
+ )
68
+ }
69
+
70
+ /** Admit the named shape envelope from an offline painter. Geometry remains
71
+ * opaque here and must pass the consumer's complete geometry grammar; no model
72
+ * is constructed and unrelated source metadata is stripped as before. */
73
+ export function specimenShapeSources(
74
+ input: unknown,
75
+ ): { key: string; name: string; geometry: unknown }[] {
76
+ const shapeSources = object({
77
+ rows: array(object({ key: string(), name: string(), geometry: unknown() })),
78
+ })
79
+ return parse(shapeSources, input).rows
80
+ }
@@ -0,0 +1,194 @@
1
+ import type { MeleeWeaponProfileSchema } from '@wildshard/shard-format/weaponProfiles'
2
+ import type * as v from 'valibot'
3
+
4
+ type Swing = v.InferOutput<
5
+ typeof MeleeWeaponProfileSchema
6
+ >['moves']['combo'][number]
7
+
8
+ /** Shared starter swords' authored combat parameters; the separate move recipes own poses, trails and camera response. */
9
+ export const STARTER_MELEE_PROFILE: {
10
+ family: 'melee'
11
+ damage: number
12
+ reach: number
13
+ swingScale: number
14
+ cooldown: number
15
+ comboGap: number
16
+ chainLag: number
17
+ heavyCharge: number
18
+ moves: {
19
+ combo: [
20
+ {
21
+ windup: number
22
+ slashEnd: number
23
+ total: number
24
+ damage: number
25
+ stagger: number
26
+ sweep: number
27
+ },
28
+ {
29
+ windup: number
30
+ slashEnd: number
31
+ total: number
32
+ damage: number
33
+ stagger: number
34
+ sweep: number
35
+ },
36
+ {
37
+ windup: number
38
+ slashEnd: number
39
+ total: number
40
+ damage: number
41
+ stagger: number
42
+ sweep: number
43
+ },
44
+ ]
45
+ heavy: {
46
+ windup: number
47
+ slashEnd: number
48
+ total: number
49
+ damage: number
50
+ stagger: number
51
+ sweep: number
52
+ }
53
+ }
54
+ lunge: {
55
+ range: number
56
+ heavyRange: number
57
+ cone: number
58
+ stop: number
59
+ speed: number
60
+ minTime: number
61
+ maxTime: number
62
+ }
63
+ sweep: {
64
+ rays: number
65
+ extensions: number[]
66
+ step: number
67
+ maxSamples: number
68
+ maxHits: number
69
+ }
70
+ } = {
71
+ family: 'melee',
72
+ damage: 12,
73
+ reach: 2.2,
74
+ swingScale: 1,
75
+ cooldown: 0.08,
76
+ comboGap: 0.6,
77
+ chainLag: 0.02,
78
+ heavyCharge: 0.45,
79
+ moves: {
80
+ combo: [
81
+ {
82
+ windup: 0.07,
83
+ slashEnd: 0.235,
84
+ total: 0.35,
85
+ damage: 1,
86
+ stagger: 0,
87
+ sweep: 1,
88
+ },
89
+ {
90
+ windup: 0.06,
91
+ slashEnd: 0.22,
92
+ total: 0.34,
93
+ damage: 1,
94
+ stagger: 0,
95
+ sweep: -1,
96
+ },
97
+ {
98
+ windup: 0.1,
99
+ slashEnd: 0.28,
100
+ total: 0.44,
101
+ damage: 16 / 12,
102
+ stagger: 0.25,
103
+ sweep: 0.5,
104
+ },
105
+ ] satisfies [Swing, Swing, Swing],
106
+ heavy: {
107
+ windup: 0.06,
108
+ slashEnd: 0.3,
109
+ total: 0.62,
110
+ damage: 2,
111
+ stagger: 1,
112
+ sweep: 0.35,
113
+ },
114
+ },
115
+ lunge: {
116
+ range: 4,
117
+ heavyRange: 5,
118
+ cone: (25 * Math.PI) / 180,
119
+ stop: 1.1,
120
+ speed: 22,
121
+ minTime: 0.08,
122
+ maxTime: 0.15,
123
+ },
124
+ sweep: {
125
+ rays: 5,
126
+ extensions: [0.12, 0.24, 0.36, 0.48],
127
+ step: 0.09,
128
+ maxSamples: 6,
129
+ maxHits: 8,
130
+ },
131
+ } satisfies v.InferOutput<typeof MeleeWeaponProfileSchema>
132
+ /** Existing iron upgrade changes only base contact damage. */
133
+ export const IRON_MELEE_PROFILE: {
134
+ damage: number
135
+ family: 'melee'
136
+ reach: number
137
+ swingScale: number
138
+ cooldown: number
139
+ comboGap: number
140
+ chainLag: number
141
+ heavyCharge: number
142
+ moves: {
143
+ combo: [
144
+ {
145
+ windup: number
146
+ slashEnd: number
147
+ total: number
148
+ damage: number
149
+ stagger: number
150
+ sweep: number
151
+ },
152
+ {
153
+ windup: number
154
+ slashEnd: number
155
+ total: number
156
+ damage: number
157
+ stagger: number
158
+ sweep: number
159
+ },
160
+ {
161
+ windup: number
162
+ slashEnd: number
163
+ total: number
164
+ damage: number
165
+ stagger: number
166
+ sweep: number
167
+ },
168
+ ]
169
+ heavy: {
170
+ windup: number
171
+ slashEnd: number
172
+ total: number
173
+ damage: number
174
+ stagger: number
175
+ sweep: number
176
+ }
177
+ }
178
+ lunge: {
179
+ range: number
180
+ heavyRange: number
181
+ cone: number
182
+ stop: number
183
+ speed: number
184
+ minTime: number
185
+ maxTime: number
186
+ }
187
+ sweep: {
188
+ rays: number
189
+ extensions: number[]
190
+ step: number
191
+ maxSamples: number
192
+ maxHits: number
193
+ }
194
+ } = { ...STARTER_MELEE_PROFILE, damage: 28 }
@@ -0,0 +1,12 @@
1
+ /** The existing swap glyphs, shared by weapon rows (no equipment-id lookup in the HUD). */
2
+ export const SWAP_GLYPHS = {
3
+ sword:
4
+ '<path d="M20.5 3.5 9.2 14.8M20.5 3.5l-.6 4.2M20.5 3.5l-4.2.6"/><path d="M6.6 12.2l5.2 5.2M8.4 15.6 4 20"/>',
5
+ bow: '<path d="M6 3c7 3.5 7 14.5 0 18"/><path d="M6 3v18" stroke-width="0.9"/><path d="M4 12h15M16.5 9.5 19 12l-2.5 2.5"/>',
6
+ sabre:
7
+ '<path d="M5 19c4-3.5 9.5-9.5 13.5-15.5-1 5-5.5 11.5-11.5 16.5"/><path d="M3.5 16.5l4.5 4.5M4.5 21.5l2-2"/>',
8
+ spear:
9
+ '<path d="M4 20 16 8"/><path d="M16 8c.8-2.6 2.6-4.4 5-5-.6 2.4-2.4 4.2-5 5z"/><path d="M13.2 8.6l2.2 2.2"/>',
10
+ rifle: '<path d="M3 13h14l3-2h1v3h-4l-2 2H9l-1 3H5l1-3H3z"/>',
11
+ crossbow: '<path d="M4 7c4 3 12 3 16 0M12 5v15M8 17h8"/>',
12
+ } as const
@@ -0,0 +1,134 @@
1
+ import { STARTER_MELEE_PROFILE, IRON_MELEE_PROFILE } from './starterCombat.ts'
2
+ import { SWAP_GLYPHS } from './starterGlyphs.ts'
3
+ import {
4
+ REST,
5
+ CHARGE,
6
+ SPRINT,
7
+ COMBO,
8
+ HEAVY,
9
+ CHARGE_BLEND,
10
+ } from './starterMoves.ts'
11
+
12
+ import type { MeleeProfile as AuthoredMeleeProfile } from './meleeProfile.ts'
13
+
14
+ type MeleeProfile = AuthoredMeleeProfile<
15
+ 'sword',
16
+ 'sword' | 'sword-iron',
17
+ 'melee'
18
+ >
19
+
20
+ type EquipmentRow = Pick<
21
+ MeleeProfile,
22
+ 'id' | 'legacySlot' | 'ui' | 'meta' | 'cues'
23
+ >
24
+
25
+ /** The starter wooden sword equipment row and existing UI metadata. */
26
+ export const WOODEN_SWORD: EquipmentRow = {
27
+ cues: {
28
+ fire: 'cue.sword.swing',
29
+ reload: 'cue.reload',
30
+ impact: 'cue.sword.hit',
31
+ },
32
+ id: 'weapon.sword',
33
+ legacySlot: 'sword',
34
+ ui: {
35
+ swapIcon: SWAP_GLYPHS.sword,
36
+ name: 'Wooden sword',
37
+ icon: 'sword',
38
+ touch: 'melee',
39
+ lockOn: true,
40
+ melee: true,
41
+ tracers: false,
42
+ },
43
+ meta: {
44
+ name: 'Wooden sword',
45
+ icon: 'sword',
46
+ blurb: '',
47
+ category: 'weapon',
48
+ },
49
+ }
50
+
51
+ /** The upgraded iron sword equipment row and existing UI metadata. */
52
+ export const IRON_SWORD: EquipmentRow = {
53
+ cues: {
54
+ fire: 'cue.sword.swing',
55
+ reload: 'cue.reload',
56
+ impact: 'cue.sword.hit',
57
+ },
58
+ id: 'weapon.sword-iron',
59
+ legacySlot: 'sword-iron',
60
+ ui: {
61
+ swapIcon: SWAP_GLYPHS.sword,
62
+ name: 'Iron sword',
63
+ icon: 'sword',
64
+ touch: 'melee',
65
+ lockOn: true,
66
+ melee: true,
67
+ tracers: false,
68
+ },
69
+ meta: {
70
+ name: 'Iron sword',
71
+ icon: 'sword',
72
+ blurb: '',
73
+ category: 'weapon',
74
+ },
75
+ }
76
+
77
+ /** The base sword equipment row, retaining its legacy slot and cue IDs. */
78
+ /** The original wooden contact profile, moves and portrait framing. */
79
+ export const SWORD_WOOD: MeleeProfile = {
80
+ ...WOODEN_SWORD,
81
+ cues: {
82
+ fire: 'cue.sword.swing',
83
+ reload: 'cue.reload',
84
+ impact: 'cue.sword.hit',
85
+ hit: 'cue.sword.hit',
86
+ heavy: 'cue.sword.heavy',
87
+ },
88
+ hitStop: { body: 0.06, head: 0.06, kill: 0.06 },
89
+ family: STARTER_MELEE_PROFILE.family,
90
+ damage: STARTER_MELEE_PROFILE.damage,
91
+ reach: STARTER_MELEE_PROFILE.reach,
92
+ swingScale: STARTER_MELEE_PROFILE.swingScale,
93
+ portraitPullX: 0.32,
94
+ framing: { shrink: 0.33, dx: -0.03, dy: -0.055, tilt: 0.36, yaw: -0.02 },
95
+ moves: {
96
+ rest: REST,
97
+ charge: CHARGE,
98
+ sprint: SPRINT,
99
+ combo: COMBO,
100
+ heavy: HEAVY,
101
+ },
102
+ cooldown: STARTER_MELEE_PROFILE.cooldown,
103
+ comboGap: STARTER_MELEE_PROFILE.comboGap,
104
+ chainLag: STARTER_MELEE_PROFILE.chainLag,
105
+ heavyCharge: STARTER_MELEE_PROFILE.heavyCharge,
106
+ chargeBlend: CHARGE_BLEND,
107
+ lunge: STARTER_MELEE_PROFILE.lunge,
108
+ sweep: STARTER_MELEE_PROFILE.sweep,
109
+ trail: { samples: 20, subdivisions: 3 },
110
+ dodgeKick: { kick: 2.2, k: 160, c: 14 },
111
+ armFollow: 0.45,
112
+ feel: {
113
+ lag: {
114
+ gain: 0.5,
115
+ clampYaw: 0.12,
116
+ clampPitch: 0.1,
117
+ k: 220,
118
+ c: 20,
119
+ posYaw: 0.25,
120
+ posPitch: 0.2,
121
+ },
122
+ bob: { x: 0.018, y: 0.014, rz: 0.02, rx: 0.012 },
123
+ sway: { ax: 0.003, fx: 0.7, ay: 0.0025, fy: 1.1 },
124
+ fovHip: 72,
125
+ },
126
+ }
127
+ /** The base sword equipment row, retaining its legacy slot and cue IDs. */
128
+ /** The original iron contact profile, retaining the wooden parent and 28 damage. */
129
+ export const SWORD_IRON: MeleeProfile = {
130
+ ...SWORD_WOOD,
131
+ ...IRON_SWORD,
132
+ parent: SWORD_WOOD.id,
133
+ damage: IRON_MELEE_PROFILE.damage,
134
+ }
@@ -0,0 +1,172 @@
1
+ import * as THREE from 'three'
2
+
3
+ import { STARTER_MELEE_PROFILE } from './starterCombat.ts'
4
+
5
+ import type {
6
+ MeleeKey as Key,
7
+ MeleeMove as Move,
8
+ MeleeMoveSet,
9
+ } from './meleeProfile.ts'
10
+
11
+ type SweptBladeRig = MeleeMoveSet & {
12
+ chargeBlend: number
13
+ tipX: number
14
+ tipY: number
15
+ }
16
+
17
+ /**
18
+ * SwordMoves — the keyframes of every sword swing (Sword.ts evaluates them): the three-hit light combo and the heavy.
19
+ * Camera space at scale 1 (landscape): +X right, +Y up, -Z forward; a key is where the hands are, which way the blade
20
+ * points and the roll about it (0 = the flat toward the eye). Each move has a wind-up key (cocked), a mid-slash key
21
+ * and a follow-through key; the swing starts from wherever the sword IS (the rest pose, or the previous swing's
22
+ * follow-through when the combo chains) and recovers to REST.
23
+ *
24
+ * 1 · slash right → left, horizontal — the wooden-sword mockup (art/driftwood-isle/round-2-first-person/driftwood-fp-sword-wooden.png)
25
+ * 2 · backhand left → right, rising a little — cocked from where the slash left the blade
26
+ * 3 · finisher raised high on the right, an overhead diagonal down to the lower left (the iron mockup's arc)
27
+ * H · heavy charged overhead (CHARGE key held with the blade raised), released into a wide slow overhead chop
28
+ *
29
+ * Times are seconds from the swing's start: `windup` (the active window opens), `slashEnd` (it closes; a queued combo
30
+ * swing chains here), `total` (back at rest). The hit test is the blade itself, swept through the active window (Sword.ts).
31
+ */
32
+
33
+ const Y_AXIS = new THREE.Vector3(0, 1, 0)
34
+ const _q2 = new THREE.Quaternion()
35
+ /** quaternion that takes +Y to `dir` then rolls about it */
36
+ export function poseQuat(
37
+ out: THREE.Quaternion,
38
+ dir: THREE.Vector3,
39
+ roll: number,
40
+ ): THREE.Quaternion {
41
+ out.setFromUnitVectors(Y_AXIS, dir)
42
+ return out.multiply(_q2.setFromAxisAngle(Y_AXIS, roll))
43
+ }
44
+ /** Build an authored sword key from its time, hand position, blade direction and roll. */
45
+ export const key = (
46
+ t: number,
47
+ px: number,
48
+ py: number,
49
+ pz: number,
50
+ dx: number,
51
+ dy: number,
52
+ dz: number,
53
+ roll: number,
54
+ ): Key => ({
55
+ t,
56
+ pos: new THREE.Vector3(px, py, pz),
57
+ q: poseQuat(
58
+ new THREE.Quaternion(),
59
+ new THREE.Vector3(dx, dy, dz).normalize(),
60
+ roll,
61
+ ),
62
+ })
63
+
64
+ /** rest = the spawn mockup, held lower (E129: it covered Wendell and the middle-right of the view): hands at the lower-right
65
+ * edge, the blade tipped forward so its tip rests low-right of the crosshair, clear of an NPC you walk up to (was 0.27, -0.33 · dir -0.34, 0.76, -0.55) */
66
+ export const REST: Key = key(0, 0.31, -0.35, -0.52, -0.2, 0.58, -0.79, 0.35)
67
+ /** RMB / touch AIM held: the blade raised high over the right shoulder, tip up and a little back — the heavy's charge */
68
+ export const CHARGE: Key = key(0, 0.27, -0.09, -0.5, 0.24, 0.92, 0.3, 0.1)
69
+ /** The original lowered hand pose while sprinting. */
70
+ export const SPRINT: Key = key(0, 0.34, -0.46, -0.58, -0.2, 0.55, -0.81, 0.6)
71
+
72
+ const white = (r: number, g: number, b: number) => new THREE.Color(r, g, b)
73
+
74
+ /** The original first light-combo move and trail parameters. */
75
+ export const SLASH: Move = {
76
+ name: 'slash',
77
+ keys: [
78
+ key(0.07, 0.42, -0.25, -0.5, 0.62, 0.62, -0.48, 0.55), // cocked: blade up-right, tip toward the frame's right edge
79
+ key(0.13, 0.22, -0.33, -0.48, -0.7, 0.48, -0.53, 0.3), // mid-slash: sweeping across, tip upper-left of centre (the mockup frame)
80
+ key(0.235, -0.02, -0.35, -0.46, -0.88, 0.22, -0.42, 0.15), // follow-through: blade out to the left, still rising a little
81
+ ],
82
+ ...STARTER_MELEE_PROFILE.moves.combo[0],
83
+ hitStop: 0.06,
84
+ kick: { pitch: -0.6, roll: 1.6 },
85
+ trail: {
86
+ from: 0.62,
87
+ color: white(1, 1, 1),
88
+ alpha: 0.6,
89
+ inner: 0,
90
+ life: 0.13,
91
+ },
92
+ }
93
+
94
+ /** The original second light-combo move and trail parameters. */
95
+ export const BACKHAND: Move = {
96
+ name: 'backhand',
97
+ keys: [
98
+ key(0.06, -0.12, -0.28, -0.48, -0.82, 0.46, -0.34, -0.35), // cocked further left, edge turned to lead the other way
99
+ key(0.125, 0.1, -0.3, -0.5, 0.02, 0.62, -0.78, -0.2), // mid: tip straight ahead and up, crossing the centre
100
+ key(0.22, 0.4, -0.26, -0.5, 0.86, 0.36, -0.36, -0.1), // follow-through: blade out to the right, tip past the frame edge
101
+ ],
102
+ ...STARTER_MELEE_PROFILE.moves.combo[1],
103
+ hitStop: 0.06,
104
+ kick: { pitch: -0.6, roll: -1.6 },
105
+ trail: {
106
+ from: 0.58,
107
+ color: white(0.9, 0.97, 1),
108
+ alpha: 0.6,
109
+ inner: 0.05,
110
+ life: 0.13,
111
+ },
112
+ }
113
+
114
+ /** The original final light-combo move and trail parameters. */
115
+ export const FINISHER: Move = {
116
+ name: 'finisher',
117
+ keys: [
118
+ key(0.1, 0.3, -0.08, -0.5, 0.32, 0.92, -0.22, 0.2), // raised high on the right, tip up
119
+ key(0.19, 0.12, -0.2, -0.48, -0.36, 0.52, -0.77, 0.15), // coming down through the centre, tip forward-up-left
120
+ key(0.28, -0.14, -0.44, -0.44, -0.72, -0.28, -0.63, 0.05), // low left, tip below the frame centre
121
+ ],
122
+ ...STARTER_MELEE_PROFILE.moves.combo[2],
123
+ hitStop: 0.09,
124
+ kick: { pitch: -1.8, roll: 1.1 },
125
+ trail: {
126
+ from: 0.5,
127
+ color: white(1, 0.97, 0.88),
128
+ alpha: 0.7,
129
+ inner: 0.1,
130
+ life: 0.15,
131
+ },
132
+ }
133
+
134
+ /** The original charged-heavy move and trail parameters. */
135
+ export const HEAVY: Move = {
136
+ name: 'heavy',
137
+ keys: [
138
+ key(0.06, 0.29, -0.03, -0.5, 0.3, 0.89, 0.36, 0.1), // an extra pull back over the shoulder off the charge pose
139
+ key(0.17, 0.08, -0.18, -0.52, -0.16, 0.58, -0.8, 0.05), // the chop: blade forward-up through the centre, edge on
140
+ key(0.3, -0.12, -0.5, -0.44, -0.56, -0.46, -0.69, 0.0), // buried low left, tip below the frame
141
+ ],
142
+ ...STARTER_MELEE_PROFILE.moves.heavy,
143
+ hitStop: 0.14,
144
+ kick: { pitch: -2.6, roll: 0.8, fov: -2 },
145
+ trail: {
146
+ from: 0.34,
147
+ color: white(1, 0.98, 0.94),
148
+ alpha: 1.0,
149
+ inner: 0.35,
150
+ life: 0.22,
151
+ },
152
+ }
153
+
154
+ /** The original light-combo order, preserving move object identities. */
155
+ export const COMBO: Move[] = [SLASH, BACKHAND, FINISHER]
156
+
157
+ /** Seconds the blade takes to rise into the charge pose. */
158
+ export const CHARGE_BLEND = 0.16
159
+ /** The starter sword's tip up its blade (m from the grip): `buildSword`'s guard, step and blade length. */
160
+ export const STARTER_SWORD_TIP: number = 0.085 + 0.014 + 0.52
161
+ /** Everything a blade sweep needs of the starter sword, renderer-free: its swings and where its tip sits. The page's `Sword`
162
+ * sweeps these; so does the native owner (P1-E3.5), since the shard's rows carry a move's numbers and never its keys. */
163
+ export const STARTER_BLADE: SweptBladeRig = {
164
+ rest: REST,
165
+ charge: CHARGE,
166
+ sprint: SPRINT,
167
+ combo: COMBO,
168
+ heavy: HEAVY,
169
+ chargeBlend: CHARGE_BLEND,
170
+ tipX: 0,
171
+ tipY: STARTER_SWORD_TIP,
172
+ }
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ export { abilities } from './abilities.ts'
2
+ export { biped, quadruped } from './body.ts'
3
+ export { temperament } from './temperament.ts'
4
+ export { commonSpeciesRows } from './geometry/species.ts'
5
+
6
+ export type {
7
+ AbilityHelper,
8
+ AbilityName,
9
+ AbilityOptions,
10
+ AbilityTemplate,
11
+ } from './abilities.ts'
12
+ export type { BodyOptions } from './body.ts'
13
+ export type { CommonSpeciesKind } from './geometry/species.ts'
14
+ export type {
15
+ PresetName,
16
+ TemperamentHelper,
17
+ TemperamentOptions,
18
+ TemperamentProfile,
19
+ } from './temperament.ts'
20
+
21
+ export { commonCreature } from './creatures.ts'
22
+ export type {
23
+ CommonCreatureKind,
24
+ CreatureOptions,
25
+ CreatureContent,
26
+ } from './creatures.ts'
@@ -0,0 +1,25 @@
1
+ import {
2
+ StrikeDebrisSchema,
3
+ type StrikeDebrisPolicy,
4
+ } from '@wildshard/shard-format/strikeDebris'
5
+ import { parse } from 'valibot'
6
+
7
+ import content from '../content/sword-debris.json' with { type: 'json' }
8
+
9
+ /** Compile the former sword effects into ordinary target-row declarations, with no runtime kind lookup. */
10
+ export function legacySwordDebris(
11
+ species: readonly Readonly<{ id: string; kind: string }>[],
12
+ ): StrikeDebrisPolicy {
13
+ const overrides = species.flatMap(row => {
14
+ const effect = Object.entries(content.kinds).find(
15
+ ([kind]) => kind === row.kind,
16
+ )?.[1]
17
+ return effect === undefined
18
+ ? []
19
+ : [{ target: row.id, effect: { ...effect } }]
20
+ })
21
+ return parse(StrikeDebrisSchema, {
22
+ default: { ...content.default },
23
+ overrides,
24
+ })
25
+ }