Advancing the state of commoner AI
#1
Posté 29 juin 2011 - 02:15
So I wanted to ask what kinds of things would people be interested in seeing out of commoner behavior?
#2
Posté 29 juin 2011 - 02:56
Modifié par BartjeD, 29 juin 2011 - 02:56 .
#3
Posté 29 juin 2011 - 03:10
#4
Posté 29 juin 2011 - 03:32
Hide and seek is already there but things like Simon Says or Tag would be neat to see and add variety.
Jobs are difficult in NWN especially since you have to account for the placeables and surroundings. I'd think of chores such as cleaning up things, keeping it tidy, repairing damaged doors and placeables. Taking out the garbadge is another one that would be funny
Modifié par BartjeD, 29 juin 2011 - 03:34 .
#5
Posté 29 juin 2011 - 04:25
#6
Posté 29 juin 2011 - 05:07
#7
Posté 29 juin 2011 - 05:28
The childrens game Ding dong ditch/knock knock Ginger would be doable, since it requires only a single npc and some doors/waypoints. Soccer would be out, too many npcs interacting with each other as a group.
Uncle FB helpfully provides a number of common cases, hide and seek, bartender/maid etc. I should just be able to use his templates to predefine more activities and build in variability.
#8
Posté 29 juin 2011 - 06:16
It might be worth looking at some of the HotU scripts. There are a lot of ambient scripts (I think prefixed "x2_am_") for doing stuff like waitressing already. I've never tried them so I don't know if/how well they work, and one or two may not work in NWN2, but it seems like there might be a whole load of stuff one could use without having to re-write it all from scratch.
Tig/tag would be pretty doable (I think they actually had it in the NWN1 OC somewhere) and you probably could do football, at least medieval-style football where there's no off-side, etc, though it would take a little more work (a variable for the team, two goal waypoints or triggers, then it's just one-on-one between each player and the player with the ball) and you wouldn't be able to see the ball anyway unless you made some sort of vfx for it.
On the streets, a lot of peasants can just be walking about, because most people you see on a street are just going somewhere indeterminate anyway (recall, if you've ever seen it, The Trueman Show, where the motorist, cyclist and pedestrian just keep walking around his house), but interiors and features like inns and taverns, shops, and perhaps temples, could use a bit of something to bring them to life.
#9
Posté 29 juin 2011 - 06:53
I'll have to look at lugiads work, no point reinventing the wheel if he's done a lot of this. No longer have nwn1, so maybe someone could dig up those scripts.
#10
Posté 29 juin 2011 - 07:00
http://nwvault.ign.c...l.Detail&id=297
It uses a custom spell so you will need a modified spell.2da
#11
Posté 29 juin 2011 - 08:10
I like the sound of your proposal to use several systems, You can draw the best from each to give a lively ambience to the city.
If I were to add more I would like, in additon to many of the above, to see fishing, kissing, sawing I would very much like preist who blessed people, also I would love to see your street entertainer working.
The streets of Crimmor are calling me
PJ
#12
Posté 29 juin 2011 - 08:26
Men negotiating with prostitutes? People doing or playing some kind of medieval sport? Bar fights?
#13
Posté 30 juin 2011 - 12:47
I'm adding the ability to set schedules to the minute instead of hour, and have each of the six time periods in Uncle FB's system both start at a random time offset from the defined base time, and optionally last a random amount of time instead of exactly x hours.
#14
Posté 01 juillet 2011 - 12:32
//sleeping midnight behavior for beds
//sleeping midnight behavior for benches etc...
//sleeping behavior for beds
//sleeping behavior for benches etc...
//Agreeable conversation behavior
//Angry conversation behavior
//Sad conversation behavior
//Standard Cook Behavior
//Multiple location cooking behavior
//Standard Dancing Female Behavior
//Standard Dancing Male Behavior
//Standard drumming behavior for NPC
//Standard flute behavior for NPC
//Standard forge behavior for NPC
//Multiple location forge behavior
//Standard guitar behavior for NPC
//Standard woodsman behavior for NPC
//Standard meditate behavior for NPC
//Standard stand post behavior for NPC
//Standard reading (sitting) behavior for NPC
//standard sitting behavior (no eating)
//Standard dinner behavior (sitting)
//Standing behavior (chat, laugh, etc...)
//Training routine for armed combatants
//cheering and clapping behavior
//Trainer Pacing behavior
//Standard WWP behavior
// standard thief behavior
//Thief behavior where the thief actually steals
//Assassin behavior where the Assassin actually kills
//standard hiding behavior no wp required
//standard seeking behavior no wp required
//multi location merchant behavior
//multiple locatin worker behavior (moving bottles)
//kneel and talk animation
//raking animation
//NPC will activate/deactivate light objects
//standard barmaid working with bartender
//standard bartender working with barmaid
Lugaid helpfully defined lots of common actions to use with Dana'an.
//Moves to given post
//For combat, returns to post when not in combat
//wanders aimlessly in area with post sPostTag
//wanders aimlessly in area with post sPostTag, stops to sweep/rake occaisonally
//weeding: used for gnomes in rice paddies in Danaan unvanquished
//for cows, wanders close to sPost, grazes using DRINK animation
//sleeps near sTag
//Sits at Target, Fidgets
//Stands at Target
//Stands at Target
//Plays animation at Post, w/ facing
//runs to post, starts shoveling. Used for sappers laying mines
//Plays various listening animations facing target
//Plays Custom animation at Post, w/ facing
//Attacks sTarget on Post w/ranged weapon
//Attacks sPostTag
//Plays taunt animation
//Plays flute animation, creature must have a flute
//Plays Guitar animation
//Plays Drum animation
//Sits on the ground
//Plays Cooking animations
//Stands and messes with stuff on table
//Stands and does heavy-labour stuff
//Stands and looks around
//Stands and worships
//Stands and uses social animations
//Like talk, but for instructors, leaders, overseers
//Plays bardsong animation
//Plays clapping animation
//Plays dancing animation
//Plays slowed dancing animation
//Plays shoveling animation
//Plays drinking animation
//Plays reading animation
//Plays Cower animation
//moves from one random creature to another, good for barmaids, townwalkers, etc.
//moves from one random waypoint to another, designed for bats
//Chases from nearest object with sPostTag
//Follows at a walk nearest object with sPostTag
//Refugees moving en mass in one direction.
There is some duplication, but I will probably include both versions to give people the choice. Between the two, it looks like most common things are going to be in there.
Here are the suggestions that are not already in the list: Woodcutting, getting water from a well, cleaning clothes, feeding chickens, driving cattle/livestock, feeding cattle/livestock, fishing, Simon Says or Tag, kissing, sawing, priest blessing the congregation, kids going to school if there's one in town, Men negotiating with prostitutes
#15
Posté 01 juillet 2011 - 12:55
Included on the discussion page is a thread that has templates (that were in Uncle FB's code) for single location and multi-location behaviors, so you can write your own behaviors to be added to this project. I'm going to focus on integrating Uncle FB's and Lugaid's existing behaviors, and injecting more randomness into them. There is also a thread on what I am hoping to accomplish.
#16
Posté 01 juillet 2011 - 01:02
I could imagine another kind of generic script for some of the others, using my mingle script but with different animations added in. For example, the NPC could move to random NPC with a certain variable or tag, and perform the worship, plead, getlow, or bow animations, depending on whether they're soliciting ladies of the evening, slopping pigs, or saving souls.
Another neat script might be some sort of 'flock' behavior, where NPCs with the same variable or tag get together and then move as a group towards some other, random goal, like a pack of schoolkids either going to school or playing hookey.
If you can get a set of conventions going, I could start filling in the gaps.
BTW- do either of the expansion packs add any animations?
#17
Posté 01 juillet 2011 - 01:32
Exactly. Between your and Uncle FB's work the makings of a complete system are mostly already in there, with common cases already done and templates for new actions being defined. One beautiful thing FB did was provide templates for actions, making adding new behaviors something that can be done without a high level of scripting knowledge. Your work is also a nice building block, so that someone that sees that activity X is just an matter of combining y and z. You have things like the sap action (run to point, dig), that can easily be turned into run to x, do y.Lugaid of the Red Stripes wrote...
The remaining tasks really just come down to either creating new animations or using old animations in creative ways. Woodcutting could be attacking an i-point in a tree, clotheswashing could be using the labor animations near a pile of rags or a clothesline.
I could imagine another kind of generic script for some of the others, using my mingle script but with different animations added in. For example, the NPC could move to random NPC with a certain variable or tag, and perform the worship, plead, getlow, or bow animations, depending on whether they're soliciting ladies of the evening, slopping pigs, or saving souls.
Another neat script might be some sort of 'flock' behavior, where NPCs with the same variable or tag get together and then move as a group towards some other, random goal, like a pack of schoolkids either going to school or playing hookey.
If you can get a set of conventions going, I could start filling in the gaps.
BTW- do either of the expansion packs add any animations?
I want to get something basic done over the weekend, adding time randomization and some place randomization to Uncle FB's stuff, and make sure that works. I've already put in various optional time randomizations into a script and included it into FB's script handling transition times. You can select totally random, bell curve, curves tilted towards the beginning or end of periods, etc by commenting in/out lines in my script. Once that's working I will add support for your behaviors to FB's scripts.
Ultimately I hope to have a system where a given commoner chooses their next activity randomly according to percentages the builder defines in the scripts, so not all farmers go to the inn at dinnertime for instance. When that's working I will start adding detection of things like the npc appearance, so you don't accidentally send off people in Red Wizard clothes to farm, maybe add a chance of a holiday with a different set of activity percentages so commoners don't do the same thing every day.
Yours and Uncle FB's scripts provide a great base for someone like me to work from. I can't program from scratch for crud, but I'm not too bad at working with existing code to get what I want.
#18
Posté 01 juillet 2011 - 12:32
#19
Posté 01 juillet 2011 - 01:19
I'm sure you're kidding but that behavior is not fundamentally different that stopping for a few minutes at a bard waypoint. Npc finds itself in radius x of a waypoint, y chance to take action z for a few minutes, then continue on their way. Assuming stopping for a bard is doable (and no reason to suppose it's not), bathroom breaks are doable to.Eguintir Eligard wrote...
make em go in the outhouse and back out
#20
Posté 01 juillet 2011 - 01:27
I'm imagining two sets of functions, one to handle movement, and another to handle animations and other non-moving actions. A third set of functions would control the scheduling, with all the randomness that needs to be built in.
Might even program a Sims-style list of 'needs' for each NPC, that they seek to fulfill as they choose between their random actions, you know, bladder, entertainment, shopping, work, social. Then another table with weights for personality type. All of which can be randomly initiated at spawn, or set by local variables entered by the builder. Maybe have a set of variables on the area object to determine what mix of personalities and needs should be generated for that area (i.e. 10 peasants, 1 wizard, 3 drunks, 2 hooligans).
#21
Posté 02 juillet 2011 - 12:54
Alban on IRC is working on goal oriented AI (eg Sims style). The demos are impressive, npc's can roam areas seeking choke points for instance, then defend them. Attacking a single commoner makes all nearby commoners run away from the player. I don't see it as something that could be worked in without a major rewrite of what I'm planning to do, and probably not worth it from a "people unlikely to notice/care" standpoint since I'm working on generic commoners.
Handling spawning in up to a max of x npc type is already something I had in mind. Including ability to set different npc mixes for different times of the day (more drunks and hooligans at night for instance) and different total numbers at different times (most people go to bed at night)
I've done some script renaming of your functions to break down what is done, Sap has become RunToPostAndDig for instance, your commentary is still in there on the original purpose. Hopefully these function names will be more self explanatory for different people and make it more understandable for builders who want to make new functions.
Right now I'm going through the activity code and replacing switch case statements with d100()>x to give people more precise control over probability of one sub-action over another (playing guitar vs bowing in the PlayGuitar action for example). Doing one small step at a time to the actions like this will hopefully keep bugs down. Found a few in Uncle FB code that I'm fixing (switch cases that couldn't happen for instance: int iRand = Random (7); case 0: .... case 7 [!] )
Oh yeah, woodchopping was requested. It's already in Uncle FB code, I missed it in my list.
#22
Posté 02 juillet 2011 - 10:17
The scripts are in NWN2, amongst all the other legacy stuff that's left over. That's why I'm not sure if they will all work; there might be things missing, and certain animations have changed etc. But they should be there.kamal_ wrote...
No longer have nwn1, so maybe someone could dig up those scripts.
I don't know if you already know this, but the game counts up real-time minutes up to the number of minutes per hour, then sets it back to zero and increases the hour. Just like a real clock but there are however many minutes per hour you specify, not 60. I've been implementing some time functions myself and the real time/game time disparity caught me out a bit.kamal_ wrote...
I'm adding the ability to set schedules to the minute instead of hour...
#23
Posté 02 juillet 2011 - 11:41
I'll have to look into that. I'm calculating minutes since midnight, so if you wanted something to happen at 05:30 you'd enter 5(60)+30 = 330 minutes. If there's some real time/game time oddity I can certainly account for it, the current time tracking code's all in one spot, I can post it to the project page and you can improve on it.The Fred wrote...
I don't know if you already know this, but the game counts up real-time minutes up to the number of minutes per hour, then sets it back to zero and increases the hour. Just like a real clock but there are however many minutes per hour you specify, not 60. I've been implementing some time functions myself and the real time/game time disparity caught me out a bit.kamal_ wrote...
I'm adding the ability to set schedules to the minute instead of hour...
#24
Posté 02 juillet 2011 - 11:56
Sounds like you're volunteering to be a guinea pig... I mean testerThe Fred wrote...
This is something on my to-do list as well, but I haven't even begun building populated areas like towns yet. I do have a nice system on the go where NPCs will go to their rooms at night-time, close the door and go to sleep (though they have no sleeping animation...). I'm using this for the academy-like Iron Circle, but it could be used for inns etc. The other stuff is still off on the horizon yet.
Right now the code is mostly like Uncle FB's, with the addition of Lugaid's functions, and would work like Uncle FB's. The big advances will come when I get to the point of removing the need for local ints on commoners in favor of checking iPoints, and then having the AI choose by percentage and select among multiple waypoints for the same activity.
There's plenty of work that's mostly time consuming between now and then, like the editing out FB's case statements for d100()>x to give greater control over the amount of different sub-actions making up one action.
#25
Posté 02 juillet 2011 - 11:56
EDIT: I can send you my time code if you want, it's a bit of a WIP atm, but it seems to be working now.
Modifié par The Fred, 02 juillet 2011 - 11:58 .





Retour en haut







