diff --git a/scripts/consumable.mjs b/scripts/consumable.mjs new file mode 100644 index 0000000..98218eb --- /dev/null +++ b/scripts/consumable.mjs @@ -0,0 +1,37 @@ +import * as fs from "node:fs"; +import Logging from "log-like-a-zombie"; + +let log = new Logging('ConsumableConversion'); + +log.i(`RR Config Conversion Tool by @zombieb`); + +class FinalConsumableItem { + constructor() { + this.Count = 99; + this.CreatedAt = new Date().toISOString(); + this.Id = Math.floor(Math.random() * (999999999 - 100000000 + 1)) + 100000000; + this.UnlockedLevel = 0; + this.InitialCount = 0; + this.IsActive = false; + this.Category = 4; + this.ActiveDurationMinutes = 99; + this.PlatformMask = -1; + } +} + +// Read only db +const db = JSON.parse(fs.readFileSync('./raw.json')); +log.d(`Imported raw config`); +let final = []; + +const coerce = (val, i, arr) => { + let d = new FinalConsumableItem(); + + d.ConsumableItemDesc = val.consumableName; + + final.push(d); +} + +db.consumablePrefabData.forEach(coerce); + +fs.writeFileSync('./rawNew.json', Buffer.from(JSON.stringify(final)), {encoding:'utf8',flag:'w'}); \ No newline at end of file diff --git a/scripts/equipment.mjs b/scripts/equipment.mjs new file mode 100644 index 0000000..3f9017c --- /dev/null +++ b/scripts/equipment.mjs @@ -0,0 +1,75 @@ +import * as fs from "node:fs"; +import Logging from "log-like-a-zombie"; + +let log = new Logging('EquipmentConversion'); + +log.i(`RR Config Conversion Tool by @zombieb`); + +class FinalEquipmentItem { + constructor() { + this.PlatformMask = 0; + this.IsPlatformLocked = false; + this.Tooltip = 'For use with development builds only!'; + this.Rarity = GiftRarity.Uncommon; + } +} + +function formatFriendlyName(prefix, name) { + function removeItemAll(arr, value) { + var i = 0; + while (i < arr.length) { + if (arr[i] === value) { + arr.splice(i, 1); + } else { + ++i; + } + } + return arr; + } + + let formattedPrefix = String(prefix).replace('[', ''); + formattedPrefix = formattedPrefix.replace(']', ''); + + let item = String(name).replace(formattedPrefix, ''); + item = item.substring(1, item.length); + + let arr = String(item).split('_'); + arr = removeItemAll(arr, 'Skin'); + + // Exceptions. Some have spelling errors or simply don't look good. + if (arr.includes('aintBallRifleScoped')) removeItemAll(arr, 'aintBallRifleScoped'); + if (arr.includes('PINK')) arr[arr.indexOf('PINK')] = 'Pink'; + if (arr.includes('wood')) arr[arr.indexOf('wood')] = 'Wood'; + if (arr.includes('Watermeon')) arr[arr.indexOf('Watermeon')] = 'Watermelon'; + + return name = arr.toString().replace(',', ' '); +} + +// Read only db +const db = JSON.parse(fs.readFileSync('./raw.json')); +log.d(`Imported raw config`); +let final = []; + +const coerce = (rootVal, i, arr) => { + rootVal.skins.forEach((localVal, i, arr) => { + let d = new FinalEquipmentItem(); + d.PrefabName = rootVal.equipment.prefabName; + d.ModificationGuid = localVal.skinGuid; + d.FriendlyName = formatFriendlyName(rootVal.equipment.prefabName, localVal.skinAssetName); + log.d(`Created equipment ${d.FriendlyName} with guid ${d.ModificationGuid}`); + + final.push(d); + }); +} + +db.toolSkinMaps.forEach(coerce); + +fs.writeFileSync('./rawNew.json', Buffer.from(JSON.stringify(final)), { encoding: 'utf8', flag: 'w' }); + +const GiftRarity = { + Common: 0, + Uncommon: 10, + Rare: 20, + Epic: 30, + Legendary: 50 +} \ No newline at end of file