[SOLVED] AI Scripts and ES Design

I’m currently working on my AI. May game is Zay-ES based. I can store/load the ES and that for I put all information into the ES and do not have any kind of game objects beside that.

My AI should provide individual behaviour. So I have a little monster which is just patrolling left to right in that corridor and stands still if you click it and start to talk. If you got the right stuff and said the right things it vanishes and you can pass. If not it restarts patrolling. There are many different such kind of monsters/peoples what so ever with different patterns, behaviour and stories.

In a OO way I would give a script per instance, the same script if the same type of course. But in ES this seems not really to work. Because I want my script change ES state (add components to things or removed, set new position and stuff). So I start to think an AI script is more a system then. Am I completely wrong. How did others solve that?

I know it is not an exact topic, mostly because I have no clue where to start :slight_smile: Any hints are appreciated.

Well, in the sense that a “system” is just “Any code that uses the ES”… then yes. That’s all a “system” is, though… that’s why Zay-ES does not specifically have a “system” class because then people get wrapped around the axle about what a system is and isn’t.

So if you have a per-object script that accesses the ES (I don’t see why that’s a problem) then it’s a system.

That’s the part I don’t understand. Why can’t your script use the ES? In my case, I even have nice groovy short-cuts to the ES.

How tightly you do or don’t integrate your AI with the ES depends on the AI architecture. But if your script-per-object inclination is the easiest for you then there is nothing wrong with that. Other examples might be different behaviors in a behavior tree that are activated/deactivated based on the presence of some component. Or to have a two layer AI where one layer is the simple steering/following type code and the level above that is the actual ‘decision maker’… then you might use components to communicate targets or whatever.

1 Like

I think my problem was that have a script per monster and hand over the entityid sound more the way I would solve withouth an ES. For me a system cares for things in a 3th person perspective where OO is for me a ego perspective :wink:
But when I got you correctly that is not a real problem to bind a specific behaviour to a specific entity and re reading everything I start to think that my fear I could hack me seriously in a corner is not going to happen :slight_smile:

thanks for your help

And in the end, sometimes you have to do a thing before you see a better way to do the thing. Scripting the AI is certainly the easiest way to go, I think.

And that watch entityid starts to make a lot of sense :slight_smile:
I think my design problem was not a problem at all and is solved for now.