From 7ffadf9eb78dbe297c96819f9f5b33e9c21507c2 Mon Sep 17 00:00:00 2001 From: spirit <59442519+notaspirit@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:01:12 +0200 Subject: [PATCH] Update RemoveOcclusionFromSectors.wscript Added: 1. description and usage 2. Counter for how many nodes and sectors are affected Modified: 1. sectornames for the output file are now shortened by - 1. changing "exterior" and "interior" to "e" and "i" - 2. removing "_" within the sector name --- Scripts/RemoveOcclusionFromSectors.wscript | 39 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/Scripts/RemoveOcclusionFromSectors.wscript b/Scripts/RemoveOcclusionFromSectors.wscript index 09b6f22..9f94a70 100644 --- a/Scripts/RemoveOcclusionFromSectors.wscript +++ b/Scripts/RemoveOcclusionFromSectors.wscript @@ -1,14 +1,24 @@ -// Geneates .xl file that removes all occlusion meshes from all streamingsectors in the project -// Special thanks to simarilius for writing most of the code // @author spirit -// @version 1.0 +// @version 1.1 +// @description +// This script generates an .xl file that removes all occluder nodes from all sectors in the project. +// Does not include occlusion that is caused by collision nodes. +// Special thanks to Simarilius for helping with the foundation of this script. +// @usage +// Detailed instructions can be found in the wiki. +// 1. Indentify all sectors that add occluder nodes using RedHotTools +// 2. Add all affected sectors to a new project +// 3. Run the script +// 4. Move the generated file into your archive mod folder import * as Logger from 'Logger.wscript'; import * as TypeHelper from 'TypeHelper.wscript'; let RemoverStr = "streaming:\n sectors:\n" -let sectorNames = "OcclusionRemover_" +let sectorNames = "NoOccl_" let sectors = [] +let removedNodesCount = 0 +let removedSectorCount = 0 // Gets FileName only from path function getFileNameWithoutExt(filePath) { @@ -16,6 +26,21 @@ function getFileNameWithoutExt(filePath) { const ext = fileNameWithExt.lastIndexOf('.'); return ext === -1 ? fileNameWithExt : fileNameWithExt.slice(0, ext); // Remove extension } + +// generates a shortened sector name +function shortenSectorName(sectorName) { + let shortSectorName = "" + let sectorNameArray = sectorName.split("_") + if (sectorNameArray[0] == "exterior") { + shortSectorName += "e" + } else if (sectorNameArray[0] == "interior") { + shortSectorName += "i" + } else { + Logger.warn("Error while shortening sector name, unexpected sector type!") + } + shortSectorName += sectorNameArray[1]+sectorNameArray[2]+sectorNameArray[3]+sectorNameArray[4]+"_" + return shortSectorName +} // Lists all streamingsectors in Projects for (let filename of wkit.GetProjectFiles('archive')) { if (filename.split('.').pop() === "streamingsector") { @@ -24,7 +49,7 @@ for (let filename of wkit.GetProjectFiles('archive')) { } // Goes through all streamingsectors for (const fileName of sectors) { - + removedSectorCount += 1 let node_data_indexs=[] if (wkit.FileExistsInProject(fileName)) { var file = wkit.GetFileFromProject(fileName, OpenAs.GameFile); @@ -35,7 +60,7 @@ for (const fileName of sectors) { let nodeData = json["Data"]["RootChunk"]["nodeData"]["Data"] // Generates the Path and expected Nodes section RemoverStr += " - path: "+fileName+"\n"+" expectedNodes: "+nodeData.length.toString()+"\n"+" nodeDeletions:"+"\n"; - sectorNames += ""+getFileNameWithoutExt(fileName); + sectorNames += ""+shortenSectorName(getFileNameWithoutExt(fileName)); Logger.Info('Identifying Occulder Nodes in '+fileName) let nodes = json["Data"]["RootChunk"]["nodes"]; @@ -53,6 +78,7 @@ for (const fileName of sectors) { for (let index2 in node_data_indexs) { if (nodeData[index]["NodeIndex"]==node_data_indexs[index2]["index"]) { RemoverStr += " - index: "+index+"\n type: "+node_data_indexs[index2]["type"]+"\n"; + removedNodesCount += 1; } } } @@ -61,3 +87,4 @@ for (const fileName of sectors) { // Saves the File to Resources wkit.SaveToResources(sectorNames+".xl", RemoverStr); Logger.Info("Saved "+sectorNames+".xl to resources!"); +Logger.Info("Removed "+removedNodesCount+" nodes from "+removedSectorCount+" sectors!")