Sign in to follow this  
teremy

NPCs/Computer Enemies in Online Games

Recommended Posts

Hello.

 

I managed to write my own "reliable UDP" network protocol, so my basic game already works ( a bomberman clone ). What I want now is to have monsters, or enemies in general, on the map. Some of them may be passive ( just walking around ) whereas others may follow a certain player when within range.

How exactly are those kind of enemies handled?

Clients send move requests and the server answers with the position, is the server also constantly telling the clients the new positions of other enemies/npcs? I wonder how this is done in games like GTA, where there are a lot of npcs walking around on the map.

Maybe there is a cheaper ( regarding network traffic ) solution instead of just telling the clients the new positions as with normal players ( the other clients )?

 

Thanks in advance!

Share this post


Link to post
Share on other sites
Typically, yes, the server will send the clients the "truth" about enemies.

The logic for what an enemy does may be co-simulated deterministically on each client, too, with occasional corrections/updates from the server, depending on the specifics.

Note that, if an enemy always follows the closest player, this will be different on different screens (unless you run everyone behind with a round-trip command latency,) so the server likely needs to at least send out "currently, enemy X is following player Y," and maybe more occasionally send out "and enemy X is at position Z with direction/orientation/velocities W."

Share this post


Link to post
Share on other sites

Since you wrote your own reliable protocol you also know how to make a parallel non-reliable protocol/stream within its mechanism.

 

For object location updates which can quickly become obsolete it can improve efficiency to have certain message types be shortshrifted on how 'reliably' they are transmitted (like short term resend then give up past an expiration time or if superceded by another message of the same specification (like an objects revised position).

 

Certain messages have to be reliable (key one-shot events) but many dont have to be.

 

Of course this complicates the ties between the application and the message transport, but you probably want to investigate that anyway (eventually) for some kind of traffic throttling adaptibility (for when the network slows down, then simulation traffic is simplified temporarily to avoid sending packets which probably (in the detected degraded traffic situation) will resend over and over wastefully).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this