Portal SAMP
[Plugin] FCNPC Criador de npcs controláveis - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Lançamentos (https://portalsamp.com/forumdisplay.php?fid=26)
+---- Fórum: Plugins (https://portalsamp.com/forumdisplay.php?fid=10)
+---- Tópico: [Plugin] FCNPC Criador de npcs controláveis (/showthread.php?tid=3048)



FCNPC Criador de npcs controláveis - zBreno - 03/12/2022

Esse plugin é um fork https://github.com/ziggi/FCNPC do projeto desse autor https://github.com/MedAnisBenSalah/FCNPC plugin que adiciona recursos extras aos npcs padrão do samp a wiki dele https://github.com/ziggi/FCNPC/wiki não tá totalmente completa mas já ajuda um pouco os programadores que mantêm esse fork são ativos na página de questões https://github.com/ziggi/FCNPC/issues no discord do samp / open.mp o plugin precisa do mapandreas e do colandreas pra o npc não ficar atravessando paredes e nem flutuando

cole isso na pesquisa do google
Código:
site:sampforum.blast.hk fcnpc
pra ver as páginas arquivadas de ajuda sobre ele, no download do arquivo vem três fs mostrando como movimentar os ncps, o comportamento da movimentação segue aquele padrão da roda gigante aquele fs que já vem nos arquivos do samp server

esse fs carrega 100 npcs no servidor https://raw.githubusercontent.com/atx150w/pawn/main/peds.pwn autor neutralneu

exemplo de guardas anti-dm no dp de ls eles vão ficar parados esperando alguém atirar, se você quiser que ele vá ate o jogador tem que usar a native go to player no weapon shot e a go to no on player death pra ele voltar pra o seu ponto de spawn e dar spawn nele pra mudar a face dele e aplicar a sua animação novamente fcnpc_move_type define o jeito de andar nessas duas natives 0 pra caminhar e 1 pra correr lento e 2 pra correr rápido, se você não definir nada o padrão será o auto, abra a include para ler as natives, quando o servidor inicia ele sempre gera um log de crash FCNPC_UseCrashLog(false); de npc pra você publicar lá no github se precisar de ajuda, existe um bug que acontece as vezes onde o npc segue você depois de morto se a sua área de spawn for muito perto da área de gatilho dele, eu não sei como resolver isso

Código:
#include <mapandreas>
#include <colandreas>
#include <fcnpc>

new Guardas[6], AnimNpcForPlayer[MAX_PLAYERS]; // FCNPC
forward RespawnGuardas();
forward AplicarAnimacao();

public OnGameModeInit()
{
FCNPC_UseCrashLog(false);
MapAndreas_Init(MAP_ANDREAS_MODE_FULL); // FCNPC
Guardas[0] = FCNPC_Create("Mario");
Guardas[1] = FCNPC_Create("Moises");
Guardas[2] = FCNPC_Create("Marlon");
Guardas[3] = FCNPC_Create("Alan");
Guardas[4] = FCNPC_Create("Adriel");
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetWeapon(Guardas[0], 31);
FCNPC_UseInfiniteAmmo(Guardas[0], true);
FCNPC_SetInvulnerable(Guardas[0], true);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[0], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetWeapon(Guardas[1], 31);
FCNPC_UseInfiniteAmmo(Guardas[1], true);
FCNPC_SetInvulnerable(Guardas[1], true);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[1], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetWeapon(Guardas[2], 31);
FCNPC_UseInfiniteAmmo(Guardas[2], true);
FCNPC_SetInvulnerable(Guardas[2], true);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[2], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetWeapon(Guardas[3], 31);
FCNPC_UseInfiniteAmmo(Guardas[3], true);
FCNPC_SetInvulnerable(Guardas[3], true);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[3], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetWeapon(Guardas[4], 31);
FCNPC_UseInfiniteAmmo(Guardas[4], true);
FCNPC_SetInvulnerable(Guardas[4], true);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[4], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
SetTimer("AplicarAnimacao",3000,false);
return 1;
}

// Como esse plugin tem algum problema para animar os npcs to tentando várias formas de aplicar a animação antes do jogador entrar.
public AplicarAnimacao()
{
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[0], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[1], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[2], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[3], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[4], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
print("Aplicando animação nos Guardas!");
return 1;
}

public OnPlayerConnect(playerid)
{
AnimNpcForPlayer[playerid] = 0;
return 1;
}

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerInRangeOfPoint(playerid,100.0,1479.4541,-1656.3832,14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1515.0442, -1717.6755, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1444.3602, -1717.5654, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1444.5616, -1607.2711, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1514.5153, -1607.2125, 14.0469))
{
if(AnimNpcForPlayer[playerid] == 0)
{
SendClientMessage(playerid, -1, "Um guarda viu você atirando aqui!");
FCNPC_ClearAnimations(Guardas[0]);
FCNPC_AimAtPlayer(Guardas[0], playerid, true);
//FCNPC_GoToPlayer(Guardas[0], playerid); // Segue o player depois que ele morre

FCNPC_ClearAnimations(Guardas[1]);
FCNPC_AimAtPlayer(Guardas[1], playerid, true);
//FCNPC_GoToPlayer(Guardas[1], playerid);

FCNPC_ClearAnimations(Guardas[2]);
FCNPC_AimAtPlayer(Guardas[2], playerid, true);
//FCNPC_GoToPlayer(Guardas[2], playerid);

FCNPC_ClearAnimations(Guardas[3]);
FCNPC_AimAtPlayer(Guardas[3], playerid, true);
//FCNPC_GoToPlayer(Guardas[3], playerid);

FCNPC_ClearAnimations(Guardas[4]);
FCNPC_AimAtPlayer(Guardas[4], playerid, true);
//FCNPC_GoToPlayer(Guardas[4], playerid);

AnimNpcForPlayer[playerid] = 1;
}
}
return 1;
}

public RespawnGuardas()
{
FCNPC_Respawn(Guardas[0]);
FCNPC_Respawn(Guardas[1]);
FCNPC_Respawn(Guardas[2]);
FCNPC_Respawn(Guardas[3]);
FCNPC_Respawn(Guardas[4]);
print("O Guarda foi respawnado!");
return 1;
}

public FCNPC_OnSpawn(npcid)
{
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
return 1;
}

public FCNPC_OnRespawn(npcid)
{
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
return 1;
}

public OnPlayerSpawn(playerid)
{
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[4], 133.0138);
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
FCNPC_StopAim(Guardas[0]);
//FCNPC_GoTo(Guardas[0], 1479.6072, -1659.0735, 14.0469);
FCNPC_StopAim(Guardas[1]);
//FCNPC_GoTo(Guardas[1], 1515.0442, -1717.6755, 14.0469);
FCNPC_StopAim(Guardas[2]);
//FCNPC_GoTo(Guardas[2], 1444.3602, -1717.5654, 14.0469);
FCNPC_StopAim(Guardas[3]);
//FCNPC_GoTo(Guardas[3], 1444.5616, -1607.2711, 14.0469);
FCNPC_StopAim(Guardas[4]);
//FCNPC_GoTo(Guardas[4], 1514.5153, -1607.2125, 14.0469);
SetTimer("RespawnGuardas", 10000, false);
AnimNpcForPlayer[playerid] = 0;
return 1;
}