Need help to achieve npc inventory respawning

Post » Thu Jul 21, 2011 5:57 pm

Hi there, i am new to the forum and to scripting. I have a mod with some guard NPCs that i want to script so that at gamehour 22 (before they go to sleep) their longsword, shield, gauntlets, armor etc. respawns, that is all i want to do. This is because the guards frequently have ongoing battles and i notice their armor and weapons take damage and maintain it right until the NPC dies before the whole NPC itself respawns. As said i need to script the guards so that at a certain time each day/week their armor and weapons are replaced. I am having problems in construction set, i know about additem and removeitem and number count, and "on gamemode", so far unfortunately my script mod has made the NPC just spawm loads of weapons and armor at a particular time of the day rather than just remove one item and replace it with one other item. I would greatly appreciate if someone would spare me enough time to write me here a small script and leave a space or symbol to represent the object ID that i want to remove and replace, thanks.
User avatar
Genocidal Cry
 
Posts: 3357
Joined: Fri Jun 22, 2007 10:02 pm

Post » Thu Jul 21, 2011 10:17 pm

ScriptName AttachThisObjectScriptToYourNPCInt bReplaceStuffBegin GameMode	If (GameHour >= 22) != bReplaceStuff		Set bReplaceStuff to (bReplaceStuff == 0)		If bReplaceStuff			RemoveItem EditorID 1			AddItem EditorID 1		EndIf	EndIfEndIf
...should do it.
User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Thu Jul 21, 2011 6:09 pm

Will selecting levelled list items respawn?
User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Thu Jul 21, 2011 8:48 pm

*LVLIs can be added but not removed. Items must be added and removed individually.

Retroactive interference: Guess that only works with the Fallouts...
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm

Post » Fri Jul 22, 2011 3:45 am

so that can compensate for the script then? Does that mean all individual items need to be removed when leveled lists are placed into inventory, such as rings and amulets don't need to be respawned?
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Thu Jul 21, 2011 11:02 pm

It's probably because I'm a noob, but I don't really get the script. I'd try this if that doesn't work:

ScriptName AttachThisObjectScriptToYourNPCshort bReplaceStuffBegin GameMode	If (GameHour >= 22) && (bReplaceStuff == 0)		Set bReplaceStuff to 1		RemoveItem item1 1		AddItem item1 1		RemoveItem item2 1		AddItem item2 1;		...	ElseIf (GameHour < 22) && (bReplaceStuff == 1)		Set bReplaceStuff to 0	endifEndIf

User avatar
anna ley
 
Posts: 3382
Joined: Fri Jul 07, 2006 2:04 am

Post » Thu Jul 21, 2011 6:04 pm

so that can compensate for the script then? Does that mean all individual items need to be removed when leveled lists are placed into inventory, such as rings and amulets don't need to be respawned?
With the Fallouts, a LVLI can be added and all the items will be given, but it looks like only one item from a list is added with Oblivion, so I'd just add and remove everything individually.
It's probably because I'm a noob, but I don't really get the script. I'd try this if that doesn't work:

ScriptName AttachThisObjectScriptToYourNPCshort bReplaceStuffBegin GameMode	If (GameHour >= 22) && (bReplaceStuff == 0)		Set bReplaceStuff to 1		RemoveItem item1 1		AddItem item1 1		RemoveItem item2 1		AddItem item2 1;		...	ElseIf (GameHour < 22) && (bReplaceStuff == 1)		Set bReplaceStuff to 0	endifEndIf

It's the same ol' same ol'... but with less code. Set Boolean to (Boolean == 0) toggles it to whatever it's not, making for one check per iteration rather than two. Particularly in GameMode, one should keep things 'cheap'.

[yes, it works]

Also: Int, Long, and Short are all interchangeable. Int just makes for less typing. *is lazy* :P
User avatar
JERMAINE VIDAURRI
 
Posts: 3382
Joined: Tue Dec 04, 2007 9:06 am

Post » Thu Jul 21, 2011 7:51 pm

OK... I think I get it now...

And I wasn't sure whether or not "int" was an OBSE variable. I see it in the OBSE documentation but not on the http://cs.elderscrolls.com/constwiki/index.php/Category:Variables.
User avatar
Emily Shackleton
 
Posts: 3535
Joined: Sun Feb 11, 2007 12:36 am

Post » Fri Jul 22, 2011 12:24 am

I tripped on the 'Set Bool to Bool == 0' hinge ...thing too, at first (Cipscis' code), but it's quite enabling once it clicks.

Int is indeed a stock variable (integer).
User avatar
Ludivine Poussineau
 
Posts: 3353
Joined: Fri Mar 30, 2007 2:49 pm

Post » Thu Jul 21, 2011 1:46 pm

ok thanks, i'll have to see when NPCs are havign a battle, have a look at the armor the next day to see if it is back to hundred percent health. You wouldn't happen to know anything about why a shield, once an NPC has been killed, appears in a red hand icon, rather than a white, considering the shield is not attached to any faction, and it is ok for me to loot all other items from the npc? It doesn't come up as a stolen item though, when i take it. Could it be the .nif files of the shield that is displaying this red hand icon? Ok that was my last question.
User avatar
Kelly Osbourne Kelly
 
Posts: 3426
Joined: Sun Nov 05, 2006 6:56 pm

Post » Thu Jul 21, 2011 9:47 pm

No prob :) All should go well with that template script.

Stolen shields: Are you certain the soldier was dead rather than set as essential and merely unconscious? If that's not it, I'd have to see the plugin and witness it to try to figure that one out. Sorry....
User avatar
Josh Sabatini
 
Posts: 3445
Joined: Wed Nov 14, 2007 9:47 pm

Post » Thu Jul 21, 2011 6:12 pm

I figured it out, it was because i left "can corpse check" on, i thought that just meant you could search the npcs body. But when i turned it off then the shield appeared with a white hand icon. Thanks for your help, and i wonder if i can delete this thread, so other posts can receive important attention.
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm


Return to IV - Oblivion