Portal SAMP
[Ajuda] Movimento aleatório FCNPC - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Movimento aleatório FCNPC (/showthread.php?tid=1733)



Movimento aleatório FCNPC - DeathSync - 17/10/2021

To tentando criar um sistema de movimentação aleatória, mas tô com um problema, os nps estão indo em uma unica direção e saem atravessando tudo, alguém sabe como faço para eles ficarem rodando aleatoriamente?

Código:
                else if(dist >= 20.0)
                 {
                    new Float:x, Float:y, Float:z;
                    if(Attack[npcid] == 1)
                    {
                        new pos = random(4);
                        if(pos == 0) { x = x + 100.0; }
                        else if(pos == 1) { x = x - 100.0; }
                        else if(pos == 2) { y = y + 100.0; }
                        else if(pos == 3) { y = y - 100.0; }
                       

                    }
                        FCNPC_SetKeys(npcid, 0, 0, 0);
                        FCNPC_GoTo(npcid, x, y, z, FCNPC_MOVE_TYPE_WALK);

                }



RE: Movimento aleatório FCNPC - Vel - 17/10/2021

Código:
RandomlyMoveNPC(npcid, Float: radius = 3.0) {
  new Float: x,
    Float: y,
    Float: z,
    Float: min_x,
    Float: min_y,
    Float: max_x,
    Float: max_y;

  FCNPC_GetPosition(npcid, x, y, z);

  min_x = x - radius;
  min_y = y - radius;
  max_x = x + radius;
  max_y = y + radius;

  x = random(floatround(max_x) - floatround(min_x)) + floatround(min_x);
  y = random(floatround(max_y) - floatround(min_y)) + floatround(min_y);

  FCNPC_GoTo(npcid, x, y, z);
}

Agora, para que o NPC não atravesse paredes, você precisará usar o plugin ColAndreas.


RE: Movimento aleatório FCNPC - xbruno1000x - 17/10/2021

Confira nas constantes do plugin, lá tem as definições das funções que você pode usar de parâmetro para utilizar o mapandreas e o ColAndreas.

link:
https://github.com/ziggi/FCNPC


RE: Movimento aleatório FCNPC - DeathSync - 18/10/2021

Código:
filterscripts\zom.pwn(74) : error 012: invalid function call, not a valid address
filterscripts\zom.pwn(74) : warning 215: expression has no effect
filterscripts\zom.pwn(74) : error 001: expected token: ";", but found ")"
filterscripts\zom.pwn(74) : error 029: invalid expression, assumed zero
filterscripts\zom.pwn(74) : fatal error 107: too many error messages on one line
Linha 74 é a do RandomlyMoveNPC