# MMO - Boss Action Distribution

I was considering how MMO mechanics work and especially how NPC/mob decisions are calculated and distributed among players. Say for example that you have a team of 5 fighting a boss. The boss's actions/powers etc are hardcoded into the game code, but its decision making is based upon some probabilities, are those calculated server side and then distributed to all the players? For example, when it is going to use a specific "spell" or who it is even targeting.

1)If all these are calculated server side, is the boss considered as a single entity that acts based on input from other players or is it more event based?

If that is the case then how do people deal with latency? I mean the server has to emit the action of 5 characters to the other 4 + Boss and also then calculate what the boss is going to do?

2)Is one of the player's game engine "assigned" the control of the Boss's actions and when all the actions from the other players are broadcasted then the "choose" game engine calculates and distributes not only the players actions but also the boss's.

If that is the case then won't 1 player always be in favour due to latency being zero?

Thank you

Say for example that you have a team of 5 fighting a boss. The boss's actions/powers etc are hardcoded into the game code, but its decision making is based upon some probabilities, are those calculated server side and then distributed to all the players? For example, when it is going to use a specific "spell" or who it is even targeting.

Sure it is. The Server is the decision-maker, the client is the one to nicely "show" the decisions the server made by drawing graphics.

1)If all these are calculated server side, is the boss considered as a single entity that acts based on input from other players or is it more event based?

More or less. It does not have to act to input from players. Since it is a entity, things like take damage and so on are already working out of the box. It might do something special if someone casts spell xyz or it just has a set of possible actions and chooses one at random every once in a while. This depends on how you'd like the boss to act and react.

If that is the case then how do people deal with latency? I mean the server has to emit the action of 5 characters to the other 4 + Boss and also then calculate what the boss is going to do?

The server does not really emit the action to the boss the same way as it is emitting this event to the other players, since the boss itself is serverside, so no networking between server<->boss involved. But yes, it works like this. But this emitting the action is not only done while boss-fighting, it is done everytime and everywhere when more than one player is in the same area, since all other players want to see what this one player does, everything. Walking, jumping, casting, .... And they want to see what other NPC-Characters do, so 4 players and one entity is really not much.

2)Is one of the player's game engine "assigned" the control of the Boss's actions and when all the actions from the other players are broadcasted then the "choose" game engine calculates and distributes not only the players actions but also the boss's.

No, control has the server. You could say, server itself plays the role of a client for its NPC's but the input doesn't come from a keyboard and a mouse, but from AI-Scripts, Waypoints, and so on. Your Client will only be controlling your own character, other clients control their characters and everything else is controlled by the server.

If you're concerned about latency, don't be. Really, 4 characters spamming spells plus one boss is really so little, thats not even worth thinking about. Lets say your packet x casts y is 20 bytes and your cast takes half a second, thats 2 casts per second, per player plus the boss, so 10 casts per second so 200 incoming bytes for the clients and 800 bytes outgoing for the server per second. And if your server somehow batches state-updates, you could get away with far far less.
• In the most cases the server itself runs in some sort of main-loop at a fixed tickrate, your boss would then do nothing when the network-packet arrives which says i casted xyz but calculate it's action then in the next server-tick. Note though, i don't know about any MMOs which act to particular spells, most bosses - and other npc-enemies - just react to aggro which is somewhat a threatening-factor, the player which has the highest will be the bosses target. I can't speak for all MMO-Servers but i know a few which actually use scripts, for example lua, to script special boss-behavior. – tkausl Jul 27 '15 at 7:21
• The server-ticks are in some fixed step, 20 TPS could work well, even 10 TPS or less can work. Yes, the server core engine does not decide what to do but calls the bosses lua script to decide. – tkausl Jul 27 '15 at 7:38