diff --git a/index.js b/index.js index 831b27e..8bd312e 100644 --- a/index.js +++ b/index.js @@ -4567,6 +4567,232 @@ express.post("/fortnite/api/game/v2/profile/*/client/UpgradeAlteration", async ( res.end(); }); +// Reset research levels STW +express.post("/fortnite/api/game/v2/profile/*/client/RespecResearch", async (req, res) => { + const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); + + // do not change any of these or you will end up breaking it + var ApplyProfileChanges = []; + var BaseRevision = profile.rvn || 0; + var QueryRevision = req.query.rvn || -1; + var StatChanged = false; + + if (profile.stats.attributes.research_levels) { + profile.stats.attributes.research_levels.technology = 0; + profile.stats.attributes.research_levels.fortitude = 0; + profile.stats.attributes.research_levels.offense = 0; + profile.stats.attributes.research_levels.resistance = 0; + + StatChanged = true; + } + + if (StatChanged == true) { + profile.rvn += 1; + profile.commandRevision += 1; + + ApplyProfileChanges.push({ + "changeType": "statModified", + "name": "research_levels", + "value": profile.stats.attributes.research_levels + }) + + fs.writeFileSync(`./profiles/${req.query.profileId || "campaign"}.json`, JSON.stringify(profile, null, 2)); + } + + // this doesn't work properly on version v12.20 and above but whatever + if (QueryRevision != BaseRevision) { + ApplyProfileChanges = [{ + "changeType": "fullProfileUpdate", + "profile": profile + }]; + } + + res.json({ + "profileRevision": profile.rvn || 0, + "profileId": req.query.profileId || "campaign", + "profileChangesBaseRevision": BaseRevision, + "profileChanges": ApplyProfileChanges, + "profileCommandRevision": profile.commandRevision || 0, + "serverTime": new Date().toISOString(), + "responseVersion": 1 + }) + res.end(); +}); + +// Reset upgrade levels STW +express.post("/fortnite/api/game/v2/profile/*/client/RespecUpgrades", async (req, res) => { + const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); + + // do not change any of these or you will end up breaking it + var ApplyProfileChanges = []; + var BaseRevision = profile.rvn || 0; + var QueryRevision = req.query.rvn || -1; + var StatChanged = false; + + for (var key in profile.items) { + if (profile.items[key].templateId.toLowerCase().startsWith("homebasenode:skilltree_")) { + profile.items[key].quantity = 0; + + ApplyProfileChanges.push({ + "changeType": "itemQuantityChanged", + "itemId": key, + "quantity": profile.items[key].quantity + }) + } + } + + StatChanged = true; + + if (StatChanged == true) { + profile.rvn += 1; + profile.commandRevision += 1; + + fs.writeFileSync(`./profiles/${req.query.profileId || "campaign"}.json`, JSON.stringify(profile, null, 2)); + } + + // this doesn't work properly on version v12.20 and above but whatever + if (QueryRevision != BaseRevision) { + ApplyProfileChanges = [{ + "changeType": "fullProfileUpdate", + "profile": profile + }]; + } + + res.json({ + "profileRevision": profile.rvn || 0, + "profileId": req.query.profileId || "campaign", + "profileChangesBaseRevision": BaseRevision, + "profileChanges": ApplyProfileChanges, + "profileCommandRevision": profile.commandRevision || 0, + "serverTime": new Date().toISOString(), + "responseVersion": 1 + }) + res.end(); +}); + +// Upgrade research levels STW +express.post("/fortnite/api/game/v2/profile/*/client/PurchaseResearchStatUpgrade", async (req, res) => { + const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); + + // do not change any of these or you will end up breaking it + var ApplyProfileChanges = []; + var BaseRevision = profile.rvn || 0; + var QueryRevision = req.query.rvn || -1; + var StatChanged = false; + + if (profile.stats.attributes.research_levels && req.body.statId) { + profile.stats.attributes.research_levels[req.body.statId] += 1; + + StatChanged = true; + } + + if (StatChanged == true) { + profile.rvn += 1; + profile.commandRevision += 1; + + ApplyProfileChanges.push({ + "changeType": "statModified", + "name": "research_levels", + "value": profile.stats.attributes.research_levels + }) + + fs.writeFileSync(`./profiles/${req.query.profileId || "campaign"}.json`, JSON.stringify(profile, null, 2)); + } + + // this doesn't work properly on version v12.20 and above but whatever + if (QueryRevision != BaseRevision) { + ApplyProfileChanges = [{ + "changeType": "fullProfileUpdate", + "profile": profile + }]; + } + + res.json({ + "profileRevision": profile.rvn || 0, + "profileId": req.query.profileId || "campaign", + "profileChangesBaseRevision": BaseRevision, + "profileChanges": ApplyProfileChanges, + "profileCommandRevision": profile.commandRevision || 0, + "serverTime": new Date().toISOString(), + "responseVersion": 1 + }) + res.end(); +}); + +// Upgrade levels STW +express.post("/fortnite/api/game/v2/profile/*/client/PurchaseOrUpgradeHomebaseNode", async (req, res) => { + const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); + + // do not change any of these or you will end up breaking it + var ApplyProfileChanges = []; + var BaseRevision = profile.rvn || 0; + var QueryRevision = req.query.rvn || -1; + var StatChanged = false; + var CreateHomebaseNode = true; + + if (req.body.nodeId) { + for (var key in profile.items) { + if (profile.items[key].templateId.toLowerCase() == req.body.nodeId.toLowerCase()) { + profile.items[key].quantity += 1; + + ApplyProfileChanges.push({ + "changeType": "itemQuantityChanged", + "itemId": key, + "quantity": profile.items[key].quantity + }) + + CreateHomebaseNode = false; + } + } + + if (CreateHomebaseNode == true) { + const ID = makeid(); + + profile.items[ID] = { + "templateId": req.body.nodeId, + "attributes": { + "item_seen": false + }, + "quantity": 1 + } + + ApplyProfileChanges.push({ + "changeType": "itemAdded", + "itemId": ID, + "item": profile.items[ID] + }) + } + } + + StatChanged = true; + + if (StatChanged == true) { + profile.rvn += 1; + profile.commandRevision += 1; + + fs.writeFileSync(`./profiles/${req.query.profileId || "campaign"}.json`, JSON.stringify(profile, null, 2)); + } + + // this doesn't work properly on version v12.20 and above but whatever + if (QueryRevision != BaseRevision) { + ApplyProfileChanges = [{ + "changeType": "fullProfileUpdate", + "profile": profile + }]; + } + + res.json({ + "profileRevision": profile.rvn || 0, + "profileId": req.query.profileId || "campaign", + "profileChangesBaseRevision": BaseRevision, + "profileChanges": ApplyProfileChanges, + "profileCommandRevision": profile.commandRevision || 0, + "serverTime": new Date().toISOString(), + "responseVersion": 1 + }) + res.end(); +}); + // Set active hero loadout STW express.post("/fortnite/api/game/v2/profile/*/client/SetActiveHeroLoadout", async (req, res) => { const profile = require(`./profiles/${req.query.profileId || "campaign"}.json`); diff --git a/profiles/campaign.json b/profiles/campaign.json index fe65e0c..317bb3d 100644 --- a/profiles/campaign.json +++ b/profiles/campaign.json @@ -3220,7 +3220,7 @@ "xp": 0, "favorite": false }, - "quantity": 10 + "quantity": 10000 }, "e83235f3-7a27-407c-9140-a37b1066f67c": { "templateId": "Quest:plankertonquest_filler_4_d2", diff --git a/profiles/profile0.json b/profiles/profile0.json index eb5a4f5..3d2b8b5 100644 --- a/profiles/profile0.json +++ b/profiles/profile0.json @@ -756,7 +756,7 @@ "xp": 0, "favorite": false }, - "quantity": 10 + "quantity": 10000 }, "bb5e6cc5-8083-412e-a391-3b434462f4a6": { "templateId": "Token:campaignaccess",