SA-MP Forums Archive
Detecting floor surface / Flat or Angle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detecting floor surface / Flat or Angle (/showthread.php?tid=445397)



Detecting floor surface / Flat or Angle - [SF]OutLawZ - 21.06.2013

I'm not sure, I had a look but didn't seem to see anything that affiliates with this.
How could I detect if a player is standing on a rough edgy floor or a flat surface?

Thanks, OutLawZ


Re: Detecting floor surface / Flat or Angle - [SF]OutLawZ - 22.06.2013

Bump, Anyone?


Re: Detecting floor surface / Flat or Angle - Macluawn - 22.06.2013

MapAndreas


Re: Detecting floor surface / Flat or Angle - Pottus - 22.06.2013

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;
}



Re: Detecting floor surface / Flat or Angle - [SF]OutLawZ - 22.06.2013

Okay thanks, i'll try it out