Jump to content

NPC creation


Taeronai

Recommended Posts

I'm working on a really simple mod (my first one to Oblivion), with the purpose of bringing more life to the various Inns and Taverns by increasing the number of NPC:s visiting them.

The NPC:s will stay inside of the place in question, spending most of their time eating, drinking and sometimes walk out for a bit of fresh air.

I have a number of questions concerning this.

 

1. When eating, does the eaten food disappear, like when the PC consumes food? Or does the game simply activate an appropriate animation while the NPC is holding the food as if it was feeding? If it does disappear, how can I make the food respawn?

 

2. To make the NPC drink, shall I use a "UseItem"-package linked to a cup or similar object? How can I make the NPC sit down while drinking?

 

3. And the most importaint question: the NPC must not sit active in the tavern or inn during nights as if being awake, but there will in most cases not be any bed unoccupied for him to sleep in, and I do not want to create a new bedroom for every single NPC. Subsequently, I would like the NPC to simply disappear during the nights. Is there a script to instantly "teleport" the NPC to another cell, one which is not directly linked to the tavern/inn-cell? And, is there some script or package which makes the NPC walk away from sight of the PC (after which it can discreetly disappear from thin air), and which is only activatet during late hours?

Or, which I would prefer mostly, is there a way to combine the "teleporting" with using a door, so that it looks like the NPC is walking out of the building, while in fact he does not come out in the exterior cell (or adjacent interior cell) but is transpordet to the mentioned "waiting cell"?

Link to comment
Share on other sites

Eating consumes food. This is usually countered by either having a merchant or a container within the room which respawns and has enough items for everyone (if you have a merchant, be sure to give the NPC some gold, they use that too). One thing I did within my fighters guild mod was make a container with alot of food only accessable to NPCs by having a script on it. It would ensure that there is always enough food for everyone, and not allow the player to make a quick buck. The point of eating though is really only there for show, to give them something other to do than talk about mudcrabs with eachother constantly, so it's really your decision on how important this will be to your mod, and how often you plan on having players see this.

 

I believe in order to make an NPC specifically drink, you need to either only have that food item available within the search area, or specificy exactly what you want them to drink (cheap beer, wines, the actual potions). Then they will search for only that item, if the item has a restore fatigue modifier they will considder it food, find a seat, and show the drinking animation. All NPCs try to sit when eating, you don't need to add an additional package. If you want them to stand and eat, you should probably refrain from adding any usable chairs within their search area.

 

While you can use scripting to move them all to an unreachable cell at a certain time, or when they complete their final package, doing so can look odd, even when the player doesn't directly see them vanish. It's really best to just add beds or bedrolls for everyone, then if players really feel like finding that NPC to kill/feed on them, they can find them. Depending on the NPCs and the style of your city, you could probably manage a way to make it work.

Link to comment
Share on other sites

Great thanks for the extensive answer!

 

However, I would like to try scripting first. Yes, it would look a bit odd with the NPC simply disappearing, but if I combine it with using the door it would look more or less like when they uses just any door to teleport to a different cell, right? So, could I not use a package like UseItemAt or Find, and make the door in question a Persistent Reference, and then give the NPCs a script which says that when they activate the specific door (which condition?) they shall teleport to the XMarker in an empty Dummy Cell (which then is not created by some package but directly dragged from the Object Windor and given a specific Reference ID (= ###), and the command would be MoveToMarker ###, right?)?

Or, if the teleportation is instead triggered by the completion of a package like Wander (to a spot just in front of the door, marked by an XMarker, right?) which condition and command shall I use in the cript?

 

And: When they have reached the Dummy Cell, how shall I make them teleport back to the front of the door?

 

I hope you people have patience with a complete newbie. I've gone through the TES:CS-Wiki Tutorial, but it didn't cover this in particular.

Link to comment
Share on other sites

You've got it mostly right. If you're determined to use something like that, you'll run into some problems trying to make it work without crahing. While you can use a "beginonpackagedone" block in conjunction with a package which tells the NPC to use a door to move them to a marker in another cell, doing so will likely cause a crash since the actor is being moved to two seperate places (both the other side of the door, and wherever the marker is placed). You might be able to make a script on the door which diasbles regular activation for only the brief moments that the NPC is likely to use the door, but if we're talking about a dozen NPCs with different packages, it might not be worth the effort. Unfortunately there are only a few blocktypes that trigger properly when the player isn't around, which can make things difficult if what you're wanting to happen is supposed to be hidden.

 

I think you might need to do something creative like using a "beginonpackagestart" in conjunction with something like adding the NPC to a certain faction which merely acts as a flag which indivates that they should be in that hidden cell. Then use the door to detect if the actionref is part of that faction, and instead of activating, plays the normal door sound, and moves the NPC to the marker. The faction can also be used within the conditions of a package which would keep the NPC at that marker. To move them back, have a script on the NPC remove the NPC from that faction at a certain time, and place them somewhere.

 

Really though, it's easier to just add a couple rooms with beds than all of this. There is less room for something to go totally wrong. Heck, even just telling the NPC to use a bedroom that's already taken (with a package to just sit) would probably work better.

Link to comment
Share on other sites

Great thanks for the extensive answer!

 

However, I would like to try scripting first. Yes, it would look a bit odd with the NPC simply disappearing, but if I combine it with using the door it would look more or less like when they uses just any door to teleport to a different cell, right? So, could I not use a package like UseItemAt or Find, and make the door in question a Persistent Reference, and then give the NPCs a script which says that when they activate the specific door (which condition?) they shall teleport to the XMarker in an empty Dummy Cell (which then is not created by some package but directly dragged from the Object Windor and given a specific Reference ID (= ###), and the command would be MoveToMarker ###, right?)?

Or, if the teleportation is instead triggered by the completion of a package like Wander (to a spot just in front of the door, marked by an XMarker, right?) which condition and command shall I use in the cript?

 

And: When they have reached the Dummy Cell, how shall I make them teleport back to the front of the door?

 

I hope you people have patience with a complete newbie. I've gone through the TES:CS-Wiki Tutorial, but it didn't cover this in particular.

 

It should be possible to have all your guests use a single room in any of the inns. Since your characters already have a reference, then you could simply use an object script that is triggered by the NPCs once they've travelled though that door. Once the object script is triggered then issue a disable command on the triggering reference - namely your NPC. This makes them disappear from the game world until you enable them again. By staggering the time that each one uses for sleep, then there won't be an odd-looking traffic jam at the door of the room. To re-enable them, requires a quest script - one that is always running. However this can be designed to be very low impact. Once NPCs are enabled ( at dawn? ) they can have packages attached to them ( evaluate packege ) and the cycle renews.

 

However, I agree with Vagrant0 on his point of "keep it simple". With extra scripting comes the burden of several problems. "Script timing" , for instance might leave an NPC in the hall outside the room, where he is standing, but he is quite "dead". This can happen when the disable script gets run before the NPCs graphics complete the "teleport". But even this can be addressed with "cleanup" code. :)

Link to comment
Share on other sites

It should be possible to have all your guests use a single room in any of the inns. Since your characters already have a reference, then you could simply use an object script that is triggered by the NPCs once they've travelled though that door. Once the object script is triggered then issue a disable command on the triggering reference - namely your NPC. This makes them disappear from the game world until you enable them again. By staggering the time that each one uses for sleep, then there won't be an odd-looking traffic jam at the door of the room. To re-enable them, requires a quest script - one that is always running. However this can be designed to be very low impact. Once NPCs are enabled ( at dawn? ) they can have packages attached to them ( evaluate packege ) and the cycle renews.

The problem with a disable/enable, instead of moving them to some unreachable location is that the NPC has the potential to be cleared from memory, and not enabled again. Also, since the NPC is disabled, any scripts on them that might re-enable them wouldn't run since they're disabled. While yes, using a contantly running script to re-enable each and every one would solve part of the problem, it would require additional scripting, could cause crashing if the NPC is no longer in memory. or result in a disappearing/reappearing corpse if the NPC is killed.

Link to comment
Share on other sites

The problem with a disable/enable, instead of moving them to some unreachable location is that the NPC has the potential to be cleared from memory, and not enabled again. Also, since the NPC is disabled, any scripts on them that might re-enable them wouldn't run since they're disabled. While yes, using a contantly running script to re-enable each and every one would solve part of the problem, it would require additional scripting, could cause crashing if the NPC is no longer in memory. or result in a disappearing/reappearing corpse if the NPC is killed.

I have seen the phantom corpse effect. This occurred with a referenced NPC with the dead attribute set that would occasionally be invisible. Reloading a savegame would sometimes restore the NPC, however, uninstalling and re-installing the mod was the correct fix for that. But thanks for that info Vagrant0; very useful. :)

Link to comment
Share on other sites

Thanks again you guys. After hours of trying yesterday, I've given up scripting for now. ;) It's going to be the simple way instead, as you told me. However, since the buildings in Oblivion are pre-made (where in Morrowind you assembled them from individual parts) it's going to take more time than I had thought. There's not even door frames for me to use, which otherwise could be used to put up fake doors leading to separate cells where the NPCs might sleep... I'll use trap doors wherever it fits in the context (which is also more realistic, since one can of course see on the outside of the buildings that there are no space for extra rooms other than basements); in the rest of the cases I'll have to create new exteriors. Ah well, at least it'll work in the end.
Link to comment
Share on other sites

Thanks again you guys. After hours of trying yesterday, I've given up scripting for now. ;) It's going to be the simple way instead, as you told me. However, since the buildings in Oblivion are pre-made (where in Morrowind you assembled them from individual parts) it's going to take more time than I had thought. There's not even door frames for me to use, which otherwise could be used to put up fake doors leading to separate cells where the NPCs might sleep... I'll use trap doors wherever it fits in the context (which is also more realistic, since one can of course see on the outside of the buildings that there are no space for extra rooms other than basements); in the rest of the cases I'll have to create new exteriors. Ah well, at least it'll work in the end.

What building style are you working with? Some do actually have doorframes which aren't defined in the CS, but have a model in the BSA archives. I know Bravil does, and I think Anvil and skingrad do as well. The usage may be a little limited since interiors are supposed to correspond with the exterior... No one small building with 5 doorways all leading to full interiors... It's only difficult since you're trying to make it so. Every architectural style can be used to create a sort of dormhouse where you could easily fit 6-8 beds in one building. If you're using more than 14 or so NPCs, you really should considder using fewer since that many usually leads to severe frame loss. Stop trying to cheat, do things the right way, and it'll be easier.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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