19.11.2015, 20:39
Hey,
Dumb question as hell (is hell dumb?), I just don't know how to use this function with FCNPC plugin to make NPCs follow player(s) properly.
Original (in portuguese language):
https://sampforum.blast.hk/showthread.php?tid=528732
Thanks.
Dumb question as hell (is hell dumb?), I just don't know how to use this function with FCNPC plugin to make NPCs follow player(s) properly.
pawn Код:
stock DiagonalRoute(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:maxSteps = 75.0, Float:maxHeigth = 2.0, id = -1)
{
static
Float:a,
Float:x3,
Float:y3,
Float:z3;
a = atan2(y2 - y1, x2 - x1);
x3 = floatsin(-a-90, degrees); x3 *= floatabs(x2 - x1) / floatabs(x3) / maxSteps;
y3 = floatcos(-a-90, degrees); y3 *= floatabs(y2 - y1) / floatabs(y3) / maxSteps;
#pragma unused id
if(x1 > x2)
{
for( ; x1 > x2; )
{
y2 += y3;
x2 += x3;
MapAndreas_FindZ_For2DCoord(x2, y2, z3);
if(floatabs(z2-z3) > maxHeigth)
{
return 0;
}
z2 = z3;
}
}
else
{
for( ; x1 < x2; )
{
y2 += y3;
x2 += x3;
MapAndreas_FindZ_For2DCoord(x2, y2, z3);
if(floatabs(z2-z3) > maxHeigth)
{
return 0;
}
z2 = z3;
}
}
return floatabs(z3-z1) < maxHeigth;
}
https://sampforum.blast.hk/showthread.php?tid=528732
Thanks.
