forked from DevilboxGames/ReincarnationTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCRAccessory.ms
More file actions
4117 lines (3747 loc) · 137 KB
/
Copy pathCRAccessory.ms
File metadata and controls
4117 lines (3747 loc) · 137 KB
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
AccessoryTypes = #(
"StandardAccessory",
"RotatingAccessory",
"AngularDampedAccessory",
"Checkpoint",
"ManagedAccessory",
"Powerup",
"ConveyorAccessory",
"CopSpawn",
"StartingGrid",
"MultiplayerSpawn",
"TrailerSpawn",
"ExplodingAccessory",
"RockingAccessory",
"RigidBodyAnimation"
)
struct AccessoryShape
(
Type,
Points = #(),
Indices = #(),
Radius,
Part,
CollisionGroups,
fn Read f = (
Type = (f.ReadLine())
case tolower Type of (
"sphere": (
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
radius = (f.ReadLine()) as float
)
"alignedcuboid": (
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
)
"roundedalignedcuboid": (
radius = (f.ReadLine()) as float
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
)
"tictac": (
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
radius = (f.ReadLine()) as float
)
"capsule": (
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
radius = (f.ReadLine()) as float
)
"polyhedron": (
numPoints = (f.ReadLine()) as integer
for i = 1 to numPoints do
(
local pLine = f.ReadLine()
local p = ConvertFromCRSpace (StringAsPoint3 pLine)
append points p
)
)
"wireframe": (
numPoints = (f.ReadLine()) as integer
for i = 1 to numPoints do
(
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
)
numPoints = (f.ReadLine()) as integer
for i = 1 to numPoints do
(
append indices (StringAsPoint2 (f.ReadLine()))
)
)
"roundedpolyhedron": (
radius = (f.ReadLine()) as float
numPoints = (f.ReadLine()) as integer
for i = 1 to numPoints do
(
append points (ConvertFromCRSpace (StringAsPoint3 (f.ReadLine())))
)
)
)
local curPos = f.Tell()
local formCollisionsGroupsLabel = f.ReadLine()
if toLower formCollisionsGroupsLabel == "form_collision_groups" then (
CollisionGroups = (f.ReadLine()) as integer
)
else (
CollisionGroups = 0
format "\tread % from % to \n%" formCollisionsGroupsLabel curPos (f.Tell())
f.Seek curPos
format "!!!!!!!WARNING: Expected \"form_collision_groups\" and got %. I DON'T KNOW WHAT TO DO!!!!!\n" formCollisionsGroupsLabel
)
),
fn Write f = (
format "%\n" type to:f
case tolower type of (
"sphere": (
pos = ConvertToCRSpace points[1]
format "%,%,%\n" pos.x pos.y pos.z to:f
format "%\n" (radius as string) to:f
)
"alignedcuboid": (
pos1 = ConvertToCRSpace points[1]
pos2 = ConvertToCRSpace points[2]
format "%,%,%\n" (amin pos1.x pos2.x) (amin pos1.y pos2.y) (amin pos1.z pos2.z) to:f
format "%,%,%\n" (amax pos1.x pos2.x) (amax pos1.y pos2.y) (amax pos1.z pos2.z) to:f
)
"roundedalignedcuboid": (
pos1 = ConvertToCRSpace points[1]
pos2 = ConvertToCRSpace points[2]
format "%\n" (radius as string) to:f
format "%,%,%\n" (amin pos1.x pos2.x) (amin pos1.y pos2.y) (amin pos1.z pos2.z) to:f
format "%,%,%\n" (amax pos1.x pos2.x) (amax pos1.y pos2.y) (amax pos1.z pos2.z) to:f
)
"tictac": (
pos1 = ConvertToCRSpace points[1]
pos2 = ConvertToCRSpace points[2]
format "%,%,%\n" pos1.x pos1.y pos1.z to:f
format "%,%,%\n" pos2.x pos2.y pos2.z to:f
format "%\n" (radius as string) to:f
)
"capsule": (
pos1 = ConvertToCRSpace points[1]
pos2 = ConvertToCRSpace points[2]
format "%,%,%\n" pos1.x pos1.y pos1.z to:f
format "%,%,%\n" pos2.x pos2.y pos2.z to:f
format "%\n" (radius as string) to:f
)
"wireframe": (
format "%\n" (points.count as string) to:f
for v in points do
(
pos1 = ConvertToCRSpace v
format "%,%,%\n" pos1.x pos1.y pos1.z to:f
)
format "%\n" (indices.count as string) to:f
for ind in indices do
(
local ind1 = ind.x as integer
local ind2 = ind.y as integer
format "%,%\n" ind1 ind2 to:f
)
)
"polyhedron": (
format "%\n" (points.count as string) to:f
for v in points do
(
pos1 = ConvertToCRSpace v
format "%,%,%\n" pos1.x pos1.y pos1.z to:f
)
)
"roundedpolyhedron": (
format "%\n" (radius as string) to:f
format "%\n" (points.count as string) to:f
for v in points do
(
pos1 = ConvertToCRSpace v
format "%,%,%\n" pos1.x pos1.y pos1.z to:f
)
)
)
format "\n\n" to:f
format "form_collision_groups\n%\n\n" CollisionGroups to:f
)
)
struct AccessoryJoint_Weakness (
type, -- string
p3_Unknown, -- point3
strength, -- float
twistStrength, -- float
fn Read f = (
local keepLooping = true
local curPos = f.Tell()
curLine = tolower(f.ReadLine())
type = curLine
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown = [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
strength = splitLine[1] as float
if splitLine.count > 1 then (
twistStrength = splitLine[2] as float
)
),
fn Write f = (
format "%\n" type to:f
format "%,%,%\n" p3_Unknown.x p3_Unknown.y p3_Unknown.z to:f
format "%" strength to:f
if twistStrength != undefined then (
format ",%" twistStrength to:f
)
format "\n\n" to:f
)
)
struct AccessoryJoint_Constraint (
i_Unknown, -- int
strength, -- float
f_Unknown1, -- float
minDirection, -- point3
maxDirection, -- point3
f_Unknown2, -- float
weakness, -- string (none) or BreakJoint/another weakness type
p3_Unknown1, -- point3
p3_Unknown2, -- point3
fn Read f = (
local keepLooping = true
local curPos = f.Tell()
curLine = tolower(f.ReadLine())
i_Unknown = curLine as integer
curLine = tolower(f.ReadLine())
strength = curLine as float
curLine = tolower(f.ReadLine())
f_Unknown1 = curLine as float
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
minDirection = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
maxDirection = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
f_Unknown2 = curLine as float
curLine = f.ReadLine()
weakness = curLine
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown1 = [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown2 = [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
),
fn Write f = (
format "%\n" i_Unknown to:f
format "%\n" strength to:f
format "%\n" f_Unknown1 to:f
format "%,%,%\n" minDirection.x minDirection.y minDirection.z to:f
format "%,%,%\n" maxDirection.x maxDirection.y maxDirection.z to:f
format "%\n" f_Unknown2 to:f
format "%\n" weakness to:f
format "%,%,%\n" p3_Unknown1.x p3_Unknown1.y p3_Unknown1.z to:f
format "%,%,%\n" p3_Unknown2.x p3_Unknown2.y p3_Unknown2.z to:f
)
)
struct AccessoryJoint (
type, --string: world or child
label, --string: e.g. joint
flags, -- int
-- ???? Constraints? ???? JointAxis?
-- | | ____/ ______/
-- | | / /
-- [0000] [0000] [0000] [0000]
-------------------------------------------
f_Unknown1, -- float
local_position, -- point3 - in accessory's local space
parent_position, -- point3
joint_normal, -- point3
p3_Unknown2, -- point3
p3_Unknown3, -- point3
p3_Unknown4, -- point3
p3_Unknown5, -- point3
p3_Unknown6, -- point3
numConstraints, -- int
constraints, -- AccessoryJoint_Constraint
hasWeakness, -- bool outputs: (no_weakness) or weakness
weakness1, -- AccessoryJoint_Constraint
weakness2, -- AccessoryJoint_Constraint
fn Read f = (
format "Reading joint at %\n" (f.Tell())
local keepLooping = true
local curPos = f.Tell()
do (
curLine = tolower(f.ReadLine())
format "\tcurline at % to %: %\n" curPos (f.Tell()) curLine
if curLine == "<world_joint>" then type = "world_joint"
else if curLine == "<child_joint>" then type="child_joint"
else if curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keeplooping = false
)
else if curLine[1] != "[" and curLine[1] != "<" then (
label = curLine
local oldPos = f.Tell()
curLine = f.ReadLine()
format "\tcurline at % to %: %\n" oldpos (f.Tell()) curLine
flags = curLine as integer
local oldPos = f.Tell()
curLine = f.ReadLine()
format "\tcurline at % to %: %\n" oldpos (f.Tell()) curLine
f_Unknown1 = curLine as float
local oldPos = f.Tell()
curLine = f.ReadLine()
format "\tcurline at % to %: %\n" oldpos (f.Tell()) curLine
splitLine = filterstring curLine ", "
local_position = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
parent_position = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
joint_normal = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown2 = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown3 = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown4 = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown5 = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
splitLine = filterstring curLine ", "
p3_Unknown6 = ConvertFromCRSpace [splitLine[1] as float,splitLine[2] as float,splitLine[3] as float]
curLine = f.ReadLine()
numConstraints = curLine as integer
constraints = #()
for i=1 to numConstraints do (
constraint = AccessoryJoint_Constraint()
constraint.Read f
append constraints constraint
)
curLine = tolower (f.ReadLine())
if curLine == "weakness" then (
hasWeakness = true
weakness1 = AccessoryJoint_Weakness()
weakness1.Read f
weakness2 = AccessoryJoint_Weakness()
weakness2.Read f
)
keepLooping = false
)
) while keepLooping
),
fn Write f = (
local localPos = ConvertToCRSpace local_position
local parentPos = ConvertToCRSpace parent_position
local jointNormal = ConvertToCRSpace joint_normal
local u2 = ConvertToCRSpace p3_unknown2
local u3 = ConvertToCRSpace p3_unknown3
local u4 = ConvertToCRSpace p3_unknown4
local u5 = ConvertToCRSpace p3_unknown5
local u6 = ConvertToCRSpace p3_unknown6
format "\n<%>\n" type to:f
format "%\n" label to:f
format "%\n" flags to:f
format "%\n" f_Unknown1 to:f
format "%,%,%\n" localPos.x localPos.y localPos.z to:f
format "%,%,%\n" parentPos.x parentPos.y parentPos.z to:f
format "%,%,%\n" jointNormal.x jointNormal.y jointNormal.z to:f
format "%,%,%\n" u2.x u2.y u2.z to:f
format "%,%,%\n" u3.x u3.y u3.z to:f
format "%,%,%\n" u4.x u4.y u4.z to:f
format "%,%,%\n" u5.x u5.y u5.z to:f
format "%,%,%\n" u6.x u6.y u6.z to:f
if numConstraints == undefined then numConstraints = 0
format "%\n" numConstraints to:f
for i=1 to constraints.count do (
constraints[i].Write f
)
if hasWeakness != undefined and hasWeakness then (
format "weakness\n" to:f
weakness1.Write f
weakness2.Write f
)
else (
format "(no_weakness)\n" to:f
)
)
)
struct AccessoryType_StandardAppData (
CollisionAudioEvent, --string
CollisionAudioEventHeavy, --string
CollisionAudioMinTime, --float
CollisionAudioHeavyImpactMagnitude, --float
CollisionAudioLump, --string
CollisionAudioEventScrape, --string
damage_magnifier, --float
damage_magnifier_X, --float
damage_magnifier_Y, --float
damage_magnifier_Z, --float
speed_sensitive_damage_magnifier, --float
dont_target, --bool
disable_pinball, --bool
vehicle_vfx, --bool
weapon, --bool
AccessoryAudio_Sound1, --String
AccessoryAudio_Sound2, --String
AccessoryAudio_Type, --String
AccessoryAudio_LumpName, --String
force_target, --bool
recovery_exclusion_radius, --float
special_flags, --int
fn ProcessLine f = (
local curPos = f.Tell()
curLine = f.ReadLine()
local parsed = true
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
parsed= false
)
else (
local splitLine = filterstring curLine " \t"
case (tolower splitLine[1]) of (
"collisionaudioevent": CollisionAudioEvent = splitLine[2]
"collisionaudioeventheavy": CollisionAudioEventheavy = splitLine[2]
"collisionaudioheavyimpactmagnitude": CollisionAudioHeavyImpactMagnitude = splitLine[2] as float
"collisionaudiomintime": CollisionAudioMinTime = splitLine[2] as float
"collisionaudiolump": CollisionAudioLump = splitLine[2]
"collisionaudioeventscrape": CollisionAudioEventScrape = splitLine[2]
"accessoryaudio": (
AccessoryAudio_Sound1 = splitLine[2]
AccessoryAudio_Sound2 = splitLine[3]
AccessoryAudio_Type = splitLine[4]
AccessoryAudio_LumpName = splitLine[5]
)
"dont_target": dont_target = true
"disable_pinball": disable_pinball = true
"vehicle_vfx": vehicle_vfx = true
"weapon": weapon = true
"force_target": force_target = true
"damage_magnifier": damage_magnifier = splitLine[2] as float
"damage_magnifier_x": damage_magnifier_X = splitLine[2] as float
"damage_magnifier_y": damage_magnifier_Y = splitLine[2] as float
"damage_magnifier_z": damage_magnifier_Z = splitLine[2] as float
"speed_sensitive_damage_magnifier": speed_sensitive_damage_magnifier = splitLine[2] as float
"recovery_exclusion_radius": recovery_exclusion_radius = splitLine[2] as float
"message_triggered": message_triggered = splitLine[2]
"special_flags": special_flags = splitLine[2] as integer
default: format "Unknown value for StandardAccessory in %:\n\t\t%\n" f curLine
)
)
parsed
),
fn Read f = (
local keepLooping = true
while not (f.EOF) and keepLooping do (
keepLooping = ProcessLine f
)
),
fn Write f = (
if CollisionAudioEvent != undefined then (
format "CollisionAudioEvent %\n" CollisionAudioEvent to:f
)
if CollisionAudioEventHeavy != undefined then (
format "CollisionAudioEventHeavy %\n" CollisionAudioEventHeavy to:f
)
if CollisionAudioHeavyImpactMagnitude != undefined and CollisionAudioHeavyImpactMagnitude != 0 then (
format "CollisionAudioHeavyImpactMagnitude %\n" CollisionAudioHeavyImpactMagnitude to:f
)
if CollisionAudioMinTime != undefined and CollisionAudioMinTime != 0 then (
format "CollisionAudioMinTime %\n" CollisionAudioMinTime to:f
)
if CollisionAudioLump != undefined then (
format "CollisionAudioLump %\n" CollisionAudioLump to:f
)
if CollisionAudioEventScrape != undefined then (
format "CollisionAudioEventScrape %\n" CollisionAudioEventScrape to:f
)
if AccessoryAudio_Sound1 != undefined then (
format "AccessoryAudio % % % %\n" AccessoryAudio_Sound1 AccessoryAudio_Sound2 AccessoryAudio_Type AccessoryAudio_LumpName to:f
)
if dont_target == true then (
format "dont_target\n" to:f
)
if disable_pinball == true then (
format "disable_pinball\n" to:f
)
if vehicle_vfx == true then (
format "vehicle_vfx\n" to:f
)
if force_target == true then (
format "force_target\n" to:f
)
if weapon == true then (
format "weapon\n" to:f
)
if damage_magnifier != undefined and damage_magnifier != 1 then (
format "damage_magnifier %\n" damage_magnifier to:f
)
if damage_magnifier_X != undefined and damage_magnifier_X != 1 then (
format "damage_magnifier_X %\n" damage_magnifier_X to:f
)
if damage_magnifier_Y != undefined and damage_magnifier_Y != 1 then (
format "damage_magnifier_Y %\n" damage_magnifier_Y to:f
)
if damage_magnifier_Z != undefined and damage_magnifier_Z != 1 then (
format "damage_magnifier_Z %\n" damage_magnifier_Z to:f
)
if speed_sensitive_damage_magnifier != undefined and speed_sensitive_damage_magnifier != 1 then (
format "speed_sensitive_damage_magnifier %\n" speed_sensitive_damage_magnifier to:f
)
if recovery_exclusion_radius != undefined and recovery_exclusion_radius != 0 then (
format "recovery_exclusion_radius %\n" recovery_exclusion_radius to:f
)
if message_triggered != undefined then (
format "message_triggered %\n" message_triggered to:f
)
if special_flags != undefined and special_flags != 0 then (
format "special_flags %\n" special_flags to:f
)
format "\n\n" to:f
)
)
struct AccessoryType_RotatingAccessory (
StandardData, -- AccessoryType_StandardAppData
Speed, --float
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curline == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
if (tolower splitLine[1]) == "speed" then (
Speed = splitLine[2] as float
)
else (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for RotatingAccessory in %:\n\t\t%\n" f curLine
)
)
)
)
),
fn Write f = (
format "speed %\n" Speed to:f
if StandardData != undefined then StandardData.Write f
)
)
struct AccessoryType_AngularDampedAccessory (
StandardData, -- AccessoryType_StandardAppData
Damper, --float
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
if (tolower splitLine[1]) == "damper" then (
Damper = splitLine[2] as float
)
else (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for AngularDampedAccessoryin %:\n\t\t%\n" f curLine
)
)
)
)
),
fn Write f = (
format "damper %\n" Damper to:f
if StandardData != undefined then StandardData.Write f
)
)
struct AccessoryType_Checkpoint (
StandardData, -- AccessoryType_StandardAppData
radius, --float
top, --float
bottom, --Float
left, --float
right, --float
deactivated, --String
next, --String
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" or f.EOF then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
if splitLine.count > 0 then (
case (tolower splitLine[1]) of (
"radius": radius = splitLine[2] as float
"top": top = splitLine[2] as float
"bottom": bottom = splitLine[2] as float
"left": left = splitLine[2] as float
"right": right = splitLine[2] as float
"deactivated": deactivated = splitLine[2]
"next": next = splitLine[2]
default: (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for CheckpointAccessory in %:\n\t\t%\n" f curLine
)
)
)
)
)
)
),
fn Write f = (
if radius > 0 then (
format "radius %\n" radius to:f
)
if top != 0 then (
format "top %\n" top to:f
)
if bottom != 0 then (
format "bottom %\n" bottom to:f
)
if left != 0 then (
format "left %\n" left to:f
)
if right != 0 then (
format "right %\n" right to:f
)
if deactivated != undefined and deactivated != "" then (
format "deactivated %\n" deactivated to:f
)
if next != undefined and next != "" then (
format "next %\n" next to:f
)
if StandardData != undefined then StandardData.Write f
)
)
struct AccessoryType_ManagedAccessory (
StandardData, -- AccessoryType_StandardAppData
break_fuse, --Float
management_policy, --String
trigger_particles, --String
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
case (tolower splitLine[1]) of (
"break_fuse": break_fuse = splitLine[2] as float
"management_policy": management_policy = splitLine[2]
"trigger_particles": trigger_particles = true
default: (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for ManagedAccessory in %:\n\t\t%\n" f curLine
)
)
)
)
)
),
fn Write f = (
if break_fuse > 0 then (
format "break_fuse %\n" break_fuse to:f
)
if management_policy != undefined and management_policy != "" then (
format "management_policy %\n" management_policy to:f
)
if trigger_particles == true then (
format "trigger_particles\n" to:f
)
if StandardData != undefined then StandardData.Write f
)
)
struct AccessoryType_Powerup (
StandardData, -- AccessoryType_StandardAppData
type, --String
respawn_time, --Float
simple_rotate, --Float
respawn_if_not_collected_by_human_player,
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
case (tolower splitLine[1]) of (
"respawn_time": respawn_time = splitLine[2] as float
"simple_rotate": simple_rotate = splitLine[2] as float
"type": type = splitLine[2]
"respawn_if_not_collected_by_human_player": (
if splitLine[2] == "1" then
respawn_if_not_collected_by_human_player = true
else
respawn_if_not_collected_by_human_player = false
)
default: (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for PowerupAccessory in %:\n\t\t%\n" f curLine
)
)
)
)
)
),
fn Write f = (
if type != undefined and type != "" then (
format "type %\n" type to:f
)
if respawn_time != undefined and respawn_time > 0 then (
format "respawn_time %\n" respawn_time to:f
)
if simple_rotate != undefined and simple_rotate > 0 then (
format "simple_rotate %\n" simple_rotate to:f
)
if respawn_if_not_collected_by_human_player != undefined and respawn_if_not_collected_by_human_player > 0 then (
format "respawn_if_not_collected_by_human_player %\n" respawn_if_not_collected_by_human_player to:f
)
if StandardData != undefined then StandardData.Write f
)
)
struct AccessoryType_RigidBodyAnimation (
StandardData, -- AccessoryType_StandardAppData
anim, --string
looping, --bool
hit_to_trigger, --bool
time_offset, --float
max_acceleration, --float
max_angular_acceleration, --float
max_force, --float
max_force_linear, --float
break_factor, --float
stop_factor, --float
message_triggered, --string
fn Read f = (
StandardData = AccessoryType_StandardAppData()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" then (
f.Seek curPos
keepLooping = false
)
else (
local splitLine = filterstring curLine " \t"
case (tolower splitLine[1]) of (
"anim": anim = splitLine[2]
"looping": looping = true
"hit_to_trigger": hit_to_trigger = true
"max_acceleration": max_acceleration = splitLine[2] as float
"max_angular_acceleration": max_angular_acceleration = splitLine[2] as float
"max_force": max_force = splitLine[2] as float
"max_force_linear": max_force_linear = splitLine[2] as float
"break_factor": break_factor = splitLine[2] as float
"stop_factor": stop_factor = splitLine[2] as float
"message_triggered": message_triggered = splitLine[2]
default: (
f.Seek curPos
if (StandardData.ProcessLine f) == false then (
format "Unknown value for RigidBodyAnimationAccessory in %:\n\t\t%\n" f curLine
)
)
)
)
)
),
fn Write f = (
if anim != undefined and anim != "" then(
format "anim %\n" anim to:f
)
if looping == true then(
format "looping\n" to:f
)
if hit_to_trigger == true then(
format "hit_to_trigger\n" to:f
)
if max_acceleration > 0 then(
format "max_acceleration %\n" max_acceleration to:f
)
if max_angular_acceleration > 0 then(
format "max_angular_acceleration %\n" max_angular_acceleration to:f
)
if max_force > 0 then(
format "max_force %\n" max_force to:f
)
if max_force_linear > 0 then(
format "max_force_linear %\n" max_force_linear to:f
)
if break_factor > 0 then(
format "break_factor %\n" break_factor to:f
)
if stop_factor > 0 then(
format "stop_factor %\n" stop_factor to:f
)
if message_triggered != undefined and message_triggered != "" then(
format "message_triggered %\n" message_triggered to:f
)
if StandardData != undefined then StandardData.Write f
)
)
struct CustomAccessoryBlock
(
Type,
CustomData,
fn Read f = (
local keepLooping = true
local startOfBlock = f.Tell()
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()
curLine = f.ReadLine()
if curLine == undefined or curLine == "" or curLine[1] == "[" or curLine[1] == "<" or curLine == "" then (
f.Seek curPos
keepLooping = false
)
else (
Type = curLine
case (tolower curLine) of (
"angulardampedaccessory": (
CustomData = AccessoryType_AngularDampedAccessory()
CustomData.Read f
)
"rigidbodyanimation": (
CustomData = AccessoryType_RigidBodyAnimation()
CustomData.Read f
)
"checkpoint": (
CustomData = AccessoryType_Checkpoint()
CustomData.Read f
)
"rotatingaccessory": (
CustomData = AccessoryType_RotatingAccessory()
CustomData.Read f
)
"managedaccessory": (
CustomData = AccessoryType_ManagedAccessory()
CustomData.Read f
)
"powerup": (
CustomData = AccessoryType_Powerup()
CustomData.Read f
)
"standardaccessory": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"conveyoraccessory": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"copspawn": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"startinggrid": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"multiplayerspawn": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"trailerspawn": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"explodingaccessory": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"bicycle": (
CustomData = AccessoryType_StandardAppData()
CustomData.Read f
)
"rockingaccessory": (
CustomData = AccessoryType_RigidBodyAnimation()
CustomData.Read f
)
default: format "Unknown custom accessory type in %:\n\t\t%\n" f curLine
)
--f.Seek startOfBlock
--StandardData = AccessoryType_StandardAppData()
--StandardData.Read f
)
)
),
fn Write f = (
format "%\n" Type to:f
if CustomData != undefined then (
CustomData.Write f
)
)
)
struct AccessoryBreakableReplacement
(
Axis, --string +x,-x,+y,-y,+z,-z
Replacement, --string
fn Read f = (
breakableLine = f.ReadLine()
splitLine = filterstring breakableLine " "
if splitLine.count == 3 then (
Axis = splitLine[2]
Replacement = splitLine[3]
)
else (
Axis = undefined
Replacement = splitLine[2]
)
),
fn Write f =(
if Axis != undefined then
format "replace % %\n" Axis Replacement to:f
else
format "replace %\n" Replacement to:f
)
)
struct AccessoryBreakableBlock
(
Type, --string
break_impulse, --float
replacements = #(), --AccessoryBreakableReplacement[]
explode_force, --float
trigger_particles, --bool
sound, --string
random_rotation, --point2
detach_children, --bool
destroy_children, --bool
collision_with_world_will_break_me, --bool
fn Read f = (
Type = f.ReadLine()
local keepLooping = true
while not (f.EOF) and keepLooping do (
local curPos = f.Tell()