🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

JavaScript MMORPG from Scratch - Maiu online #2 - Monsters AI System

Published June 27, 2024
Advertisement

Hello, Finally I finished work on first prototype of monsters AI module. Monsters have several states: IDLE, PATROL, DEAD, FLEEING, COMBAT.

Idle monsters are non active even when someone attack them. Patrolling ones are walking around and checking each 0.5s is they have someone to attack in a range if yes then they start chase target (combat state) and attack when in range. Dead are obvious and fleeing is triggered when monster is enough far away from the position where it switched into combat state. I also added death to the monsters after 120s they respawn. Implementation have some bugs and AI it's just bunch of ugly if's but It enables further development and testing. I will go back to this after some time and try to improve it.

From the technical point of view it's designed in a way that monsters service is independent from the main engine loop. It can be deployed on separate machine, I hope this will very significantly unload main engine in the future, I'll be able to afford very inefficient AI implementation without compromising game performance. Monsters are pretty much like players but are not connected by websocket's proxy but by internal api (redis pub-sub in future, right now I'm working on the mock for simplicity but have prepared redis and mocked implementation). Monsters service keep replicated state of the whole simulation and 'AI agent' is responsible for handling all monsters logic.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement