[WIPz] NPC ACE - NPC Advanced Control Engine

Post » Wed Mar 30, 2011 9:57 am

It'd be pretty sweet if there was a project to get this system working for NPCs in Oblivion.


Seconded :D
User avatar
Breautiful
 
Posts: 3539
Joined: Tue Jan 16, 2007 6:51 am

Post » Wed Mar 30, 2011 2:43 pm

Seconded :D



I'll Bite......Thirded!!(is that a word?)

Is this something that, with an Instruction sheet anyone could help with ...Say Each person only does 10 NPC's in one City, and turns that in to Be checked over?

Wouldn't take That long to Do all of Vannila?

I realize this is not what the Npc engine is about But if this was implemented would be one of the Hottest Mods out there!!!
User avatar
Deon Knight
 
Posts: 3363
Joined: Thu Sep 13, 2007 1:44 am

Post » Wed Mar 30, 2011 6:50 am

The bottom line is that the work per NPC is not overwhelming, but it is not that trivial either.
The number of NPCs is what makes it discouraging. (there are about 2800 NPCs in the CS)

Besides, for this particular behavior (running when it is raining) there might be other, more generic, solutions.
I suppose it would not be that difficult to devise a mod that uses OBSE's SetPackageAlwaysRun to make NPCs around the player run when raining.


Anyway, I can give you guys an idea of the amount of work:

First, a quick review of the concept:
The engine replaces the AI packages, but runs on similar concepts:
- Instead of AI packages, there are Activities and Stages (data in arrays)
- Instead of package types (wander, travel, etc), there are Actions ( script functions)
- Instead of a series of packages, NPCs have a Schedule (data in arrays)

Starting from the concept bottom:

ACTIONS
Actions are the scripted behavior of the NPCs.
The scripts apply AI packages dynamically, according to the situation at hand. For example, if the NPC is running a Travel action and it starts raining, the script will either equip a raincoat or switch to a 'run to location' AI package.
There are a few already done: Travel to, Wander, Eat, Drink, Sleep and Brawl.
Other behaviors need new scripts.

ACTIVITIES and STAGES
An Activity is pretty much a list of stages to be executed one after the other.
A Stage is a block of data pointing to the Action script and the proper AI package

SCHEDULES
Schedules are the activities the NPC will perform during the day.
Each period of so many hours may have multiple activities to, randomly, choose from. This way an NPC may eat at one place one day and at another place the next day.

Now, what you may need to do to apply the existing engine (no new behaviors) to other NPCs:
Supposing you want to keep the NPC schedule close to the vanilla schedule, creating the NPC schedule would the most time consuming activity.
You need to anolyze the vanilla AI package list, their times and conditions and adapt and transpose it to the proper arrays in the mod.
A final schedule code would look like this:

  call zvActorBuildActivity   oActor  zSleep     6 30   03  9  1 1  call zvActorAddBaseActivity oActor  zSleep  100  zSleepPrivRoom02   call zvActorBuildActivity   oActor  zWander1     4  30   09 13  1 1  call zvActorAddBaseActivity oActor  zWander1  10  zWanderDock01    call zvActorAddBaseActivity oActor  zWander1  15  zWanderDock02    call zvActorAddBaseActivity oActor  zWander1  25  zWanderDock03    call zvActorAddBaseActivity oActor  zWander1  30  zWanderDock04   call zvActorAddBaseActivity oActor  zWander1  10  zWanderFocsle  call zvActorAddBaseActivity oActor  zWander1  10  zWanderFBowl  call zvActorBuildActivity   oActor  zLunch      1  15   13 14  1 1    call zvActorAddBaseActivity oActor  zLunch   80   zEatFocsle    call zvActorAddBaseActivity oActor  zLunch   20  zEatFBowl  call zvActorBuildActivity   oActor  zWander2     4  30   14 18  1 1  call zvActorAddBaseActivity oActor  zWander2  100  zWanderAnvilFountain   call zvActorBuildActivity   oActor  zWander3     3  30   18 21  1 1  call zvActorAddBaseActivity oActor  zWander3  100  zWanderShipDeck   call zvActorBuildActivity   oActor  zDrink      1 20   21 3  1 3  call zvActorAddBaseActivity oActor  zDrink   80  zDrinkFocsle    call zvActorAddBaseActivity oActor  zDrink   20  zDrinkFBowl    call zvActorBuildActivity   oActor  zDine      1  10   21 3  1 1  call zvActorAddBaseActivity oActor  zDine   80  zEatFocsle       call zvActorAddBaseActivity oActor  zDine   20  zEatFBowl       call zvActorBuildActivity   oActor  zWander4     1  30   21 3  1 2  call zvActorAddBaseActivity oActor  zWander4  10  zWanderDock01    call zvActorAddBaseActivity oActor  zWander4  15  zWanderDock02    call zvActorAddBaseActivity oActor  zWander4  25  zWanderDock03    call zvActorAddBaseActivity oActor  zWander4  30  zWanderDock04   call zvActorAddBaseActivity oActor  zWander4  10  zWanderFocsle  call zvActorAddBaseActivity oActor  zWander4  10  zWanderFBowl  call zvActorBuildActivity   oActor  zDefault     .5  10   0 0  0 0  call zvActorAddBaseActivity oActor  zDefault  100  zWanderHome


The first line reads: the period named zSleep runs for 6 hours, +/- 30 minutes, starting around 3AM, ending around 9AM and runs only once
The second line reads: the period zSleep has 100% chance of running Activity 'zSleepPrivRoom02'

While creating the schedule, you will create new Activities and Stages as needed.
Let's say you want an NPC to wander at the Arboretum.
First you need an AI package. The vanilla ones are no good, as they usually have time and duration set. But you may clone it, removing the time and duration from the schedule tab.

The you create the Activity and Stage arrays. The code would look like this:

call zvBuildStage zWanderArboretum01 zzActionWander ArboretumMainGateMarker aaMyWanderArboretumPackagecall zvBuildBaseActivity zWanderArboretum01	zOutdoors zWander call zvAddStage zWanderArboretum01 zWanderArboretum01


The first line reads: create a Stage named "zWanderArboretum01" that uses the Action function "zzActionWander", has a reference marker ArboretumMainGateMarker (a vanilla XMarker) and uses the AI package "aaMyWanderArboretumPackage"

The second line reads: Create an Activity named "zWanderArboretum01" that runs outdoors (for the raining behavior) and is of type "zWander"

The third line reads: Add the Stage "zWanderArboretum01" to the Activity "zWanderArboretum01"

Probably there are a few other minor things that escape me at the moment.
User avatar
Colton Idonthavealastna
 
Posts: 3337
Joined: Sun Sep 30, 2007 2:13 am

Post » Wed Mar 30, 2011 8:41 am

That actually looks like it would be kind of fun to do... I agree about the sheer volume of NPCs is quite daunting, but if enough people got together, we could pull it off :P
User avatar
Hazel Sian ogden
 
Posts: 3425
Joined: Tue Jul 04, 2006 7:10 am

Post » Wed Mar 30, 2011 12:59 am

The bottom line is that the work per NPC is not overwhelming, but it is not that trivial either.
The number of NPCs is what makes it discouraging. (there are about 2800 NPCs in the CS)

Besides, for this particular behavior (running when it is raining) there might be other, more generic, solutions.
I suppose it would not be that difficult to devise a mod that uses OBSE's SetPackageAlwaysRun to make NPCs around the player run when raining.


Anyway, I can give you guys an idea of the amount of work:

First, a quick review of the concept:
The engine replaces the AI packages, but runs on similar concepts:
- Instead of AI packages, there are Activities and Stages (data in arrays)
- Instead of package types (wander, travel, etc), there are Actions ( script functions)
- Instead of a series of packages, NPCs have a Schedule (data in arrays)

Starting from the concept bottom:

ACTIONS
Actions are the scripted behavior of the NPCs.
The scripts apply AI packages dynamically, according to the situation at hand. For example, if the NPC is running a Travel action and it starts raining, the script will either equip a raincoat or switch to a 'run to location' AI package.
There are a few already done: Travel to, Wander, Eat, Drink, Sleep and Brawl.
Other behaviors need new scripts.

ACTIVITIES and STAGES
An Activity is pretty much a list of stages to be executed one after the other.
A Stage is a block of data pointing to the Action script and the proper AI package

SCHEDULES
Schedules are the activities the NPC will perform during the day.
Each period of so many hours may have multiple activities to, randomly, choose from. This way an NPC may eat at one place one day and at another place the next day.

Now, what you may need to do to apply the existing engine (no new behaviors) to other NPCs:
Supposing you want to keep the NPC schedule close to the vanilla schedule, creating the NPC schedule would the most time consuming activity.
You need to anolyze the vanilla AI package list, their times and conditions and adapt and transpose it to the proper arrays in the mod.
A final schedule code would look like this:

snip


The first line reads: the period named zSleep runs for 6 hours, +/- 30 minutes, starting around 3AM, ending around 9AM and runs only once
The second line reads: the period zSleep has 100% chance of running Activity 'zSleepPrivRoom02'

While creating the schedule, you will create new Activities and Stages as needed.
Let's say you want an NPC to wander at the Arboretum.
First you need an AI package. The vanilla ones are no good, as they usually have time and duration set. But you may clone it, removing the time and duration from the schedule tab.

The you create the Activity and Stage arrays. The code would look like this:

snip


The first line reads: create a Stage named "zWanderArboretum01" that uses the Action function "zzActionWander", has a reference marker ArboretumMainGateMarker (a vanilla XMarker) and uses the AI package "aaMyWanderArboretumPackage"

The second line reads: Create an Activity named "zWanderArboretum01" that runs outdoors (for the raining behavior) and is of type "zWander"

The third line reads: Add the Stage "zWanderArboretum01" to the Activity "zWanderArboretum01"

Probably there are a few other minor things that escape me at the moment.


Hey!

Please take this with a grain of salt and take into account that I've never used or researched AI packages in Oblivion.

The way I understand they work is that they provide a schedule and certain actions for the NPC to follow.

The difference between ACE and Vanilla seems to be that your mod uses those AI Packages not directly on an NPC but through a sort of buffer that adds more variety to the types of actions a character may perform. That is, you use Activities and Stages to assign different AI Packages to the NPCs.

As things stand, going through the Oblivion NPCs and making them use this system just so they seek cover in rain seems way too much overkill. Also, should you add additional options and behaviours, it wouldn't work out-of-the-box; someone would have to go through all the NPCs again to add that behaviour. Thirdly, it would only work with Vanilla NPCs or NPCs that have been through the conversion process - it couldn't work with mod added NPCs, again, out-of-the-box.

Now, you have this buffer system in place. What I would like to ask is if another buffer level could be added. One that would take a standard Oblivion AI Package, parse it and convert it to an ACE format on the fly.
Again, my lack of knowledge on the format of the AI Packages makes this harder. But I'll try to give you a bit more information as to what I had in mind. Bear in mind there's a lot of assuming below.

The area an NPC roams is known/can be obtained fairly easy. Having the area, you know the places where an NPC could eat/pray or wander.
The schedule of the NPC is also known. Just using these two, you could change it so that when the time comes for her to go to eat, she would alternate between two or three locations. When she's going to a certain location, other local "highlights" might be chosen as alternatives as well.

Another thing that could be done is varying the schedule more. By that I mean breaking 3+ hour activities into two 1.5 hours or three 1 hour variants. This would work for things that make sense, not for sleeping, for instance.

Knowing the faction of the NPC could net other behaviours that weren't present in the original AI Package. Just take a longer period from her schedule when she was supposed to stand in a certain location and split it, so a portion of it goes towards that new activity. Fighter Guild members could be sent outside of town to nearby Forts or Ruins or Caves, for example.

Other stuff that might be "injected" into the schedule of a certain NPC would be trading, provided she has obtained a certain amount of Gold.

I'm not sure if NPCs can level up, but it would be nice if they were getting stronger. I'm drifting now...

Let me know if this makes sense and if you think it's doable.

Cheers!

cc
User avatar
Patrick Gordon
 
Posts: 3366
Joined: Thu May 31, 2007 5:38 am

Post » Wed Mar 30, 2011 6:09 am

I agree with the first part of what you said and would like add a few comments to put it into perspective:

The development of this engine was aimed to be used by modders that may need better control of their NPCs.
I will need it in my The Evolving Society mod to, among other things, make NPCs work harder or not based on their satisfaction with a series if aspects of their community (like level of security, health services available and others).

It is not designed to be used as is, but rather as a framework to be adapted to the modder's needs.
The original development was on a advlt mod and has some more complex behaviors, but, since (1) it is not proper to discuss a mature mod on public forums (even if just the technical aspects) and (2) I was asked if the engine could be applied to vanilla NPCs, I decided to create a demo mod that could be downloaded and discussed. I chose the raining behavior as the 'theme' for the demonstration of what could be done with this engine.

- - - - -

The differences between ACE and Vanilla go a little deeper:
The first one is as you said: different ways of choosing AI packages. The game has its own algorithm to run vanilla packages (top to bottom, run the first one that meets all the conditions). ACE has a different algorithm: the one described in the previous post is the one the demo uses. Other uses of the ACE engine may implement different rules.

The second aspect is that ACE gives you (the scripter) complete control over the NPC, so you can add activities/behaviors not related to AI packages. For example, using your own example, a modder may want his NPCs to buy things. So he creates a 4-stage activity:
(1) a non-AIpackage stage where the NPC will anolyze her needs and, somehow, decide whether she needs to buy a certain item (Food? Clothes? Weapons? A house?)
(2) a stage that applies a "GoToShop" AI package
(3) a non-AIpackage stage, at the shop, where the NPC will anolyze the available merchandise, the money in the pocket and , decide what to buy (or sell?), exchange money and pickup the item.
(4) finally, a stage that applies a "GoBackHome" AI package.
Come to think of it, the vendor would also have his own Activities. You might even script a haggle, I guess.


Now, you have this buffer system in place. What I would like to ask is if another buffer level could be added. One that would take a standard Oblivion AI Package, parse it and convert it to an ACE format on the fly.


Not possible at the moment. Although OBSE has functions to get/set some things in the AI package (like flags and target), it still does not cover what we would need here, like package type, schedule, conditions and location.
I've requested a set of functions to be able to anolyze and change any data in AI packages.

If and when those functions are added to OBSE (with luck, v19 - many months from now), the conversion on the fly, and your suggestions, might be possible.

Well . . I suppose there is a possibility if you hardcoded ALL the vanilla AI packages in scripts or INI files
You could get the AI packages, dynamically, from the NPCs with GetActorPackages, get the information you need from the hardcoded data and create your ACE Activities and Stages. You also need a duplicate of the AI packages (without times and conditions) to replace the original ones. Not very elegant and, most likely, with a lot of surprises along the way. And won't cover mod-added packages.

- - - - -
@Mr. Tissue Box, ishmaeltheforsaken and camaro-69_327

I am afraid I have to advise against applying ACE to all NPCs for, at least, two reasons:
First, and most important, I don't think the game can handle it. I think up to 100-200 is fine, but, with 2000 NPCs, you would have to handle too many of them every frame or devise a complex system to skip processing on NPCs that are not around and jump-place them on the right spot when they 'come into focus'.

Second, by the time you finish it, somebody may have done it in a more generic way, either using the existing SetPackageAlwaysRun function or new functions that the OBSE team may add. If you are that excited about it, I suggest you invest your time on trying to find a generic way of doing it.
User avatar
Tasha Clifford
 
Posts: 3295
Joined: Fri Jul 21, 2006 7:08 am

Post » Wed Mar 30, 2011 4:54 am

I'm bumping this, before it disappears.
User avatar
Alan Whiston
 
Posts: 3358
Joined: Sun May 06, 2007 4:07 pm

Post » Wed Mar 30, 2011 2:58 am

bump this is to good to die.
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Wed Mar 30, 2011 2:25 pm

But that is exactly what I am planning to do the next couple of weeks: An actual (although quite simple) AI system where the NPCs will learn from their experience and their decision in the future will be affected by their past experience.

Uh oh. Are you implementing some kind of system that will prevent NPCs from discovering a way to grow real bodies, leaving our computers and taking over the world? Just remember people, if all else fails, climb on top of a rock and shoot arrows at them.
User avatar
tegan fiamengo
 
Posts: 3455
Joined: Mon Jan 29, 2007 9:53 am

Post » Wed Mar 30, 2011 11:39 am

This sounds great! Just try to keep it from turning my PC into skynet okay? lol
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Wed Mar 30, 2011 8:42 am

rebump
User avatar
Jennifer May
 
Posts: 3376
Joined: Thu Aug 16, 2007 3:51 pm

Post » Wed Mar 30, 2011 11:20 am

Why don't you ask the obse 19 team when they are finishing off the current beta if they can add so ai scripts.p.s I am not trying to be rude but I saw a post back a few pages about obse 19 and ai scripts.
User avatar
tannis
 
Posts: 3446
Joined: Sat Dec 09, 2006 11:21 pm

Post » Wed Mar 30, 2011 12:15 am

Thanks for the bumps and support, guys.

Why don't you ask the obse 19 team when they are finishing off the current beta if they can add so ai scripts.
p.s I am not trying to be rude but I saw a post back a few pages about obse 19 and ai scripts.


I did ask them last year and, now, OBSE 19 has introduced almost all the required functions to get and set AI package data.

I have not tested them yet, but it seems you would only need to create a number of empty AI packages and 'fill' them on the fly as needed.

Too bad there is not a function to create a new AI package, so you still need to create a pool of empty packages in the CS. I am not complaining, at all. This is a great progress as it will reduce the setup time in the CS.
User avatar
yermom
 
Posts: 3323
Joined: Mon Oct 15, 2007 12:56 pm

Post » Wed Mar 30, 2011 2:32 pm

Too bad there is not a function to create a new AI package, so you still need to create a pool of empty packages in the CS. I am not complaining, at all. This is a great progress as it will reduce the setup time in the CS.
Can't you create cloneforms of an empty package ? You'll have to deal with bloat eventually of course (guess I should work on that temp. cloneform function I'd planned awhile ago).
User avatar
Vicki Blondie
 
Posts: 3408
Joined: Fri Jun 16, 2006 5:33 am

Post » Wed Mar 30, 2011 1:34 am

Good idea!
I've just tested it and, at first, it seemed it worked!

But the FormID of the clone is not saved: when the game is reloaded, the ref is 0.

The cloned AI packages don't seem to be saved either: I saved, then created 1000 cloned AI packages, saved again and the save filesizes are about the same size. I would guess an AI package uses about 100 bytes, so there should be around 100Kb more in the second save.

Maybe this is good news after all: don't have to worry about bloating. Just have so keep the packages values somewhere and re-clone and re-set them at game load.

I will ask at the OBSE thread if this behavior is expected.
User avatar
Isaiah Burdeau
 
Posts: 3431
Joined: Mon Nov 26, 2007 9:58 am

Post » Wed Mar 30, 2011 12:25 am

bump
User avatar
Avril Churchill
 
Posts: 3455
Joined: Wed Aug 09, 2006 10:00 am

Post » Wed Mar 30, 2011 8:29 am

Needs a nice bump on the back, I think...
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Wed Mar 30, 2011 2:49 pm

Just cuz I think this is sorely a needed development, Ima bumper this thing again. I might even have a go at a mod for say, Imperial City Market District. :)
User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Previous

Return to IV - Oblivion