forked from DevilboxGames/ReincarnationTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_FindAccessoryWeaknesses.ms
More file actions
194 lines (174 loc) · 5.36 KB
/
Copy pathTest_FindAccessoryWeaknesses.ms
File metadata and controls
194 lines (174 loc) · 5.36 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
fn getFilesRecursive root pattern =
(
dir_array = GetDirectories (root+"/*")
for d in dir_array do
join dir_array (GetDirectories (d+"/*"))
my_files = #()
for f in dir_array do
join my_files (getFiles (f + pattern))
my_files
)
fn FindWeaknessesInAccessory filename = (
f = openfile filename
seek f #eof
endOfFile = filePos f
seek f 0
weaknesses = #()
while (filePos f) != endOfFile and (eof f) == false do
(
curLine = trimLeft (trimRight (readline f))
if (tolower curline) == "weakness" then (
curLine = trimLeft (trimRight (readline f))
--while curLine == "" and (filePos f) != endOfFile do curLine = trimLeft (trimRight (readline f))
if (filePos f) != endOfFile then (
appendIfUnique weaknesses curLine
curLine = trimLeft (trimRight (readline f))
if (filePos f) != endOfFile then (
curLine = trimLeft (trimRight (readline f))
if (filePos f) != endOfFile then (
curLine = trimLeft (trimRight (readline f))
if (filePos f) != endOfFile then (
--while (curLine == "") and (filePos f) != endOfFile do curLine = trimLeft (trimRight (readline f))
if (filePos f) != endOfFile then (
appendIfUnique weaknesses curLine
)
)
)
)
)
)
)
weaknesses
)
fn FindAllWeaknessTypes dataDir:"D:\\Carmageddon Max Damage\\Data_Core\\Content\\" = (
accessoryTXTs = getFilesRecursive dataDir "accessory.txt"
weaknesses = #()
for accFile in accessoryTXTs do (
accWeaknesses = FindWeaknessesInAccessory accFile
for weakness in accWeaknesses do (
appendIfUnique weaknesses weakness
)
)
for weakness in weaknesses do (
format "%\n" weakness
)
)
fn FindCustomTypesInAccessory filename = (
f = openfile filename
seek f #eof
endOfFile = filePos f
seek f 0
customTypes = #()
while (filePos f) != endOfFile and (eof f) == false do
(
curLine = trimLeft (trimRight (readline f))
if (tolower curline) == "<customaccessorytype>" then (
curLine = trimLeft (trimRight (readline f))
while curLine == "" and (filePos f) != endOfFile and (eof f) == false do
(
curLine = trimLeft (trimRight (readline f))
)
appendIfUnique customTypes curLine
)
)
customTypes
)
fn FindAllCustomTypess dataDir:"D:\\Carmageddon Max Damage\\Data_Core\\Content\\" = (
accessoryTXTs = getFilesRecursive dataDir "accessory.txt"
customTypes = #()
for accFile in accessoryTXTs do (
accCustomTypes = FindCustomTypesInAccessory accFile
for customType in accCustomTypes do (
appendIfUnique customTypes customType
)
)
for customType in customTypes do (
format "%\n" customType
)
)
fn FindShapeTypesInAccessory filename = (
f = openfile filename
seek f #eof
endOfFile = filePos f
seek f 0
shapeTypes = #()
collisonGroups = #()
while (filePos f) != endOfFile and (eof f) == false do
(
curLine = trimLeft (trimRight (readline f))
if (tolower curline) == "<shape>" then (
shapeName = trimLeft (trimRight (readline f))
while shapeName == "" and (filePos f) != endOfFile and (eof f) == false do
(
shapeName = trimLeft (trimRight (readline f))
)
if shapeName != "(no_shape)" then (
curLine = trimLeft (trimRight (readline f))
while curLine == "" and (filePos f) != endOfFile and (eof f) == false do
(
curLine = trimLeft (trimRight (readline f))
)
numShapes = curLine as integer
--format "% shapes to parse\n" curLine
for i = 1 to numShapes do (
--format "\tParsing shaoetype: "
skippedLines = 0
curLine = trimLeft (trimRight (readline f))
while curLine == "" and (filePos f) != endOfFile and (eof f) == false do
(
skippedLines = skippedLines + 1
curLine = trimLeft (trimRight (readline f))
)
--format "% (skipped % lines)\n" curLine skippedLines
appendIfUnique shapeTypes curLine
--format "\tSkipping "
skippedLines = 0
lastlinestart = filepos f
curLine = trimLeft (trimRight (readline f))
--skippedLinesData = stringstream ""
while (curLine == "" or ((filterstring curLine ", ")[1] as integer) != undefined or curLine[1] == "-" ) and (filePos f) != endOfFile and (eof f) == false do
(
lastlinestart = filepos f
skippedLines = skippedLines + 1
-- format "\t\t%:\t%\n" skippedLines curLine
curLine = trimLeft (trimRight (readline f))
)
--format "% lines of data & blank lines\n" skippedLines
if curLine == "form_collision_groups" then (
--format "\tFound collisonGroups (#"
curLine = trimLeft (trimRight (readline f))
--format "%)\n" curLine
appendIfUnique collisonGroups curLine
)
else if i < numShapes then (
--format "stepping back % lines\n" curLine.count
seek f lastlinestart
)
)
)
)
)
#(shapeTypes, collisonGroups)
)
fn FindAllShapeTypes dataDir:"D:\\Carmageddon Max Damage\\Data_Core\\Content\\" = (
accessoryTXTs = getFilesRecursive dataDir "accessory.txt"
shapeTypes = #()
collisionGroups = #()
for accFile in accessoryTXTs do (
shapeDetails = FindShapeTypesInAccessory accFile
for shapeType in shapeDetails[1] do (
appendIfUnique shapeTypes shapeType
)
for collisionGroup in shapeDetails[2] do (
appendIfUnique collisionGroups collisionGroup
)
)
format "Collision shaped:\n"
for shapeType in shapeTypes do (
format "\t%\n" shapeType
)
format "Collision griups:\n"
for collisionGroup in collisionGroups do (
format "\t%\n" collisionGroup
)
)