Item weight and inventory stats - Wants to make item weigh less than 1 lbs.

Zorchar

Look, Ma! Two Heads!
Hey guys.

I want to make certain items, stimpaks for example, weigh less than a pound.

My current understanding is that u can't directly change an item's weight to a non integer. At least not via proto editor. I also guess u can't do it through scripting, since this is an integer (please correct me if I'm wrong.)

So, I was thinking about compiling a global script which checks how many stimpaks, for example, u have, and divide said amount by, lets say 6, than add that number to your current weight. This will be automatically rounded, but that's fine for me.

Problem is, I can't find the command which adds to your (or your companion's) current weight.

tl;dr - Is there a command with which I can affect current weight, adding or removing from it (for both PC and NPC)? If not, then what would you suggest to do in order to simulate items weighing less than a single pound (Lbs.)?

Thanks.
 
I am not familiar with inventory processes, so I don't have an answer for you, but just a brainstorm.

I can guess there is likely a process which adds up the weight of items together in order to determine the total weight in an object's inventory. I wonder if that process could be affected (don't know of way). Secondly, The total inventory weight in an object's inventory might also be saved as an integer on every object. I assume there must be a "current inventory weight" on every object (that has inventory) otherwise the game constantly has to calculate weight for every object, which I don't think would be the case.

Since you can not store item weight in float in proto data (not confirmed), and even if you could, its possible the formula that adds item weights might not add floats correctly; then your next option is to alter the final number for "current weight" stored in object's inventory. This might work.

However also realize when bartering or moving items around between objects there are also checks that count the final weight on target object to calculate if the object will become overweight and will immediately prevent from putting more items in. So even if you alter the final weight of objects, this "mid-action" check could prevent you from filling an inventory to max with stimpacks. Unless if stimpacks are stored first, but still.


Anyway, out of my expertise.
 
Thanks for thinking along. I am basically stuck at the same point you wrote about.

About this:
However also realize when bartering or moving items around between objects there are also checks that count the final weight on target object to calculate if the object will become overweight and will immediately prevent from putting more items in. So even if you alter the final weight of objects, this "mid-action" check could prevent you from filling an inventory to max with stimpacks. Unless if stimpacks are stored first, but still.

I think that shouldn't be a problem, since the proto's weight will always be lower than the modified weight, therefore no engine/unmodified script limitations on inventory's weight should be applied in either case.

Hmm but yeah actually u are right. It might prevent me from adding lets say 5 stimpaks, if the weight was already rounded up by 1 stimpak before checking if there's weight availiable. So thanks for that. I should be careful if I will use a script as a solution.

EDIT: This is not relevant in the case of stimpaks, since proto's weight will remain 0. But in items weighing >= 1lbs, it is relevant. (up to 1 lbs "waste" per item kind)

EDIT2: OK, I just realized that it isn't relevant at all, even in cases where proto's weight is >=1.
 
Last edited:
There's no function to alter current weight. You'd have to hack it in yourself or ask sfall developers.
You can fluctuate max carry weight, though, which will kind of emulate weight taken by stimpacks. Or use an intermediate item, adding it when inventory is closed and deleting when it's closed, and recalculating its weight each time.
But this is such a niche use case... Not sure if worth the trouble.
 
Thanks. I like the idea of the inventory item which gets deleted.

Though I disagree about it being niche. This will prevent stimpak/nuka cola hoarding, etc.
Which is not that big of a deal in and of itself, but is prevalent in most walkthroughs, and kind of silly IMO.
 
Last edited:
Also, the most important reason I want it to be done is it could drastically effect ammo in its entirety.

I want ammo to come in smaller cartridges, so u can make merchants have ammo, but not as much ammo, since there is no feeling of scarcity for ammo. Also if u loot bodies, u can find less then a single .233, which has 50 bullets in a cartridge. 50 bullets should be super valuable in the wastes. Not having random scavengers and merchants carry way too much ammo is a game balancing way in a good direction IMO.

So that way, critters could be carrying like 7 shotgun shells, 4 10mm JHPs, etc', and the weight will remain the same.
 
It is pointless to do something via script, without support from the engine, you will get some glitches in the implementation.
 
An update for those who are interested.

Following burn's suggestion, I've decide that the most practical solution would be to add a proto item called "extra weight", which weighs 1 lbs. and to script adding it (them) to dude's inventory whenever a certain amount of items is in dude's inventory.

With the help of sfall guys, I figured out how to use HOOK_REMOVEINVENOBJ to make these adjustments take place instantly when moving items to and from dude's inventory.

My current goal is to make an extra_weight.ini file, which could be modified, and will decide how much extra weight each light item adds.

I've never delved too much into scripting using .ini files, so any tip or help would be appreciated.

I could be finishing this as a mod without the use of .ini, but I think the benefits of easily modifying item stats in the future outweighs my need to complete it as is.

Thanks.

EDIT: BTW, I've noticed that in Mr Stalin's proto manager, there is an option "hidden item".
Can someone explain what it does? I couldn't figure out what exactly is hidden about it. I can still see it in the inventory.
 
Last edited:
Can someone explain what it does? I couldn't figure out what exactly is hidden about it. I can still see it in the inventory.

This is necessary for critters, such as the death hand claw item. so that the player does not see this item in his inventory and it does not drop out when the critter is killed.
 
The claw is not flagged as hidden item. Plus, I think the "no steal" flag prevents from looting, isn't it?
So it suppose to not be shown in my inventory if flagged? Because it doesn't work for me.
 
Last edited:
I gave an example. in general, this item can not be seen in the game if it is in the inventory of the NPC and it seems that they do not weigh anything.
 
Gotcha. I tried it out a few times, and it doesn't seem to work.
Is it possible it isn't actually implemented in the engine or something?
 
hehe, there really is a bug.
Code:
TransEnergy  = 0008 0000
HiddenItem   = 0800 0000
ShootThru    = 8000 0000
               0080 0000 <<< set flag to item
 
Last edited:
hehe, nice catch on the bug.


For ini editing there is essentially only a handful of functions. Search sfall function notes document for "ini" and you will find:

Code:
int get_ini_setting(string setting)
string get_ini_string(string setting)
void sfall_func2("set_ini_setting", string setting, int/string value)
array sfall_func1("get_ini_sections", string fileName)
array sfall_func2("get_ini_section", string fileName, string section)

Searching sfall.h for ini you will get:
Code:
#define get_ini_section(file, sect)                     sfall_func2("get_ini_section", file, sect)
#define get_ini_sections(file)                          sfall_func1("get_ini_sections", file)
#define set_ini_setting(setting, value)                 sfall_func2("set_ini_setting", setting, value)
/code]

And that's all you need.

Read the function descriptions in sfall function notes.txt.

And for use case example study fo2tweaks scripts. most of them contain some ini setting loading. However looking at damage mod and fo2tweaks.h will teach you all you need.

I can also give a you sample of my unfinished work for you to see how I am loading ini data into arrays.

My recommendation is to load ini data as sections, and not as single settings. Reduces disk IO significantly (I think).
 
Last edited:
My recommendation is to load ini data as sections, and not as single settings. Reduces disk IO significantly (I think).
Generally yes, but unless your ini contains tons of data, the number of disk I/O activity (open/read/close the file) should be the last thing you need to worry about.
 
hehe, there really is a bug.
Code:
TransEnergy  = 0008 0000
HiddenItem   = 0800 0000
ShootThru    = 8000 0000
               0080 0000 <<< set flag to item
I'm sooo jealous right now..

Anyway, is there any chance this might get fixed? :-P


Thanks for the suggestion, Cyrus. I'll try it out.
 
Amateur concerns. :roll:
Please enlighten me on this regard then. I don't suppose modern SSDs are that fragile that some INI reading from a mod can shorten their lifespan considerably?
If it's about game performance, I didn't notice much difference on my Pentium II old server with sub-5.4K rpm SCSI drive.
 
First, I hope you understood me correctly. when I said amateur concerns, I was referring to myself being amateur and having amateur concerns! (meaning unnecessary and perhaps false concerns) =))

so your point fully agreed on, ssds would laugh it off. Reducing IO from 50 to 5 would make a 300 milisecond difference for a hard drive. =))

So.... in conclusion... amateur concerns! =))
 
Last edited:
Back
Top