-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.js
More file actions
187 lines (169 loc) · 6.24 KB
/
items.js
File metadata and controls
187 lines (169 loc) · 6.24 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
import fs from "fs";
import {copyProperties} from "./common.js";
const all = JSON.parse(fs.readFileSync('basic.json'))
//const dataTable = JSON.parse(fs.readFileSync('datatables.json'))
const items = []
const todo = []
const copyProps = [
'DisplayName', 'Description',
{name: 'ItemCategory', replace: ['EItemCategory::', '']},
{name: 'ItemProfileType', replace: ['EItemProfileType::', '']},
'Encumbrance', 'EquippedEncumbrance',
{name: 'EquipmentSlot', replace: ['EEquipmentSlot::', '']},
{name: 'FactionVariant', replace: ['EFactionId::', '']},
{name: 'TechID', replace: ['ETechID::', '']},
{name: 'CostPerCrate', function: costPerCrate},
'QuantityPerCrate', 'CrateProductionTime', 'SingleRetrieveTime', 'CrateRetrieveTime',
{name: 'CompatibleAmmoNames', function: compatibleAmmoNames}, {name: 'MultiAmmo', function: compatibleAmmoNames},
'Damage', 'DamageMultiplier', 'DestructibleDamage', 'Suppression', 'SuppressionMultiplier', 'ExplosionRadius',
'DamageInnerRadius', 'DamageFalloff',
'AccuracyRadius', 'EnvironmentImpactAmount', 'AddedBurning', 'AddedBurningMultiplier', 'AddedHeat',
{name: 'DamageType', function: damageType},
'MaxAmmo',
{name: 'MaximumRange', merge: ['MaximumRange', 'GrenadeRangeLimit']},
'MaximumReachability',
{name: 'DeployDuration', merge: ['DeployDuration', 'GrenadeFuseTimer', 'FuseTimer']},
'CoverProvided',
'bPreventBorderPlacement', 'ShouldDoLandscapeCheck', 'bIsSingleUse', 'bIsLarge', 'bSupportsVehicleMounts',
'bCanFireFromVehicle', 'bRequiresCoverOrLowStanceToInvoke'
]
const ignoreCostsProps = [
'CostPerCrate', 'QuantityPerCrate', 'CrateProductionTime', 'SingleRetrieveTime', 'CrateRetrieveTime',
'MaximumRange', 'MaximumReachability', 'AddedBurningMultiplier',
]
const damageTypeProps = [
{name: 'DamageType', replace: ['EDamageType::', '']},
{name: 'VehicleSubsystemOverride', replace: ['EVehicleSubsystem::', '']},
'VehicleSubsystemDisableMultipliers', 'TankArmourPenetrationFactor',
'bApplyTankArmourMechanics',
'bApplyTankArmourAngleRangeBonuses',
'bApplyDamageFalloff',
'bCanWoundCharacter',
'bCanRuinStructures',
'bAppliesBurning',
'bNeverAppliesBleeding',
'bAlwaysAppliesBleeding',
]
const codeNames = {}
for (const codeName of Object.keys(all)) {
const dataItem = all[codeName]
if (!dataItem.BPTypes.includes('Items') && !dataItem.BPTypes.includes('ItemPickups')) {
continue
}
if (dataItem.BPTypes.includes('Vehicles')) { // || dataItem.BPTypes.includes('Structures')
continue
}
if (!dataItem.ItemProfileType) {
console.log('No type', codeName)
continue
}
const item = {
CodeName: codeName,
}
copyProperties(item, dataItem, copyProps)
if (dataItem.CompatibleAmmoCodeNameData) {
copyProperties(item, dataItem.CompatibleAmmoCodeNameData, copyProps, ignoreCostsProps)
}
if (dataItem.SingleShotCodeNameData) {
const singleShotItem = JSON.parse(JSON.stringify(item))
singleShotItem.CodeName += 'Single'
singleShotItem.DisplayName += ' (Single Shot)'
copyProperties(singleShotItem, dataItem.SingleShotCodeNameData, copyProps, ignoreCostsProps, true)
copyProperties(singleShotItem, dataItem.SingleShotAmmoCodeNameData, copyProps, ignoreCostsProps, true)
items.push(singleShotItem)
}
codeNames[codeName] = items.push(item) - 1
delete dataItem.BPTypes
delete dataItem.files
delete dataItem.SuperStruct
delete dataItem.unprocessedSuperStruct
delete dataItem.types
delete dataItem.ItemFlagsMask
delete dataItem.ResearchLevel
if (Object.keys(dataItem).length > 0) {
dataItem.codeName = codeName
dataItem.DisplayName = item.DisplayName
todo.push(dataItem)
}
}
for (const codeName of Object.keys(all)) {
const dataItem = all[codeName]
if (dataItem.ProductionCategories) {
for (const category of dataItem.ProductionCategories) {
for (const item of category.CategoryItems) {
if (item.CodeName in codeNames) {
if (!("ProducedIn" in items[codeNames[item.CodeName]])) {
items[codeNames[item.CodeName]].ProducedIn = []
}
if (!items[codeNames[item.CodeName]].ProducedIn.includes(codeName)) {
items[codeNames[item.CodeName]].ProducedIn.push(codeName)
}
}
}
}
}
if (dataItem.ConversionEntries) {
for (const conversion of dataItem.ConversionEntries) {
if (conversion.Output) {
for (const output of conversion.Output) {
if (output.CodeName in codeNames) {
if (!("ProducedIn" in items[codeNames[output.CodeName]])) {
items[codeNames[output.CodeName]].ProducedIn = []
}
if (!items[codeNames[output.CodeName]].ProducedIn.includes(codeName)) {
items[codeNames[output.CodeName]].ProducedIn.push(codeName)
}
}
}
}
}
}
if (dataItem.Modifications) {
for (const mods of dataItem.Modifications) {
if (mods.ConversionEntries) {
for (const conversion of mods.ConversionEntries) {
if (conversion.Output) {
for (const output of conversion.Output) {
if (output.CodeName in codeNames) {
if (!("ProducedIn" in items[codeNames[output.CodeName]])) {
items[codeNames[output.CodeName]].ProducedIn = []
}
if (!items[codeNames[output.CodeName]].ProducedIn.includes(codeName)) {
items[codeNames[output.CodeName]].ProducedIn.push(codeName)
}
}
}
}
}
}
}
}
}
fs.writeFileSync('docs/items.json', JSON.stringify(items, null, 2))
fs.writeFileSync('items-todo.json', JSON.stringify(todo, null, 2))
console.log(todo.length)
function costPerCrate(item, values) {
item.CostPerCrate = {}
for (const value of values) {
if (value.ItemCodeName === 'None') {
continue
}
item.CostPerCrate[value.ItemCodeName] = value.Quantity
}
}
function damageType(item, value) {
copyProperties(item, value, damageTypeProps, [])
}
function compatibleAmmoNames(item, value) {
if (!('CompatibleAmmoNames' in item)) {
item.CompatibleAmmoNames = []
}
if (typeof value === 'object') {
for (const ammo of value.CompatibleAmmoNames) {
item.CompatibleAmmoNames.push(ammo)
}
}
else {
item.CompatibleAmmoNames.push(value)
}
}