-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructures.js
168 lines (151 loc) · 5.16 KB
/
structures.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
import fs from "fs";
import {copyProperties} from "./common.js";
const all = JSON.parse(fs.readFileSync('basic.json'))
const structures = []
const todo = []
const copyProps = [
'DisplayName', 'Description',
{name: 'FactionVariant', replace: ['EFactionId::', '']},
'BuildOrder',
{name: 'BuildCategory', replace: ['EBuildCategory::', '']},
{name: 'BuildLocationType', replace: ['EBuildLocationType::', '']},
'ValidBuildTools',
{name: 'TechID', replace: ['ETechID::', '']},
{name: 'ResourceAmounts', function: resourceAmounts}, {name: 'AltResourceAmounts', function: resourceAmounts},
'MaxHealth', 'Health',
'DecayStartHours', 'DecayDurationHours',
'RepairCost', 'StructuralIntegrity',
'DetectionRadius', {name: 'TunnelConnectionRange', merge: ['TunnelConnectionRange', 'BaseTunnelConnectionRange']},
{name: 'PowerInfo', function: powerInfo},
{name: 'ArmourType', replace: ['EArmourType::', '']},
{name: 'BaseDamage', merge: ['BaseDamage', 'WeaponDamage']},
'WeaponDamageAT',
{name: 'MinimumRange', merge: ['MinDistance']},
{name: 'MaximumRange', merge: ['MaximumRange', 'MaxDistance']},
'MaximumReachability', 'FiringPeriod',
'TrackingSpeed', 'DamageDelay',
'TimeToFullFireRateAndAccuracy', 'EnemyPursueDuration', 'ShouldAggroOnDamage',
{name: 'TankArmourEffectType', replace: ['ETankArmourEffectType::', '']},
'VehicleSubsystemDisableMultipliers',
'ConnectorMinLength', 'ConnectorMaxLength',
'UpgradeStructureCodeName',
{name: 'Items', function: techItems},
{name: 'ProductionCategories', function: productionCategories},
{name: 'ConversionEntries', function: conversionEntries},
{name: 'Modifications', function: modifications},
'FuelTanks',
'IsVaultable', 'RamDamageReceivedFlags',
'bCanBeHidden', 'bApplyTankArmourMechanics', 'bCanBeHarvested', 'bIsDamagedWhileDrivingOver', 'bLogWhenDestroyed',
'bBuildOnBridges', 'bIsBuiltOnFoundation', 'bIsConnector', 'bIsManualConnector', 'bClearModificationsOnDowngrade',
'bExposeInUI', 'bDropsLargeMaterialsWhenDestroyed', 'bIsGarrisonEnabled', 'CoverProvided', 'bIsRemovable'
]
const codeNames = {}
for (const codeName of Object.keys(all)) {
const dataItem = all[codeName]
if (!dataItem.BPTypes.includes('Structures')) {
continue
}
if (dataItem.ItemProfileType) {
continue
}
if (dataItem.bIsVehicleProxy) {
continue
}
// if (dataItem.BPTypes.includes('Vehicles') || dataItem.BPTypes.includes('Structures')) {
// continue
// }
const item = {
CodeName: codeName,
}
copyProperties(item, dataItem, copyProps)
codeNames[codeName] = structures.push(item) - 1
// delete dataItem.BPTypes
delete dataItem.files
delete dataItem.SuperStruct
delete dataItem.unprocessedSuperStruct
// delete dataItem.types
if (Object.keys(dataItem).length > 0) {
dataItem.codeName = codeName
dataItem.DisplayName = item.DisplayName
todo.push(dataItem)
}
}
fs.writeFileSync('docs/structures.json', JSON.stringify(structures, null, 2))
fs.writeFileSync('structures-todo.json', JSON.stringify(todo, null, 2))
console.log(todo.length)
function resourceAmounts(item, value) {
if (!('ResourceAmounts' in item)) {
item.ResourceAmounts = []
}
const data = {}
if (value.Resource.CodeName === 'None') {
return
}
data[value.Resource.CodeName] = value.Resource.Quantity
for (const other of value.OtherResources) {
data[other.CodeName] = other.Quantity
}
item.ResourceAmounts.push(data)
}
function powerInfo(item, value) {
item.Power = value.PowerDelta
if (value.PowerLength) {
item.PowerLength = value.PowerLength
}
if (value.MaxConnections) {
item.PowerMaxConnections = value.MaxConnections
}
}
function techItems(item, value) {
item.Techs = []
for (const tech of value) {
item.Techs.push({
TechID: tech.TechID.replace('ETechComponentID::', ''),
Requirement: tech.Requirement,
NextTechID: tech.NextTechID.replace('ETechComponentID::', '')
})
}
}
function productionCategories(item, value) {
if (!('Production' in item)) {
item.Production = []
}
for (const category of value) {
for (const categoryItem of category.CategoryItems) {
item.Production.push({
'Item': categoryItem.CodeName,
'Category': category.Type.replace('EFactoryQueueType::', ''),
})
}
}
}
function conversionEntries(item, value, requiredModification = null) {
for (const conversion of value) {
if (conversion.Output) {
const conversionData = {
Input: [...conversion.Input, ...conversion.FuelInput],
Output: [...conversion.Output, ...conversion.FuelOutput],
Duration: conversion.Duration,
Power: conversion.PowerDelta,
bConsumeResourceNodes: conversion.bConsumeResourceNodes,
}
if (requiredModification) {
conversionData.RequiredModification = requiredModification;
}
if (!('Conversions' in item)) {
item.Conversions = []
}
item.Conversions.push(conversionData)
}
}
}
function modifications(item, value) {
for (const mod of value) {
if (mod.ConversionEntries) {
conversionEntries(item, mod.ConversionEntries, mod.type.replace('EFortModificationType::', ''))
}
else {
console.log(mod)
}
}
}