-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTES5.ksy
4430 lines (4103 loc) · 104 KB
/
TES5.ksy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###############################################################################
# FILE INFORMATION #
###############################################################################
meta:
id: tes5
title: Elder Scrolls Plugin/Master
application: The Elder Scrolls V (Skyrim)
file-extension:
- esp
- esm
- esl
endian: le
###############################################################################
# ROOT FILE STRUCTURE #
###############################################################################
seq:
- id: header
type: file_header
doc: ESP/ESM header form
- id: top_groups
type: esp_groups
doc: Top level groups
###############################################################################
# ENUMERATIONS #
###############################################################################
enums:
group_type:
0: top
1: world_children
2: interior_cell_block
3: interior_cell_sub_block
4: exterior_cell_block
5: exterior_cell_sub_block
6: cell_children
7: topic_children
8: cell_persistent_children
9: cell_temporary_children
10: cell_visible_distant_children
glob_fnam_type:
0x73: short
0x6C: long
0x66: float
fact_xnam_combat:
0: neutral
1: enemy
2: ally
3: friend
fact_plvd_specification_type:
0: near_reference
1: in_cell
2: near_package_start_location
3: near_editor_location
6: linked_reference
12: near_self
ctda_operator:
0: equal_to
1: not_equal_to
2: greater_than
3: greater_than_or_equal_to
4: less_than
5: less_than_or_equal_to
ctda_run_on_type:
0: subject
1: target
2: reference
3: combat_target
4: linked_reference
5: quest_alias
6: package_data
7: event_data
hdpt_option:
0: generic_default
1: default
2: char_gen
race_data_size:
0: small
1: medium
2: large
4: extra_large
race_tinp_mask_type:
0: none
1: lip_color
2: cheek_color
3: eyeliner
4: eye_socket_upper
5: eye_socket_lower
6: skin_tone
7: paint
8: laugh_lines
9: cheek_color_lower
10: nose
11: chin
12: neck
13: forehead
14: dirt
15: unknown
bodt_skill:
0: light_armor
1: heavy_armor
2: none
spgd_data_shader_type:
0: rain
1: snow_dust_fog
clfm_fnam_playable:
0: non_playable
1: playable
equp_data_enum:
0: false
1: true
gras_data_distance_application:
1: above_at_least
2: above_at_most
3: below_at_least
4: below_at_most
5: either_at_least
6: either_at_most
7: either_at_most_above
8: either_at_most_below
effect_cast_type:
0: constant_effect
1: fire_and_forget
2: concentration
effect_delivery:
0: self
1: touch
2: aimed
3: target_actor
4: target_location
ench_enit_enchant_type:
0x06: enchantment
0x0C: staff_enchantment
spel_spit_spell_type:
0x00: spell
0x01: disease
0x02: power
0x03: lesser_power
0x04: ability
0x05: poison
0x0A: addiction
0x0B: voice
###############################################################################
# TYPE DEFINITIONS #
###############################################################################
types:
###############################################################################
# GLOBAL/COMMON TYPES #
###############################################################################
lstring:
params:
- id: data_size
type: u2
doc: Size of string
seq:
- id: index
type: u4
if: _root.header.header.flags.localized
doc: Index of localized string (stored in *STRINGS file)
- id: string
type: strz
encoding: UTF-8
size: data_size
if: not _root.header.header.flags.localized
doc: Full string if file is not localized
actor_value_skills:
seq:
- id: one_handed
type: u1
doc: One handed skill
- id: two_handed
type: u1
doc: Two handed skill
- id: marksman
type: u1
doc: Archery skill
- id: block
type: u1
doc: Block skill
- id: smithing
type: u1
doc: Smithing skill
- id: heavy_armor
type: u1
doc: Heavy armor skill
- id: light_armor
type: u1
doc: Light armor skill
- id: pickpocket
type: u1
doc: Pickpocket skill
- id: lockpicking
type: u1
doc: Lockpicking skill
- id: sneak
type: u1
doc: Sneak skill
- id: alchemy
type: u1
doc: Alchemy skill
- id: speechcraft
type: u1
doc: Speechcraft skill
- id: alteration
type: u1
doc: Alteration skill
- id: conjuration
type: u1
doc: Conjuration skill
- id: destruction
type: u1
doc: Destruction skill
- id: illusion
type: u1
doc: Illusion skill
- id: restoration
type: u1
doc: Restoration skill
- id: enchanting
type: u1
doc: Enchanting skill
###############################################################################
# FILE HEADER (TES4) #
###############################################################################
file_header:
seq:
- id: header
type: tes4_header
doc: TES4 form-specific header
- id: fields
type: tes4_fields
size: header.data_size
doc: TES4 form-specific fields
tes4_header:
seq:
- id: type
type: str
size: 4
encoding: UTF-8
doc: Form type code
- id: data_size
type: u4
doc: Size, in bytes, of form (minus header)
- id: flags
type: file_header_flags
doc: Form-specific bitflags
- id: form_id
type: u4
doc: Unique form ID
- id: revision
type: u4
doc: Used for revision control by the CK
- id: version
type: u2
doc: Version number
- id: unknown
type: u2
doc: Unknown purpose
file_header_flags:
seq:
- id: localized
type: b1
doc: Localized strings flag
- type: b6
- id: master
type: b1
doc: Master (ESM) file flag
- type: b1
- id: light_master
type: b1
doc: Light master (ESL) file flag
- type: b22
tes4_fields:
seq:
- id: fields
type: tes4_field
repeat: eos
doc: TES4 form-specific fields
tes4_field:
seq:
- id: type
type: str
size: 4
encoding: UTF-8
doc: Field type code
- id: data_size
type: u2
doc: Size, in bytes, of field (minus header)
- id: data
type:
switch-on: type
cases:
'"HEDR"': tes4_hedr_field
'"CNAM"': tes4_cnam_field
'"SNAM"': tes4_snam_field
'"MAST"': tes4_mast_field
'"DATA"': tes4_data_field
'"ONAM"': tes4_onam_field
'"INTV"': tes4_intv_field
doc: Field data
tes4_hedr_field:
seq:
- id: version
type: f4
doc: Version number
- id: num_records
type: s4
doc: Number of forms
- id: next_object_id
type: u4
doc: Next form ID
tes4_cnam_field:
seq:
- id: author
type: str
size: _parent.data_size
encoding: UTF-8
doc: Author of file (optional)
tes4_snam_field:
seq:
- id: description
type: str
size: _parent.data_size
encoding: UTF-8
doc: Description of file (optional)
tes4_mast_field:
seq:
- id: master
type: str
size: _parent.data_size
encoding: UTF-8
doc: Master filename
tes4_data_field:
seq:
- id: file_size
type: u8
doc: Master filesize
tes4_onam_field:
seq:
- id: overrides
type: u4
repeat: expr
repeat-expr: _parent.data_size / 4
doc: Overriden form IDs
tes4_intv_field:
seq:
- id: intv
type: u4
doc: Internal version (?)
tes4_incc_field:
seq:
- id: incc
type: u4
doc: Unknown purpose, introduced in Skyrim 1.6 - Update.esm
###############################################################################
# GROUPS (GRUP) #
###############################################################################
esp_groups:
seq:
- id: groups
type: esp_group
repeat: eos
doc: Top level groups
esp_group:
seq:
- id: type
contents: "GRUP"
doc: Type code
- id: group_size
type: u4
doc: Size, in bytes, of group (including header)
- id: label
type: u4
doc: Group label (depends on group type)
- id: group_type
type: s4
enum: group_type
doc: Group type enumeration
- id: stamp
type: u2
doc: Date stamp
- type: u2
- id: version
type: u2
doc: Unknown purpose
- type: u2
- id: data
type: esp_forms
size: group_size - 24
doc: Forms and sub-groups belonging to group
subgroup:
seq:
- id: header
type: group_header
doc: Group header information
- id: group_data
size: header.group_size - 24
doc: Forms belonging to subgroup
group_header:
seq:
- id: group_size
type: u4
doc: Size, in bytes, of group (including header)
- id: label
type: u4
doc: Group label (depends on group type)
- id: group_type
type: s4
enum: group_type
doc: Group type enumeration
- id: stamp
type: u2
doc: Date stamp
- type: u2
- id: version
type: u2
doc: Unknown purpose
- type: u2
###############################################################################
# COMMON FORM (RECORD) ELEMENTS #
###############################################################################
esp_forms:
seq:
- id: forms
type: esp_form
repeat: eos
doc: Form list held by group/subgroup
form_header:
seq:
- id: data_size
type: u4
doc: Size, in bytes, of form (minus header)
- id: flags
type: form_header_flags
doc: Form-specific bitflags
- id: form_id
type: u4
doc: Unique form ID
- id: revision
type: u4
doc: Used for revision control by the CK
- id: version
type: u2
doc: Version number
- id: unknown
type: u2
doc: Unknown purpose
form_header_flags:
seq:
- type: b18
- id: compressed
type: b1
doc: Indicates form data compression (zlib)
- type: b13
esp_form:
seq:
- id: type
type: str
size: 4
encoding: UTF-8
doc: Form type code
- id: subgroup
type: subgroup
if: type == 'GRUP'
doc: Special subgroup (contained in CELL, WRLD and DIAL top groups)
- id: form
type: form
if: type != 'GRUP'
doc: Form data
form:
seq:
- id: header
type: form_header
doc: Form header information
- id: form_data
size: header.data_size
doc: Size, in bytes, of form (minus header)
type:
switch-on: _parent.type
cases:
'"GMST"': gmst_form
'"KYWD"': kywd_form
'"LCRT"': lcrt_form
'"AACT"': aact_form
'"TXST"': txst_form
'"GLOB"': glob_form
'"CLAS"': clas_form
'"FACT"': fact_form
'"HDPT"': hdpt_form
'"EYES"': eyes_form
'"RACE"': race_form
'"SOUN"': soun_form
'"ASPC"': aspc_form
'"LTEX"': ltex_form
'"ENCH"': ench_form
'"SPEL"': spel_form
'"STAT"': stat_form
'"GRAS"': gras_form
'"TREE"': tree_form
'"LVLN"': lvln_form
'"IDLM"': idlm_form
'"COBJ"': cobj_form
'"HAZD"': hazd_form
'"CLMT"': clmt_form
'"SPGD"': spgd_form
'"RFCT"': rfct_form
'"LSCR"': lscr_form
'"EFSH"': efsh_form
'"FLST"': flst_form
'"SHOU"': shou_form
'"EQUP"': equp_form
'"OTFT"': otft_form
'"CLFM"': clfm_form
'"REVB"': revb_form
_: unknown_form_data
doc: Fields contained by form
unknown_form_data:
seq:
- id: data
type: str
encoding: UTF-8
size: _parent.header.data_size
doc: Used for undefined forms
###############################################################################
# COMMON FIELDS #
###############################################################################
unknown_field_data:
params:
- id: data_size
type: u2
seq:
- type: u1
repeat: expr
repeat-expr: data_size
edid_field:
params:
- id: data_size
type: u2
doc: Size, in bytes, of field (minus header)
seq:
- id: editor_id
type: strz
encoding: UTF-8
size: data_size
doc: Form name displayed in CK
full_field:
params:
- id: data_size
type: u2
doc: Size, in bytes, of field (minus header)
seq:
- id: full
type: lstring(data_size)
doc: Full in-game text
color:
seq:
- id: r
type: u1
doc: Red value
- id: g
type: u1
doc: Green value
- id: b
type: u1
doc: Blue value
- id: a
type: u1
doc: Alpha (?) value
obnd_field:
seq:
- id: x1
type: u2
doc: X-coordinate 1
- id: y1
type: u2
doc: Y-coordinate 1
- id: z1
type: u2
doc: Z-coordinate 1
- id: x2
type: u2
doc: X-coordinate 2
- id: y2
type: u2
doc: Y-coordinate 2
- id: z2
type: u2
doc: Z-coordinate 2
citc_field:
seq:
- id: condition_item_count
type: u4
doc: Count of following CTDA fields
cis1_field:
params:
- id: data_size
type: u2
doc: Size of zstring
seq:
- id: variable
type: strz
encoding: UTF-8
size: data_size
doc: Variable represented as string
cis2_field:
params:
- id: data_size
type: u2
doc: Size of zstring
seq:
- id: variable
type: strz
encoding: UTF-8
size: data_size
doc: Variable represented as string
ctda_field:
seq:
- id: operator_info
type: ctda_operator_info
doc: Condition operator information
- id: unknown
size: 3
doc: Unknown purpose (padding?)
- id: glob_comparison_value
type: u4
if: operator_info.use_global
doc: Value against which the function result is compared (GLOB)
- id: comparison_value
type: f4
if: not operator_info.use_global
doc: Value against which the function result is compared
- id: function_index
type: u2
doc: Function index (map to number+4096)
- id: padding
type: u2
doc: Padding, unused bytes
- id: parameters
type: ctda_parameters
doc: Function parameters
if: function_index != 576
- id: parameters_get_event_data
type: ctda_parameters_get_event_data
doc: Function paramaters (for GetEventData function)
if: function_index == 576
- id: run_on_type
type: u4
enum: ctda_run_on_type
doc: How to apply the condition
- id: reference
type: u4
doc: Function reference
- id: unknown_2
type: s4
doc: Unknown purpose (always -1)
ctda_operator_info:
seq:
- id: operator
type: b3
enum: ctda_operator
doc: Function operator
- id: or
type: b1
doc: OR multiple conditions (default is AND)
- id: parameters_use_aliases
type: b1
doc: Parameters use quest alias data
- id: use_global
type: b1
doc: Use global
- id: use_pack_data
type: b1
doc: Parameters use pack data
- id: swap_target
type: b1
doc: Swap subject and target
ctda_parameters:
seq:
- id: param_1
size: 4
doc: 1st parameter (refer to function index for type)
- id: param_2
size: 4
doc: 2nd parameter (refer to function index for type)
ctda_parameters_get_event_data:
seq:
- id: param_1
type: u2
doc: Event function
- id: param_2
type: str
encoding: UTF-8
size: 2
doc: Event member
- id: param_3
type: u4
doc: 3rd parameter
generic_modt:
params:
- id: data_size
type: u2
doc: Size, in bytes, of data
- id: version
type: u2
doc: Version of MODT field
seq:
- id: modt
type: modt_field(data_size)
if: version < 40
- id: modt_v40
type: modt_v40_field
if: version >= 40
modt_field:
params:
- id: data_size
type: u2
doc: Size, in bytes, of data
seq:
- id: hashes
type: modt_texture_hash
repeat: expr
repeat-expr: data_size / 12
modt_texture_hash:
seq:
- id: file_hash
type: u4
doc: Hash of file name
- id: unknown
type: str
encoding: UTF-8
size: 4
doc: Unknown bytes
- id: folder_hash
type: u4
doc: Hash of folder
modt_v40_field:
seq:
- id: num_headers
type: u4
- id: texture_count
type: u4
- id: unused
type: str
encoding: UTF-8
size: 4
- id: unique_tex_count
type: u4
if: _parent.data_size >= 16
- id: materials_count
type: u4
if: _parent.data_size >= 20
- id: hashes
type: modt_v40_texture_hash
repeat: expr
repeat-expr: (_parent.data_size - 20) / 12
if: (_parent.data_size > 20)
- id: unknown
type: u4
doc: Unknown
if: _parent.data_size > 20
modt_v40_texture_hash:
seq:
- id: flags
type: u4
- id: type
type: u4
- id: texture_hash
type: u4
bodt_field:
params:
- id: data_size
type: u2
doc: Size, in bytes, of data
seq:
- id: node_flags
type: bodt_node_flags
doc: Body part node flags
- id: flags
type: bodt_flags
doc: Further flags
- id: skill
type: u4
enum: bodt_skill
doc: Corresponding skill (heavy or light armor)
if: data_size == 12
bodt_node_flags:
seq:
- id: head
type: b1
- id: hair
type: b1
- id: body
type: b1
- id: hands
type: b1
- id: forearms
type: b1
- id: amulet
type: b1
- id: ring
type: b1
- id: feet
type: b1
- id: calves
type: b1
- id: shield
type: b1
- id: tail
type: b1
- id: long_hair
type: b1
- id: circlet
type: b1
- id: ears
type: b1
- id: body_addon_3
type: b1
- id: body_addon_4
type: b1
- id: body_addon_5
type: b1
- id: body_addon_6
type: b1
- id: body_addon_7
type: b1
- id: body_addon_8
type: b1
- id: decapitate_head
type: b1
- id: decapitate
type: b1
- id: body_addon_9
type: b1
- id: body_addon_10
type: b1
- id: body_addon_11
type: b1
- id: body_addon_12
type: b1
- id: body_addon_13
type: b1
- id: body_addon_14
type: b1
- id: body_addon_15
type: b1
- id: body_addon_16
type: b1
- id: body_addon_17
type: b1
- id: fx01
type: b1
bodt_flags:
seq:
- id: modulate_voice
type: b1
- type: b3
- id: non_playable
type: b1
- type: b27
modl_field:
params:
- id: data_size
type: u2
seq:
- id: model_path
type: strz
encoding: UTF-8
size: data_size
doc: Model path
mods_field:
seq:
- id: remaining_textures
type: u4
- id: alternate_textures
type: mods_alternate_texture
repeat: expr
repeat-expr: remaining_textures
mods_alternate_texture:
seq:
- id: string_length
type: u4
doc: Length of 3D name string
- id: three_d_name
type: str
encoding: UTF-8
size: string_length
doc: 3D name
- id: texture_id
type: u4
doc: Texture set (TXST) FormID
- id: three_d_index
type: u4
doc: 3D index
efid_field:
seq:
- id: effect_id
type: u4
doc: Magic effect MGEF FormID
efit_field:
seq:
- id: magnitude
type: f4
doc: Magnitude
- id: area_of_effect
type: u4
doc: Area of Effect
- id: duration
type: u4
doc: Duration (0 = instant)
coed_field:
seq:
- id: owner
type: u4
doc: Owner FACT or NPC_ FormID
- id: value
type: u4
doc: NPC_ form, GLOB - FACT form, int32 value
- id: item_condition
type: f4
doc: Item condition
###############################################################################
# GMST (GAME SETTING) FORM #
###############################################################################
gmst_form:
seq:
- id: fields
type: gmst_field
repeat: expr
repeat-expr: 2