Quote:
Originally Posted by Macluawn
|
Mapandreas and some trig to determine RX/RY of the slope of course you'll also need a distance function mine is getdist3d yours might be different.
This should work.
pawn Код:
stock GetSlopeAtPoint(playerid, X, Y, &Float:RXAngle, &Float:RYAngle)
{
new Float:North[3], Float:South[3], Float:East[3], Float:West[3], Float:opposite, Float:hypotenuse;
// Set slope positions
North[0] = X;
North[1] = Y + 1;
South[0] = X;
South[1] = Y - 1;
East[0] = X + 1;
East[1] = Y;
West[0] = X - 1;
West[1] = Y;
// Use map andreas to get Z Values
MapAndreas_FindZ_For2DCoord(North[0], North[1], North[2]);
MapAndreas_FindZ_For2DCoord(South[0], South[1], South[2]);
MapAndreas_FindZ_For2DCoord(East[0], East[1], East[2]);
MapAndreas_FindZ_For2DCoord(West[0], West[1], West[2]);
// Calculate Slope angles
// North South RX
hypotenuse = getdist3d(North[0], North[1], North[2], South[0], South[1], South[2]);
opposite = getdist3d(North[0], North[1], North[2], North[0], North[1], South[2]);
RXAngle = asin(floatdiv(opposite, hypotenuse));
if(South[2] > North[2]) RXAngle *= -1;
// West East RY
hypotenuse = getdist3d(West[0], West[1], West[2], East[0], East[1], East[2]);
opposite = getdist3d(West[0], West[1], West[2], West[0], West[1], East[2]);
RYAngle = asin(floatdiv(opposite, hypotenuse));
if(East[2] > West[2]) RYAngle *= -1;
return 1;
}