Aller au contenu

Photo

Advancing the state of commoner AI


  • Veuillez vous connecter pour répondre
72 réponses à ce sujet

#26
kamal_

kamal_
  • Members
  • 5 240 messages
ok, removed all the actions that were duplicate and cleaned up the naming so it's uniform between UncleFB and Lugaid's actions. Here is the current list of actions that will be available.

Cases 1-6 mean you can force npc's to run things normally done at different times of the schedule. Cases having "multi" in their names are built as multiple waypoint activities, such as a smith going from the forge to the water to cool the forged item, etc.

    case 0: NpcHidden
    case 1: NpcActOne
    case 2: NpcActTwo
    case 3: NpcDinner
    case 4: NpcMidnightBed
    case 5: NpcSleepBed
    case 6: NpcWake
    case 7: NpcAgree
    case 8: NpcAngry
    case 9: NpcSad
    case 10: NpcCook

    case 11: NpcDanceFemale
    case 12: NpcDanceMale
    case 13: NpcDrum
    case 14: NpcFlute
    case 15: NpcForge
    case 16: NpcGuitar
    case 17: NpcWoodsman
    case 18: NpcMeditate
    case 19: NpcPost
    case 20: NpcRead

    case 21: NpcSit
    case 22: NpcSitDinner
    case 23: NpcStandChat
    case 24: NpcTrainingOne
    case 25: NpcTrainingTwo
    case 26: NpcTrainerPace
    case 27: NpcWwp
    case 28: NpcCheer
    case 29: NpcCookMulti
    case 30: NpcForgeMulti

    case 31: NpcMidnightNonBed
    case 32: NpcSleepNonBed
    case 33: NpcThief
    case 34: NpcHide
    case 35: NpcSeek
    case 36: NpcThief2  //thief2 actually steals, unlike thief
    case 37: NpcAssassin
    case 38: NpcMerchantMulti
    case 39: NpcKneelTalk
    case 40: NpcLightKeeper

    case 41: NpcBarmaid
    case 42: NpcBartender
    case 43: NpcFollowPC
    case 44: NpcCombatMoveToPost
    case 45: NpcWander
    case 46: NpcWanderSweep
    case 47: NpcWeeding
    case 48: NpcAnimalGraze
    case 49: NpcSitFidget
    case 50: NpcRunToPostAndStand

    case 51: NpcAnimate
    case 52: NpcPlaySound
    case 53: NpcRunToPostAndDig
    case 54: NpcListen
    case 55: NpcAnimateCustom
    case 56: NpcPracticeRanged
    case 57: NpcPraciceMelee
    case 58: NpcTaunt
    case 59: NpcSitGround
    case 60: NpcTendStore

    case 61: NpcWork
    case 62: NpcSentry
    case 63: NpcWorship
    case 64: NpcTalk
    case 65: NpcInstruct
    case 66: NpcBardSong
    case 67: NpcClap
    case 68: NpcSlowDance
    case 69: NpcShovel
    case 70: NpcDrink

    case 71: NpcCower
    case 72: NpcMingle
    case 73: NpcWanderRandomly
    case 74: NpcFleeFromTagged
    case 75: NpcChaseTagged
    case 76: NpcFollowTagged
    case 77: NpcFollowAndScriptHidden

#27
PJ156

PJ156
  • Members
  • 2 982 messages
Heh, no pressure Kamal but whens it ready :)

PJ

#28
kamal_

kamal_
  • Members
  • 5 240 messages

PJ156 wrote...

Heh, no pressure Kamal but whens it ready :)

PJ

Three 3pm Eastern today, time randomized. :P

Progress report

Up to now it's all been quick and basic things like the time randomization, or time consuming but bookkeeping things like eliminating duplicate actions,standardizing action names and making the action waypoints. The fun starts now, I have to change the scripts to look to ipoints placed in the area instead of local ints on self, get them to randomly select an available action based on local ints on the ipoints, then randomly select from available waypoints for that action. More complicated, and more to go wrong.

#29
PJ156

PJ156
  • Members
  • 2 982 messages
Good luck with that, how are you going to decide which list they randomly pick from?

I can envisage sending my man to the market to talk with his friends but he randomly picks weeding :)

I really appreciate you taking this on Kamal_ I treasure ambience over most other modding detail. Problem is all my towns are done now. I'm going to have to write another mod :D

PJ

#30
kamal_

kamal_
  • Members
  • 5 240 messages

PJ156 wrote...

Good luck with that, how are you going to decide which list they randomly pick from?

I can envisage sending my man to the market to talk with his friends but he randomly picks weeding :)

I really appreciate you taking this on Kamal_ I treasure ambience over most other modding detail. Problem is all my towns are done now. I'm going to have to write another mod :D

PJ

This system isn't for an npc you want to force doing anything specific, it's for random npcs. If you require an npc to do something specific you're still going to need to tell them as you've always done.

When done, it should be fairly painless to backport to an existing mod.

Here's how it will work from a builder perspective on a new mod:
1. Drop the seven required iPoints anywhere in your area.
2. Change the integers on the iPoints variables to the desired percentage for an action at a given time.
3. Drop the waypoints for any actions you want to happen at the spots you want them happening.
4. If you have multiple waypoints for an action.Set a local int on then to indicate relative percentage to go to that waypoint. (eg, 90% at one and 10% at the other)
5. Make sure the random npc's are tagged appropriately and are using the included heartbeat script. (tag must include "commoner", "merchant", or ""noble" by default)
Done. Steps 1-4 shouldn't take more than a few minutes per area. The iPoints, action waypoints, and example creatures (commoner, noble, merchant) will be included in the package, so you don't have to create them, just place them.

To backport to an existing mod, the difference from above would be:
1-4 above: same.
5. Change the tags the scripts are looking for to whatever tag you were using for commoners/merchants etc, and give the npcs the new heartbeat.

Modifié par kamal_, 03 juillet 2011 - 03:40 .


#31
kamal_

kamal_
  • Members
  • 5 240 messages
Progress Update: The heartbeat problem I ran into and posted a scripting thread on caused me to re-diagram the logic the scripts I needed to follow for the ai decision making in order to try to determine where the problem was. This re-diagramming turned up several logical errors I made, which I've started working on resolving. So while the broken heartbeat was frustrating, it ultimately saved me time.

#32
nicethugbert

nicethugbert
  • Members
  • 5 209 messages
Is raised fist or cleaver shaking already included?

What happens when an activity is interrupted?

#33
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
case 58: Taunt comes close, you could mix it up with the talk_forceful animations, and a few choice voice chats.

#34
kamal_

kamal_
  • Members
  • 5 240 messages
Let's get a base of things working first. As Lugaid said, the Taunt function is similar. Adding new cases is straightforward (there are action templates included in the script).

Progress: I rewrote some sections for better performance and to make them easier to understand for those who would look to modify things. My bug that caused the npc's to go hostile has been eliminated. (It made the test case amusing, I was forcing the playing of the guitar animation, so the npc would spawn his lute and attack me with it :-) )

The rewriting did add a time detection bug. It's alwas detecting it's time to sleep. Oops -_-. Once the single npc single waypoint testing is working, I'll add multiple npc's and waypoints.

One thing worth mentioning: If an npc needs an object to do their animations, it's automatically given to them. So the lute spawns on npc's getting the guitar animation, axes spawn on the woodsman, etc. That bit was included in the original code, but I don't think I mentioned it.

#35
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Not that you don't have enough to do already, but have you given any thought to sound effects? I know you can play a mono sound directly from the NPC, but in practice that doesn't seem to be audible. I guess another option would be to play the sound off the nearest PC, if the PC is within a certain distance. I usually handled it by placing down a SFX by hand, but that seems to go against your quick&easy design philosophy.

#36
kamal_

kamal_
  • Members
  • 5 240 messages

Lugaid of the Red Stripes wrote...

Not that you don't have enough to do already, but have you given any thought to sound effects? I know you can play a mono sound directly from the NPC, but in practice that doesn't seem to be audible. I guess another option would be to play the sound off the nearest PC, if the PC is within a certain distance. I usually handled it by placing down a SFX by hand, but that seems to go against your quick&easy design philosophy.

I suppose creating an appropriate sound at the location of the waypoint could be added to the basic functionality at some point. By someone else anyway, I have other ideas for Crimmor that will require placed sounds.

#37
kamal_

kamal_
  • Members
  • 5 240 messages
Here's an initial demo video. youtube link

These five npc's are stock npc's that have simply been placed in the area and assigned the heartbeat script. As you can see by the debug code, they are automatically choosing and carrying out different activities and actions, reading what actions to do from an iPoint, and moving to designated waypoints.

There are still significant bugs. One went hostile for an as yet unknown reason (I'm tracking that pesky bug down) and they can change their minds on the next heartbeat (haven't put in code to stop that yet.)

#38
kamal_

kamal_
  • Members
  • 5 240 messages
Hostile commoners is now fixed.

In Uncle FB's code, some cases reset the faction of the npc based on a local int as part of a ClearFlags function call. The problem was the local int was never getting assigned, so the faction the npc got assigned to would be invalid and make the faction change return hostile.

The new bit of code is optional and commented out by default, you can reset the faction to that of an object in the area as part of the ClearFlags function. This allows you to set them to custom factions. And the system requires ipoints in the area anyway.

I also added a bit of code that detects if they are in combat, so they don't suddenly change faction mid-combat. That really should happen just about never, a commoner who went hostile and lived long enough to experience a change in their activity times (activity changes are every 4 hours or so).

#39
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Random thought- you could make Commoners immortal, but when their HP goes below a certain threshold (say, 10%), they pass out and lie drooling on the ground (this could be programmed as just another activity). When it's time for an activity change, they heal themselves and go on to the next activity, along with fixing their faction.

All this would allow the PC to slap around NPCs without breaking the game, or de-populating an area.

#40
kamal_

kamal_
  • Members
  • 5 240 messages

Lugaid of the Red Stripes wrote...

Random thought- you could make Commoners immortal, but when their HP goes below a certain threshold (say, 10%), they pass out and lie drooling on the ground (this could be programmed as just another activity). When it's time for an activity change, they heal themselves and go on to the next activity, along with fixing their faction.

All this would allow the PC to slap around NPCs without breaking the game, or de-populating an area.

Most modules dont allow attacking the commoner faction anyway. I suppose that could be added eventually by someone.

#41
kamal_

kamal_
  • Members
  • 5 240 messages
In this testing code, the npc's change their activities on each heartbeat, instead of at designated times. This will allow quick testing. It would be a bug if it did that on release, but it's intentional for the test code.

There's debug strings all over the place, you may wish to comment them in/out them.

Feel free to tear it apart and suggest replacement/improvement/fixed code, I don't claim to be a super awesome code ninja. Heck it's probably one step from falling apart. If you want to code in some kind of behavior or detection have at it. The kinds of improvements I'd like to see are appearance detection (no npcs with the red wizard robe appearance will select digging for instance), and detecting strings in npc tags to divide the npc's into groups ("nobles" never weed)

Commoner AI readme

Commoner AI erf for testing

#42
kamal_

kamal_
  • Members
  • 5 240 messages
No one's tried it I guess?

#43
bealzebub

bealzebub
  • Members
  • 352 messages
I tried it out today. It seemed to work as advertised. I'm really looking forward to the finished product. Thanks for all your hard work.

#44
nicethugbert

nicethugbert
  • Members
  • 5 209 messages
IIRC, Brian Meyer was working on NPC activity scripting as part of a big DM client overhaul. IS there any overlap here? I mean scripting as in an actor's script, not a programming language per se.

#45
kamal_

kamal_
  • Members
  • 5 240 messages
I don't know what he is doing, but if it's something dms launch it may not have much overlap other than the actions that can be called.

#46
rjshae

rjshae
  • Members
  • 4 485 messages
I'd like to see some interrupt logic that will react when a PC is seen doing anything inappropriate like breaking into a home, picking a lock, or disarming a trap. For example, the commoner viewing the act can yell out, the neighboring commoners can turn to watch the event, and one of them can run to fetch a law enforcement officer. One of them may even work up the courage to approach the PC and ask what they are doing. Or they may all flee the scene.

#47
MokahTGS

MokahTGS
  • Members
  • 946 messages

rjshae wrote...

I'd like to see some interrupt logic that will react when a PC is seen doing anything inappropriate like breaking into a home, picking a lock, or disarming a trap. For example, the commoner viewing the act can yell out, the neighboring commoners can turn to watch the event, and one of them can run to fetch a law enforcement officer. One of them may even work up the courage to approach the PC and ask what they are doing. Or they may all flee the scene.


Yeah, this reminds me of my first trip through Ultima 7 where I was trying to wander off with someone elses goods, when I was spotted by a villager.  She didn't leave me alone to go on with my pilfering, she told me to stop it and then followed me around and kept an eye on me...I guess I looked shifty.

NPCs also restored order, like opening shutters to windows that I had closed, for...ahem...privacy reasons.

These kinds of touches, is what makes a good game, great.

Modifié par MokahTGS, 26 juillet 2011 - 09:48 .


#48
Dann-J

Dann-J
  • Members
  • 3 161 messages
Gothic III had a good thief detection system. If you were caught opening a chest or picking something up indoors, you were warned to stop. You therefore had to sneak behind NPCs to prevent them from turning to look at you - although if you were caught just trying to sneak around you also got a warning.

Failing to heed the warning eventually turned the NPC hostile against you, and if you got caught stealing too many times the entire town would be hostile if you tried to return. You could however learn a feat that allowed you to talk your way out of such confrontations - although even that only worked so many times before you were black-listed.

#49
rjshae

rjshae
  • Members
  • 4 485 messages

DannJ wrote...

Gothic III had a good thief detection system. If you were caught opening a chest or picking something up indoors, you were warned to stop. You therefore had to sneak behind NPCs to prevent them from turning to look at you - although if you were caught just trying to sneak around you also got a warning.

Failing to heed the warning eventually turned the NPC hostile against you, and if you got caught stealing too many times the entire town would be hostile if you tried to return. You could however learn a feat that allowed you to talk your way out of such confrontations - although even that only worked so many times before you were black-listed.


It might be fun to have a bounty system. The town might not have sufficient power to take you into custody, but, if you don't pay a fine for your transgressions, they could put a price on your head. After that, bounty hunters start coming after you. They can become more dangerous over time as your negative reputation grows.

So perhaps a scenario like this... First offence: NPC walks up and gives you a warning and asks that you return what you stole. Your local reputation suffers and you get poorer deals from the local shops. Second offense: a local legal representative arrives to say that you need to pay a fine and return what you stole. There's no need to build in a combat situation because it is up to you the player whether you pay or not. But until you do, your reputation is even lower and you get snubbed by the local stores. On the third offence, you hear that there is a bounty on your head. This triggers encounters with hardened NPCs, usually when your party is travelling or tries to sleep.

Should be do-able AI wide, with a minimum of fuss I think.

Modifié par rjshae, 27 juillet 2011 - 10:51 .


#50
Dann-J

Dann-J
  • Members
  • 3 161 messages
That reminds me of Baldur's Gate, if you decided to go crazy and kill a bunch of villagers. Eventually a group of guards spawned in, backed up by some rather nasty battle mages.