Who's a good little boy? Not Sidorovich! This is a script to extract all traders' prices for all items. There's also a link to my spreadsheet to compare Anomaly 1.5.2 prices.
The extracted data can be seen here: Docs.google.com
It shows that DON'T BUY FROM SID! But you can sell to him and he won't rip you off. Also Butcher doesn't buy almost anything but he has a fetish for 12.7x55mm barrels.
Features
- The script runs on actor_first_update. In other words when loading screen has finished and just before "press any key" appears.
- This means the script is universal and will work with mods and MO2. If an item is added through an ltx file then it will be in the data.
- However, the script can't access the trade info that is injected through other scripts, so it's not the ultimate solution to everything.
- Your computer will freeze during the calculation but stuff is happening in the background. It took 13-14 minutes with 3.2 GHz processor to calculate all of the prices (2090 items, 34 traders, buy and sell = 140 000 prices to process).
- You might need a lot of RAM (maybe 4-7 GB) depending on how much data you are extracting at once. Anomaly doesn't have time to do proper garbage collection during the calculations.
- CSV file is output into Anomaly/appdata folder if you modify the Anomaly path variable correctly and the folder has write permission for Anomaly app.
- There's point to using the script itself if there's new data (new Anomaly version or a mod). Otherwise vanilla Anomaly data is included in the download and in the Spreadsheet.
Instructions
- Install. Drop the gamedata folder into Anomaly's main folder or enable the mod from the Mod Organizer 2.
- Modify variables. Open Banjaji_extractor.script and modify "Modder-defined variables" at the beginning. Try it with only one category first to test output!
- Load the game until you'd normally have to "press any key" to start playing. Then the script will start calculating
- Wait. The computer will freeze for a long time (a lot of prices and LUA is suboptimal) depending on how many categories you extract. All data took 13-14 minutes for me (3.2 GHz).
- Check output. Check Anomaly/appdata/trader_values.csv file. If it's not there then check whether you inserted the path variable correctly and check write permission for the folder.
- Back up the output file. As soon as you run the script again the file is overwritten.
- Disable script. Write "use_script" variable as false in Banjaji_extractor.script.
- Uninstall. Delete the file or simply disable the mod in Mod Organizer 2.
How did I do it?
I loaded all sections into memory by reading system cache (from system.ltx?). Then I sorted all objects that had name, cost and weight defined (normal item section) into categories defined by "kind" value. Then I read through all trader scripts (had to hardcode file names) and calculated the buy and sell cost for every item for every trader.
Final words
You can modify my changes or ideas in any way you want. However, if your work is based largely on my ideas then please give credit! In case you find bugs please let me know! Some things are changed by the scripts and it's impossible to tell what they're doing without spawning every trader and trying every item with them manually (eg artefacts in containers aren't bought even when this data says they sometimes are). However, you can still find outliers through the data extraction (eg flea market trader buys npc pda-s for 0 rbl).
[Notice board]
The spreadsheet: Docs.google.com
There's point to using the script itself if there's new data (new Anomaly version or a mod).
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_pcall_failed
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 206
[error]Description : fatal error
[error]Arguments : LUA error: ...y 1.5.2/bin/..\gamedata\scripts\banjaji_extractor.script:203: attempt to index local 'file' (a nil value)
stack trace:
Happens every time. On new game and loading older saves. Through MO2 and modded exes. With or without any mods.
I'm guessing lua can't open output_file because there isn't a folder for it or the folder doesn't have write permissions for Anomaly. Did you modify the variables in the script (2nd point under instructions here)?
Yes, didn't save it though, lmao.
Doesn't seem to run though. Unsure what "Try it with only one category first to test output!" exactly entails and do not have the time to mess around with that on my own right now. I'm guessing I just have to give the script the instructions on what to look for, I just have no idea what that'd be.
I assume I'm missing something obvious here?
It's okay, extracting the data again is useful only if you have a mod that changes trade prices in LTX files.
Only thing you actually need to do is change
local anomaly_path = "D:/Games/Stalker Anomaly"
into your Anomaly install path.
Otherwise (optionally) to do a quick test you can write eg
local check_categories = {"w_melee"}
because that category only has about 10 sections.
Okay, so I got it working. It didn't want to run when I had E/ the first time so had to reinstall the add-on in MO2 and then it worked (for some reason, checked the two scripts in winmerge and they were identical). it does however crash before fully finishing.
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_pcall_failed
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 206
[error]Description : fatal error
[error]Arguments : LUA error: ...y 1.5.2/bin/..\gamedata\scripts\banjaji_extractor.script:305: attempt to perform arithmetic on local 'multiplier' (a nil value)
stack trace:
It's about a broken price in a trader file (existing, but broken). I'm assuming you're dealing with a mod. A fix is to write the following on line 304:
if not multiplier then
printf("Error| Trade price broken. Item: %s, trader: %s buy/sell: %s", item, trader, buy_sell_str)
multiplier = 1
end
If it's a mod that you're making then the error is actually a good way to point you to a right direction. You can bring the variable "trader" to that function through function arguments from line 241 and 242.
But I'll update the mod with the quick fix some time in the future.
The spreadsheet confirms something I found out some time ago. Go to the Train Depot in Garbage and buy a fracture hand from Butcher for 220. Sell it back to him immediately and you have 280. Bug or (cheating) feature?
Only as long as you have progression difficulty settings on easy mode or similar values. Increase buy factor and decrease sell factor and you won't be making a profit anymore.
Oh boy, maybe I can finally put together a proper starting loadout, which uses in-game prices instead of that point-based BS...
And can I just say: HOLY COW THATS A LOT OF PRICES!
Anomaly rules! You rule!
(wow I'm really showing my age as an '80s kid... gotta see a therapist lol)
But if you do make a mod to convert the loadout points to prices (assuming it doesn't already exist) then don't hardcode! As in you can even copy-paste my code to import the price instead of just taking it from the extracted data. Otherwise small change like an update of Anomaly may break your mod.
I would love to have a similar script that extracts detailed weapon stats or at least a script that shows much more detailed weapon stats in-game (degradation, bullet-drop, recoil, time to reload, etc.)