Register for your free account! | Forgot your password?

Go Back   elitepvpers > Conquer Online 2 > CO2 PServer - Discussions / Questions
You last visited: Today at 04:26

  • Please register to post and access all features, it's quick, easy and FREE!

Entities spwan/w.e sure take a look and see if you can help

Old   #1
elite*gold: 0
Join Date: Aug 2010
Posts: 985
Received Thanks: 1,064
Entities spwan/w.e sure take a look and see if you can help

hello everyone .

what is the best way to do the clients/monsters/npc's spawns

like when a player jumps what is the best way to spawn the in range entities .

i have tried to store the entities in some kind of dictionary (Local entities) and spawn them on jumping/walking ...> slow

i have stored every single valid X/Y in the game maps as a key with a Dictionary associated to that key as a value and stored the entities in that dictionary depending on the X/Y and spawned them on jumping/walking ...> slow

you know we ............ Improvise but fail sometimes :P

i have tried a foreach in the client map entities and yet ....> slow

tried to stick to the way TQ does it but it spawns the entities only on jumping... i guess i did it wrong or maybe there is a different way to do the spawns and i cant figure it out .

however when i say slow it means that when 35/40 player goes online and walk/jump all together at the same time maybe a guild war or something the cpu usage goes a little bit higher which can kill the processor when it comes to 300 or maybe 400 player ,

and the spawn amount is around 700 to 800 entities in each map .

walking is worse than jumping though as a walk packet is being sent for each step a player takes .

thats all i got soooo anything Inspiring/creative/smart something i never thought about or maybe something to make it a little bit better :P .

i mean anything ?

{ Angelius } is offline  
Old 06/29/2011, 23:03   #2
elite*gold: 0
Join Date: Oct 2009
Posts: 762
Received Thanks: 539
Use QuadTrees for best performance. (Prove me wrong and I'll agree with you:P)

-impulse- is offline  
Old 06/30/2011, 05:44   #3
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,311
I'm no expert on the matter by any means impulse but I seem to remember reading that Quad won't experience any noticeable performance gain until there were insane numbers of objects being processed (tens-hundreds of thousands+). A conquer map generally deals with the low thousands at the most (say... 100 players a map max and 1000 mobs, few hundred items seems fair for many maps)

Personally we've been using a spawn system reversed engineered from the leaked tq sources.

For our map system we just have something known as ILocatable object which contains Map, X, Y and UID for objects (anything needing to be located). Maps contain a collection of all locatable objects on the map. We can then Insert (adds to collection, spawns to local), Remove (removes from collection, despawns to local), Search based on uid and Query functions which allow us to just set up a viewing rectangle and pull objects which are contained by it.

Whenever a movable object is moved we run a Callupdate method which pulls all objects from the map inside the viewing rectangle and we then eliminate these results using a UID key system for currently spawned objects.

Anything in the spawned lists (by uid) that is NOT in the new pulled list needs to be DESPAWNED
Anything in the new list that is NOT in the spawned lists (by uid) needs to be SPAWNED
Anything contained in both needs to be IGNORED

Very simple system and has proven decently efficient and quite foolproof (just remember that on move you need to spawn Self to others and Others to self for players) and it will work out just fine.

Quad is a lovely idea for the map system but I just feel it's kind of overkill for conquer application. The improved query speed isn't much of a benefit when you have such delayed insertion/removal/movement speeds.
pro4never is offline  
1 User
Old 06/30/2011, 11:34   #4
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,503
QuadTree's were designed with 2d applications in mind (the 3d version is an OctTree), the speed gain you get from querying is based upon the fact that you only query what and where you need to query instead of running through an entire list looking for something that matches.

To be honest if you created a multi-threaded Quadtree system with dedicated threads for insertion/removal and moving the speed gains would definitely exceed querying a list, and if im honest i've never noticed slow insertion or removal speeds, moving is abit complex as you have to go up the tree untill you can go back down in, but thats only because i never bothered writing a horizontal move system whereby the area your in knows who and where its neighbours are so you can just jump next door so to speak.

Korvacs is offline  
Old 06/30/2011, 12:42   #5
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,503
Originally Posted by Y u k i View Post
You know, one thread can do multiple work. Why using 3 Threads if 1 for the Quadtree is enough?
Because your talking about inserting and removing and moving 50 - 100k objects, and thats only if you dont include items. One thread running, assuming your sleeping it would struggle to do the work, if your not sleeping it and are triggering it using an event for example would still struggle to be honest.
Korvacs is offline  
Old 06/30/2011, 22:46   #6
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,503
Originally Posted by Y u k i View Post
So how about an asynchronus threadpool (non blocking) with max. of lets say 3 Threads. Will only launch as much as needed. I do not try to be a pain in the ***, but i was recently invited to a microsoft .net teaching event, they explained on how to do it the real way.
That would indeed be a very nice and elegant solution, although since its always active i would question the need for a threadpool over 3 dedicated threads, simply because of the amount of work that the threads will be required to do when the server is under load.

I just wrote a synchronised non-blocking threadpool which can be used wherever i require a threadpool for task completion, its very nice
Korvacs is offline  
Old 07/01/2011, 09:29   #7
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,503
Originally Posted by Y u k i View Post
Since .net 3.5 the threadpool is empty when it gets initialized, or created however you wanna call it. After threads complete their work they will stay in the pool for 60 seconds on the 61st second beeing IDLE they get removed. so there is no acctual wasting.

Since a Thread uses more than 1MB of RAM id keep the count low.
I assumed we were talking about writing our own custom threadpools, mine doesnt use .Net's threadpool class.

Korvacs is offline  

« VIP MAP NPC | Wonder How to do random damage of Terato »

Similar Threads
Spawn Entities, Current Patch
03/25/2011 - CO2 PServer - Discussions / Questions - 18 Replies
EDIT: Nevermind, my packet was off a few bytes :P Has spawning entities in the lastest patch changed? Entities (ex: Players) don't spawn to each other on my source since the latest patch.
a little help. :P entities line 213..(lotf/Pazeco)
08/05/2009 - CO2 PServer - Discussions / Questions - 3 Replies can anyone help me with this..
entities.cs problem
10/13/2008 - CO2 Programming - 2 Replies
hi, i have a problem with entities.cs when i start my server it loads everyting almost all mobs i have but when he is on SpawnALLMobs it give an error at line:217 error=System.NullReferenceException: Object reference not set to an instance of an object. line:218 is DataBase.Mobs = null; now you know where to look just above line:218 this is what i have: public static void SpawnAllMobs() { try {
Map lab,spwan,...
07/07/2007 - CO2 Guides & Templates - 3 Replies
Hi all i take an old post but which my been useful much and i thing that it will serve for you too :DD PS:sry for my english i am french text2schild.php?smilienummer=1&text=lol' border='0' alt='lol' />

All times are GMT +1. The time now is 04:26.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.