Accessing NPC inventories

Post » Fri Jan 22, 2010 7:05 pm

Hi there, i was wondering how i would go about accessing NPC inventories when im playing. I couldnt find anything at the CS Wiki so i thought id ask here. its for my companion mod i made. Also will it require OBSE, not a problem if it does though. thx!
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Fri Jan 22, 2010 7:21 pm

Generally, it can be done by moving a persistent non-respawning container near the player, dumping the companion's inventory to that container, forcing the player to activate that container, then dumping everything from that container to the actor (without ownership flags) when done.
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Fri Jan 22, 2010 1:27 pm

Check http://www.tesnexus.com/downloads/file.php?id=17497 to find out how it is done.
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am

Post » Fri Jan 22, 2010 11:20 am

ok thx guys, ill probably be back in a bit with more questions though :P
User avatar
Claudz
 
Posts: 3484
Joined: Thu Sep 07, 2006 5:33 am

Post » Fri Jan 22, 2010 2:30 pm

ok after going through active inventory spell im still compltely lost... so heres my questions
1. what worldspace would i place the container in?
2. how would i force the NPC's inventory to that container?
3. how would i force the player to open that container?
4. how would i transfer those items back to the same NPC?
5. can this be done to happen to only a single NPC?
6. how would i get this to happen through dialogue, would i put the script in the result script box of the dialogue?

thx
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Fri Jan 22, 2010 4:12 pm

bump. it isnt breaking the rules to do it yet is it?
User avatar
Jade MacSpade
 
Posts: 3432
Joined: Thu Jul 20, 2006 9:53 pm

Post » Fri Jan 22, 2010 5:59 pm

Just create an interior cell, doesn't matter what worldspace. Place the container you want to use there. It needs to have a unique, non-generic name.

Use dialog to trigger a script that does Actorid.removeallitems targetcontainerid
then do a player.activate targetcontainerid
when the player closes the container, do targetcontainerid.removallitems actorid
User avatar
RaeAnne
 
Posts: 3427
Joined: Sat Jun 24, 2006 6:40 pm

Post » Fri Jan 22, 2010 1:08 pm

Just create an interior cell, doesn't matter what worldspace. Place the container you want to use there. It needs to have a unique, non-generic name.

Use dialog to trigger a script that does Actorid.removeallitems targetcontainerid
then do a player.activate targetcontainerid
when the player closes the container, do targetcontainerid.removallitems actorid



I just tried this, and all it did was take the items off of my companion lol.
Do you place the script in the result script box of the dialouge?
also, the activate container portion of the script didn't bring up the container's contents.
User avatar
Chris Jones
 
Posts: 3435
Joined: Wed May 09, 2007 3:11 am

Post » Fri Jan 22, 2010 7:49 pm

might have to move the container to near the player..... post your script?
User avatar
Lizs
 
Posts: 3497
Joined: Mon Jul 17, 2006 11:45 pm

Post » Fri Jan 22, 2010 2:36 pm

thank you! this is being used for a companion mod, so should it go into that script or should i put it in the result script box?
User avatar
Shelby McDonald
 
Posts: 3497
Joined: Sat Jan 13, 2007 2:29 pm

Post » Fri Jan 22, 2010 3:46 pm

Not sure.......

JQ's&DM's backpacks use pretty much the same method, a bag that exists in a cell far far away...... that is moved to the player when needed. As it is an object script, and I don't (generally) have to worry about the backpack running off..... makes things a lot easier. I have no experience at all with dialog. :D
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Fri Jan 22, 2010 4:30 pm

ok so i need to put the unique chest in its own cell and then make an object script with the above and attach it to the chest? and then i guess i would have to use it as a result script in the dialogue? thats easy enough to do, ill try that, thank you!
User avatar
Michelle Smith
 
Posts: 3417
Joined: Wed Nov 15, 2006 2:03 am

Post » Fri Jan 22, 2010 6:21 pm

Chiming in a bit late, but by using OBSE there are a much simpler way:

ref npcRefref itemRefshort itemCountshort items...; assuming npcRef holds the NPC refset itemCount to npcRef.GetNumItemsWhile itemCount > 0	set itemCount to itemCount - 1	set itemRef to GetInventoryObject itemCount		; itemRef now refers to one item type in NPC's inventory, letting you do things like:	set items to npcRef.GetItemCount itemRef	PrintC "%n has %.0f items of type %n", npcRef, items, itemRef		npcRef.RemoveItemNS itemRef 1	PrintC "Removed one item of type %n from %n", itemRef, npcRef	if (GetObjectType itemRef) == 33		PrintC "%n is a weapon", itemRef	endifLoop

User avatar
Allison Sizemore
 
Posts: 3492
Joined: Wed Jul 19, 2006 6:09 am

Post » Fri Jan 22, 2010 2:37 pm

wait so i can use that as a script? using OBSE isnt a problem one bit so thats ok. is there editing i need to do to thatn script do i can use it? thx
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Fri Jan 22, 2010 6:47 am

wait so i can use that as a script?
Yes :)

is there editing i need to do to thatn script do i can use it? thx
Not sure exactly what you're asking here... You must of course put the code within a code block (probably MenuMode or GameMode, depending on what you need), and have something controlling when it is called). And you must of course swap the code after the two first lines inside the While..., with your own code where you do what you want with the items.
User avatar
Stephanie Nieves
 
Posts: 3407
Joined: Mon Apr 02, 2007 10:52 pm

Post » Fri Jan 22, 2010 9:26 pm

i meant do i need to change anything in the script to get it to work right. i understood most of what you said but how do i get it to swap the code after the first 2 lines and how would i control when the script is activated, like when it will start and when it will end? thx for the help!
User avatar
Eileen Collinson
 
Posts: 3208
Joined: Thu Dec 28, 2006 2:42 am

Post » Fri Jan 22, 2010 10:09 am

i meant do i need to change anything in the script to get it to work right. i understood most of what you said but how do i get it to swap the code after the first 2 lines!
I meant that you need to replace my examples of what you can do with inventory objects, with the code where you do what you intend to do with the inventory objects.

and how would i control when the script is activated, like when it will start and when it will end?
If you don't know about Menumode, Gamemode and "if" lines, I think you should start reading the basic scripting courses at the CS Wiki site.
User avatar
Hope Greenhaw
 
Posts: 3368
Joined: Fri Aug 17, 2007 8:44 pm

Post » Fri Jan 22, 2010 4:09 pm

thank you for the suggestions, TheNiceOne, ive never scripted before and im trying to learn to right now, im tired of not being able to do these things at all! im gonna read every bit of scriptingn course on the CS Wiki i can find.
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am

Post » Fri Jan 22, 2010 7:40 am

sorry to necro this thread, but I've made a script that successfully dumps the items, lets me mess with them, then successfully dumps them back to the npc. The problem is, my npc never equipts the items I give him. only weapons. here is my script

scn ACgriusscriptshort ShareBegin Gamemodeif Share == 1		set Share to 2		ACgriusref.removeallitems ACchestref		acchestref.moveto Player		ACchestref.Activate Player		ACchestref.moveto ACgriuschestmarker		return	elseif Share == 2			set Share to 0			ACchestref.RemoveAllItems ACgriusref			return		endifend


share is set to 1 through the results of a dialouge option.

I know SOMETHING is missing, but not what it might be.

Thanks for the continued help.

EDIT: forgot to say, my npc is wearing clothes when i access his inventory, and even if I remove nothing, just close the chest, he is naked with only his weapon. He has the items, but won't equipt them.
User avatar
Kelsey Anna Farley
 
Posts: 3433
Joined: Fri Jun 30, 2006 10:33 pm

Post » Fri Jan 22, 2010 11:15 am

sorry to necro this thread, but I've made a script that successfully dumps the items, lets me mess with them, then successfully dumps them back to the npc. The problem is, my npc never equipts the items I give him. only weapons. here is my script

scn ACgriusscriptshort ShareBegin Gamemodeif Share == 1		set Share to 2		ACgriusref.removeallitems ACchestref		acchestref.moveto Player		ACchestref.Activate Player		ACchestref.moveto ACgriuschestmarker		return	elseif Share == 2			set Share to 0			ACchestref.RemoveAllItems ACgriusref			return		endifend


share is set to 1 through the results of a dialouge option.

I know SOMETHING is missing, but not what it might be.

Thanks for the continued help.

EDIT: forgot to say, my npc is wearing clothes when i access his inventory, and even if I remove nothing, just close the chest, he is naked with only his weapon. He has the items, but won't equipt them.



You don't need to move the container to the player.

To get them to equip items just add something like...

elseif Share == 2
set Share to 0
ACchestref.RemoveAllItems ACgriusref
ACgriusref.additem daedricboots 1
ACgriusref.equipitem daedricboots
ACgriusref.removeitem daedricboots 1
return
endif

You can use any item I always just used the boots. Having them equip them then removing them forces the NPC to re-evaluate their inventory like they do on a cell load.
User avatar
FirDaus LOVe farhana
 
Posts: 3369
Joined: Thu Sep 13, 2007 3:42 am

Post » Fri Jan 22, 2010 11:49 am

it worked perfectly.
thanks for all the help, I'll give you credit for the script if I ever release the mod.

for reference, here is my final script:
scn acgriussharescriptshort share;share is initiated through dialougeBegin Gamemodeif Share == 1		set Share to 2		ACgriusref.removeallitems ACchestref		ACchestref.Activate Player		returnelseif Share == 2	set Share to 0		ACchestref.RemoveAllItems ACgriusref		ACgriusref.additem daedricboots 1		ACgriusref.equipitem daedricboots		ACgriusref.removeitem daedricboots 1		returnendifend

User avatar
Theodore Walling
 
Posts: 3420
Joined: Sat Jun 02, 2007 12:48 pm


Return to IV - Oblivion