Multi point patrols

Post » Fri May 27, 2011 2:23 pm

Hi. Iv followed the Wiki example to create a patrolling guard, and that works just fine, however, what do I do if I want to make the guard patrol from point A to point B and then to Point C ... before returning to point A?

Iv looked at the patrols of the guards in the game, and tried to copy their makeup, but my NPC patrols the first section and ignores all the rest. How can I make him follow the whole series of points and patrol around the whole town?

cheers

MVK
User avatar
He got the
 
Posts: 3399
Joined: Sat Nov 17, 2007 12:19 pm

Post » Fri May 27, 2011 4:01 pm

Hi. Iv followed the Wiki example to create a patrolling guard, and that works just fine, however, what do I do if I want to make the guard patrol from point A to point B and then to Point C ... before returning to point A?

Iv looked at the patrols of the guards in the game, and tried to copy their makeup, but my NPC patrols the first section and ignores all the rest. How can I make him follow the whole series of points and patrol around the whole town?

cheers

MVK


I think this'll work.

make a package to travel from point A to point B, then make a package from point B to point C, and then from C to A.
User avatar
Sophie Morrell
 
Posts: 3364
Joined: Sat Aug 12, 2006 11:13 am

Post » Fri May 27, 2011 2:13 pm

I think this'll work.

make a package to travel from point A to point B, then make a package from point B to point C, and then from C to A.


That's what I did! I basically copied the travel package but started it from point B and sent it to end at point C. However, the NPC doesn't move past point B, and instead of going toward point C he turns around and goes back to point A (and then back to B etc).

This is what confused me - Id assumed that what you just said would work, but for some reason it doesn't. Does the class of the character have any bearing on this, or should any class follow the travel packages like this.

cheers

MVK

[EDIT]
Just to make sure I just removed all the packages bar the sleep package, and set the NPC standing on top of point A. I then added a Travel package to point B, with "Must Reach Location" checked so that the list of packages will be assessed as soon as he gets there. Another travel package follows that should send him to point C and then on to Point A again. There are no times or durations in these packages (as set out in the Wiki page on the travel package).

It fails. The NPC stands on the spot. If I add a condition (GetDistance <512) the NPC does not start on Point A, and appears someplace between A and B, and that's where he stays. If I add the same condition to all of the packages he does the same.

It seems that the duration is irrelevant, that "Must Reach Location" is irrelevant, and that the original starting location of the NPC is irrelevant. I must be doing something wrong, but I have no idea what - as far as I can see Iv followed the Wiki and the advice given here, but I'm still getting no result.

Any ideas?
User avatar
Isaac Saetern
 
Posts: 3432
Joined: Mon Jun 25, 2007 6:46 pm

Post » Fri May 27, 2011 12:10 pm

What you basically need to do is setup packages that work off a controlling condition that becomes set when they've reached the destination of their previous package. The problem however is that in order for it to work, you need to script each actor separately. Meaning that each of your guards has to be a unique NPC with its own packages and scripts. Fortunately however, if you are wanting your NPCs to just keep running through their routines endlessly unless another package is called, you can just make a single package for every route and use both their placement on the list and a controlling condition to decide when they should run that package.

The easiest controlling condition would probably be by using a faction rank which is changed based on what the previous package was. You will probably already have a faction created for these guards, so all you're really doing is making further use of something that is already present. Factions have an advantage over script functions in this case since they don't need to point to a specific actor within package conditions and instead check against the actor the package is attached to (don't need to make unique packages for every actor). Make about a dozen of these to start.

With the package conditions, make the package available at any time, any day, but based on one of those faction ranks you defined earlier. Each NPC will only travel this path for as long as they are set to that specific rank. As soon as they change rank (through scripting) they will move to a different path). For the sake of simplicity, we'll work around the assumption of a square shaped path with a side hall that you also want covered:

#1-----------------#5
|XXXXXXXXXXXXX|
|XXXXXXXXXXXXX|
|XXXXXXXXXXXXX|
|XXXXXXXXXXXXX|
|XXXXXXXXXXXXX|
|XXXXXXXXXXXXX|
#2-----------------#3
|
|
|
|
|
|
#4

The numbers relate to the destination of the package and their respective faction condition. Remember, packages define the end location, not the starting one, so both the conditions and scripts should dictate the destination rather than the path. So, package with condition 1 will have the ending location at #1, package with condition 2 will have an ending location at #2... and so on. All packages should be travel packages.

The script will be dictating which location would be next to be traveled to based around a http://cs.elderscrolls.com/constwiki/index.php/OnPackageDone block. Although you will probably need to make unique scripts for each actor, this is much easier than trying to make both unique scripts and packages. Fortunately, you can use the same scripts for the same actors who walk the same paths (day and night shift) or use the same script for two actors who have different package targets (different package sets). Using the above layout, the script for one patrol route could look like:

begin onpackagedone PRTwalktoNum1setfactionrank 4endbegin onpackagedone PRTwalktoNum4setfactionrank 2endbegin onpackagedone PRTwalktoNum2setfactionrank 3endbegin onpackagedone PRTwalktoNum3setfactionrank 5endbegin onpackagedone PRTwalktoNum5setfactionrank 1end

Although you may need to make multiple scripts, the scripting for each, as you can see, is very simple and low demand.

This would make the actor walk in a counter clockwise pattern from 1 to 4, from 4 to 2 to 3, then from 3 to 5 to 1, ignoring any other small hallway or room connections that might exist in the X'ed area. The thing to watch out for when setting up this route is to avoid circular logic like:

begin onpackagedone PRTwalktoNum4setfactionrank 2endbegin onpackagedone PRTwalktoNum2setfactionrank 3endbegin onpackagedone PRTwalktoNum3setfactionrank 2endbegin onpackagedone PRTwalktoNum2setfactionrank 4end


The problem with this bit is that the return trip from 3 to 2 to 4 won't work since you're using the same package and destination twice. Rather than go back to 4, the NPC would just keep walking between points 2 and 3. To get around this, either you would need to place a new point #6 at the same location as 2, and tie it to the condition of 6, changing it to:

begin onpackagedone PRTwalktoNum4setfactionrank 2endbegin onpackagedone PRTwalktoNum2setfactionrank 3endbegin onpackagedone PRTwalktoNum3setfactionrank 6endbegin onpackagedone PRTwalktoNum6setfactionrank 4end


Or if there are no shorter routes between point 3 and 4, just directing the NPC to point #4 from point #3, skipping 2 entirely.

It's a little complicated, but with a bit of thought and planning can work out rather well. Just remember that you don't need to have the end of a package at every single corner the NPC will cross, or even every turn, but instead only in places where you have multiple routes between two "ends" of the patrol route (point #3 to point #1, point #1 to #3). For all your other packages, just use the normal hourly settings, and place those packages at the top of the list. This will mean that the actor will just keep running his route from the last point he ended on until interrupted by eating/sleeping. By having the packages setup this way, you can have different shifts for the same route and packages, just using different eat/sleep package times. Below those packages add all the patrol packages that the actor will use based on their script.

Before completing the NPC, set their initial faction rank to one of the points within their package route. If you forget to give them a faction that relates to a package destination, they won't do anything. As an actor's faction is controlled in the base form, their rank will constantly be changing, deciding which package to use next, and will persist across play sessions or even respawns of that actor.
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Fri May 27, 2011 9:33 pm

Thanks Vagrant0 - I'll give this a go later on today.

cheers

MVK
User avatar
Penny Wills
 
Posts: 3474
Joined: Wed Sep 27, 2006 6:16 pm

Post » Fri May 27, 2011 8:20 pm

Many thanks for your time Vagrant0 - that worked a treat and my guards can now patrol a far more complex route than before. I'm not too worried about making individual packages and scrips for each NPC, just so long as the end result makes it appear that the guards (and possibly now other NPC's as well!) are walking about with some purpose and destination.

Excellent result, I'm very grateful.

One more point: Using this method is it then possible to have an NPC follow a route that crosses worldspaces and/or move into and out of buildings etc? Its not something that I need to do right away, but Iv been considering a scenario that would require an NPC to cross between two worldspaces and subsequently into a building where he would pick up an item and return with it. This method seems to be good for that, since I can add the item to the NPC when I re-set the faction rank.

In any case, many thanks for your efforts.

MVK
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Sat May 28, 2011 2:31 am

If your question is whether a patrol package to go into another cell/worldspace, then yes - I believe it can. Well, more that I can't see why it wouldn't be able to. I don't see why there would be a restriction on crossing into something new (as there isn't on any other package type).
User avatar
carla
 
Posts: 3345
Joined: Wed Aug 23, 2006 8:36 am

Post » Fri May 27, 2011 11:08 am

Many thanks for your time Vagrant0 - that worked a treat and my guards can now patrol a far more complex route than before. I'm not too worried about making individual packages and scrips for each NPC, just so long as the end result makes it appear that the guards (and possibly now other NPC's as well!) are walking about with some purpose and destination.

Excellent result, I'm very grateful.

One more point: Using this method is it then possible to have an NPC follow a route that crosses worldspaces and/or move into and out of buildings etc? Its not something that I need to do right away, but Iv been considering a scenario that would require an NPC to cross between two worldspaces and subsequently into a building where he would pick up an item and return with it. This method seems to be good for that, since I can add the item to the NPC when I re-set the faction rank.

In any case, many thanks for your efforts.

MVK

There are really only two things you need to remember about using factions in this way:

1. The faction change is applied to the base actor, not the instance, so if you have more than one actor with the same base, they will have exactly the same packages at all times. If you MUST have a similar system work off an instanced actor, you will need to use disposition checks toward a dummy actor to control package behavior per instance (as well as have the same scripts on all actors). The disposition method is not always as reliable, so should not be used for controlling complex behaviors.

2. If the actor is killed or otherwise delayed in the middle of their route, but is respawned or resumes, they will continue from wherever their last package was telling them to go. In regards to crossing cells and worldspaces, this can have some complications in that an actor may take several hours to reach a location that's nearby when they are not within the active area. But, as long as they reach their destination, the scripting that tells them the next one will trigger regardless where the player might be, so you can use this method reliably to move actors around the world so long as their destination is reachable.

Other than that, the viability of this system is really about how its implemented and how the actor and worlds are setup. You may however want to include some sort of safety trigger to default their faction to a specific level should they ever get stuck somewhere.
User avatar
Franko AlVarado
 
Posts: 3473
Joined: Sun Nov 18, 2007 7:49 pm

Post » Fri May 27, 2011 2:38 pm

Thanks. This method will be used on a per NPC basis - I don't re-use NPC's because I'm using them in a fairly small area, and I don't want to be bumping into the same character all over the place.

Destinations will always be reachable, and just so long as the NPC can re-spawn and continue on his way I'm none too worried. The NPC who goes on such a journey would not have a sleep package (or any other package), so he would be very single minded about what he was doing, and Id have no worries about packages interfering with each other.

You may however want to include some sort of safety trigger to default their faction to a specific level should they ever get stuck somewhere.

What would be the best way to implement this? I'm not very good with scripting just yet (I'll get there though!) and I cant see how this would work if it were a condition.

Again, many thanks for your time

MVK
User avatar
BrEezy Baby
 
Posts: 3478
Joined: Sun Mar 11, 2007 4:22 am


Return to IV - Oblivion