Register for your free account! | Forgot your password?

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

  • 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: 971
Received Thanks: 1,048
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   #2
elite*gold: 0
Join Date: Oct 2009
Posts: 759
Received Thanks: 537
Use QuadTrees for best performance. (Prove me wrong and I'll agree with you:P)

-impulse- is offline  
Old   #3
elite*gold: 21
Join Date: Jul 2005
Posts: 9,196
Received Thanks: 5,305
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   #4
elite*gold: 20
Join Date: Mar 2006
Posts: 6,122
Received Thanks: 2,490
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   #5
elite*gold: 20
Join Date: Mar 2006
Posts: 6,122
Received Thanks: 2,490
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   #6
elite*gold: 20
Join Date: Mar 2006
Posts: 6,122
Received Thanks: 2,490
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   #7
elite*gold: 20
Join Date: Mar 2006
Posts: 6,122
Received Thanks: 2,490
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  

« Previous Thread | Next Thread »

Similar Threads
Spawn Entities, Current Patch
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...
18 Replies - CO2 PServer - Discussions / Questions
a little help. :P entities line 213..(lotf/Pazeco) can anyone help me with this..
3 Replies - CO2 PServer - Discussions / Questions
entities.cs problem
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...
2 Replies - CO2 Programming
Map lab,spwan,...
Hi all i take an old post but which my been useful much and i thing that it will serve for you too :DD ...
3 Replies - CO2 Guides & Templates

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

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.