Advertisement

Build a System for a Battle Royal Game Concept

Started by July 10, 2019 11:21 PM
9 comments, last by Sylon87 5 years, 5 months ago

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?

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

Advertisement
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

 

 

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

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.

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. 

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

Advertisement
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

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.

 

There was a topic some time ago that asked for a way to interact with NPCs, maybe you find some inspiration in there

https://www.gamedev.net/forums/topic/703073-trying-to-create-an-in-game-bestiary-for-a-horror-game/?tab=comments#comment-5409376

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 !

 

 

This topic is closed to new replies.

Advertisement