Implementing NPC schedules

Feedback on past, current, and future development.
Post Reply
Golken
Posts: 27
Joined: 04 May 2015, 05:03

Implementing NPC schedules

Post by Golken »

Has there been planning of this feature? It definitely seems to be a thing that should warrant discussion. Especially when approaching 1.0, as work on features like this is supposed to start after that release.

As would be expected, OpenMW should offer the ability to add NPC schedules in a more native, far better (and bug-free) and seamless way than possible with vanilla mods. There's questions of how to go about implementing schedules, attaching them to NPCs, and allowing loaded mods to modify them (and easily provide new schedules for their new NPCs), as well as how to maintain compatibility with quests, mods that may make NPCs move around or become able to be temporary or permanent followers of the player, and as such. As well as how our implementation and results will compare to those of the later TES games.

I don't know much about Oblivion and Skyrim's implementation of schedules. I understand that they are implemented as sort of passive AI packages, which are made functional by keeping such AI active in the background even when the NPC is not loaded (i.e. not in a loaded cell). Keeping AI active may be useful anyway to allow such things as reacting to the player leaving the cell (following or pursuing beyond the cell, or maybe retreating to a safe spot or healing, or perhaps in a certain location actually going up to the roof or a watchtower to snipe at the retreating player from), but do we want to implement schedules in a similar way, or a different one? How is the moddability and compatibility of that approach?

On the topic of per-NPC schedule creation, it's possible to use the existing schedules that were created for Morrowind so far (for LCV) as a base, in fact it is possible to directly use the LCV Schedules.etxt base file that defines them, and convert it to whatever data we would be using, perhaps even in the end we could take a similar approach and use loaded data in such a format that dynamically defines schedules. We could have schedule records in a mod file that would use such a (similar or not) text format, which would obviously be expanded.
Schedule records could be named (have IDs), and there could be some sort of setup to attach certain schedule records to a certain NPC or group of NPC by default, as well as to add and remove them dynamically from an NPC by scripting functions. This could be reminiscent of how dialog works; include possibilities to be based on conditions such as the NPCs location, faction membership(s?), race and class, even Disposition to the player, journal entries/quest progress, global vars et cetera.

It should be mentioned that the Living Cities of Vvardenfell project does more things which we could also want to support, and not all are included in the aforementioned LCV Schedules.etxt file; here is the LCV feature list from its readme, I think said etxt file only pertains to the first item on it:
• Adds schedules to the NPC's in many of the towns in Vvardenfell (see Areas Covered), but does not modify, in any fashion, individual NPC's (thus avoiding incompatibility with other mods). NPC's will go home at night, go to bars, go out at night, go shopping, go walking, and live their little lives on a daily basis. More guards come out at night (works brilliantly with mods such as TLM), and the schedules of NPC's have been done so as to imply who is sleeping with who, who is the shady business elf, so on and so forth.
• Adds training sessions at several locations.
• Adds fishing boats at fishing villages.
• Adds NPC lodging at some locations.
• Dims lighting for many cells at night.
• Adds schedules to door locks. Homes and places of business will now be locked at night.
Some things (like training, brawls and eating) could actually be directly added with new markup to the schedule text format in OpenMW with little issues - as well as missing things, such as sleeping (and working animations, such as fishing and mining?).

Door lock scheduling is almost a separate thing (which is also handled by a separate ESP in LCV), but we definitely want a more robust and flexible method of implementing it than present in the Morrowind engine, so that any cities and city overhaul mods can be supported by it, without the need for specifically-made patches for any modified or new city.

A possible idea on this is to affect (dynamically) all doors within a city, allowing for some exceptions depending on the door's parameters (i.e. id/mesh, position, destination), so that doors leading into tavern cells are never automatically locked, also with the possibility to control it from quests/scripting as well so that a place can stop getting locked at night after an event happened or the player befriended the owner or a faction or has a high rank. The implementation might include adding a flag to door instances whether they should be autolocked or not...

Another, different way to go about it could be better, though: simply include the door locking as a actual part of the NPC's schedule, so it is a task in it just like 'eat' or 'sleep' or 'go to a new location or cell'. It could just be an invisible task that happens whenever the player is outside of the NPC's house (but doesn't start on time if the player happens to be inside it at the moment, so he isn't locked in - the same could apply to the sleeping task). It would work in the following dynamic manner: the NPC's private schedule would specify which buildings (interior cells) belong to the NPC, and at which time(s) he locks and unlocks them. The schedule doesn't need to include anything more on the matter (except perhaps the exterior cell(s) of where those owned buildings reside, if that cannot be reliably gotten automatically - but it should be possible to keep an index of all the doors leading to a given cell, if nothing else) - the lock and unlock actions will automatically effect all doors in the exterior that point to an owned cell (so city overhaul/re-landscaping mods that move around doors to existing interiors, delete some doors and add new ones, are automatically supported without a hitch).
This way, door locking is opt-in per door (it won't be locked if the schedule doesn't say so, so taverns are automatically exempt), and also will cease on its own if all the owners of a building are now dead (if you add ownership to the Mages Guild guildhall to all guild members in it, then if any one of them is alive it will continue to be relocked, but won't once they're all dead), since dead NPC's schedules wouldn't process. Exceptions could be added so that doors are only auto-unlocked if they are currently locked as a result of automatic scheduling, doors which are always locked by default (i.e. locked in the ESP/ESM that added them) are not touched, and further, specific/manual per-door exceptions might be made in some manner, again based on door parameters (id, mesh/type, etc). So some careless NPC could lock all the doors leading into his house, but not the trapdoor(s).


Thoughts and ideas?
User avatar
Sslaxx
Posts: 233
Joined: 12 Aug 2011, 18:59
Location: Malvern, UK
Contact:

Re: Implementing NPC schedules

Post by Sslaxx »

In itself, no OpenMW won't implement NPC schedules, but it's likely going to make a mod that does easier to implement.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Implementing NPC schedules

Post by Zini »

Actually, no. In one way or the other we will add a framework for NPC schedules to OpenMW. Doing schedules with scripts only (mod) is too much of a pain in the arse. But we need to figure out an approach that is sufficiently configurable to not force a specific type of NPC scheduling on the modding community. I haven't given the issue much thought yet and unless there is a developer who really want to push it, we won't see the feature in the near future (i.e. 1.1 or 1.2).
Golken
Posts: 27
Joined: 04 May 2015, 05:03

Re: Implementing NPC schedules

Post by Golken »

Zini wrote:Actually, no. In one way or the other we will add a framework for NPC schedules to OpenMW. Doing schedules with scripts only (mod) is too much of a pain in the arse.
Yeah. It's very messy. Knowing that, I created this thread.
Zini wrote:But we need to figure out an approach that is sufficiently configurable to not force a specific type of NPC scheduling on the modding community. I haven't given the issue much thought yet and unless there is a developer who really want to push it, we won't see the feature in the near future (i.e. 1.1 or 1.2).
Sure, maybe it will only end up in even 1.5 or later, who knows. I only said that it would be on the list of things to do once v1.0 is out. I guess a temporary/preliminary, primitive version may naturally come earlier, by virtue of letting existing LCV run under OpenMW without the engine bugs it suffers under Morrowind. Naturally, it wouldn't be very extensible, work the best, play well with everything, or be convenient to work with, but it would function.
Zini wrote:But we need to figure out an approach [...]
Yep, before work can begin on developing it in earnest, it needs to actually be carefully designed, first. Hence, this thread.
ezze
Posts: 513
Joined: 21 Nov 2013, 13:20

Re: Implementing NPC schedules

Post by ezze »

Let's start with some raw ideas then...

As very beginning we need actions to do; examples includes: sleeping, drinking, eating, training. Each would require its animations and possibly sounds.

We probably do not want to setup schedules for each singular NPC, but we need generic packages that can fine tuned or applied to a single NPC if it is the case.
For example: fisherman: wakes up at 7, eats, go fishing, comes back at 17, eats, goes to bar, drinks, goes to sleep at 20.
What is his bed, kitchen, where to fish, and which bar he wants depends on the single npc.

For each action we need AIs about how the npc reacts if the action is not possible or something is wrong. Examples, what is the player (or a random animal) killed the barman? What is the player is inside the home when he comes back?
This brings new actions like: attack, call the guards, complain. In Oblivion, for example, if a house owner wants to go to sleep he asks the player to leave in order to close the door.
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Implementing NPC schedules

Post by Chris »

ezze wrote:As very beginning we need actions to do; examples includes: sleeping, drinking, eating, training. Each would require its animations and possibly sounds.
Generally, these basically fall under 'go to marker/cell, find/use item or object'. It would be a good idea to take a look at how Oblivion does it, check how it defines packages and how NPCs execute them (even if we don't do it the same way, it would a least give a starting point for dos and don'ts).
Post Reply