Hi
Im looking at some advice for a method for determing which players/monsters are within LOS (ie within a certain radius) of another player/monster emitting an event of sort. Im working on the server for a game where we have some pretty large playfields (mmo style) and where transmitting every event to the entire playfield population is not an option. So the problem really boils down to: given an object with an x,y coordinate, find a fast way to determine other objects that are within a certain distance.
Let me start by telling about my current idea for an algorithm/datastructure. I’m thinking about splitting the entire playfield up in non-overlapping squares of side width equal to the wanted LOS in the game, lets say 50x50. Meaning the entire playfield is sort of covered in tiles. When a player moves around he is constantly associated with a single square. Once the player generates an event I can then create a list of “observers” present in the current square, and the 6 squares around it. That ensures that I find all observers within 50 units of the event without getting the entire population. This structure also gives me a simple way of keeping track of which players have been “introduced” to each other, and thereby when to send a “CharEnteredAreaEvent” and such things.
Anyway, im pretty new to all this so I was hoping I could pick up a few suggestions on other ways to do something like this =)
Thanks in advance