Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: City AI Project
PostPosted 03.03.2012, 18:22 
Since CryENGINE 3 came out, with a new AI system, based on XMLs combined with LUA, it is time to think about new opportunities of AI scripting.

Here, I have a task of creating a complex and brand new AI units, which will are possible to use in a City environment. Since this engine could be used to create RPGs, many people will have this task. This I want this thread to be devoted to such questions and a solution.

The overview

First of all, I want to make a small overview to compare the AI systems of FPS and a city simulator. The last one is much different from the AI of Crysis or CryENGINE3 sample AI. In the regular FPS/Action games, you complete the levels and fight with AI units, which need to have functions of attacking, complex navigation, complex behavior. These can be called an NPC - the characters, who are playing against or with Player, and need to have the realistic behavior.

In the city simulator, player usually doesn't interact much with civilian AI. Here, the game needs to produce a lot of AI units around the player in its field of view. AI is spawning dynamically and is following the pre-made paths. Spawning such a great count of NPSc will hand the system down, and reduce the FPS count, therefore we should make it different. It shouldn't be smart or realistic, but it is needed just to fill the city environment. AI units should have the functions to follow paths, run or attack player if he attacks first, and sometimes say some phrases. They are similar to Boids, just more complicated. Such AI units can be called a Dummy - randomly spawned units, following paths and almost always ignoring the player.

Of course, in such games the regular AI for enemies or friendly NPCs is used too, but only in missions or in special moments.

Steps to create Dummy AI system

Paths

First of all, we need to find out, what elements of AI system should we create, to make it possible to use Dummy AI in maps. Imagine the city and the street. First of all, designer need to place the Paths on these streets - a special shapes, which are used to be followed by Dummies. Secondly, designer needs to define the Transition points - the special objects, placed between the end of one Path, and start of another. They are needed for random transition between these paths.

Image


Spawners

After the previous part of the task is realized, we need to spawn the Dummies on the Paths somehow. This is possible in 2 ways:
  • We attach the Spawner elements to each Path, in a places where A Dummies should be spawned
  • The AI system (Spawn System in further) will find the closest to the player paths and spawn the fixed amount of Dummies on them

First way requires a lot of designer work, but it allows designer more options to set up. Second way is more complicated to make, but it is easier to control, because all settings are stored in one place inside a code.
I think that it is better to use a second way. Let's talk more about it. It is possible to find the entities dynamically in game, so it will be possible to find the Paths, which are situated in a defined radius around the Player. After we find the list of these Paths, we should spawn Dummies on them. It is better to spawn Dummies all over the length of Path. In this case, we can make a path to be consisting of a few points, like on an image below:

Image


Spawn System will take each Path from the list, then take each point from the chain, get its global coordinates, spawn the Dummy and make it follow the Path. Another system checks the paths areas for Dummies, and if they are too far from Player, it removes the redundant units.

Now, what we got from our plan

After all the steps above completed, we got the simple and useful system of civilian pedestrians, Dummies, which will be everywhere on the streets around the player. They will walk, switch the paths randomly. They will be removed from that area, and spawned in another place, when Player gets to another city area. It will create the impression on the Player, that the whole city is populated by those pedestrians.

This is an example of the system, in theory:

Image


Now, I want to complete that system in scripts and programming. This article will be updated in future. I would like to listen to suggestions and discussions from other game designers and programmers about that task. Maybe together we can handle it and introduce the brand new AI System.


Last edited by Alex626 on 05.03.2012, 14:21, edited 2 times in total.

User avatar   Skilled Modder Skilled ModderMember since: 23.03.2011, 05:21Posts: 798Location: Calgary / Alberta / Canada Likes: 14
 

 Post Topic: Re: City AI - Pedestrians \ random AI Paths \ random AI spaw
PostPosted 04.03.2012, 02:11 
Hmm, you could do this flow graphs, iirc someone already did
User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: Re: City AI - Pedestrians \ random AI Paths \ random AI spaw
PostPosted 04.03.2012, 10:30 
No, no. I'm talking about the only scripted solutions. As I already mentioned, spawning such a large amount of standard AI units from CryENGINE3 will hang down any system. The task is to create new AI scripts and new AI navigation elements.
  Beginner BeginnerMember since: 29.12.2011, 23:32Posts: 20 Likes: 0
 

 Post Topic: Re: City AI Project
PostPosted 05.03.2012, 21:10 
Good luck with that. The AI right now is a complete mess, I've tried coding an AI which does nothing but idle, yet it forces itself into "stick" goalop. I've tried doing a simple complete AI, gets in range => follows => checks melee range => melee attacks. Yet it still just forces itself to "stick" to the player. I really don't know why we're given the chance to code our AI's behavior if there are predetermined behaviors which force themselves into execution :P. Hell, the FogOfWar AI, included in cryengine 3 doesn't work either, and the CoverST AI works "most" of the time, but the pathfinding is a joke. Sometimes I'm in front of the AI and it just runs away in a completely random direction without ever turning its attention back to me.
  Trainee TraineeMember since: 19.08.2011, 10:04Posts: 178Location: Prague, Czech Rep. Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 06.03.2012, 13:32 
It sounds like nice project :) Btw i suggest to start with imho for you useless things like Nanosuit and others in BasicActor and Player .lua. For me it was 4 days of tracing what is called from where, what i can delete etc. Nicely spend time, but its needed. Many things are obsolete but no one cares... :( Im afraid same wasting of time is waiting in AI Behaviors and Goalpipes :(
User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 07.03.2012, 15:35 
I've also tried to learn goalops and tactical point system, but I think that it will be needed for a C++ coding for that project.
  Trainee TraineeMember since: 19.08.2011, 10:04Posts: 178Location: Prague, Czech Rep. Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 07.03.2012, 17:51 
Quote by Alex626:
I've also tried to learn goalops and tactical point system, but I think that it will be needed for a C++ coding for that project.

Not exactly, only for new goalops but you can get reasonable results with already created goalops. Main problem is that there are not tutorials but even without them is possible to understand what to do :) More important is to understand how BST works, what events and callback you can get from code and then is making action realy simple
User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 08.03.2012, 23:26 
Yeah.

But I really wonder, how can we create new shapes, like AI Path, from editor?

Here, it shouldn't be difficult too much to create AI pedestrians. We just need to code a new AI with a small amount of functionality - for a better performance. Then we need to make a kind of triggers, like ProximityTrigger, which will be placed on a corner between paths, and redirect spawned AI units randomly into different connected paths. Instead of a new Path entity, we can use AI Path.
  Beginner BeginnerMember since: 29.12.2011, 23:32Posts: 20 Likes: 0
 

 Post Topic: Re: City AI Project
PostPosted 11.03.2012, 00:35 
As far as I know, dynamic AI path creation on the fly isn't possible. However, you can use tag points to get the AI to go to PoI. And, what exactly do you plan to do that can't be done with standard AI paths?
User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 11.03.2012, 20:22 
Quote by botulox:
As far as I know, dynamic AI path creation on the fly isn't possible. However, you can use tag points to get the AI to go to PoI. And, what exactly do you plan to do that can't be done with standard AI paths?


Why? You can spawn any entity, activate the AI in it, and send it a signal to follow the AI Path. I think it's possible to with standard AI Path object, but how to operate them in C++?
  Experienced Modder Experienced ModderMember since: 16.03.2011, 05:55Posts: 528Location: Utah, USA Likes: 29
 

 Post Topic: Re: City AI Project
PostPosted 11.03.2012, 21:08 
The GDC tech demo showed off a Dynamic navigation mesh which (In theory) should allow a large number of characters on screen at once.
  Beginner BeginnerMember since: 29.12.2011, 23:32Posts: 20 Likes: 0
 

 Post Topic: Re: City AI Project
PostPosted 11.03.2012, 22:29 
Quote by Alex626:
Quote by botulox:
As far as I know, dynamic AI path creation on the fly isn't possible. However, you can use tag points to get the AI to go to PoI. And, what exactly do you plan to do that can't be done with standard AI paths?


Why? You can spawn any entity, activate the AI in it, and send it a signal to follow the AI Path. I think it's possible to with standard AI Path object, but how to operate them in C++?

Oh, I thought you meant creating entirely new AI paths on demand, based on dynamic shapes, like a city whose buildings move (just an example). What you said is perfectly possible. You should check the documentation, there should be examples on how to do it.
User avatar   Uber Modder Uber ModderMember since: 15.04.2008, 19:40Posts: 2321Location: London, UK Likes: 1
 

 Post Topic: Re: City AI Project
PostPosted 12.03.2012, 18:51 
I think yes, It's possible. But are the AI paths entities, or what?