Jump to content
  • Advertisement
Sylon87

Build a System for a Battle Royal Game Concept

Recommended Posts

hello!

i'm planning to build a little battle royal game, and i'm wondering in how organize my code to control every player, update positions, and report the closest player to every players, for example.. if player a, is close more than 1 meter to the player b, it can be eaten...

in game there is also the NPC so they can eat also each other based on the distance, and if it's facing or not... some Advice?

Share this post


Link to post
Share on other sites
Advertisement

This depends on how you want to setup your game server.

Calculate anything server side; then the server needs to be feeded with the information of all clients and calculate everything by itself.

Calculate aynthing client side; then the server is just a message router to the clients, the clients calculate each on their own for the player logged in if that player is able to eat an other player or NPC. You then can add a sanity check to the server to prevent cheating

Share this post


Link to post
Share on other sites
15 hours ago, Shaarigan said:

This depends on how you want to setup your game server.

Calculate anything server side; then the server needs to be feeded with the information of all clients and calculate everything by itself.

Calculate aynthing client side; then the server is just a message router to the clients, the clients calculate each on their own for the player logged in if that player is able to eat an other player or NPC. You then can add a sanity check to the server to prevent cheating

hello!

at first thankàs you for your advice..

actually i made a mistake because i totally forgot to wrote that it will be not an Online game but just a local party game

 

 

Share this post


Link to post
Share on other sites

What do you mean about "local party"?

Old-School-everybody-sits-in-front-of-the-same-screen kind of party game: Then you treat anything as through as you play a normal singleplayer game. Track which input sources belong to what characters on the screan and thats it. This would be a good case for an ECS because you then can have an amount of characters and attach as needed either the AI component or the PlayerController component.

If it should be a game for the local network: -> redirection to my first post in this topic here

Share this post


Link to post
Share on other sites
6 hours ago, Shaarigan said:

What do you mean about "local party"?

Old-School-everybody-sits-in-front-of-the-same-screen kind of party game: Then you treat anything as through as you play a normal singleplayer game. Track which input sources belong to what characters on the screan and thats it. This would be a good case for an ECS because you then can have an amount of characters and attach as needed either the AI component or the PlayerController component.

If it should be a game for the local network: -> redirection to my first post in this topic here

yes, exactly that, a split screen local party game, will have a max of 4 players in game, and the screen will be splitted, what i'm wondering in is witch is the best way to build a system where every player/npc will now witch character is the nearest one.

Share this post


Link to post
Share on other sites

Your first question was a bit too vague to help with. But this question is specific enough for some guidance.

1 minute ago, Sylon87 said:

what i'm wondering in is witch is the best way to build a system where every player/npc will now witch character is the nearest one

Here's an algorithm assuming each actor (NPC or player) knows where its position is.

// loop through each actor: currentActor (I assume you have a list of these)

// for each actor, loop through all the other actors: otherActors

// compute the distance and store it in the currentActor

That's the basics to get that working. Once you have that working you can worry about optimizations. Like realizing once you've computed the distance from currentActor to otherActor you also know the distance from otherActor to currentActor. That means your outer loop goes from 0...n, but your inner loop can go from currentActor's index to n. 

Share this post


Link to post
Share on other sites
48 minutes ago, Eck said:

Your first question was a bit too vague to help with. But this question is specific enough for some guidance.

Here's an algorithm assuming each actor (NPC or player) knows where its position is.


// loop through each actor: currentActor (I assume you have a list of these)

// for each actor, loop through all the other actors: otherActors

// compute the distance and store it in the currentActor

That's the basics to get that working. Once you have that working you can worry about optimizations. Like realizing once you've computed the distance from currentActor to otherActor you also know the distance from otherActor to currentActor. That means your outer loop goes from 0...n, but your inner loop can go from currentActor's index to n. 

thet's great thank's you, what about a Specific object that will get character List position and return the closest one? what i mean is to build an object that will do it, just to be in topic ithis was what i was asking for, witch is the best way to build this kind of system, i'm actually learning the Design Pattern, so i'm wondering in witch is the best for my case

Share this post


Link to post
Share on other sites
3 hours ago, Sylon87 said:

i'm actually learning the Design Pattern, so i'm wondering in witch is the best for my case

Probably several together somewhat fit.

Design patterns are documented solutions to common problems. That means all non-common problems aren't considered at all, the largest part of the problem space is totally ignored.

Real world problems are normally a mix of several common problems and some uncommon problems. Trying to fit a few common problems onto that seems to me a very hard problem, Instead I look for a solution of the entire real world problem first without trying to fit (parts of) the solution in named boxes.

 

Share this post


Link to post
Share on other sites
On 7/12/2019 at 8:00 PM, Alberth said:

Probably several together somewhat fit.

Design patterns are documented solutions to common problems. That means all non-common problems aren't considered at all, the largest part of the problem space is totally ignored.

Real world problems are normally a mix of several common problems and some uncommon problems. Trying to fit a few common problems onto that seems to me a very hard problem, Instead I look for a solution of the entire real world problem first without trying to fit (parts of) the solution in named boxes.

 

ok! thank's you!!

i'll try to build it, i have some idea.. i'll update this post when i finish it !

 

 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!