Stellar blade Nanosuit Randomizer correction.

꿈돌리 · 2025-07-15 07:10 · 수정됨: 2025-07-15 07:11
조회수 67

Source: https://www.nexusmods.com/stellarblade/mods/1344?tab=posts

-- Set your save file path here if the automatic save file detection does not work

local manualSavePath = "" -- e.g. "C:/Users/ewanh/Downloads/uykuykuy/SaveGames/76561198298951619/StellarBladeSave00.sav"

--------------------------------------

-- Set NanoSuit filters here
-- ignoredSuits: Any suit IDs listed here will be excluded from random selection.
-- includedSuits: If this list is not empty, ONLY the suits listed here will be considered.
-- Use the Game ID for each suit, which can be found here: https://pastebin.com/jrTJVcde

local ignoredSuits = {}
local includedSuits = {}

-- Example:
-- local ignoredSuits = { "BS_Leather_Jean", "BS_31", "BS_Nikke_01" }
-- local includedSuits = { "BS_42", "BS_15_Var2", "BS_Black_Leather_bikini_Var2" }

--------------------------------------

local UEHelpers = require("UEHelpers")
local SBCheatManager = nil
local usedLabels = {}
local savePath = nil
local cachedSaveContent = nil
local lastReadTime = 0
local labels = {}

local function detectSavePath()
  if savePath then return true end

  if manualSavePath ~= "" then
    local f = io.open(manualSavePath, "rb")
    if f then
      f:close()
      savePath = manualSavePath
      print("Using manually specified save path:", savePath)
      return true
    else
      print("Manual save path invalid:", manualSavePath)
    end
  end

  local SBSaveBase = FindAllOf("SBSaveBase")
  local steamId = nil

  for _, value in ipairs(SBSaveBase) do
    local id = value.OnlineAccountInfo and value.OnlineAccountInfo.OnlineAccountID
    if id and id:ToString() ~= "" then
      steamId = id:ToString()
      break
    end
  end

  if steamId then
    local PathsLibrary = StaticFindObject("/Script/Engine.Default__BlueprintPathsLibrary")
    local base = PathsLibrary and PathsLibrary.ProjectSavedDir():ToString()
    if base then
      local testPath = base .. "SaveGames/" .. steamId .. "/StellarBladeSave00.sav"
      local f = io.open(testPath, "rb")
      if f then
        f:close()
        savePath = testPath
        print("Found save via Steam ID:", savePath)
        return true
      else
        print("Steam ID path exists but file missing:", testPath)
      end
    else
      print("Failed to get ProjectSavedDir")
    end
  else
    print("Steam ID not found via SBSaveBase")
  end

  return false
end

local function getAllLabelsFromContent(content)
  local out = {}
  local seen = {}

  for label in content:gmatch("\0BS_([a-zA-Z0-9_]+)\0\x10\0\0\0ItemVisualAlias\0") do
    local full = "BS_" .. label
    if not seen[full] then
      seen[full] = true
      table.insert(out, full)
    end
  end

  return out
end

local function loadSaveContent()
  local now = os.time()

  if cachedSaveContent and (now - lastReadTime) < 60 then
    return cachedSaveContent
  end

  if not savePath and not detectSavePath() then
    print("Save file not found")
    return nil
  end

  local file = io.open(savePath, "rb")
  if file then
    local content = file:read("*a")
    file:close()
    cachedSaveContent = content
    lastReadTime = now
    labels = getAllLabelsFromContent(content)
    return content
  else
    print("Failed to open save file, using cached version if available")
    return cachedSaveContent
  end
end

local function getFilteredLabels(allLabels)
  local filtered = {}

  for _, label in ipairs(allLabels) do
    local isIgnored = false
    for _, ignore in ipairs(ignoredSuits) do
      if label == ignore then
        isIgnored = true
        break
      end
    end

    local isIncluded = (#includedSuits == 0)
    if not isIncluded then
      for _, include in ipairs(includedSuits) do
        if label == include then
          isIncluded = true
          break
        end
      end
    end

    if not isIgnored and isIncluded then
      table.insert(filtered, label)
    end
  end

  return filtered
end

-- loadSaveContent()

UnregisterCustomEvent("Lua_TriggerSuitRandomiser")
RegisterCustomEvent("Lua_TriggerSuitRandomiser", function ()
  if not cachedSaveContent then
    if not loadSaveContent() then
      print("Unable to load save file")
      return
    end
    -- local content = loadSaveContent()
    -- if not content then
    --   print("Unable to load save file")
    --   return
    -- end
  end

  if #labels == 0 then
    print("No NanoSuit labels found")
    return
  end

  local remaining = {}
  for _, label in ipairs(getFilteredLabels(labels)) do
    if not usedLabels[label] then
      table.insert(remaining, label)
    end
  end

  if #remaining == 0 then
    print("All valid outfits used — resetting history")
    usedLabels = {}
    remaining = getFilteredLabels(labels)
  end

  if #remaining == 0 then
    print("No eligible outfits found after filtering")
    return
  end

  local chosen = remaining[math.random(1, #remaining)]
  usedLabels[chosen] = true
  print("Equipping:", chosen)

  if not SBCheatManager or not SBCheatManager:IsValid() then
    SBCheatManager = FindFirstOf("SBCheatManager")
  end

  if SBCheatManager and SBCheatManager:IsValid() then
    SBCheatManager:SBPlayerEquipItem("NanoSuit", true, chosen)
  else
    print("SBCheatManager not valid")
  end
end)
파일 첨부
첨부된 파일이 없습니다.

댓글

댓글을 불러오는 중...

아직 댓글이 없습니다. 첫 댓글을 작성해보세요!

댓글을 작성하려면 로그인이 필요합니다.

댓글 수정


 

분류 없음. 테스트.