Jump to content

Discussion of spawn points (developer feedback requested)


ainesophaur

Recommended Posts

As I'm developing my first plugin, I'm noticing a lot of woes that many first versions of popular plugins face in terms of spawn points. Example, @Albo1125 tow truck went through improvements of the spawn logic (same with the transport backup).. I remember the early days where items would spawn either next to me or in a canal. Obviously those days are gone (for the most part) but I'm sure it wracked his brain as it is mine currently. I'm sure it also took a lot of time and frustration to nail it.

After seeing the discussion on blip colors, I wanted to see what the community concession is in terms of dealing with spawn points.

In my mind, I'm thinking of traveling around los Santos and statically picking out spawn points, guaranteeing a minimum and maximum distance when picking the spawn point.

I've also thought of getting a random vehicle within a sphere and then spawning the vehicles behind it.. But I'm sure it'll lead to me spawning a vehicle that physically collides with another

Is everyone still depending on natives when spawning items like vehicles and peds, or have some used static spawn points.

Am I missing any RAGE methods or native methods which allow me to detect a road with an X and Y offset? Or would I have to loop through the values returned from natives until I find one that satisfies my requirements?

Link to comment
Share on other sites

If you want a spawnpoint on the nearest valid road, you can use this:

World.GetNextPositionOnStreet(YourSpawnPoint);

If you have the Vector3.Around extensions (https://github.com/LMSDev/LSPDFR-API/blob/master/Extensions/Vector3Extensions.cs) you can use this to get a spawnpoint roughly 200m from the player:

World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Around(200f));

A Vector3 will be returned and it's guaranteed to be on a GTA valid road.
Hope this helps.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

It's worth noting though that this is also what can cause vehicles to spawn in the canals. Canals, alleyways, dirt tracks, sections of sidewalk (I'm looking at you, Los Santos Cemetery) all seem to somehow count as roads. Hell, I've even had things spawn on Vespucci Beach (like, on the damn sand!) that apparently counts as a road.

The main drawbacks to using static spawns are it takes a metric crapton of time driving around the map and grabbing coordinates, and can cause issues when the player triggers your callout but is a long way from the nearest static spawns.

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

Link to comment
Share on other sites

2 minutes ago, Darkmyre said:

It's worth noting though that this is also what can cause vehicles to spawn in the canals. Canals, alleyways, dirt tracks, sections of sidewalk (I'm looking at you, Los Santos Cemetery) all seem to somehow count as roads. Hell, I've even had things spawn on Vespucci Beach (like, on the damn sand!) that apparently counts as a road.

The main drawbacks to using static spawns are it takes a metric crapton of time driving around the map and grabbing coordinates, and can cause issues when the player triggers your callout but is a long way from the nearest static spawns.

Use of various natives can make this slightly better, e.g. only getting points on paved roads. But the problem I always seem to have with the various get node natives is that they'll only return points with the same Z coordinate value as the location you put in. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

The way I chose spawn points was by setting a map marker and grabbing the coords of the waypoint via code.. So I was able to quickly obtain a few decent spawn points. 

I was considering building an XML doc that would be shared via this form. It'd be composed of a list of locations and possibly a couple tags to reference the ideal callout candidate.. Eg an ally on xyz Street would be good for hookers, drugs, murder, but not a welfare check.

If we have enough contributions we could have a great locations list that give a consistent feel for the developers and players. I can see the need for some callouts to have a random spawn location.. But too many times do I find peds in the middle of a road or a car in the middle of an ocean

Link to comment
Share on other sites

I have done static spawns myself using XML (.NET makes it pretty easy, just a few attributes and the XmlSerializer class) as has the author of the GTA Comes Alive mod, as far as I can see.

 

It definitely produces the "best" results, if you go through all the effort of setting it up. And there's the question of somehow making the spawn points generic so you can use several sets of spawn points for the same thing. Or you'd have to set up spawn points all over the map for each variant of call out you wanted to set up.

 

I think a better solution would be figuring out how to access the pathfinding/spawn nodes in memory. If you notice, pedestrians don't spawn in the middle of nowhere - there are obviously either zones or individual nodes baked into the map for each area/point where pedestrians can be spawned. Parked cars must be the same way, and I think I remember seeing that you can edit the parked car nodes in map editors for some of the older games. Presumably, the pathfinding nodes on the rode must store the direction they're facing (or is calculated from the position of the next node?) so that the engine can spawn vehicles on the road with peds already driving them. Unfortunately I'm not a good enough programmer/hacker to figure out how to access that data, but maybe somebody with more skills than me can take a crack at it!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...