Check if valid spawn point

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Check if valid spawn point

Post by Grue »

Hey all,

How do I check if a single float[3] is a valid spawn point?

I know I can do the getSpawnPointWithin for a zone, but don't want to use zones in this case.

Thanks,
Grue
etigah
Private First Class
Private First Class
Posts: 98
Joined: Tue May 22, 2012 4:08 pm

Re: Check if valid spawn point

Post by etigah »

You could try DropGeometry::dropPlayer from DropGeometry.h
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Check if valid spawn point

Post by blast »

Use the bz_getStandardSpawn function to get a valid spawn location for a player somewhere in the world, or bz_getSpawnPointWithin to get a valid spawn location within a custom zone object.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Re: Check if valid spawn point

Post by Grue »

Well, there's several problems with this.

a) I have a point, and I want to check whether or not the player can spawn there
b) If that point is in the air, that's fine, I would still like them to spawn there

bz_getSpawnPointWithin and bz_getStandardSpawn both generate random spawn points which is not what I'm going for, and they don't allow for airspawns.
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Check if valid spawn point

Post by blast »

Well that's not how the API works. Another suggestion would be to define a custom map object that defines a valid spawn point and then pick one of those locations. Then the map would have a list of known good locations coded into it.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
Zehra
Private First Class
Private First Class
Posts: 914
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Check if valid spawn point

Post by Zehra »

There's one terrible work-around for this, have some sort of converter made for the map to find all the objects and create a zone for the "object" in question. Now simply check if the the spawn point is within a "zone" and if it is, it isn't a valid spawn point, in other words, all non-zoned spaces are valid spawn points if they are within the world. (Yes, this is perhaps the most tedious suggestion, especially if mesh objects are used.)

-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Re: Check if valid spawn point

Post by Grue »

Zehra wrote: Mon Aug 15, 2022 12:05 am There's one terrible work-around for this, have some sort of converter made for the map to find all the objects and create a zone for the "object" in question. Now simply check if the the spawn point is within a "zone" and if it is, it isn't a valid spawn point, in other words, all non-zoned spaces are valid spawn points if they are within the world. (Yes, this is perhaps the most tedious suggestion, especially if mesh objects are used.)

-Zehra
I actually did this, but I couldn't figure out how to make an airspawn count as a valid spawn point. Really, I need any point that is not sealed to count as a valid spawn point.
User avatar
Zehra
Private First Class
Private First Class
Posts: 914
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Check if valid spawn point

Post by Zehra »

Try using the bz_eGetPlayerSpawnPosEvent to modify a spawn position.

Something like this might work:

Code: Select all

SpawnPosEvent: {
  While (spawn is not valid) {
     SpawnLocation = SelectSpawnLocation();
     //Your custom spawn position selection
     For (Zones in in World) {
       If (SpawnLocation is in Zone) {
         spawn = is not valid;
       }
     }
     If (spawn is valid) {
       Break;
     }
   }
   SpawningZone = SpawnLocation;
}
Also, you might want to add some units of space away from a zone to prevent any partial sealed issues. (About half a tank in length should be enough, plus 1-2 world units.)

-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Post Reply