Reliable Way To Make An Npc Stay Put

Post » Wed Aug 26, 2009 2:30 am

In my vampire mod, I want be be able to lure NPC's into a cage and trap them there. I have tried adding a wander package with 24 or more hours on it and a must complete flag but that doesn't work.

I was able to pin them down with modav2 encumbrance 9999 but when their next package arrived after I used wait or sleep, they basically teleported out of the cage and were gone.

It seems that their default AI just kicks in and overrides anything I do. Any ideas?
User avatar
Ross Zombie
 
Posts: 3328
Joined: Wed Jul 11, 2007 5:40 pm

Post » Wed Aug 26, 2009 6:44 am

I'm very much a beginner but Ill take a shot at an idea - Others can correct me if I'm wrong....


Could you not create a package for sleep and use item for each NPC, but not add them to the NPC to start with.

Once in the cage run a small script to add those packages, which both have an override condition that will keep them in the cage until that condition is no longer valid (Or until you script the removal of the packages). A bedroll might be needed for each NPC though, and possibly a chair?

That's what Id look at to start with.

I hope that might be of some help (and equally if its wrong, I'm happy to hear the proper way to go about it - interesting question)

Cheers

MVK
User avatar
jesse villaneda
 
Posts: 3359
Joined: Wed Aug 08, 2007 1:37 pm

Post » Tue Aug 25, 2009 9:46 pm

I'm very much a beginner but Ill take a shot at an idea - Others can correct me if I'm wrong....


Could you not create a package for sleep and use item for each NPC, but not add them to the NPC to start with.

Once in the cage run a small script to add those packages, which both have an override condition that will keep them in the cage until that condition is no longer valid (Or until you script the removal of the packages). A bedroll might be needed for each NPC though, and possibly a chair?

That's what Id look at to start with.

I hope that might be of some help (and equally if its wrong, I'm happy to hear the proper way to go about it - interesting question)

Cheers

MVK

I already tried a wander package in the cell. Must complete doesn't apply to wander packages, so essentially there is no way to make that package last forever. I don't think a sleep package will be any different, once the factory packages roll around eventually the added script package will be replaced. Unless maybe I put an X marker behind the wall and made them try to travel to it but they couldn't reach it. But then they might walk at the wall which would look dumb.

The main problem is the other packages seem to kick in and the actor takes off.
User avatar
Kelly Upshall
 
Posts: 3475
Joined: Sat Oct 28, 2006 6:26 pm

Post » Wed Aug 26, 2009 6:21 am

If you can have a chair in the cage then you can set the NPC to use it - same goes with a bed. If you can find a condition to add to both, that will keep the NPC using them, then he should stay put.

Perhaps something like a distance check to the center of the cage - if the check says do this if the NPC is within X distance, which could be set to slightly larger than the current cell, then stay on the chair/bed. Such packages would never stop however, so the NPC would be there forever unless you could remove their current package from within a script. By rights they should then lock on to their normal packages, and providing they moved outside of the range of your cage, they would then continue normal life until such a time as they came close enough again.

You can use AddScriptPackage from a script to add the packages when they are needed. RemoveScriptPackage removes the current package for the named NPC, and once that's called they should break out of the cycle again (If you never want them to escape then you never need to call the remove on them).

MVK
User avatar
Philip Lyon
 
Posts: 3297
Joined: Tue Aug 14, 2007 6:08 am

Post » Wed Aug 26, 2009 4:52 am

Have you tried using SetRestrained? It locks NPCs in place (Although they can still be moved by bumping in to them, but at least they themselves won't move...)
User avatar
Kristian Perez
 
Posts: 3365
Joined: Thu Aug 23, 2007 3:03 am

Post » Wed Aug 26, 2009 7:24 am

There are many possible different problems with this but as I can't physically see what's wrong, I'm gonna give you a few suggestions.

First: when you create a new creature, they come with their own AI (default) if you haven't done this then simply delete whatever they previously had there and then put what you want in. (often their base AI will override your own)

If that doesn't work or you already did it, then set their energy level and agression level lower. This will prevent them from attacking (again, I haven't seen the context of this mod) whatever they see and going off and killing it or something.

They might ALSO have a script attatched to them which is easy to fix also; just go to script on the NPC box and scroll up until you get to 'NONE'.

The final thing you might want to look at is if they have a class or a combat style that would give them reason to leave and kill something or look for something to kill.

Hope this helped.
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Wed Aug 26, 2009 3:00 am

Have you tried using SetRestrained? It locks NPCs in place (Although they can still be moved by bumping in to them, but at least they themselves won't move...)
No, I had seen that used before and I tried it and maybe I typed it wrong because Oblivion thought it was a short variable so I threw that idea out I'll try it again., thanks! I know what I did, I must have went set restrained to 1 and that is why the editor thought it was a short and not a function. I bet it will work fine after I do that, I'll let you know.


There are many possible different problems with this but as I can't physically see what's wrong, I'm gonna give you a few suggestions.

First: when you create a new creature, they come with their own AI (default) if you haven't done this then simply delete whatever they previously had there and then put what you want in. (often their base AI will override your own)

If that doesn't work or you already did it, then set their energy level and agression level lower. This will prevent them from attacking (again, I haven't seen the context of this mod) whatever they see and going off and killing it or something.

They might ALSO have a script attatched to them which is easy to fix also; just go to script on the NPC box and scroll up until you get to 'NONE'.

The final thing you might want to look at is if they have a class or a combat style that would give them reason to leave and kill something or look for something to kill.

Hope this helped.

I can't remove their packages, the player can cast this spell on anyone in the game, removing all the ai would break the game. aggression isn't the problem, its when their normal packages kick in they take off and go about their business instead of staying in the cage.

I can't remove the scipt from the actor, I don't know what actor will be down there. Its a power that the player can use on anyone to lure them down to the cage and then the cage has a trigger script which is applied to the npc.

Thanks for the ideas, but I am hoping setrestrained will do it.
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Wed Aug 26, 2009 5:43 am

This whole thing does not sound right.

When you add a package with AddScriptPackage, the NPC will return to the normal AI packages only when
(1) the added package finishes,
(2) the package conditions become false,
(3) a script removes the package - RemoveScriptPackage function
(4) a script replaces the package by adding a new one
(5) a script forces its end using the EvaluatePackage function)
Or, I suppose, (6) the package scheduled date and time expires.

Since a wander package never finishes, check if one of the other conditions is causing it
User avatar
RAww DInsaww
 
Posts: 3439
Joined: Sun Feb 25, 2007 5:47 pm

Post » Wed Aug 26, 2009 4:38 am

Ya, the wander package should work fine if set to must reach location, and must complete. I would use 0 duration though instead of the 24 or whatever you tried. The editor gives an error about must complete on the wander package when loading the esp, but I just ignore it as it does what I need it to.

Make sure you have a couple pathnodes in the cage also as the actors seem to spawn between them on a cell load.
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Post » Tue Aug 25, 2009 9:08 pm

This whole thing does not sound right.

When you add a package with AddScriptPackage, the NPC will return to the normal AI packages only when
(1) the added package finishes,
(2) the package conditions become false,
(3) a script removes the package - RemoveScriptPackage function
(4) a script replaces the package by adding a new one
(5) a script forces its end using the EvaluatePackage function)
Or, I suppose, (6) the package scheduled date and time expires.

Since a wander package never finishes, check if one of the other conditions is causing it

Forgot
(5b) when the NPC is called to run a different package or process due to either external actions (something talking to the NPC) or the NPC simply evaluating their packages as part of normal processing (happens after about 30 seconds).

If you're going to use the AddScriptPackage route for anything, you should make sure that either it is something which can be completed quickly before anything interrupts the NPC, or make it where the package is continuously added to the NPC through scripting.

If you don't want the NPC to do anything but stand there like a rock, you can usually accomplish this with setrestrained, setunconscious, ToggleActorsAI. You can go beyond this if necessary, but that becomes a bit too much overkill.
User avatar
Alan Cutler
 
Posts: 3163
Joined: Sun Jul 01, 2007 9:59 am

Post » Wed Aug 26, 2009 5:38 am

For the record if a scrip package is added to an actor and the must complete flag is checked calling EVP will not remove that package, nor will it be removed when the actor reevaluates in any circumstance. The exception to this is packages that can be completed, like a travel package, or a use item at package. A follow package, for instance, will persist forever if flagged as must complete unless it is removed with removescriptpackage, or another script package is added. In the same way a wander package will persist if flagged as must complete.
User avatar
priscillaaa
 
Posts: 3309
Joined: Sat Dec 30, 2006 8:22 pm

Post » Wed Aug 26, 2009 10:50 am

For the record if a scrip package is added to an actor and the must complete flag is checked calling EVP will not remove that package, nor will it be removed when the actor reevaluates in any circumstance. The exception to this is packages that can be completed, like a travel package, or a use item at package. A follow package, for instance, will persist forever if flagged as must complete unless it is removed with removescriptpackage, or another script package is added. In the same way a wander package will persist if flagged as must complete.

My mistake. For some reason I was thinking that Velwyn Benirus used a script added package which cuts out after about 30 seconds without completing instead of a normal package which cuts out after 30 seconds without completing. It is still a good idea to reinforce a script package periodically at any rate, pretty sure there are ways to disrupt even a "must complete" one which I'm just not remembering.
User avatar
JD bernal
 
Posts: 3450
Joined: Sun Sep 02, 2007 8:10 am

Post » Wed Aug 26, 2009 1:48 am

This whole thing does not sound right.

When you add a package with AddScriptPackage, the NPC will return to the normal AI packages only when
(1) the added package finishes,
(2) the package conditions become false,
(3) a script removes the package - RemoveScriptPackage function
(4) a script replaces the package by adding a new one
(5) a script forces its end using the EvaluatePackage function)
Or, I suppose, (6) the package scheduled date and time expires.

Since a wander package never finishes, check if one of the other conditions is causing it

I tried a wander package with 0 duration, 24, 25 and 1000 hours duration. If you put the must complete flag on he follows you around saying he needs to lock up, like he's a shop owner, and regardless of package length, when his next scheduled package arrives, he is gone. The only thing that has worked so far is setrestrained. So in this case, addscriptpackage doesn't seem to keep the npc there, eventually it expires or perhaps a wander package is a lower priority package internally... the npc disappears.

I'm ok with setrestrained. I just need to remove it so you can let them go if you want. So if its already triggered and the player re-enters it releases the victim. Either that or tie it into the cage door.
User avatar
CArla HOlbert
 
Posts: 3342
Joined: Wed Feb 21, 2007 11:35 pm


Return to IV - Oblivion