-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-legacy-factions.js
295 lines (257 loc) · 9.82 KB
/
make-legacy-factions.js
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
/**
mods/1-LibertyMod
mods/2-LibertyCampaign
mods/3-SwarmMod
mods/4-SwarmCampaign
mods/5-VoidMod
mods/6-VoidCampaign
mods/7-VoidMulti
**/
import * as SCParser from "./index.js";
import fs from 'fs'
import {capitalize, deep, formatData} from "./index.js";
import path from "path";
SCParser.SCGame.directories.mods = `C:\\Program Files (x86)\\StarCraft II\\mods\\all-races-mods`
//Legacy X
if(false) {
let mod = await SCParser.createMod({
core: [
'$mods/dependencies/Core',
'$mods/dependencies/Base',
],
mods: [
'$mods/dependencies/Legacy',
]
})
mod.renamePickedEntities()
await mod.writeMod('compiled/Legacy','./data/compiled-legacy',{Name:`[ARX] Legacy`, LongDest: `Compiled Legacy dependency`})
}
// //Legacy X + Starlight
//
if(false) {
let mod = await SCParser.createMod({
core: [
'$mods/dependencies/Core',
'$mods/dependencies/Base',
],
mods: [
'$mods/dependencies/Legacy',
'$mods/factions/Scion',
'$mods/dependencies/Starlight',
]
})
mod.renamePickedEntities()
await mod.writeMod('compiled/Starlight','./data/compiled-legacy',{Name:`[ARX] Starlight`, LongDest: `Compiled Starlight dependency`})
}
/**
* Make Base Dependency
* Path: dependencies/Coop.sc2mod/Base.SC2Data/GameData
* Path: dependencies/Coop.sc2mod/enUS.SC2Data
* Path: dependencies/Coop.sc2mod/ruRU.SC2Data
*/
if(false){
let mod = new SCParser.SCMod()
await mod.read([
'./data/legacy/factions/Liberty',
'./data/legacy/factions/Swarm',
'./data/legacy/factions/Void',
'./data/legacy/factions/Multi'
])
await mod.writeMod( 'combined/VoidMulti','./data/base', {Name:`[ARC] VoidMulti`, LongDest: `Combined Void Multi dependency`})
}
/**
* Make Base Dependency
* Path: dependencies/Coop.sc2mod/Base.SC2Data/GameData
* Path: dependencies/Coop.sc2mod/enUS.SC2Data
* Path: dependencies/Coop.sc2mod/ruRU.SC2Data
*/
if(false){
let mod = new SCParser.SCMod()
await mod.read([
'$mods/legacy/base/Liberty',
'$mods/legacy/base/Swarm',
'$mods/legacy/base/Void',
'$mods/legacy/base/Multi',
'$mods/legacy/base-campaign/Liberty',
'$mods/legacy/base-campaign/Swarm',
'$mods/legacy/base-campaign/Void',
'$mods/legacy/base-campaign/Coop',
'$mods/legacy/base-campaign/Coop2',
])
await mod.writeMod( 'combined/Base','./data/base', {Name:`[ARC] Base`, LongDest: `Combined Base dependency`})
}
/**
* Make Coop Dependency
* Path: dependencies/Coop.sc2mod
*/
if(false){
let mod = new SCParser.SCMod()
await mod.read([
'$dependencies/Coop',
])
mod.saveCore()
await mod.read([
'$mods/legacy/factions/Liberty',
'$mods/legacy/factions/Swarm',
'$mods/legacy/factions/Void',
'$mods/legacy/factions/Multi',
'$mods/legacy/factions-campaign/Liberty.SC2Mod',
'$mods/legacy/factions-campaign/Swarm.SC2Mod',
'$mods/legacy/factions-campaign/Void.SC2Mod',
'$mods/legacy/factions-campaign/Coop.SC2Mod',
])
mod.removeUnusedSounds()
await mod.writeMod('combined/Legacy','./data/combined-legacy', {Name:`[ARC] Legacy`, LongDest: `Combined Legacy dependency`})
mod.renamePickedEntities(mod)
await mod.writeMod('compiled/Legacy','./data/compiled-legacy',{Name:`[ARX] Legacy`, LongDest: `Compiled Legacy dependency`})
}
/**
* Mace Factions Mod
*/
if(true){
let mod = await SCParser.createMod({
core: [
'$mods/dependencies/Core',
'$mods/dependencies/Base',
'$mods/factions/Legacy',
],
mods: [
// '$mods/dependencies/LegacyCoop',
// '$mods/factions/ProtossTalon',
'$mods/dependencies/Triggers',
'$mods/factions/Scion',
'$mods/factions/Hybrids',
'$mods/factions/UED',
'$mods/factions/Dragons',
'$mods/factions/UPL',
'$mods/factions/Umojan',
'$mods/factions/Synoid',
'$mods/dependencies/Melee',
// '$mods/factions/Colonial',
// '$mods/factions/Tyranid',
// '$mods/factions/WarCraft',
// '$mods/factions/Nexus',
]
})
let result = {
Ready :{},
Birth :{},
What :{},
Yes :{},
Attack :{},
Pissed :{},
}
mod.index()
if(false){
mod.removeUnusedSounds()
function removeSoundReference(actor,sound, events, type){
if(sound?.id){
for(let event of events){
let unit = event.Terms.split(".")[1]
if(!result[type]){
result[type] = {}
}
let assets = sound.$$resolved.AssetArray?.map(asset => {
if(asset.TemplateParam){
let template = sound.$$resolved.AssetArrayTemplate
asset = Object.assign(asset,{
File: template.File.replace(/\^TemplateParam[1-9]\^/,asset.TemplateParam),
FacialAnim: template.FacialAnim.replace(/\^TemplateParam[1-9]\^/,asset.TemplateParam),
FacialGroup: template.FacialGroup.replace(/\^TemplateParam[1-9]\^/,asset.TemplateParam),
FacialFile: template.FacialFile.replace(/\^TemplateParam[1-9]\^/,asset.TemplateParam),
Volume: asset.Volume?.replace(/\.0+/g,""),
Pitch: asset.Pitch?.replace(/\.0+/g,"")
})
delete asset.TemplateParam
// <AssetArrayTemplate File="LocalizedData\Sounds\VO\Protoss\^TemplateParam2^.ogg" FacialAnim="^TemplateParam1^" FacialGroup="^TemplateParam1^" FacialFile="LocalizedData\Sounds\VO\Protoss\^TemplateParam1^.fxe"/>
// return asset.File
}
for(let prop in asset){
if(!asset[prop]){
delete asset[prop]
}
}
return asset
})
if(assets){
result[type][unit] = {
// id: sound.id,
AssetArray: assets,
Pitch: sound.$$resolved.Pitch?.replace(/\.0+/g,""),
Volume: sound.$$resolved.Volume?.replace(/\.0+/g,""),
}
}
}
if(!sound.$$references){
console.log("removeSoundReference - No Refenrces: " + sound.id + " actor: " + actor.id)
}
sound.$$references = sound.$$references?.filter(ref => ref.target !== actor)
if(!sound.$$references || sound.$$references.length === 0){
mod.remove(sound)
console.log("Sound Removed: " + sound.id)
count++
return;
}
}
}
let count = 0
for(let actor of mod.catalogs.actor){
if(actor.default || actor.__core)continue
let events = actor.$$resolved.On?.filter(On => /UnitBirth.[\w@]+/.test(On.Terms) && On.Send === "Create")
if(!events?.length) continue
let types = ['Birth','Ready','What','Pissed','Yes','Attack']
for(let type of types){
if(actor.$$resolved.DeathArray){
for(let deathType in actor.$$resolved.DeathArray){
let deathArrayValue = actor.$$resolved.DeathArray[deathType]
if(deathArrayValue.SoundLink){
SCParser.deep(actor,{DeathArray: {[deathType]: {SoundLink: ""}}})
removeSoundReference(actor,mod.cache.sound[deathArrayValue.SoundLink], events, "Death" + deathType)
}
}
}
let soundArrayTypes = ['GroupSoundArray','SoundArray']
for(let soundArrayType of soundArrayTypes){
let soundArray = actor.$$resolved[soundArrayType]
if(soundArray?.[type]){
SCParser.deep(actor,{SoundArray: {[type]: ""}})
removeSoundReference(actor,mod.cache.sound[soundArray[type]], events, type)
// let symbol = sound?.id ? '✔' : '⨉'
// console.log(symbol + ' Birth Sound ID: ' + soundArray.Birth)
}
}
}
}
console.log("removed sounds: " + count)
fs.writeFileSync('result2.json',JSON.stringify(result),{encoding: 'utf-8'})
}
await mod.writeMod('./result2','./data/combined-factions',{Name:`[ARC] Factions`, LongDest: `Combined Factions dependency`, ShortDesc: `1-16`})
}
/**
* make coop
factions/Scion
factions/Hybrids
factions/UED
factions/Dragons
factions/UPL
factions/UPLMulti
factions/UPLCampaign
factions/Umojan
factions/War�raftMulti
**/
if(false){
let mod = await SCParser.createMod({ mods: [
'$coop/Legacy',
'$coop/Factions',
'$coop/Nexus',
'$coop/ProtossTalon',
'$coop/UmojanKerrigan',
'$coop/KeironMeneltor',
// '$coop/UPLCampaign',
'$coop/Warcraft',
]})
mod.removeUnusedSounds()
await mod.writeMod('combined', 'Coop',{Name:`[ARC] Coop`, LongDest: `Combined Coop dependency`, ShortDesc: `1-16`})
// renamePickedEntities(mod)
// await writeMod(mod,'compiled','Coop',{Name:`[ARX] Coop`, LongDest: `Compiled Coop dependency`, ShortDesc: `1-16`})
}