Thursday, January 15, 2015

QuadTree improvements.

If you are not a developer this might not make sense to you, just think of it as something important for a good gaming experience and it will keep track of objects in game (monsters, npc, player).

I have been working on improving the QuadTree implementation the server uses so that we can have monsters with AI to fight with.

Quad Tree can be viewed here: http://codepen.io/LiamKarlMitchell/pen/raxRKq

The query region shown in blue now picks up nodes (Game objects) that are just on the edge of the circle as well as outside it but intersecting.

Empty leafs that are no longer fill and have children leafs with nothing in them and so on are removed.

An option enables us to have nodes outside of the created quad tree regions. We were having problems not knowing the full sizes/positions of the maps just yet where players/monsters/npc/item could go outside the area and be removed from the world which caused problems. So that will be fixed soon.

A getByNodeID method allows us to find 1 or more nodes by id.

Improvements that could be made:
A function could be made to query back up the tree from a node, to find Nodes by ID assuming its close first this would speed up trade, duel, attacking etc any interaction that is in close proximity between two game objects.

Adding AI manager, I hope to work on having the monsters attack, walk, agro, die next.

Adding events for on enter/onleave + sensors. (Basically querys that are checked after each node update and could be nodes themselves) although this could be unneeded and would slow down.

Migrate the rest of the functions in the server for object/location lookups to use the quadtree.
For instance we have functions that send an event to all connected clients, that will benefit speed wise from using the tree. Such as updating player action/location, sending a chat message in normal chat, dropping item, monster action/state, npc action/state, duel packets.


Happy New Year btw,

17 comments:

  1. In whatever you do, we support ya! :)

    ReplyDelete
  2. would be cool if it was coded that below a certain level in the tree, no two players could occupy the same quadtree... no running 'through' another player... imagine the fun in having to 'defend' the player holding yang form instead of everyone just stacking on them... shield defence where you actually HAVE to pvp to get at the shield guardians instead of just aoeing the area... oh the fun :D

    ReplyDelete
    Replies
    1. That's not quite how it works, the idea is to allow close objects to be in the same leaf for faster lookups.
      Making players solid could have implications, would have to be applied client side and server side and there would be a lot of checks to do.

      Delete
    2. Are there actually any mmorpg where players are solid?

      Delete
    3. thats a shame... this was interesting reading though...

      http://wenku.baidu.com/view/13931affaef8941ea76e0599.html?re=view

      Delete
    4. Ah yes, I was thinking of that for another game I want to develop in the future.
      Sphere tree is kinda like Octtree, (where you would have cubes). I would use a mixture as shown in the quad tree implmentation.

      Like I use circle and square because this game is basically 2D if you look at it top down there are no points where you can be on top of or beneath. Excluding skill like jump.



      To make players solid we would have to hook and re code the movement on client to be the same as what we would code on the server. If it was only server side you would notice lag as you walk inside the player or even through then are corrected from the server to be in front of it again.

      If anyone wants to investigate that go ahead :D I would start by looking at what writes to location to its right after location of player/monster/npc in the structure it could be investigated with cheat engine and maybe ida pro. It would require a lookup on each update to see if something solid is in front and if so stop moving there. Or if its in something solid to back out slightly.

      Possible place to hook is games frame loop, although there should be a game entity update function somewhere that handles movement.

      It would be possible but a lot to look at and learn how it works.

      Seems like interesting read yup thanks for sharing.

      Delete
  3. Krichek are u the fujin from serenity?

    ReplyDelete
    Replies
    1. i was indeed... (Goth)Covenant was my tag

      Delete
    2. Hello Krichek, Maslicka here. I wonder if you remember me. Hope to see you in this game soon o.o

      Delete
    3. yeah i do :) i'll be there...

      Delete
    4. I'm Saburo, hope to see many more ts1 players there, what do u guys think?

      Delete
    5. Can't wait to fight again in Yangok ^^
      I was 3moe4ita in Serenity, i always had the tag (Gank) in every guild

      Delete
    6. was never that bothered with guans but i really hope LauraRo and DacianaRo (serenity jins) play again... had hours of quality PvP with those two

      Delete
    7. one from the archive... you guys remember this?

      http://img.photobucket.com/albums/v369/vanityassassin/S00225-1.jpg

      Delete
    8. I'm not 100% sure but i think i was in the group of people ON the stone xD

      Delete
  4. ill spread this in ts2 hungames after they release their CBT 2

    ReplyDelete