This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom scripts to generate data for MTGA from various sources JET/Pre…
…sets/SPT
- Loading branch information
Showing
6 changed files
with
294 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Copy assets database into this location for scripts to work properly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Folder where generated staff will be present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |