diff --git a/#scripts/SPT_assets/readme.md b/#scripts/SPT_assets/readme.md new file mode 100644 index 00000000..5a7a8933 --- /dev/null +++ b/#scripts/SPT_assets/readme.md @@ -0,0 +1 @@ +Copy assets database into this location for scripts to work properly \ No newline at end of file diff --git a/#scripts/convertMapsData.js b/#scripts/convertMapsData.js index 159b6f2a..08f99b36 100644 --- a/#scripts/convertMapsData.js +++ b/#scripts/convertMapsData.js @@ -1,3 +1,13 @@ + +/* +Made by TheMaoci for MTGA + +this scripts cakes old type of containers/dynamic/quest/weapons data structure +and changes it to newer more compressed one +files are not overriden and are named as originalname2 +*/ + + "use strict"; const fs = require('fs'); const path = require('path'); @@ -12,6 +22,7 @@ var WORKING_DIR = "../assets/database/locations"; var MapNames = fs.readdirSync(`${WORKING_DIR}`); +/* var FolderStructure = { MapName: { bossWaves: "filesContainingBossWaves", @@ -19,7 +30,7 @@ var FolderStructure = { waves: "filesContainingWaves" } } - +*/ for(let mapName of MapNames) { @@ -33,6 +44,10 @@ for(let mapName of MapNames) // we are skipping IsStatic cause it will be always static for containers and false for dynamics + // --- STATIC - CONTAINERS --- + // --- STATIC - CONTAINERS --- + // --- STATIC - CONTAINERS --- + // --- STATIC - CONTAINERS --- let newContainers = []; for(let container of containers) { @@ -44,6 +59,10 @@ for(let mapName of MapNames) } fs.writeFileSync(`${WORKING_DIR}/${mapName}/lootspawns/containers2.json`, stringify(newContainers)); + // --- DYNAMIC - LOOSELOOT --- + // --- DYNAMIC - LOOSELOOT--- + // --- DYNAMIC - LOOSELOOT --- + // --- DYNAMIC - LOOSELOOT --- let newDynamic = []; for(let dynamic of dynamics) { @@ -81,6 +100,10 @@ for(let mapName of MapNames) } fs.writeFileSync(`${WORKING_DIR}/${mapName}/lootspawns/dynamic2.json`, stringify(newDynamic)); + // --- STATIONARY - WEAPONS --- + // --- STATIONARY - WEAPONS --- + // --- STATIONARY - WEAPONS --- + // --- STATIONARY - WEAPONS --- let newWeapon = []; for(let weapon of weapons) { @@ -92,6 +115,10 @@ for(let mapName of MapNames) } fs.writeFileSync(`${WORKING_DIR}/${mapName}/lootspawns/weapons2.json`, stringify(newWeapon)); + // --- QUESTS --- + // --- QUESTS --- + // --- QUESTS --- + // --- QUESTS --- let newQuest = []; for(let quest of newQuest) { @@ -117,23 +144,4 @@ for(let mapName of MapNames) newQuest.push(newData); } fs.writeFileSync(`${WORKING_DIR}/${mapName}/lootspawns/quests2.json`, stringify(newQuest)); - - //let getFiles = fs.readdirSync(`${WORKING_DIR}/${mapName}/lootspawns`); - //let MapFiles = []; - //let FilesToDeleteAfterWorkIsDone = []; - - - //for(let file of getFiles) - //{ - // if(file.includes(".json")) - // { - // MapFiles.push(parse(read(`${WORKING_DIR}/${mapName}/${file}`)).Location) - // FilesToDeleteAfterWorkIsDone.push(`${WORKING_DIR}/${mapName}/${file}`); - // } - // } - - //log(MapFiles); - - //break; - } \ No newline at end of file diff --git a/#scripts/generateDynamicLootBaseFromPresets.js b/#scripts/generateDynamicLootBaseFromPresets.js new file mode 100644 index 00000000..28540570 --- /dev/null +++ b/#scripts/generateDynamicLootBaseFromPresets.js @@ -0,0 +1,71 @@ +/* +Made by TheMaoci for MTGA + +This scripts generates 1 file with all the loot spawns with simplified names +and what items will be spawning on that locations based on presets in #presets folder in MTGA database +*/ + + +"use strict"; +const fs = require('fs'); +const path = require('path'); +const log = console.log; + +const stringify = (data) => JSON.stringify(data, null, "\t"); +const parse = (string) => JSON.parse(string); +const read = (file) => fs.readFileSync(file, 'utf8'); + +var WORKING_DIR = "../assets/database/locations"; + +var MapNames = fs.readdirSync(`${WORKING_DIR}`); + +for(let mapName of MapNames) +{ + if(mapName.includes(".")) continue; + let presetFileNames = fs.readdirSync(`${WORKING_DIR}/${mapName}/#presets`); + let presetLocationDynamicSpawnNames = {}; + //let presetsData = []; + for(let presetName of presetFileNames) + { + let data = parse(read(`${WORKING_DIR}/${mapName}/#presets/${presetName}`)); + + if(typeof data.Location == "undefined"){ + + data = data.data; + } else { + data = data.Location; + } + if(typeof data.Loot == "undefined") + { + log(presetName + " undefined data.[Location or data].Loot") + continue; + } + + let LootSpawns = data.Loot; + for(let loot in LootSpawns) + { + if(typeof LootSpawns[loot].IsStatic != undefined) + { + if(LootSpawns[loot].IsStatic == false) + { + let name = LootSpawns[loot].Id; + name = name.replace(/[\(\)\[\]0-9- ]{1,99}/g ,""); + name = name.replace("__", ""); + if(name.includes("quest")){ + + continue; + } + if(typeof presetLocationDynamicSpawnNames[name] != "undefined"){ + presetLocationDynamicSpawnNames[name].OrgId.push(LootSpawns[loot].Id) + } else { + log(name); + presetLocationDynamicSpawnNames[name] = { OrgId: [LootSpawns[loot].Id] } + } + } + } + } + //presetsData.push(data); + + } + fs.writeFileSync("./dynamicLootAll.json", stringify(presetLocationDynamicSpawnNames)); +} \ No newline at end of file diff --git a/#scripts/generateDynamicLootBaseFromSPT.js b/#scripts/generateDynamicLootBaseFromSPT.js new file mode 100644 index 00000000..5f8d4560 --- /dev/null +++ b/#scripts/generateDynamicLootBaseFromSPT.js @@ -0,0 +1,123 @@ + +/* +Made by TheMaoci for MTGA + +Generates our loot structs from SPT type of files +requires database of SPT in SPT_assets folder +will generate output into generated-from-spt + +*/ + +"use strict"; +const fs = require('fs'); +const path = require('path'); +const log = console.log; + +const stringify = (data) => JSON.stringify(data, null, "\t"); +const parse = (string) => JSON.parse(string); +const read = (file) => fs.readFileSync(file, 'utf8'); + +var WORKING_DIR = "SPT_assets/locations"; + +var MapNames = fs.readdirSync(`${WORKING_DIR}`); + +var TotalDynamicLootSpawns = {}; +//var TotalForcedLootSpawns = {}; +for(let mapName of MapNames) +{ + if(mapName.includes(".")) continue; + const lootFile = `${WORKING_DIR}/${mapName}/looseLoot.json`; + if(!fs.existsSync(lootFile)) continue; + + let MapDynamicLootSpawns = []; + let MapForcedLootSpawns = []; + let MapSpawnerItemsTable = {}; + const data = parse(read(lootFile)); + + const forcedSpawns = data.spawnpointsForced; + for(let spawn of forcedSpawns) + { + const template = spawn.template; + MapForcedLootSpawns.push({ + "worldId": template.Id, + "questItmTpl": template.Items[0]._tpl, + "Position": [ + template.Position.x, + template.Position.y, + template.Position.z + ], + "Rotation": [ + template.Rotation.x, + template.Rotation.y, + template.Rotation.z + ] + }) + } + + const spawns = data.spawnpoints; + for(let spawn of spawns) + { + const template = spawn.template; + let lootToPush = { + "worldId": template.Id, + "Position": [ + template.Position.x, + template.Position.y, + template.Position.z + ] + } + if(template.useGravity == true) + { + lootToPush["useGravity"] = true; + } + if(template.randomRotation == true) + { + lootToPush["randomRotation"] = true; + } else { + lootToPush["Rotation"] = [template.Rotation.x,template.Rotation.y,template.Rotation.z]; + } + MapDynamicLootSpawns.push(lootToPush); + + + let name = template.Id + name = name.replace(/[\(\)\[\]0-9- ]{1,99}/g ,""); + name = name.replace("__", ""); + + // map data + if(typeof MapSpawnerItemsTable[name] != "undefined"){ + for(let dist of spawn.itemDistribution) + { + if(!MapSpawnerItemsTable[name].includes(dist.tpl)) + MapSpawnerItemsTable[name].push(dist.tpl); + } + } else { + MapSpawnerItemsTable[name] = []; + for(let dist of spawn.itemDistribution) + { + MapSpawnerItemsTable[name].push(dist.tpl); + } + } + // global data + if(typeof TotalDynamicLootSpawns[name] != "undefined"){ + for(let dist of spawn.itemDistribution) + { + if(!TotalDynamicLootSpawns[name].includes(dist.tpl)) + TotalDynamicLootSpawns[name].push(dist.tpl); + } + } else { + TotalDynamicLootSpawns[name] = []; + for(let dist of spawn.itemDistribution) + { + TotalDynamicLootSpawns[name].push(dist.tpl); + } + } + + } + fs.mkdirSync(path.join(__dirname, 'generated-from-spt', mapName)); + + fs.writeFileSync(`./generated-from-spt/${mapName}/dynamics.json`, stringify(MapDynamicLootSpawns)); + fs.writeFileSync(`./generated-from-spt/${mapName}/quests.json`, stringify(MapForcedLootSpawns)); + fs.writeFileSync(`./generated-from-spt/${mapName}/availableSpawns.json`, stringify(MapSpawnerItemsTable)); + +} +fs.writeFileSync(`./generated/TotalAvailableSpawns.json`, stringify(TotalDynamicLootSpawns)); diff --git a/#scripts/generated-from-spt/readme.md b/#scripts/generated-from-spt/readme.md new file mode 100644 index 00000000..72f5c885 --- /dev/null +++ b/#scripts/generated-from-spt/readme.md @@ -0,0 +1 @@ +Folder where generated staff will be present \ No newline at end of file diff --git a/#scripts/updateLocationsBasedOnGeneratedFromSPT.js b/#scripts/updateLocationsBasedOnGeneratedFromSPT.js new file mode 100644 index 00000000..c135c371 --- /dev/null +++ b/#scripts/updateLocationsBasedOnGeneratedFromSPT.js @@ -0,0 +1,70 @@ + +/* +Made by TheMaoci for MTGA + +This scripts loops through generated locations dynamic/quests files in folder generated-flom-spt +checks if that entry is existing in our MTGA locations data and if not adds it in there. +this files not overrides anything you will need to manually go inside each location folder +and review and change names from dynamic_new and quests_new to dynamic and quests and deleting original files + +*/ + +"use strict"; +const fs = require('fs'); +const path = require('path'); +const log = console.log; + +const stringify = (data) => JSON.stringify(data, null, "\t"); +const parse = (string) => JSON.parse(string); +const read = (file) => fs.readFileSync(file, 'utf8'); + +var WORKING_DIR = "./generated-from-spt"; +var WORKING_DIR_OUT = "../assets/database/locations"; + +var MapNames_GEN = fs.readdirSync(`${WORKING_DIR}`); +var MapNames_ORG = fs.readdirSync(`${WORKING_DIR_OUT}`); + + +for(let mapName of MapNames_ORG) +{ + if(mapName.includes(".")) continue; + if(!fs.existsSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/dynamic.json`)) + { + let dynCopy = parse(read(`${WORKING_DIR}/${mapName}/dynamics.json`)); + fs.writeFileSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/dynamic.json`, stringify(dynamicLoot)); + } + if(!fs.existsSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/quests.json`)) + { + let queCopy = parse(read(`${WORKING_DIR}/${mapName}/quests.json`)); + fs.writeFileSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/quests.json`, stringify(questLoot)); + } + let dynamicLoot = parse(read(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/dynamic.json`)); + let questLoot = parse(read(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/quests.json`)); + let ListOfDynamicsInList = [] + let ListOfQuestsInList = [] + for(let dyn of dynamicLoot) + { + ListOfDynamicsInList.push(dyn.worldId) + } + for(let quest of questLoot) + { + ListOfQuestsInList.push(quest.worldId) + } + + let newDynamic = parse(read(`${WORKING_DIR}/${mapName}/dynamics.json`)); + let newQuest = parse(read(`${WORKING_DIR}/${mapName}/quests.json`)); + + for(let dyn of newDynamic) + { + if(!ListOfDynamicsInList.includes(dyn.worldId)) + dynamicLoot.push(dyn); + } + for(let quest of newQuest) + { + if(!ListOfQuestsInList.includes(quest.worldId)) + questLoot.push(quest); + } + + fs.writeFileSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/dynamic_new.json`, stringify(dynamicLoot)); + fs.writeFileSync(`${WORKING_DIR_OUT}/${mapName}/lootSpawns/quests_new.json`, stringify(questLoot)); +} \ No newline at end of file