Repository navigation
A3D_FindRandomPoint
Find a random spot on the ground around a point where something fits, such as a spawn or a dropped item.
The spot lies on ground that faces up within 45 degrees, out of the water, with room for a sphere of clearance resting on it, free of the map and of every kind of body.
native bool:A3D_FindRandomPoint(
Float:x,
Float:y,
Float:z,
Float:radius,
&Float:spotX,
&Float:spotY,
&Float:spotZ,
Float:height = 5.0,
Float:clearance = 0.5,
worldid = -1
);| Parameter | Description | Default |
|---|---|---|
Float:x |
Centre on the X axis. | |
Float:y |
Centre on the Y axis. | |
Float:z |
Centre on the Z axis. | |
Float:radius |
Distance from the centre to look within. | |
&Float:spotX |
Spot found on the X axis. | |
&Float:spotY |
Spot found on the Y axis. | |
&Float:spotZ |
Height of the ground at the spot. | |
Float:height |
How far above and below z the ground is looked for. Inside a building it must stay under the ceiling. |
5.0 |
Float:clearance |
Radius of the room needed. | 0.5 |
worldid |
Virtual world to look in, or -1 for every world. |
-1 |
-
truewhen a spot was found. -
falsewhen none of 16 tries found one.
The native makes up to 16 tries. Each picks a column at random inside the circle, spread evenly over its area, and looks down it from z + height to z - height for the map and static objects. The column is kept when:
- the ground faces up within 45 degrees of the vertical,
- the ground lies out of the water,
- a sphere of
clearanceresting on the ground touches nothing, neither the map nor any kind of body.
The point written lies on the ground. Add the height of what is placed there, about a metre for a player.
Inside a building, keep z + height under the ceiling, or the columns find the roof. The spots differ from call to call. When all 16 tries fail, such as in a crowded room or on a steep hill, the native returns false.
Scatters the loot of a box around it.
stock ScatterLoot(Float:x, Float:y, Float:z, count) {
new
Float:spotX,
Float:spotY,
Float:spotZ
;
for (new i; i != count; ++i) {
if (!A3D_FindRandomPoint(x, y, z, 4.0, spotX, spotY, spotZ, 3.0, 0.3)) {
continue;
}
CreatePickup(1212, 1, spotX, spotY, spotZ + 0.5);
}
}- A3D_FindGround: Find the ground under a point.
- A3D_IsModelColliding: Whether a model would touch anything at a position.
- A3D_IsPointInsideMap: Whether a point lies inside the collision of the map, such as a player who fell under the ground or into a closed model.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions