NPC's and door behaviour

Post » Wed Aug 26, 2009 9:19 am

Hi. I'm in the process of playing with NPC AI (again!), and Iv run into an issue.

I have an XMarker on the walkway on a castle wall. There is a door at the base of a tower, and a linked trapdoor on the top of the wall. There are pathgrids that run right up to the door in the tower and from the trapdoor to way past the XMarker.

I assigned a simple travel package to an NPC that required him to walk a short distance, go through the door to the top of the tower and then along the walkway on the top of the wall, however, when he gets to the door he does not go through it, and instead spends the rest of his time walking into the door, bouncing off and trying again.

Is there something specific that i need to do to get the NPC to walk through the door to get where he is meant to be going? Iv not had this problem before, but previously my NPC's have gone through a door to an interior. In this case its through one door and directly out of the next. Iv a feeling that this is causing the problem, but I don't know where to begin in fixing it (Assuming that it can in fact be fixed)

I can already see the alternative, where every tower has an interior with a ladder to get to the roof, but this is hardly ideal for what I had in mind.

Any suggestions?

Cheers

MVK
User avatar
Connor Wing
 
Posts: 3465
Joined: Wed Jun 20, 2007 1:22 am

Post » Tue Aug 25, 2009 11:21 pm

NPCs can't use doors where both the source and the destination lie within the same cell or worldspace. There is no way to get around this without using another interior cell to bridge the gap. Instead of using the door once, they will be caught in some sort of loop. Even scripting the door to move the actor and temporarily prevent usage doesn't seem to work, and will crash the game more often than not.
User avatar
Alessandra Botham
 
Posts: 3440
Joined: Mon Nov 13, 2006 6:27 pm

Post » Tue Aug 25, 2009 11:06 pm

Hmm. Bugger! :lol:

Okay Vagrant0, cheers for that. At least I wont waste time trying to script the blasted thing! It looks like Ill have to path them through a small interior to get them there.

Cheers

MVK
User avatar
Mrs. Patton
 
Posts: 3418
Joined: Fri Jan 26, 2007 8:00 am

Post » Wed Aug 26, 2009 6:00 am

Hi.

I have done a little testing, added an interior for each tower of a castle gate with a door and a ladder to move between the ground outside and the top of the gate.

Using a script and the faction rank I have an NPC who should move in a constant circle, from the ground, into tower one on the gate, through the interior, up the ladder to the top of the gate, across the top of the gate, through a trapdoor into the interior of the second tower, and then through another door to return to the ground outside. Real simple.

Using the same method and script I can have the same NPC walking in short little circles wherever I want him - so the script and the packages work okay.

However, my NPC is displaying some pretty odd behavior. He will happily enter the tower through the door, but instead of moving across the tower (its empty, so nothing is in the way and it has a pathgrid to get him between door and ladder, just in case!) he will stand on the spot doing nothing until I enter the tower interior to find out whats he's up to, at which point he will head directly for the ladder and exit to the top of the gate as he is meant to.

He is quite able to make his way across the top of the gate, and he uses the trapdoor to get down into the second tower, where once again he will stand waiting until I enter the same cell.

All of the packages used are Travel packages with 'Must reach location' checked, no time limit, and the correct faction rank condition.

Any ideas why the NPC is waiting on the spot? It seems almost as if he is waiting for me to refresh the cell, but I don't know why. here is the script:

ScriptName Militia01Scriptbegin onpackagedone Militia01Patrol00  setfactionrank AMilitia 1endbegin onpackagedone Militia01Patrol01  setfactionrank AMilitia 2endbegin onpackagedone Militia01Patrol02  setfactionrank AMilitia 3endbegin onpackagedone Militia01Patrol03  setfactionrank AMilitia 0end


As I say, this works fine if the XMarkers that each package is aimed at are outside, but as soon as the NPC goes inside the tower he stops, apparently until I enter the tower and presumably refresh the cell or something.

Any ideas?

cheers

MVK
User avatar
Latino HeaT
 
Posts: 3402
Joined: Thu Nov 08, 2007 6:21 pm

Post » Wed Aug 26, 2009 9:05 am

I believe there's a bit of "tree falling in the forest" happening here. The game engine doesn't always run the details of AI packages when they don't show (because the player's not there to see it), it just looks at who is supposed to be around at that time and makes sure they're doing what they should.

In this case, once the NPC moves into a different cell from the Player, it doesn't bother processing him any more, but will check to see what the character should be doing when you visit the cell. Since your packages don't have a schedule, just a sequence, it's not going to move him until you watch. However, if you had a package that says he has to be in the gate interior on Sundas at noon, he'll get there at that time, if you're there to watch him arrive.

Think of it as "Load the cell or worldspace the player is in; see who should be there with him/her; have them do what they're supposed to do." If you fast travel to where this AI loop happens, the NPC will always be doing the first leg where he heads inside the tower, because that package is the first match for the conditions. It won't be figuring out how long a circuit takes, and looking at the clock to make the decision, because that's too much work.

That also explains why a character who has no valid path to another location can get there if they have an AI package that places them there. The engine is just evaluating the endpoint, not the path to get there, when it places an NPC into the cell where the player is. Valen Dreth may be permanently locked in a cell in the starter prison, but if you give him a (higher priority) AI package to wander in the Archmage's bedroom, he'll be there without unlocking his door or joining the Mages Guild.

There are a few exceptions around, of course. If an NPC is a quest target, then the target arrow is always in the player's view, and will be updated for an appropriate location of the NPC, but again, this is only done when the arrow is viewed. The new position is estimated and shown on the map, but the NPC is only moved to the corresponding point if you go look.
User avatar
Flesh Tunnel
 
Posts: 3409
Joined: Mon Sep 18, 2006 7:43 pm

Post » Wed Aug 26, 2009 5:45 am

Okay, thanks. That makes perfect sense, but.... whats the solution? I need the NPC to move from the a door at ground level to the top of the gate, walk across it and return 'through' the other door (Of course there is more to it than that but there is no point proceeding with the idea if this section cant be done!).

Would it work if I placed a Trigger Zone just inside the first door (which the NPC goes through without an issue) that moved him to the roof of the gate?

I'm not sure how to proceed. I have castle with walls all the way around and Id like an NPC to be patrolling the walls, but that means moving 'into' a tower to reach the top, across the top, and then back 'into' it to reach the walkway on the other side.

Any ideas?

Cheers

MVK
User avatar
Dagan Wilkin
 
Posts: 3352
Joined: Fri Apr 27, 2007 4:20 am

Post » Wed Aug 26, 2009 1:44 am

Although you can force the actor into a higher processing priority by flagging them as a quest object, this can have some unwanted consequences, especially if the actor is just meant for scenery. The solution, as unfortunate as it seems, is to just not have that part of the route with one single actor. At least from a reality standpoint it can make sense since nobody would want to go constantly climbing up and down a tower several times a day on patrol. A person patrolling at the top would likely remain there for most the day, and may even be camping out in the top of the tower. The person on the lower level would likely keep their route to those areas that don't require lots of climbing around.
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm

Post » Wed Aug 26, 2009 11:06 am

Thanks Vagrant0.

I was actually just considering my options in this respect anyway. From what has been said it seems that providing the NPC has to be at point X at a specific time, that's where he will be, even if he doesn't actually go through the tower. There is also no reason why I cant have the NPC sleep in the tower and simply come out and stand about as part of his patrol - just so long as I have someone on the walls looking busy, as you say, not many people will want to follow him around to see what 'else' he does.

Cheers

MVK
User avatar
Michelle Chau
 
Posts: 3308
Joined: Sat Aug 26, 2006 4:24 am

Post » Wed Aug 26, 2009 6:14 am

what do you know about subspaces?

http://cs.elderscrolls.com/constwiki/index.php/SubSpace

;)
User avatar
Tanya Parra
 
Posts: 3435
Joined: Fri Jul 28, 2006 5:15 am

Post » Wed Aug 26, 2009 1:13 am

what do you know about subspaces?

http://cs.elderscrolls.com/constwiki/index.php/SubSpace

;)

Not much :)

However, looking briefly at that link it seems that it doesn't apply when the door that the NPC needs to use is actually a normal teleport kind of door, for example one at the bottom of a tower that links to a trapdoor on the top of the tower. Ill still experiment though! Cheers

MVK
User avatar
maria Dwyer
 
Posts: 3422
Joined: Sat Jan 27, 2007 11:24 am

Post » Wed Aug 26, 2009 1:46 am

what do you know about subspaces?

http://cs.elderscrolls.com/constwiki/index.php/SubSpace

;)

If you've managed to get it to work with NPCs, I would love to see it. In all my tests, it didn't change anything, so it's probably not so simple.
User avatar
Michael Korkia
 
Posts: 3498
Joined: Mon Jul 23, 2007 7:58 pm

Post » Wed Aug 26, 2009 5:16 am

Not much :)

However, looking briefly at that link it seems that it doesn't apply when the door that the NPC needs to use is actually a normal teleport kind of door, for example one at the bottom of a tower that links to a trapdoor on the top of the tower. Ill still experiment though! Cheers

MVK


where do you read that? subspaces are exactly for this purpose: a door that teleports to the same cell.


If you've managed to get it to work with NPCs, I would love to see it. In all my tests, it didn't change anything, so it's probably not so simple.


maybe it's much simpler than you think? just place the subspace, done. NPCs use the door that teleports to that subspace.
User avatar
Lisa
 
Posts: 3473
Joined: Thu Jul 13, 2006 3:57 am

Post » Wed Aug 26, 2009 12:48 am

maybe it's much simpler than you think? just place the subspace, done. NPCs use the door that teleports to that subspace.

Are you guessing, or have you actually done this? Although a subspace will work in the case of two doors in an interior leading to the same exterior for the purpose of separating the ground floor from the balcony, it doesn't work when there is no interior between them. The player can use this door, but NPCs still get caught in the same old loop.
User avatar
Bethany Watkin
 
Posts: 3445
Joined: Sun Jul 23, 2006 4:13 pm

Post » Wed Aug 26, 2009 2:25 am

Are you guessing, or have you actually done this? Although a subspace will work in the case of two doors in an interior leading to the same exterior for the purpose of separating the ground floor from the balcony, it doesn't work when there is no interior between them. The player can use this door, but NPCs still get caught in the same old loop.


i did it inside of an interior cell with no other cell in between.

maybe it just doesn't work for exteriors. or you did it wrong...
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Tue Aug 25, 2009 11:11 pm

i did it inside of an interior cell with no other cell in between.

maybe it just doesn't work for exteriors. or you did it wrong...

Well then that isn't exactly the same situation that we're dealing with now is it. You might want to save that smug "all-knowing" attitude for when you actually know what you're talking about.
User avatar
KRistina Karlsson
 
Posts: 3383
Joined: Tue Jun 20, 2006 9:22 pm

Post » Wed Aug 26, 2009 5:10 am

ok, if this really doesn't work in exteriors, i have another idea:

you could link the ladder to a dummy interior cell, link a door from there to the roof. then add an OnActivate block to the door, that teleports directly to the roof. NPCs would use the door like any 'normal' door. of course you would still need subspaces.

just take care: the moveto funtion acts as a return called on the player and called on any other actor no remaining scripts will execute in this frame! setpos can crash the game when used on the player.


Well then that isn't exactly the same situation that we're dealing with now is it. You might want to save that smug "all-knowing" attitude for when you actually know what you're talking about.


sorry, i did not realize that you are a wannabe all-knowing person. i just wanted to help. and telling something that the asker did not know yet should not be called all-knowing and especially not attitude at all...

AND: nothing is EVER the exact same situation. sharing experience and knowledge means we have to transfer. that this would not work here could no one know, especially if it's claimed to work in the wiki. it's just another anomaly. IF you really did it right. which i don't beleave. because your attitude is a bit to much 'nothing-works-everything-is-a-big-problem' and you don't even consider that you may fail...

AND:

NPCs can't use doors where both the source and the destination lie within the same cell or worldspace.


this is definitely wrong. i successfully did this in interior cells. so do YOU actually know what you're talking about?! ;)
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Wed Aug 26, 2009 9:25 am


Are you purposely trying to start something here or are you just naturally this abrasive towards others?

As I already explained, while scripting the doors to move an actor "can" work, it also causes quite alot of instability in the game. Using moveto or movetomarker on NPCs to move them from an unloaded cell to an unloaded cell does not always work well, and in the case of a door which might be used several times a day by a persistent and patrolling NPC, this is only opening up the chance for things to go horribly wrong. Furthermore, some looping or multiple activation of the door may still occur as the NPC may still be trying to reach the point they were last traveling to even after being moved.

NPCs can't use doors where both the source and the destination lie within the same cell or worldspace.

this is definitely wrong. i successfully did this in interior cells. so do YOU actually know what you're talking about?! ;)

I have not seen this happen, have not had it happen in my own modding since there are very few times where you NEED to have a teleport door lead to another part of the same cell, but cannot be reached normally (subspaces prevent this for NPCs), when such a situation would not benefit more from just being a separate cell. I accept that it might be possible, and that I might be wrong to some degree, but don't see how this argument is relevant to THIS situation. If it happens or not it doesn't change the fact that it cannot be applied to the problem at hand. My comment

You might want to save that smug "all-knowing" attitude for when you actually know what you're talking about.

was directed more at the way that you suggest things which you have not personally tested and know works... And your general attitude.
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Wed Aug 26, 2009 9:20 am

Using moveto or movetomarker on NPCs to move them from an unloaded cell to an unloaded cell does not always work well, ...


thank you for this hint. but there's a really simple solution for this:
the cell is loaded if you can see the guard. if he is not loaded, he doesn't have to get teleported via moveto, because the player doesn't watch him taking the route through the dummy cell.
(the engine doesn't actually move NPCs that are not loaded, it just calculates the 'result' of the movement and will put him in the right place when a cell gets loaded. ghastley already explained it...)
just check if the player is in the same cell as the NPC in the OnActivate block.

@Vagrant0:
please stay on topic. we try to find a solution here. if you have something constructive to add, fine. if you want to block the solution because it's not YOUR idea or if you just want to put me down, talk with a therapist instead.
User avatar
Shannon Lockwood
 
Posts: 3373
Joined: Wed Aug 08, 2007 12:38 pm

Post » Wed Aug 26, 2009 10:40 am

Sorry guys, I didn't want to provoke a fight!

Anyway...

just check if the player is in the same cell as the NPC in the onactivate block


I understand the words and what they mean but I have no idea how such a thing would be implemented or what the purpose would be. Does this mean that if the player is in a different cell then the NPC would move to the top of the tower, but not otherwise? If so the solution might work in theory but not in this instance: I can see several cells at the same time, including the NPC's on the wall etc. So I would see NPC's on the other side of the city moving up the tower, but the ones standing next to me would not (Its quite a small open city).

Currently Iv skipped this behavior, and the NPC,s on the wall stay there forever in their patrol, while those below patrol around the city buildings. It would just be nice to have the NPC's able to walk across the city, up a tower to the wall and back down the other side somewhere.

Thanks for your efforts guys.

MVK
User avatar
Katey Meyer
 
Posts: 3464
Joined: Sat Dec 30, 2006 10:14 pm

Post » Wed Aug 26, 2009 10:47 am

Does this mean that if the player is in a different cell then the NPC would move to the top of the tower, but not otherwise?


sorry, i wrote it wrong. you have to check if the cell with the NPC is loaded which for exterior cells doesn't have to be the same cell. (it's a 5x5 grid by default.)

the NPC will always move to the top of the tower. but if his cell is loaded he gets teleported, otherwise the AI calculates his way through the dummy cell if the package is scheduled or positions him like ghastley explained.
User avatar
Darren Chandler
 
Posts: 3361
Joined: Mon Jun 25, 2007 9:03 am

Post » Tue Aug 25, 2009 10:46 pm

Okay thanks side, Ill look into that tomorrow.

MVK
User avatar
Queen Bitch
 
Posts: 3312
Joined: Fri Dec 15, 2006 2:43 pm

Post » Wed Aug 26, 2009 5:20 am

thank you for this hint. but there's a really simple solution for this:
the cell is loaded if you can see the guard. if he is not loaded, he doesn't have to get teleported via moveto, because the player doesn't watch him taking the route through the dummy cell.
(the engine doesn't actually move NPCs that are not loaded, it just calculates the 'result' of the movement and will put him in the right place when a cell gets loaded. ghastley already explained it...)
just check if the player is in the same cell as the NPC in the OnActivate block.

All well and good, except that once again, in this case it isn't much of a solution. At any given time, there are 25 or more active cells around the player, meanwhile the player is only in one of them. Meaning that if the player is in any nearby cell at the moment of activation, the NPC would not be moved with scripting, and would become stuck momentarily within the interior cell until the player was no longer in the area and enough time had passed for the NPC to move to his package location. While you fixed yourself and mentioned this, you didn't explain how this would be achieved or that it would require specific scripting of each door. Furthermore, the door scripts would be constantly triggered when used by anyone (along with the constant check to see if they're loaded) which could lead to minor performance issues and instability depending on how quickly the NPCs run their routes.

You may not want to accept it, but in this case, it's simply easier and ultimately better to just have another guard who handles just this part of the wall. The reality is that all of this stuff related to working around a flawed game mechanic isn't worth the effort when everything is centered mostly around just making the guards look busy and functional. If Max was needing to have an NPC perform this route as part of some sort of quest sequence, it might make more sense, and might be practical, but as it is here, doing what you suggest is not.

I know you mean well, but I don't see how all this guessing about possible solutions is helping anything.
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Wed Aug 26, 2009 2:53 am

While you fixed yourself and mentioned this, you didn't explain how this would be achieved or that it would require specific scripting of each door. Furthermore, the door scripts would be constantly triggered when used by anyone (along with the constant check to see if they're loaded) which could lead to minor performance issues and instability depending on how quickly the NPCs run their routes.

And now perhaps we reach a crux: As I mentioned, currently the NPC's have allocated places and that's where they stay. None of the NPC patrols use these doors now, they are either on the wall patrol or they are not.

As much as I want this to work the fact remains that these NPC's are mostly scenery to give the impression of a bustling little community. I say mostly scenery, because the NPC's currently in question are Militia who attack enemy guards from others cities should they chase the player. This means that at some point a wall guard might well jump off the wall to attack an enemy, in which case, if my understanding is correct, they will appear back on the wall where their package says they should be, but not until the player has left the area and returned.

If I reach the stage, which it seems I might have done, where to make this work will require an inordinate amount of scripting and could even cause performance issues, then Id rather stick with the current situation and learn from this exchange as best I can. What is important is that the city appears to be populated, with someone going somewhere at pretty much any time of the day. The patrols on the ground and the patrols on the wall manage this, even though there is no deliberate interaction between them anymore, and, as I think someone here pointed out to me, the chances of a player actually following the guards around for a whole day just to see what they do, is quite limited.

It would be nice to have a bustling community, where every NPC has multiple packages so that they are not doing the same thing every time the player sees them, but in this particular case it would seem that the best bet would be to stop trying to make more work for myself, and live with something that will only be seen as robotic if the player spends enough time watching to see if there is a guard change or if a guard uses the towers, which of course does not happen.

I like the idea of being able to include such realism, but in this instance I don't think there is any point in chasing perfection, especially when it means a ton of work and possible performance problems; I am adding NPC's as the Quests follow the plot line, so the city will become busier as the story unfolds (If there is space once all the quests are done with, then Ill add some more NPC's), and I wouldn't want a performance hit halfway through the mod, simply because I chased this particular issue too hard.

Id like to thank both of you for your input, and I apologize for being so tenacious with this issue - I'm feeling my way along at the moment, and probably getting carried away with the possibilities for realism that I see. I appreciate the time that you've given this question, and I think that now would be the time to call it a day.

Many thanks

MVK
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Wed Aug 26, 2009 5:28 am

I like the idea of being able to include such realism, but in this instance I don't think there is any point in chasing perfection, especially when it means a ton of work and possible performance problems;


it's 5 minutes work for the script and 20 seconds for each door. no performance hit because the script runs OnActivate only. it's really easy. don't get discouraged! especially if you say the guard had to JUMP from the wall otherwise!

i will tell you how to do it: create an invisible activator, put it in the same cell as the door, make it a parent for the door. in the OnActivate block of the door check if the activator is loaded. (use GetParentRef, check if it's valid.) that's it.

if you (or anyone) really fear performance or stability issues with such a simple solution, you (or anyone) should not mod at all. sorry. i made more than one mod with REALLY complex scripts thousands of lines and the weirdest workarounds and i still run 200+ mods. i can play HOURS before i get the first CTD (if any). and i don't get any CTD's reported from thousands of users of my mods (except the ones that are to stupid to install the needed OBSE version).

again: don't let them discourage you!

;)
User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am

Post » Wed Aug 26, 2009 2:10 am

Hmm, thanks.

I'm not discouraged, not at all. This is my first foray into modding Oblivion, I'm not new to the process, although I am to the engine and editor - Iv been modding games since the first Quake editor (Eep! I'm showing my age!) and I'm not discouraged easily.

In this case Iv made about half a dozen mods, experimenting with different things, and Iv amalgamated most of them into a single story line. The thing that comes hard at the moment is getting my head around the way scripts and world objects interact and the restrictions they have. Scripting of itself is not an issue - Iv scripted before, its just getting to grips with a new language and environment.

Currently I'm just playing with getting the links between Quests 1 and 2 smoothed out and cleaning up some of the little bits and bobs as I go. This issue with the NPC's going through towers is aesthetics rather than a real requirement to the mod, but I'm starting to learn that the realism in the game is based on the where and when of the player;
As long as something is going on while you are there, things look busy, and unless you spend ages following people around you wont actually have any idea that their lives consist of pretty much nothing but what you see. (One guard on the wall is the same as the next one unless you follow the guy around through his whole shift!)

However I must stress that I appreciate the time that you and everyone here has given me - I learn while I work which means I live in places like this and post question after question. So....

Thanks again for your time, and no, I'm not discouraged in the slightest!

Cheers

MVK
User avatar
Craig Martin
 
Posts: 3395
Joined: Wed Jun 06, 2007 4:25 pm


Return to IV - Oblivion