コード例 #1
0
    public static void ReloadParams()
    {
        if (!File.Exists(ParamPath))
        {
            Debug.Log("Data0.bdt not found. This will make treasure editor have less functionality.");
            return;
        }
        BND4 paramBnd = SFUtil.DecryptDS3Regulation(DarkSoulsTools.GetOverridenPath(ParamPath));

        DS3Param = PARAM.Read(paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "ItemLotParam.param").Bytes);
        PARAM.Layout layout = PARAM.Layout.ReadXMLFile($@"{Application.dataPath.Replace('/', '\\')}\dstools\ParamLayouts\DS3\{DS3Param.ID}.xml");
        DS3Param.SetLayout(layout);

        // Build and cache the item name list
        HashSet <int> usedItemIds = new HashSet <int>();

        ItemNameList = new List <Tuple <int, string> >();
        foreach (var row in DS3Param.Rows)
        {
            ItemLotParam param = new ItemLotParam(row);
            foreach (int id in param.ItemID)
            {
                if (!usedItemIds.Contains(id))
                {
                    usedItemIds.Add(id);
                    ItemNameList.Add(new Tuple <int, string>(id, FMGUtils.LookupItemName(id)));
                }
            }
        }
        ItemNameList.Sort((a, b) => StringComparer.InvariantCulture.Compare(a.Item2, b.Item2));
    }
コード例 #2
0
ファイル: EnemyParamUtils.cs プロジェクト: swordworld/dstools
    public static void ReloadParams()
    {
        if (!File.Exists(ParamPath))
        {
            Debug.Log("DS2 enc_regulation.bnd.dcx not found");
            return;
        }
        if (!BND4.Is(DarkSoulsTools.GetOverridenPath(ParamPath)))
        {
            Debug.Log("Decrypt your regulation by saving in Yapped");
            return;
        }
        BND4 paramBnd = BND4.Read(DarkSoulsTools.GetOverridenPath(ParamPath));

        EnemyParam = PARAM.Read(paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "EnemyParam.param").Bytes);
        PARAM.Layout layout = PARAM.Layout.ReadXMLFile($@"{Application.dataPath.Replace('/', '\\')}\dstools\ParamLayouts\DS2SOTFS\{EnemyParam.ID}.xml");
        EnemyParam.SetLayout(layout);

        // Build and cache the enemy param dictionary
        ParamDictionary = new Dictionary <long, PARAM.Row>();
        foreach (var row in EnemyParam.Rows)
        {
            ParamDictionary.Add(row.ID, row);
        }
    }
コード例 #3
0
    public static void SaveParams()
    {
        if (GameType != DarkSoulsTools.GameType.DarkSoulsIII || DS3Param == null)
        {
            return;
        }

        BND4 paramBnd = SFUtil.DecryptDS3Regulation(DarkSoulsTools.GetOverridenPath(ParamPath));
        var  param    = paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "ItemLotParam.param");

        param.Bytes = DS3Param.Write();

        // Save a backup if one doesn't exist
        if (!File.Exists(ParamPath + ".backup"))
        {
            File.Copy(ParamPath, ParamPath + ".backup");
        }

        string paramPath = ParamPath;

        if (DarkSoulsTools.GetModProjectPathForFile(ParamPath) != null)
        {
            paramPath = DarkSoulsTools.GetModProjectPathForFile(ParamPath);
        }

        // Write as a temporary file to make sure there are no errors before overwriting current file
        if (File.Exists(paramPath + ".temp"))
        {
            File.Delete(paramPath + ".temp");
        }
        SFUtil.EncryptDS3Regulation(paramPath + ".temp", paramBnd);

        // Make a copy of the previous map
        File.Copy(paramPath, paramPath + ".prev", true);

        // Move temp file as new map file
        File.Delete(paramPath);
        File.Move(paramPath + ".temp", paramPath);
    }