PDA

View Full Version : decision based AI



saymoo
11-11-2009, 11:53 AM
Hello all,

in many games (like SWAT 4), NPC AI characters like civilians and suspects, have random spawn locations during level start. The suspects have waypoint flee paths, in case they decide to flee when a teamplayer is within sight, or they "hear" a teamplayer within a range shout "hands up!". Or they give up, and put their hands up to surrender, or they shoot back (and possible flee later).

I've only seen pathfinding and shooting on sight tutorials as of yet.
But none about what i need: decision based AI, when NPC thug spots human (or team) player actor(s).

e.g. NPC thug can have these choices when spotting player actor(s)
1) shoot on sight (uncovered)
2) take cover behind object
3) take cover behind object and fire occasionally remaining under cover. (other anims apply there)
4) Flee to safety, (other waypoint that are out of player sight)
5) flee and also blind fire during flee..

player actor shoots back:

6) npc thug takes cover when player shoot npc actor
7) npc thug stays in position when player shoot npc actor
etc etc etc

i think you get the idea...

Furthermore:
How can i setup the random spawn locations, for 1) suspects locations, and 2) civilians, in such way, that i preconfigure how many suspects there are inside the level, and how many civs. (between min and max amount per npc type).

eeyk
11-11-2009, 12:31 PM
yes i remember me swat 4 But you like that Controls?

saymoo
11-11-2009, 12:38 PM
yes i remember me swat 4 But you like that Controls?


you mean the player controls? (keys etc?)

or what do you mean..? :)

Anyway, the question is about the AI, and the spawning.

saymoo
11-12-2009, 05:23 AM
It appears, nobody needs decision based AI (advanced form of AI)??
Or perhaps i'm a dummy, not knowing how, while other do?

Wake up people, this affects all, since most blockbuster games utilize desicion based AI :)

immortius
11-12-2009, 07:09 AM
The simple answer is that you code it. :P

I haven't actually coded much AI, but I imagine it would go something along the lines of:
* Create states for each action the AI can engage in (i.e. flee, take cover, etc).
* Create decision function(s) that determine what the AI will do
* Hook into any events and information (such as seeing a player, getting hurt, health, etc) which can then cause the AI to potentially change action or influence their decisions.
* In some cases you may need to create systems for propagating events to the AI (like the player making noises)

Although I'm sure there are multiple ways of approaching it and that is only one. At any rate it is not a trivial task.

You'ld probably want to exploit UnrealScript's state mechanics whatever you're doing, so you should look into that if you're not familiar with it.

I see that you've asked the same question on the Unity forums, and the answer is mostly the same. There may be some packages that can help, but there's no drop-in solution that I'm aware of.

For spawning, you'ld create some subclasses of NavigationPoint and place them in your map(s) to mark where things might spawn. Specifying the number of spawns depends on your requirements regarding how it should be set, but a simple way is creating a subclass of MapInfo that can hold the required settings and setting them in the editor (via World Properties->WorldInfo->My Map Info).

saymoo
11-12-2009, 09:05 AM
thanks, i'll dive into the information provided. :)
And the state mechanics documentation.

ThunderBeef
11-12-2009, 06:15 PM
You can setup random spawn locations in editor using Kismet. They can be event driven - on level start or some arbitrary event. Theres some logic stuff in there so you can make it as random or exact as you want to. (random switches, variables/conditions, etc)