Moving items from player to a container

Post » Tue Jan 19, 2016 11:33 am

I'm looking for a way to transfer items from the player to a container via script, retaining health percentage. In NV RemoveItem accepts a destination container so it's easy, but in FO3? I was thinking about GetInventoryObject + EquipItem + GetEquippedCurrentHealth + AddItemHealthPercent to container + RemoveItem from player, but is there a less clunky way? Thanks



Related to this, is there a way to get the ref for a specific object in the inventory, and not the base form (through GetInventoryObject), then add it to a container?

User avatar
Laura Simmonds
 
Posts: 3435
Joined: Wed Aug 16, 2006 10:27 pm

Post » Tue Jan 19, 2016 9:48 pm



Ya thats a tuff one ... but looks like your method will work just fine ... as far as being clunky , I consider something clunky if it eats up to much cpu cycles as in the GameMode block.



Could you explain it in terms of the senario that is suppose to be rendered to the player? Maybe I can point out an alternate method to simulate it. Is this object limited to a few , or is its possibility anything thats equipable?



As far your last question ... does declaring and setting a ref var do what you want?



Example ...



~~~~~~~~~~~~


SCN MyScript



Ref rMyObject



Begin On???? (what ever block ,except GameMode)



Set rMyObject to Player.GetEquippedObject 5

User avatar
Sudah mati ini Keparat
 
Posts: 3605
Joined: Mon Jul 23, 2007 6:14 pm

Post » Tue Jan 19, 2016 10:16 am


The mod I'm working on is http://www.nexusmods.com/fallout3/mods/21920?, right now I've limited it to items that don't have a health condition, but it'd be much better if I could make it unload weapons and armors too, so that's what I was looking for. A CPU-intensive solution wouldn't be a problem I think, because the scripts are attached to containers and are self-terminating, my current scripts run without much apparent effort on my PC, anyway I added "DisablePlayerControls" checks just to be safe.



Other than being a bit awkward scripting-wise, I wouldn't want it to play weird animations (like equipping and unequipping stuff), also there's the problem that if an item has 0% health can't be equipped, and when I move it in a container via script it would regain 100% health. Unless 1. the game unequips automatically the item in the following frame and 2. in the same frame that it processes the "equipitem" script, the "GetEquippedCurrentHealth" returns that weapon.



Basically conditions for it to work as I'd like are:



1. no weird animations of quickly equipping/unequipping stuff


2. no equipping sounds


3. and that it also works for items with 0% health.



Right now I can't try it because I'm on a different PC, also I had another priority (an option menu) for that same mod, but if there is a solution for weapons/armor I'll add it to the update when it's ready.



Yes your example is right but it's only applicable to equipped items so this forces me to adopt the same workaround.. thanks anyway.

User avatar
Robyn Howlett
 
Posts: 3332
Joined: Wed Aug 23, 2006 9:01 pm

Post » Tue Jan 19, 2016 9:43 am


OIC ... your making an auto sort , and you don't actually want to remove what is equiped ?



There is "GetCurrentHealth" & "SetObjectHealth" Which should work for any ref object ... but then its still a matter of picking it out of your inventory.



Have you had a look at some of the other auto sort mods on the nexus to see how they are doing it?

User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am

Post » Tue Jan 19, 2016 5:05 pm


I thought GetCurrentHealth only worked for actors and I don't see SetObjectHealth listed among FOSE/GECK functions, but I don't know of a way to select an inventory item as a specific reference and not as a baseform (GetNthObject returns the baseform), if there is then it would be perfect, otherwise I'll try that workaround with GetEquippedCurrentHealth. I'm not aware of any autosort mods, otherwise I wouldn't have done mine probably.. Thanks anyway.



Edit: ok I found this



http://www.nexusmods.com/fallout3/mods/19441/?



I'll see how it works

User avatar
des lynam
 
Posts: 3444
Joined: Thu Jul 19, 2007 4:07 pm

Post » Tue Jan 19, 2016 7:05 pm

There are also these 2 I can think of ...



http://www.nexusmods.com/fallout3/mods/17781/?



http://www.nexusmods.com/fallout3/mods/9592/?



Although I'm not sure if they will actually sort armour and weapons.



What about the universal sorter , does it do that ?




On the "GetCurrentHealth" ... it says it returns the health of the calling reference ...


Where as "GetHealthPercentage" says specifically an actorRef ...



So I was assuming it worked on any reference with a health stat.



"SetCurrentHealth" is a NVSE function ... so thats why I mentioned the "SetObjectHealth"



But I just had a thought on how you could bypass needing to get its health while in your inventory ... What if you drop the item from inventory , and have it fall through an area trigger , which would then send it to a container ?



Add edit: I realized you said you don't see "SetObjectHealth" And not "SetCurrentHealth"



Here it is http://geck.gamesas.com/index.php?title=SetObjectHealth

User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am

Post » Wed Jan 20, 2016 12:06 am


It seems the 2 you mentioned don't sort weapons or armors, universal sorter does but it uses "RemoveAllItems" to a temporary container, with the drawback that it unequips all items and clears all hotkeys, I wanted to avoid that and I had already the checks in place. "GetCurrentHealth"/"SetObjectHealth" would be great but it's not possible to know the exact ref (not baseform) of an item without equipping it, so I can't use them. I'll try that workaround since it seems the only possibility, if it looks too bad in game I'll leave them be, it wouldn't be such a big deal. Your last suggestion is interesting, I'll see what I can do, I'll keep out all this from the next update anyway. Thanks for the assistance.

User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am


Return to Fallout 3