Fixes the amount of uses in multi-use items that get discharged in crafting, as well as the use of multiple multi-use items in crafting.
Installation: Just drag and drop gamedata folder in Stalker Anomaly directory.
v1.0:
Release
V2.0:
RERELEASED. Fixed my own fix. Now it should work properly completely. Previously, changing the amount had also affected other part amount requirements. Now there is a separate variable just for multi-use items.
v2.2: fixed separate variable change
v2.3: Included patch for artifax's Weapon Parts Overhaul
v2.4: Included patch for artifax's Outfit Parts and Repair Overhaul
v2.5: Kinda tidied folder a little. Gave Main + Weapon Parts Overhaul + Outfit Parts and Repair Overhaul patch its own folder.
v2.6 Updated to 1.5.2 and now relatively conflict free! Should be compatible with WPO, OPO and any other script that makes changes to ui_workshop.script
___________________________________________________________________________________________
!!!EXPLANATION ONE!!!
When crafting with multi-use items, the number of uses your item contains is supposed to be negated by the amount required.
However that is not the case.
///////////
-- to discharge
if count > amount then
self.craft_item_remain[n] = { id = id , cnt = (count - amount) }
break
end
///////////
self.craft_item_remain's second index (cnt = (count - amount)) defines how many times the multi use item is supposed to be discharged.
"count" is the number of uses your supporting item has, while "amount" is SUPPOSED to be the amount of uses that get discharged for the craft.
Unfortunately, there's a mistake here. If you have a 5 use item (count = 5) and the amount of uses
required for the craft is 3 uses (amount = 3), cnt will actually equal how many uses ITS SUPPOSED TO HAVE LEFT.
But incorrectly, cnt ends up being the number of uses that get discharged.
So 5 - 3, the multi-use item gets discharged TWO times.
And now you're left with 3 uses left out of the 5. Allowing you to use the item for crafting again!
It's supposed to be discharged 3 times, with 2 uses left out of the 5.
The code below executes the number of times the multi-use item discharges, "cnt" times.
///////////
if obj_itm and cnt then
print_ws("- UIWorkshopCraft:Craft() | discharge item (%s) [%s] %s times", id_r, obj_itm:section(), cnt)
for k=1,cnt do
utils_item.discharge(obj_itm)
end
//////////
So I fixed the code so that the number of times the multi-use item is discharged is the current
number of uses (count), minus the number of uses its supposed to have left (count - dischargeAmount).
!!!So the resultant number = the number of times the code will discharge the item.!!!
if count > amount then
//////////
...local dischargeAmount = amount...
self.craft_item_remain[n] = { id = id , cnt = (count - (count - dischargeAmount)) }
break
end
//////////
This fixes the logic error created, and so forth correctly discharges the correct amount of the multi-use item. I added a separate variable, "dischargeAmount" so that the actual amount variable does not charge.
!!!EXPLANATION TWO!!!
When crafting with MULTIPLE multi-use items, the game just DELETES one of the items.
//////////
count = 0
for id,cnt in pairs(parts_id) do
count = count + cnt
-- to delete
if (count <= amount) then
self.craft_item[n][#self.craft_item[n] + 1] = id
end
if count == amount then
break
end
//////////
Using this script logic, it scans the number of uses for the first multi-use has.
When crafting, you have a use requirement of 3, and you have two multi-use items. One multi-use item has 1 use, while the other item has 3 uses.
You have 4 uses in total, and so you meet the crafting requirement with ONE use extra.
Executing the crafting script, if the crafting script uses the multi-use item with 1 use, and THEN the multi-use item with 3 uses, you should have a multi-use item with one use left right?
Unfortunately, no.
The script logic above detects the multi-use item with 1 use left, and just DELETES IT, not having it contribute to the amount of uses left for crafting.
So the first multi-use item with 1 use just gets deleted,
and so forth onto the next multi-use item.
The next multi-use item has 3 uses, since the amount required still equals 3 uses, that item gets deleted too, and the crafting script is over.
You see the problem here, you should have been left with one multi-use item with one use left.
Your one multi-use item with one use did NOT contribute to how many uses the requirement amount is left.
So I fixed the problem by changing the code.
//////////
-- to delete
if (count <= amount) then
self.craft_item[n][#self.craft_item[n] + 1] = id
dischargeAmount = dischargeAmount - count
end
//////////
As you see here, when one of the multi-use items in the crafting process is less than the required amount, it gets deleted,
and now REDUCES THE REQUIRED AMOUNT LEFT (USING A SEPARATE VARIABLE EQUIVALENT TO PREVIOUS AMOUNT VARIABLE) ACCORDING TO HOW MANY USES THAT ITEM HAD.
So now when you have a use requirement amount of 3,
inputting one multi-use item with 1 use, and another one with 3 uses,
The multi-use item with 1 use gets used up, the required amount left is 2, the second multi-use item with 3 uses gets used up TWO times now, leaving 1 remaining use on that item.
You will now get back one multi-use item with 1 use left, because your total of uses met the requirement, and the correct amount of uses has been used up in total.
Good hunting.
Average
9.733 votes submitted.
My apologies for the re-upload. I archived this addon at first, because I've almost given up on trying to fix this code bs lol. I've figured it out now, and now the fix is working as intended.
Дай бог тебе здоровья <3
Thanks <3
Weapon Parts Overhaul and Outfit Parts Overhaul patch (both separated and together...3 patches?), that's a Monolith request.
lol plz do it my brat, take your time, good hunting
10-4, can do for Weapon Parts Overhaul.
What mod is the second one?
I can make them separately, but if they aren't compatible together in the first place, it is up to them to make a compatibility patch.
Outfit Parts Overhaul (https://www.moddb.com/mods/stalker-anomaly/addons/outfit-parts-and-repair-overhaul) have a patch for WPO on its download file, you could use it as a base for the OPO + WPO + this mod here patch
Thanks, patches will be up within a couple hours.
Gj mate :)
I appreciate it <3
you know if its possible to make and ammo 1:1 crafting, without changing anything else (except maybe some new recepies for items and w&a mods that are missing)
tnx
Like, 30 pieces of old ammo equal 30 pieces of new ammo?
Is it possible to use this addon together with Outfit Parts Overhaul AND Weapon Parts Overhaul?
There are 3 folders in the file:
Main
Main + Outfit Parts Overhaul Patch (actually includes the WPO patch or it is named incorrectly)
Main + Weapon Parts Overhaul Patch (there's no patch in this folder)
One patch file is missing.
P̶a̶t̶c̶h̶ ̶w̶i̶l̶l̶ ̶b̶e̶ ̶a̶v̶a̶i̶l̶a̶b̶l̶e̶ ̶i̶n̶ ̶t̶w̶o̶ ̶h̶o̶u̶r̶s̶.̶
A̶n̶d̶ ̶I̶'̶l̶l̶ ̶t̶i̶d̶y̶ ̶u̶p̶ ̶t̶h̶e̶ ̶f̶o̶l̶d̶e̶r̶ ̶l̶o̶l̶,̶ ̶m̶y̶ ̶b̶a̶d.
It is already possible to use OPO + WPO + Main, the wpo patch in the OPO patch folder enables you to use both. Should probably point that out. And Main + WPO Patch is the patch file.
Thanks for the quick reply! I'll try it out when I have the time.
Greetings!
Looking forward to trying out this mod.
Not to be rude, but downloadable file contents seem to be a mess. The archive contains 3 main folders:
1) Main
2) Main + Outfit Parts Overhaul Patch - which contains WPO (?) patch in a separate folder
3) Main + Weapon Parts Overhaul Patch - which contains no additional patches (?)
So, what does somebody with both WPO and OPO installs?
I went with "Main + Weapon Parts Overhaul Patch" and installed it with MO2. MO2 shows that it overwrites both WPO (as expected per folder name) and OPO (not expected per folder name).
Does this mean that it already contains OPO patch?
If not, where can I find one? There is no OPO patch among the downloaded files.
Hopefully you will find my feedback useful.
P.S.
Only noticed the post above me right after I posted mine - no idea how did I miss it.
To be honest, your explanation in your answer to that post is pretty confusing too - what the hell do I install and in what order to get it working with both OPO and WPO?
Some tidying up would still be great as obviously there is no shortage of smoothbrains like me, lmao
Yea, I'll tidy it up at some point lol. Working on two other projects. Addon only changes one file, so just install the WPO patch inside of Main + OPO. The WPO patch inside of that one will allow both WPO and OPO to work together. Next update I'll make it a little less confusing. I'll give that WPO patch its own separate folder that'd be Main + WPO + OPO. Sorry for the confusion, I don't personally use a mod organizer. I just do everything manually, so it's just kind of tailored to how I install things.
Edit: Tidy update now available
my bad, I did mistake on my part. I was upgrading in first situation - so it is cannot be applied and in second situation I did mistake.
I will delete this thread.
It's all alrighty
Thank you so much man, it works fine. I used Mistercat addon and it was a problem. My vote is 10 for that...
I'll try this one, and will tell if see anything off.
Thanks, mate!
Thanks for mod. Can you please update WPO and OPO patches to the actual version of this mod?
Nice one. I added your mod's main file (no patches) into my own mod (giving credit of course): Moddb.com. Basically I merged our changes to the script. If for some reason you don't want me to include your content in the script then please send a direct message (preferable) or comment under my mod!
Can you make a patch for the mod "No Toolkit Requirements for Vices"?
This should be stickied or simply added to vanilla anomaly.
Moddb.com
this mod conflicts with the mod I attached here as a link.
can you do something about that??
Should be compatible now!
Does this also fix drag and drop crafting?
I don't know if drag and drop crafting was broken, never tested it before. Just tested it now though, it seems to work fine for me.