Make entities can randomly spawn on the ground :D

Is it possible ? :-?.
If it’s possible, i will try to use it in my stalkerrp :-?
(For make artifart system, yeah XD)

I don’t know about totally random ground locations, but if you have a specific map you like, and you find several good locations, you could add the Vectors to a table, and have a spawn function (that might run every 30 seconds?) get a random slot from the table, and spawn the NPC there.

I know this is very vague, but so is the title. =-p

** EDIT

I have this example from a gamemode I was working on a while back:

[lua]/**********************
Antlion Spawn Vectors
**********************/

mapLoc = {}

mapLoc[“gm_flatgrass”] = {
Vector(472.200470,37.777916,5),
Vector(1596.546021,27.853199,5),
Vector(996.150513,839.530701,5),
Vector(1050.112915,-819.645874,5)
}

mapLoc[“rp_cscdesert_v2-1”] = {
Vector(10539.213867,1212.355347,123.319061),
Vector(4358.338379,4574.538574,69.029198),
Vector(-6476.650391,8838.351563,69.031250),
Vector(-7220.419922,5073.442871,69.031250)
}[/lua]

If this doesn’t make any sense, reply with more detail on what you want.


-- Type GetPos in console to get cordinates
local points = {
    Vector(0, 0, 0), 
    Vector(0, 0, 0),
}

hook.Add("InitPostEntity", "SpawnNPC", function()
    local pos = table.Random(points)
    local npc = ents.Create("npc_kleiner")
    npc:SetPos(pos)
    npc:Spawn()
end)

init.lua

Well, thank for all your guys help :slight_smile: !
But, yeah…
I need a code what can make my entities spawn on a “totally random ground locations”
Because i don’t want they just camp around the artifact spawn point XD

The easiest way would be for you to just include lots of spawn points.

Edit - Even better make it not choose points which have players nearby.

Yea, just put in alot of spawn points, and if you want it to change position, you could create a timer to change it’s position.

This is really easy mate. First take a random X and Random Y across the lines of the map with a Z a nice value thats above most of the terrain and will not spawn under any displacements or such.
Then trace straight down towards the map, getting the position.
Then add about 20 to Z, and spawn w/e you want there.