new Float:x,Float:y,Float:z;
FCNPC_GetPosition(npcid,x,y,z);
new Float:px, Float:py;
new Float:p,Float:p1,Float:p2;
GetPlayerPos(playerid,p,p1,p2);
GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),1.0,px,py);
// Check collision
if(IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc) || IsPointInWaterOrientOfElement(npcid,item_fcnpc,3.0,o_front))
{
FCNPC_SetAngle(npcid, RandomFloat(0.0,360.0));
}
else // No collision, move.
{
new rand = random(3);
switch(rand)
{
case 0: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.1);
case 1: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.2);
case 2: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.3);
case 3: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.4);
}
}
GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),0.5,px,py);
IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc)
Have you tried to lower the radius?
Код:
GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),0.5,px,py); Код:
IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc) |
Tryg3D::Function:: IsBetweenElementToPointIsWall(Float:x,Float:y,Float:z,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
new Float:xB,Float:yB,Float:zB,Float:T3D:tmp;
if(!GetElementPos(targetid,target_type,xB,yB,zB)) return false;
return ColAndreas::RayCastLine(xB,yB,zB,x,y,z,T3D:tmp,T3D:tmp,T3D:tmp);
}
This knowledge will not help you
PHP код:
|
FCNPC_ToggleMapAndreasUsage()
new inverted_angle = (floatround(FCNPC_GetAngle(npcid)) + 180) % 360; FCNPC_SetAngle(npcid, float(inverted_angle));
Do you have MapAndreas enabled in FCNPC?
Код:
FCNPC_ToggleMapAndreasUsage() Код:
new inverted_angle = (floatround(FCNPC_GetAngle(npcid)) + 180) % 360; FCNPC_SetAngle(npcid, float(inverted_angle)); |
new Float:x,Float:y,Float:z; FCNPC_GetPosition(npcid,x,y,z); printf("Debug 1 > %f", z); new Float:px, Float:py; new Float:p,Float:p1,Float:p2; GetPlayerPos(playerid,p,p1,p2); GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),1.0,px,py); // Check collision if(IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc) || IsPointInWaterOrientOfElement(npcid,item_fcnpc,3.0,o_front)) { FCNPC_SetAngle(npcid, RandomFloat(0.0,360.0)); } else // No collision, move. { new rand = random(3); switch(rand) { case 0: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.1); case 1: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.2); case 2: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.3); case 3: FCNPC_GoTo(npcid, px, py, z, MOVE_TYPE_WALK, 0.4); } printf("Debug 2 > %f", z);