IF I SEE YOU ASK A QUESTION THAT IS ALREADY ANSWERED IN THE DESCRIPTION YOU RISK ME IGNORING YOU!
Some things to note:
I'm new to modding with REFramework, and I couldn't find a way to store, or retrieve, the unmodified item values. So things like "changing item sell price, or weight, base on a %" isn't possible for me currently. The issue that happens is that anytime the script reloads (save reloads, zone changes, deaths, etc) it will reapply the % value. So a 50% reduction in weight would keep re-applying and you'd end up with crazy negative weighted items.
Same issue with Prices and Weight.
Decayable items having their Decay set to "nil", aka: the same as armor/weapons/etc, is only experimental. I didn't have anything decay with this set in 7 in-game days of playing but it still might happen!
Change MaxStackSize higher than 999 at your own risk. I did not test higher than 999!
Updated with a bunch of requested features and testing Medusa Head Anti-Decay. Give it a shot and let me know how it goes! Read the updated Descriptions etc for the mod.
New Medusa Head Decay idea reported as not working. Most likely a script/internal event I can't change (yet). Hopefully someone figures that out!
For the Medusa Head, I noticed the main image in another modding program that someone put up ("DD2-Editor - User File Editor" https://www.nexusmods.com/dragonsdogma2/mods/522) that lists the secondary items that each item decays into. Ie, How the "apple" item decays into the "ripened apple" item.
Would it be possible to modify the "normal medusa head" item so that it decays into the "preserved head" version (having the "normal head" decay into the preserved head, and then letting the "preserved head" decay into the "normal head" as normal would let us know the mod is working)? I don't know if that would also work for the spoiled head too, but maybe that would be worth a shot?
And since Medusa Heads are harder to come by, maybe you could also make the apples do the same for testing purposes? Ie, ripened/rotten apples decay into normal apple?
I tested this just insofar as to see if REFramework could write game data out to a file. It can. So, you could look for a cache file with saved data and generate it if it's missing. You can refer back to this cache data when comparing values to get around the reapplication problem when the script runs multiple times. Basically this looks like so.
if itemCache==nil then itemCache = {}
while iter:get_Current():get_Value()~=nil do local itemCommonParam=iter:get_Current():get_Value()
Unfortunately it's very difficult to determine what an item is without building a lengthy manual list. Maybe someone better than me can figure it out. :)!
Hmmm... Maybe take a look at Synthlight's mod(Item Tweaks) it seems like they found a way to separate items away from equipment. Not sure if it'll help but I figured I'd pointed out, I haven't looked at the code or anything so I wouldn't know. lol --------edit oh it looks like you're already in discussions with them, I just scrolled down and noticed lol
Ok, so, I think I got a solution to the weight multiplication not applying. Or rather, applying too much. At least it SEEMS to be working, in my limited testing. It's probably not the most elegant solution - I hadn't touched lua or REframerwork scripting before last night, and I'm not exactly a super experienced programmer anyway - but it should work. I'll paste the changes that need to be made to Braxton01's GigaItemConfig.lua script (inside the autorun folder), and if it works and they like the solution, they can go ahead and implement it (maybe a nod in my general direction would be cool, if it does work) in their release. Also, hope Braxton doesn't mind me fucking with their work. Aight, enough talk, let's go!
First, before line 43 (local iter=im._ItemDataDict:GetEnumerator()) and after line 42 paste the following snippet: local itemWeights = json.load_file("defaultItemWeights.json") or {} -- first loop to reset weights if needed local iter=im._ItemDataDict:GetEnumerator() iter:MoveNext() while iter:get_Current():get_Value()~=nil do local itemCommonParam=iter:get_Current():get_Value() local thisItemId = itemCommonParam._Id -- check if this item's weight has been set, since I don't know if the list is contextual if itemWeights[tostring(thisItemId)] == nil then itemWeights[tostring(thisItemId)] = itemCommonParam._Weight else itemCommonParam._Weight = itemWeights[tostring(thisItemId)] end
iter:MoveNext() end
--store the itemWeights table local file = io.open("defaultItemWeights.json", "w") file:write(json.dump_string(itemWeights, 0)) file:close() What it does is, it looks for a defaultItemWeights.json file in the data folder and, if it's not yet populated (first execution) fills it with the item's base weights. If it finds the weights there, it resets them to their default value so that we can multiply them later. I could probably include this in Braxton's base loop, but because inexperience I didn't want to risk messing stuff up.
By the way, you can create a defaultItemWeights.json file with just "{}" in it inside the data folder in your Fluffy Mod Manager's "Games\DragonsDogma2\Mods\GigaItemConfig\reframework\data" directory if you want, since then you can clean it automatically by disabling and enabling the mod if something goes wrong or if the baseweights get messed up somehow.
So, then, inside the next loop (the one that was already there), after the line " local itemCommonParam=iter:get_Current():get_Value()", paste local thisItemId = itemCommonParam._Id If I was sure everything went as it should before, we wouldn't use this, but since I'm not, we shall.
Finally, near the end, replace if config.weightval ~= -1 then if config.weightval >= 0 then itemCommonParam._Weight = config.weightval end end with if config.weightval ~= -1 then if config.weightval >= 0 then itemCommonParam._Weight = itemWeights[tostring(thisItemId)] * config.weightval end end Which will divide the item's weight from the table and assign it. DO NOT FORGET that the "weightval" property from Braxton's .json file will now be a MULTIPLIER. So set it anywhere between 0 and 1 to get a lower weight and over if you want to get overencumbered quickly.
If it does work, as it seems to, you're welcome. I didn't play much with it enabled, but I did reload my save a shitload of times and my character's load remained consistent. If it doesn't I'm sorry for wasting your time. Don't forget to wait for REframework to properly load before you load your game, I keep forgetting and having to reload my save. Cheers!
Oh I see what you did. As the script is just a script it can't save long-term lists/sets into memory, and we can't directly add new fields/collections to game objects. So you simply "backed up" the original weights into a .json for long-term comparison and reverting.
A very interesting implementation and idea. I might add this officially into mine, or even write something in a similar vein from scratch.
Thanks! If you do go with it, you can probably get away with generating the json once and just including the whole unmodified item weight list with your files. You'd save a whole loop, with the downside that you'd have to generate it again if the game updated. Assuming the ItemManager does include every item in the game at all times and not, like, just the items the player has seen or something similar. Of course, that loop is probably unneeded anyway and you can just add the default weight table creation instructions to the loop you already have.
EDIT: Of course, if there was a way to somehow use global variables that persisted throughout the game session the json would be entirely unneeded, you'd just create the list once and check if it existed in subsequent script executions. I don't know if that's something you can do within REframework, though.
All right, it seems like I was sleepier than I thought last night, because I could swear I had tried setting up a global variable and it ignored it when the script ran again. I replaced the local itemWeights = json.load_file("defaultItemWeights.json") or {} with if ItemWeights == nil then ItemWeights = {} end Then removed the json creation and let the rest stay as it was, and the weights seem to remain consistent even thought I went back to the menu screen and loaded a few times. When I reset the scripts (meaning the table got deleted and created again) while in-game, the items did lose a part of their weight again, though the new value remained consistent through game loads once more, which makes sense.
I cleaned up the Medusa AntiDecay code that didn't work as expected, and cleaned up the mod's detail page to reflect that it's not a supported function of the mod anymore.
62 comments
Some things to note:
Cheers~
and testing Medusa Head Anti-Decay.Give it a shot and let me know how it goes! Read the updated Descriptions etc for the mod.New Medusa Head Decay idea reported as not working. Most likely a script/internal event I can't change (yet). Hopefully someone figures that out!
Would it be possible to modify the "normal medusa head" item so that it decays into the "preserved head" version (having the "normal head" decay into the preserved head, and then letting the "preserved head" decay into the "normal head" as normal would let us know the mod is working)? I don't know if that would also work for the spoiled head too, but maybe that would be worth a shot?
And since Medusa Heads are harder to come by, maybe you could also make the apples do the same for testing purposes? Ie, ripened/rotten apples decay into normal apple?
if itemCache==nil then
itemCache = {}
while iter:get_Current():get_Value()~=nil do
local itemCommonParam=iter:get_Current():get_Value()
itemCache[itemCommonParam._Id] = {}
itemCache[itemCommonParam._Id].BuyPrice = itemCommonParam._BuyPrice
itemCache[itemCommonParam._Id].SellPrice = itemCommonParam._SellPrice
itemCache[itemCommonParam._Id].Weight = itemCommonParam._Weight
iter:MoveNext()
end
json.dump_file("GigaItemCache.json", itemCache)
-- reset iter so we can enumerate it again below to apply desired values
iter=im._ItemDataDict:GetEnumerator()
iter:MoveNext()
end
AND
Can you separate items(Curatives, materials and etc) weight from weapons and armor weight?
Thanks!
Not sure if it'll help but I figured I'd pointed out, I haven't looked at the code or anything so I wouldn't know. lol
--------edit
oh it looks like you're already in discussions with them, I just scrolled down and noticed lol
Thanks :)
Aight, enough talk, let's go!
First, before line 43 (local iter=im._ItemDataDict:GetEnumerator()) and after line 42 paste the following snippet:
local itemWeights = json.load_file("defaultItemWeights.json") or {}
What it does is, it looks for a defaultItemWeights.json file in the data folder and, if it's not yet populated (first execution) fills it with the item's base weights. If it finds the weights there, it resets them to their default value so that we can multiply them later. I could probably include this in Braxton's base loop, but because inexperience I didn't want to risk messing stuff up.-- first loop to reset weights if needed
local iter=im._ItemDataDict:GetEnumerator()
iter:MoveNext()
while iter:get_Current():get_Value()~=nil do
local itemCommonParam=iter:get_Current():get_Value()
local thisItemId = itemCommonParam._Id
-- check if this item's weight has been set, since I don't know if the list is contextual
if itemWeights[tostring(thisItemId)] == nil then
itemWeights[tostring(thisItemId)] = itemCommonParam._Weight
else
itemCommonParam._Weight = itemWeights[tostring(thisItemId)]
end
iter:MoveNext()
end
--store the itemWeights table
local file = io.open("defaultItemWeights.json", "w")
file:write(json.dump_string(itemWeights, 0))
file:close()
By the way, you can create a defaultItemWeights.json file with just "{}" in it inside the data folder in your Fluffy Mod Manager's "Games\DragonsDogma2\Mods\GigaItemConfig\reframework\data" directory if you want, since then you can clean it automatically by disabling and enabling the mod if something goes wrong or if the baseweights get messed up somehow.
So, then, inside the next loop (the one that was already there), after the line " local itemCommonParam=iter:get_Current():get_Value()", paste
local thisItemId = itemCommonParam._Id
If I was sure everything went as it should before, we wouldn't use this, but since I'm not, we shall.Finally, near the end, replace
if config.weightval ~= -1 then
if config.weightval >= 0 then
itemCommonParam._Weight = config.weightval
end
end
with
if config.weightval ~= -1 then
Which will divide the item's weight from the table and assign it. DO NOT FORGET that the "weightval" property from Braxton's .json file will now be a MULTIPLIER. So set it anywhere between 0 and 1 to get a lower weight and over if you want to get overencumbered quickly.if config.weightval >= 0 then
itemCommonParam._Weight = itemWeights[tostring(thisItemId)] * config.weightval
end
end
If it does work, as it seems to, you're welcome. I didn't play much with it enabled, but I did reload my save a shitload of times and my character's load remained consistent. If it doesn't I'm sorry for wasting your time.
Don't forget to wait for REframework to properly load before you load your game, I keep forgetting and having to reload my save.
Cheers!
A very interesting implementation and idea. I might add this officially into mine, or even write something in a similar vein from scratch.
Good job! :)
If you do go with it, you can probably get away with generating the json once and just including the whole unmodified item weight list with your files. You'd save a whole loop, with the downside that you'd have to generate it again if the game updated. Assuming the ItemManager does include every item in the game at all times and not, like, just the items the player has seen or something similar.
Of course, that loop is probably unneeded anyway and you can just add the default weight table creation instructions to the loop you already have.
EDIT: Of course, if there was a way to somehow use global variables that persisted throughout the game session the json would be entirely unneeded, you'd just create the list once and check if it existed in subsequent script executions. I don't know if that's something you can do within REframework, though.
I replaced the
local itemWeights = json.load_file("defaultItemWeights.json") or {}
withif ItemWeights == nil then
Then removed the json creation and let the rest stay as it was, and the weights seem to remain consistent even thought I went back to the menu screen and loaded a few times.ItemWeights = {}
end
When I reset the scripts (meaning the table got deleted and created again) while in-game, the items did lose a part of their weight again, though the new value remained consistent through game loads once more, which makes sense.
Thanks!