Greslin Posted March 29, 2017 Share Posted March 29, 2017 So lately I've been exploring the options available for porting/rewriting my FNV Tuckered Out mod to Papyrus and the Fallout 4 engine. I assumed that there would be some major roadblocks to making that work, but as I dug deeper, I was pleasantly surprised to discover that most of the issues could be overcome relatively easily. Except one major one. Did Bethesda seriously remove AV.InventoryWeight from the game?? If so, I have a few workaround ideas, but none of them sound particularly elegant. Has anyone yet managed to figure out how to determine the player's current carrying weight in a script? Link to comment Share on other sites More sharing options...
shavkacagarikia Posted March 29, 2017 Share Posted March 29, 2017 There is no such Actor value and direct way to determine player inventory weight, only max carrying weight of the player himself. I'm just interested which workaround ideas do you have? Link to comment Share on other sites More sharing options...
Greslin Posted March 29, 2017 Author Share Posted March 29, 2017 (edited) On 3/29/2017 at 6:59 PM, shavkacagarikia said: There is no such Actor value and direct way to determine player inventory weight, only max carrying weight of the player himself. I'm just interested which workaround ideas do you have? A bunch of ones that are thoroughly untested and likely all awful. From digging around in the script code, right now it seems to me that the main tools we have to detect inventory weight conditions are fAVDCarryWeightBase, fAVDCarryWeightMult, and IsOverEncumbered(). There's also some additional code in HC_Manager that overlays on top of that. So short of somehow hacking into the PipBoy UI code (I mean, that screen is getting that number from SOMEWHERE) or an F4SE miracle (hint hint guys), here are the options I've seen so far. They all involve running a constant script in the background, with a trigger probably on OnItemAdd and OnItemRemove: 1. "Rocks in pockets". Quietly and invisibly add objects of incremental weights to the player inventory until IsEncumbered() gets tripped, then quickly take them out. Use the difference to determine how close we are to the max. 2. Temporarily lower max carry weight until IsEncumbered() trips, then put it back. Should get the difference without having to add and remove items from inventory, but we still have the encumbrance effect/message. But there should be a way around that. 3. Brute force. Hook into OnItemAdd() and OnItemRemove(), and every time they trip, run a weight calc on the items that get processed. Keep a running tally and use that. Again, they all suck, especially option #1. #2 trips encumbrance events/rules, and there are a lot of ways that #3 can go wrong. I haven't actually tested any of them, so I may be overstating - or dramatically understating - the risks of each. Barring any better ideas, I'll probably start with a test of #2. This is immensely frustrating for me, because so far it seems that this is the ONLY roadblock issue standing in the way of a port. And with this new engine, I can probably do much more with the mod than I was able to do in FNV. I swear. Some days I do think that just before they release a new Fallout title, there's someone at Bethesda whose sole job is to find the one fundamental thing that they can do to ruin a modder's day. Edited March 29, 2017 by Greslin Link to comment Share on other sites More sharing options...
Greslin Posted April 14, 2017 Author Share Posted April 14, 2017 Just wanted to update on this. Now that I have my current mod projects fairly stable, I've started running tests on calculating current inventory weight. This function works.float Function GetWeight() Actor PlayerRef = Game.GetPlayer() float CurWVal = PlayerRef.GetValue(Carryweight) float vCount = 0 while (!PlayerRef.IsOverEncumbered()) vCount = vCount + 40 PlayerRef.DamageValue(Carryweight, 40) endwhile while (PlayerRef.IsOverEncumbered()) vCount = vCount - 20 PlayerRef.RestoreValue(Carryweight, 20) endwhile while (!PlayerRef.IsOverEncumbered()) vCount = vCount + 10 PlayerRef.DamageValue(Carryweight, 10) endwhile while (PlayerRef.IsOverEncumbered()) vCount = vCount - 5 PlayerRef.RestoreValue(Carryweight, 5) endwhile while (!PlayerRef.IsOverEncumbered()) vCount = vCount + 1 PlayerRef.DamageValue(Carryweight, 1) endwhile PlayerRef.RestoreValue(Carryweight, vCount) return CurWVal - vCount + 1 endFunctionThis basically implements option #2 from my last post. It adjusts the Player's Carryweight AV until IsOverEncumbered() trips, then resets Carryweight back to its pre-state. This code is a crude proof of concept. The first iteration simply ran a loop from Carryweight down to IOE(), with 1.0 decrements, and came back with the right number after 3-4 seconds. This version takes a series of min-max steps and gets it in about 1-2 seconds. For this thing to be practical, I need two things: 1. An algorithm that further reduces the determination steps. The halving process, above, gets it fast. But not fast enough. Ideally I'd like to be able to determine this in under a second. 2. A good firing event. I need to be able to run this regularly, but at a time when playing with Carryweight isn't going to interfere with gameplay (which probably rules out just using game timers). The event I'm using right now for testing is OnEnterSneaking(), but obviously that's not going to work for production use. The ideal option would be OnItemAdded() and OnItemRemoved(). The catch there is that the weight accounting would run on every.. single.. item.. which I imagine would be an unholy mess in a Get All/Store All situation. I'm convinced that this is workable. Just need to solve a few more problems. Anyone has any ideas, please let me know. Thanks. Link to comment Share on other sites More sharing options...
havokjv Posted April 29, 2018 Share Posted April 29, 2018 Sorry for resurrecting this post, but have you made any progress on this?I'm attempting to make a UI mod that would show the player's current weight / maximum carry weight under the quick loot box, and the absence of AV.InventoryWeight is quite problematic indeed. I've been thinking of using your function to calculate the current weight on load, and then add to this value every time an item is added or removed from the inventory. Seems like a pain to do for a value that should be easily accessed though. Link to comment Share on other sites More sharing options...
Recommended Posts