How do you ensure that AI will not break when their routine or behavior is interrupted by players?asked by Amadeus
TL;DRFrancesco Roccucci says behaviours check for required items and can restock them, for example through other NPCs or usables, and state is kept consistent across interruptions and server transitions by building behaviours with proper state transitions.
So we have different ways of doing that, of course. Let's say you have the routine behavior of a janitor. A lot of our behaviors, of course, make sure that you need to have specific things to perform the operation, so you can check what you have. Let's say combat starts, right? Then the janitor needs to react, so he drops his mop, his broomstick or his bucket, whatever. Then we always need to make sure that, the same way as if the janitor started from scratch, he needs to be able to pick up those things, or he cannot perform specific operations. So of course, if the player steals all the broomsticks in the environment, well, he won't be able to get one, but we can also always allow some other specific AI to come from a spawn closet and bring back those things, or have specific usables that can still provide the NPCs with the objects they need, or let them perform specific behaviors where they restock the objects they require before they can do the other behaviors. And then the other part is, of course, making sure of their state. For us, there are different parts. It's not just the player influencing the behavior. Eventually it could be, for example, an NPC transitioning from one server to another, because maybe it's performing its duty on your ship, and in that case your ship can change server. And we also need to make sure that that consistency is propagated for its behavior. So a lot of it is building those behaviors in the right way and allowing the transition between the different states, from what you need to what you can perform, basically.