Advancing the state of commoner AI
#26
Posté 03 juillet 2011 - 01:54
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
Posté 03 juillet 2011 - 09:07
PJ
#28
Posté 03 juillet 2011 - 12:07
Three 3pm Eastern today, time randomized.PJ156 wrote...
Heh, no pressure Kamal but whens it ready
PJ
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
Posté 03 juillet 2011 - 12:26
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
PJ
#30
Posté 03 juillet 2011 - 01:01
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.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
PJ
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
Posté 06 juillet 2011 - 02:02
#32
Posté 07 juillet 2011 - 01:21
What happens when an activity is interrupted?
#33
Posté 07 juillet 2011 - 01:33
#34
Posté 09 juillet 2011 - 08:46
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
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
Posté 09 juillet 2011 - 09:57
#36
Posté 09 juillet 2011 - 10:22
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.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.
#37
Posté 10 juillet 2011 - 03:09
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
Posté 10 juillet 2011 - 04:26
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
Posté 10 juillet 2011 - 06:05
All this would allow the PC to slap around NPCs without breaking the game, or de-populating an area.
#40
Posté 10 juillet 2011 - 06:09
Most modules dont allow attacking the commoner faction anyway. I suppose that could be added eventually by someone.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.
#41
Posté 10 juillet 2011 - 07:43
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
Posté 18 juillet 2011 - 12:31
#43
Posté 19 juillet 2011 - 02:15
#44
Posté 19 juillet 2011 - 12:43
#45
Posté 19 juillet 2011 - 12:53
#46
Posté 19 juillet 2011 - 07:11
#47
Posté 26 juillet 2011 - 09:47
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
Posté 27 juillet 2011 - 01:25
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
Posté 27 juillet 2011 - 10:38
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
Posté 27 juillet 2011 - 11:44





Retour en haut







