26.06.2014, 22:44
Hey Mauzen, nice update I'll test this version.
Now, I'm trying know how to make a PathFinder (not %100 functional), the code work well, but I don't know how to find a free path. This is the code:
I know that the code is bad, I need help
Now, I'm trying know how to make a PathFinder (not %100 functional), the code work well, but I don't know how to find a free path. This is the code:
pawn Code:
stock GetFreePath(playerid, &Float:fX, &Float:fY) // 'fX' and 'fY' would be the free positions.
{
new Float:Pos[3], Float:Z, Float:Angle;
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Angle);
Pos[0] += (5.0 * floatsin(-Angle, degrees)); // Check if to 5 mtrs. there a free path
Pos[1] += (5.0 * floatcos(-Angle, degrees));
MapAndreas_FindZ_For2DCoord(Pos[0], Pos[1], Z);
if((Z - Pos[2]) > 5.0)
{
for(new Float:i = Angle; i < 360; i += 6.0) // Search per the NPC angle if there a free path.
{
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
Pos[0] += (5.0 * floatsin(-i, degrees));
Pos[1] += (5.0 * floatcos(-i, degrees));
MapAndreas_FindZ_For2DCoord(Pos[0], Pos[1], Z);
if((Z-Pos[2]) < 5.0)
{
fX = Pos[0];
fZ = Pos[1];
break;
}
}
}
return 1;
}
I know that the code is bad, I need help