Jump to content

Trouble Getting a Value with 'GetAV InventoryWeight'


user826

Recommended Posts

Hey, everyone! So, I've got a dummy NPC in a hidden cell that I'm using as a storage container. I'm trying to make a backpack that doesn't just increase the player's carrying capacity by a fixed amount, but rather actually has a limited storage capacity. Problem is, calling "DummyREF.GetAV InventoryWeight" in my script always returns 0. It doesn't matter if I'm setting it as a variable (i.e. "set CurrentWeight to DummyREF.GetAV InventoryWeight") or if I'm using it in a condition (i.e. "if DummyREF.GetAV InventoryWeight > 50"), none of my scripts will trigger because the value always returns 0.

 

The dummy NPC does not have an actor script, has no AI packages, and none of the flags (i.e. No Low Level Processing, Essential, Respawn, No VATS Melee, etc.) are set. I'm calling "DummyREF.OpenTeammateContainer 1" in my activator script to open the inventory, which seems to be working fine. It's just that nothing else that relies on GetAV InventoryWeight works.

 

Here's what my script looks like at the moment:

scn aaaSCPTBackPackActivator

int Button
int BackPackFull
float CurrentWeight
float PreviousWeight
int InvWeightRestore

begin OnActivate Player
    set CurrentWeight to (BackPackREF.GetAV InventoryWeight)
    ShowMessage aaaMESGBackPackMENU CurrentWeight aaaGLOBPackWeightMax
end

begin OnAdd Player
    Player.EquipItem aaaARMOBackPack 0 1
end

begin GameMode
    set Button to GetButtonPressed
    if (Button == 0)
        BackPackREF.OpenTeammateContainer 1
    elseif (Button == 1)
        Player.AddItem aaaARMOBackPack 1
        if (BackPackREF.GetAV InventoryWeight > aaaGLOBPackWeightMax)
            set BackPackFull to 1
            set CurrentWeight to (BackPackREF.GetAV InventoryWeight)
            Player.ModAV InventoryWeight CurrentWeight
            set PreviousWeight to CurrentWeight
        elseif (BackPackREF.GetAV InventoryWeight <= aaaGLOBPackWeightMax) && (BackPackFull == 1)
            set BackPackFull to 0
            set InvWeightRestore to (0 - PreviousWeight)
            Player.ModAV InventoryWeight InvWeightRestore
        endif
        Disable
        MarkForDelete
    endif
end

Any insight is appreciated!

 

EDIT: Using the console to run "GetAV InventoryWeight" on some base game NPCs also returns 0, which suggests that this actor value only works on the Player. But then that raises the questions, how do companions know when to speak their overburdened dialog? And can I use that as a condition check instead?

Edited by user826
Link to comment
Share on other sites

I don't see you setting "BackPackREF" variable to an actual reference anywhere? Presumably you defined it elsewhere, but you should implement a check that the Ref is valid if only for debugging.

 

The console doesn't know about "references" other than those identified by the "prid" command. So, unlike in a script, unless the NPC is immediately "in-scene" so it can be selected, you can't reference it. "BackPackREF.<cmd>" doesn't work in the console.

 

-Dubious-

Link to comment
Share on other sites

Yes, I understand that. But I seem to have failed to make my point. Your script is acting as if it does not have a memory of things that happen elsewhere via an object reference. THAT script you posted is not an object script of BackPackREF (its an object of Player) and does not seem to assign the "in-game, runtime" explicit reference to BackPackREF to it's local variable. You are making an assumption which (for debugging purposes) you need to test. You may need to use "GetRefVariable".

 

Another consideration: how do you determine that this is not the very first time you have attempted to obtain the weight, when the companion does NOT have any beyond starting equipment (and could be returning zero)? There is no check that "CurrentWeight" or "PreviousWeight" is initially zero, which perhaps is to be expected. (I'm not certain that companion starting equipment actually has weight? "Companion ammo" doesn't. The game replaces the model used when a unique companion weapon such as Boone's is removed at the casinos, for instance.)

 

-Dubious-

Link to comment
Share on other sites

I don't quite understand what you mean. I thought that the point of naming a persistent reference was so that you could reference it in scripts globally. I'm not trying to run this script in the console, it's attached to a piece of armor that the player has to unequip and drop into the worldspace before they can interact with it. I understand that running BackPackREF.GetAV <whatever> won't work if I typed it into the console because of the missing prid, but that's not what I'm trying to do here. I don't understand the relevance. In any case, is there a way to check GetRefVariable if I don't have NVSE?

 

Also, the dummy NPC I'm using has no gear or starting inventory whatsoever, so I *am* expecting the initial value to be 0. That first ShowMessage call is returning the correct value. I was assuming that once I put something in the bag (in actuality, placing it in my dummy NPC's inventory) and then checking the current weight again, it would no longer be 0. But no matter how much I put in the inventory, over several interactions, the value won't update.

 

My worry, like in the edit that I posted under the script, is that GetAV InventoryWeight doesn't work on NPCs because I opened the console, clicked on a Goodsprings Settler to get his prid, and then entered "GetAV InventoryWeight" and it still returned 0, even though he had about 8 lbs. worth of gear and weapons in his inventory at the time. Meanwhile, typing "Player.GetAV InventoryWeight" immediately afterwards returned the correct value of 7.53.

Link to comment
Share on other sites

My apologies. I somehow got fixed on the idea that because you were trying to do this in the console you were having the problem. But now that it is clear you are still getting a zero weight in the script, your idea about the function not working on NPCs has merit.

 

Doing some more digging: According to the "Inventory Reference" page of the GECKWiki, "objects stored inside of the inventories of actors or containers are not references". As explained in that discussion, you are going to need NVSE to approximate them as temporary references within a loop which is iterating over the inventory. "The temporary nature of inventory references require some extra care in their use. The contents of the source container should not be modified within the loop." The "NVSE Addon Plugins" such as JIP and Lutana were developed to overcome limitations and provide needed functionality missing from the base NVSE and GECK.

 

I note that Lutana added the function "GetInventoryWeight" that "Returns the total weight of items in the inventory of a reference." Try that instead of "GetAV" or the loop in the "Inventory Reference" page. Suspect he turned it into a function to solve that very problem.

 

See "Issue - How to get GECK to load with NVSE" of the 'GECK: Common Problems' section of the wiki "Getting started creating mods using GECK" article. (If you have any NVSE plugin such as "JIP LN NVSE Plugin" installed, it will automatically get used when NVSE is used in the GECK.)

 

-Dubious-

Link to comment
Share on other sites

I go for a minimalist approach to my mods and don't want an NVSE dependency, which is why I don't use those functions even though I have NVSE installed to run Tale of Two Wastelands. I was really hoping that this could be done using vanilla GECK only.

 

But again, this raises the question then, if GetAV InventoryWeight doesn't work on NPCs, how do NPC companions know when to speak their overburdened dialog topic, and is there a way I could co-opt that to do what I want?

 

I'm thinking it could be done by having a script that runs on startup to do something like "BackPackREF.ForceAV CarryWeight 50" and then have a condition like "if BackPackREF.IsOverburdened == 1" and then change the player character's inventory weight accordingly. This all depends on figuring out how the companions know they're overburdened though.

Link to comment
Share on other sites

In that case, all I can suggest is you locate some companion dialog, isolate that "overburdened" bark, and find where it is used (probably in a "result script"). See "TIP Obsidian Conversation Editor aka OCE" and "TIP Say Once use" under the "Dialogue and Lipsynch" section of the wiki "Getting started creating mods using GECK" article.

-Dubious-

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...