Zombies climbing over poles.
#1

Zombies are climbing over the poles, dunno why.
Here is the code
PHP код:
             new Float:x,Float:y,Float:z;
             
FCNPC_GetPosition(npcid,x,y,z);
             new 
Float:pxFloat: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(npcidRandomFloat(0.0,360.0));
             }
             else 
// No collision, move.
             
{
                      new 
rand random(3);
                    switch(
rand)
                    {
                       case 
0FCNPC_GoTo(npcid,  pxpyzMOVE_TYPE_WALK0.1);
                       case 
1FCNPC_GoTo(npcid,  pxpyzMOVE_TYPE_WALK0.2);
                       case 
2FCNPC_GoTo(npcid,  pxpyzMOVE_TYPE_WALK0.3);
                       case 
3FCNPC_GoTo(npcid,  pxpyzMOVE_TYPE_WALK0.4);
                    }
             } 
Reply
#2

isn't the pole too small?
Reply
#3

It's the normal pole, the street lights, and even on trees, they climb sometimes and when they climb they just bug themselves out, they just keep moving up and down rapidly on the pole/tree.
Reply
#4

Have you tried to lower the radius?
Код:
GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),0.5,px,py);
Could you share this part of the code?
Код:
IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc)
Reply
#5

Quote:
Originally Posted by whadez
Посмотреть сообщение
Have you tried to lower the radius?
Код:
GetPointInFront2D(x,y,FCNPC_GetAngle(npcid),0.5,px,py);
Could you share this part of the code?
Код:
IsBetweenElementToPointIsWall(px,py,z,npcid,item_fcnpc)
This knowledge will not help you
PHP код:
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);

Reply
#6

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
This knowledge will not help you
PHP код:
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);

So... any idea?
Reply
#7

Do you have MapAndreas enabled in FCNPC?
Код:
FCNPC_ToggleMapAndreasUsage()
Also, when a NPC finds an obstacle his facing angle SHOULD be inverted, not randomly changed. Doing so will eventually cause you an headache.

Код:
new inverted_angle = (floatround(FCNPC_GetAngle(npcid)) + 180) % 360;
FCNPC_SetAngle(npcid,  float(inverted_angle));
Reply
#8

Quote:
Originally Posted by Marricio
Посмотреть сообщение
Do you have MapAndreas enabled in FCNPC?
Код:
FCNPC_ToggleMapAndreasUsage()
Also, when a NPC finds an obstacle his facing angle SHOULD be inverted, not randomly changed. Doing so will eventually cause you an headache.

Код:
new inverted_angle = (floatround(FCNPC_GetAngle(npcid)) + 180) % 360;
FCNPC_SetAngle(npcid,  float(inverted_angle));
I use ColAndreas only, not MapAndreas, as ColAndreas can do many stuffs including what MapAndreas does and about that angle, I'll keep that in mind, thanks and about that pole issue, what should I do?
Reply
#9

It's probably caused by FCNPC internal behaviour, let's discard an option:

Код:
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);
If there is a difference between debug 1 and debug 2 then a function is internally changing the Z variable. Otherwise, FCNPC internal movement process automatically sets the NPC to the highest Z (like mapandreas).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)