2012/12/04

Cube World AI

I've been working on the artificial intelligence of Cube World's NPCs and monsters. I've added pathfinding and some behavior features to the AI. The pathfinding is based on the A* algorithm, with some additional features like climbing and arbititrarily sized bounding boxes for creatures and obstacles. NPCs like villagers use it to find their way to various places in the city. Enemies use it to follow the player even to the most unreachable locations.

Below are a few screenshots to demonstrate the AI. The small red and yellow cubes are just for visualization purposes and won't be visible in the final game.

Let's spend the day with Alerick, a nice NPC living in this house in Tririon City.


Looks like he is still sleeping.


Ah, now he's awake. Let's see where he's going...



As mentioned above, the red dots are just for visualization of the path. The path is computed and updated on the fly while the NPC is walking. Obstacles like street lights are avoided.



Seems like Alerick is chilling in the park.


Now he's going to the armor shop...


Looks like he wants to go to the market next.




Where is he going?


Ah, to the item shop. :)



Looks like Alerick wants to hang out in the park again...



He just entered this inn.


His NPC friends are here, too.


Seems like he has enough of them. :) He's choosing a different seat.


Maybe he wants to tell me something in confidence. :)


Ok, time to get out of here.


He's going to the weapon shop.


Maybe I should buy some new weapons, too.




Later, in the evening...


It's time to go home.



Looks like Alerick is tired. His wife is already sleeping.


Good night!


In the next morning...


Let me show you the monster AI.


This plant creature is following me everywhere.


It can even climb up here.


Let's go to that castle.


As a rogue I can become stealthy. It works best in the shadow. The darker it is the faster I can become stealthy. When the stealth bar is full, enemies can't see me. Also my spirit increases so I can open the fight with a special attack.


Dungeon enemies are standing together in groups. If one of them sees me, the whole group will attack me.


There are also patrols like this Ogre. He is stronger than normal enemies.


He is patrolling from corner to corner.



It's better to eliminate the groups without the patrol...


... which is the specialty of an assassin. :)


Sometimes it's useful to pull groups around corners, e.g. when some of them are attacking from range.




That's all I have to show for now. I'm currently working on quests and the homepage. Maybe I'm gonna make a new video when the new quests are working.