Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   findnearestplayers(x,y) specs. (https://forums.graalonline.com/forums/showthread.php?t=63885)

jake13jake 02-03-2006 05:33 AM

findnearestplayers(x,y) specs.
 
The script obviously loads an array of indexes of the nearest players, but what are it's limitations? Can it only load so many players? Can it only load players within a certain distance?

napo_p2p 02-03-2006 05:51 AM

I don't believe it returns an array of indexes, but rather an array of 'players' (objects). From my experience with it, it returns an array of all the players in the level, arranged from closest to farthest.

jake13jake 02-03-2006 06:09 AM

Quote:

Originally Posted by napo_p2p
I don't believe it returns an array of indexes, but rather an array of 'players' (objects). From my experience with it, it returns an array of all the players in the level, arranged from closest to farthest.

oh right, yea, it does return an array of objects :P
If that's the case, to maximize efficiency on a rectangular field, you'd want to break the checking loop when you encounter the first instance where the player's distance from the center of the field is greater than the distance from the center of the field to the corner of the field.

I'm working on a new damage system for Classic, and although it's working 100x better than the current one, I'd still like to optimize it as much as possible. I was actually wondering if I'd have to distribute the damage field into checking different spots, but after what you tell me, I could actually decrease lag. Of course, most efficient if you use squares or circles.

Admins 02-07-2006 04:56 PM

Could add some kind of findareaplayers() :) Currently you get the full list of players because the players array is normall relatively small, compared to the npcs array (especially on gmap).

jake13jake 02-07-2006 07:07 PM

Quote:

Originally Posted by Stefan
Could add some kind of findareaplayers() :) Currently you get the full list of players because the players array is normall relatively small, compared to the npcs array (especially on gmap).

Stefan, that would definitely make a maximum optimization of the damage system. for static values of x,y,width,height.

It's still impossible, however, to create a reliable moving damage field (internal to baddies and such); this is the larger problem. Now I'm also wondering if you read my setshape mode suggestion, because it would also be good to support a radius-based function in the damage system.

xXziroXx 02-08-2006 09:51 AM

Quote:

Originally Posted by Stefan
Could add some kind of findareaplayers() :) Currently you get the full list of players because the players array is normall relatively small, compared to the npcs array (especially on gmap).

I would definediatly want to see that future on Graal, could turn out to be quite usefull.

Lance 02-08-2006 11:29 AM

Quote:

Originally Posted by Stefan
Could add some kind of findareaplayers() :) Currently you get the full list of players because the players array is normall relatively small, compared to the npcs array (especially on gmap).

I'd like it.


All times are GMT +2. The time now is 01:20 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.