JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System

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 eac…


This content originally appeared on DEV Community and was authored by Maiu

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 ungly if's but It enables further development and testing. I will go back to this after some time and try to impove 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.

Hope You like it!


This content originally appeared on DEV Community and was authored by Maiu


Print Share Comment Cite Upload Translate Updates
APA

Maiu | Sciencx (2024-06-27T20:38:48+00:00) JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System. Retrieved from https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/

MLA
" » JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System." Maiu | Sciencx - Thursday June 27, 2024, https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/
HARVARD
Maiu | Sciencx Thursday June 27, 2024 » JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System., viewed ,<https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/>
VANCOUVER
Maiu | Sciencx - » JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/
CHICAGO
" » JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System." Maiu | Sciencx - Accessed . https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/
IEEE
" » JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System." Maiu | Sciencx [Online]. Available: https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/. [Accessed: ]
rf:citation
» JavaScript MMORPG – Maiu Online #babylonjs – Ep: 25 – Monsters AI System | Maiu | Sciencx | https://www.scien.cx/2024/06/27/javascript-mmorpg-maiu-online-babylonjs-ep-25-monsters-ai-system/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.