Refactored `registerProduction()` to also use this code
Fix code that was getting value to 4dp, not 3dp
Skip doing work in `getHideoutManagementConsumptionBonus()` if hideoutMgmt skill is 0
The error people are getting about a lock file already existing is due to `checkFileSync` returning false if the lock file is "stale".
The default "stale" timeout is 10 seconds, so if a save takes longer than this, the user will end up in a state where they can no longer save.
The documentation for `proper-lockfile` recommends using the callback returned by `lockFileSync` to remove the lock file, so I've switched to using this, and the error no longer occurs with long running save operations
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/239
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This resolves an issue where FiR tools were coming back as non-FiR. We now just store the whole .upd property, so any stats on the tool should carry over to after the craft is finished
Note: Will break any in-progress crafts that use tools
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/238
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
#### Summary
> Should fix [Issue 523](https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/523)
Tested a few different scenarios and the items were always correctly removed and returned to the player, however I did see the console warnings reported in the issue.
Both of the following call `this.ragfairOfferHandler.removeOffer(...)`:
- `this.returnPlayerOffer(...)`
- `this.removeOfferById(...)`
The latter logs a warning to the console because the offer is already removed when we reach that point.
This fix simply returns after the offer has been returned to the player, letting `returnPlayerOffer` deal with removing from the flea
Co-authored-by: phrisk <phrisk@phrisk.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/237
Co-authored-by: phrisk <phrisk@noreply.dev.sp-tarkov.com>
Co-committed-by: phrisk <phrisk@noreply.dev.sp-tarkov.com>
When starting a craft, tools are now taken, and the templateId is stored in the production in the user profile
When finishing a craft, space for both the tools and crafted item is verified, then both are added to the player stash correctly flagged as non-FiR and FiR respectively
Included a bit of code cleanup/reorg in areas I was working in
A few assumptions were made:
- Tools are expected to be single items, not stacks of an item (productions.json doesn't include a count property for tools, so this seems safe)
- Tools will never be a preset or have child items
- That the `canPlaceItemsInInventory` method over a concatenation of the tools and crafted item(s) will result in the same result as calling it individually over the two collections of items individually
Will need tested once merged into 380, I did basic testing, but there's a lot of different crafts that require tools
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/234
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This resolves an issue where a mod with bad preset data is able to break loot generation
Can be tested by changing the "\_id" property of an item preset in globals.json, and seeing the error output to the console.
A better solution for the future may be to deprecate the "\_id" property entirely, and use just the object key, however that would have more far reaching changes compared to this simple fix
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/233
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Remove a tpl from loot pool once an item limit has been reached - prevents it being picked over and over
Remove loot data from pmc jsons as its generated dynamically, adding data into jsons now acts as an override for the dynamic generation
Reduced rouble max count to 1 for PMCs
Split PMC loot caches by side (usec/bear)
All loot is now weighted - weights come from offline-live bot dumps
Removed `lootNValue` - loot is no longer picked by its value
Regenerated bot loot files - i saw some additional weapons get added to scavs
Reduce key listing cap to 15k
lower key price the less uses it has
Increase current durability cap of armor to 50% from 1%
Reduce jewlery cap to 40k from 50k (removes gp coins and golden necklace)
There is no need to copy all achievement counters from scav to PMC, we only need to copy the achievement counters where the achievement side is "Savage"
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/232
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Also move the relaxation key single spawn limit to Streets instead of shoreline
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/231
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Switched `transferItem` to use the `getOwnerInventoryItems` method, so that it properly handles transfer events on the scav inventory
Bit of cleanup and consistency changes made to the `transferItem` method
Testing instructions in issue: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/483
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/230
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This change should handle any map having its level range changed.
With base data, no changes should occur, because GZ currently lists level 0-100 as its level range. You can however change GZ's base.json to limit it to level 20 for testing
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/229
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Some plate carriers have no required plates, and thus were failing the functional check. I've changed it to check for an item count greater than the required plate count (Since `items` also contains the carrier itself).
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/228
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
It now returns an empty array if the pool is initially empty.
This function does not guarantee the number of elements returned because it will break out the loop early if the pool is exhausted.
Co-authored-by: qe201020335 <qe201020335@sina.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/227
Co-authored-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
Co-committed-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
A similar field can also be seen in static container generation which the value is respected
Also Limited the amount of random draws to avoid going over the `desiredSpawnpointCount`
- Consider a potential mod that changes every spawn point's `IsAlwaysSpawn` to true, then there is absolute no point for the generator to draw them again and only to have them removed during dedupe
Co-authored-by: qe201020335 <qe201020335@sina.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/226
Co-authored-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
Co-committed-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
The server expects that the total "Progress" when a bitcoin is complete to be the "ProductionTime" value (145000 by default). However the server was using a modified target value, while only adding the actual time change to the Progress.
This results in a drift over time between the client/server while the server is stopped, as the client gets an incorrect value on startup.
If we instead scale the addition to Progress based on the adjusted craft time, and target the base productionTime for completion, we can get a much more accurate progress while offline that matches the client
I used the profile from this ticket for testing: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/496
The user has both an upgrade and bitcoin going at the same time, so they should progress at the same rate. This is what the code was previously resulting in:
![image](/attachments/fe428a3b-d271-40e1-a3f6-08ef936224b6)
While the server was shut down for 50 minutes (As noted by the upgrade), only 36 minutes was deducted from the bitcoin craft.
This is the result of that same profile after these changes were made:
![image](/attachments/d2ce44e6-1a0e-4991-aa51-3eb340c22ca5)
You can see that ~2 hours 25 minutes was deducted from both the upgrade, as well as the bitcoin craft timer. There is still a slight discrepancy, but in a total bitcoin run it should be minimal
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/225
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
As far as I can tell, there's no need to strip backslashes, as they should only exist to escape other characters (Double quotes, for example). Stripping them will more often than not result in invalid JSON
NOTE: Due to the loss of git history, I'm unable to see _why_ exactly this replacement was done in the first place. There may be some valid reason I'm not thinking of. If this is the case, I can look at other solutions
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/488
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/222
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Clone flea items prior to passing them off to the createSingleOfferForItem method
This change results in more armor on the flea having 100% durability, and less having identical non-max durability values
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/447
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/223
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>