Giter Site home page Giter Site logo

fcnpc's Introduction

FCNPC - Fully Controllable NPC

GitHub version Build Status Build status

Fully Controllable NPC (FCNPC) is a plugin for SA-MP servers which adds a lot of capabilities to the existing standard NPCs.

The latest version can be found in the releases section.

This is a fork of the original repository by OrMisicL.

If you encounter a bug or a crash, create an issue in the issues section with your crashlog and your Pawn script.

For more elaborate discussions see the forum thread (isn't working now, but we hope), or the Russian forum thread.

See the wiki for documentation.

MapAndreas and ColAndreas support

FCNPC supports working with MapAndreas or ColAndreas, for better NPC height positioning. Just add these plugins before FCNPC on the plugins line in the server.cfg file.

Sources

To download the sources, use the following git command:

git clone --recursive https://github.com/ziggi/FCNPC.git

Note the use of the --recursive argument, because this repository contains submodules.

Building

To build the project you can use Visual Studio. To generate the project you can use CMake.
On Windows, execute the following commands:

cd FCNPC
mkdir build
cd build
cmake .. -A Win32

On Linux, execute the following commands:

cd FCNPC
mkdir build
cd build
cmake ..
make

Special thanks

  • SA-MP Team: SA-MP
  • OrMisicL: FCNPC creator
  • Zeex: Subhook library
  • kurta999: YSF plugin
  • Lorenc_, kurta999, Neutralneu, therainycat, Freaksken, karimcambridge: Contributors
  • urShadow, Incognito: Code samples in their plugins
  • Freaksken: Creating and updating the wiki
  • Whole SA-MP community: Testing

Constants

#define FCNPC_INCLUDE_VERSION		The current FCNPC include version.

#define FCNPC_ENTITY_CHECK_NONE		(0)
#define FCNPC_ENTITY_CHECK_PLAYER	(1)
#define FCNPC_ENTITY_CHECK_NPC		(2)
#define FCNPC_ENTITY_CHECK_ACTOR	(4)
#define FCNPC_ENTITY_CHECK_VEHICLE	(8)
#define FCNPC_ENTITY_CHECK_OBJECT	(16)
#define FCNPC_ENTITY_CHECK_POBJECT_ORIG	(32)
#define FCNPC_ENTITY_CHECK_POBJECT_TARG	(64)
#define FCNPC_ENTITY_CHECK_MAP		(128)
#define FCNPC_ENTITY_CHECK_ALL		(255)

#define FCNPC_ENTITY_MODE_AUTO		(-1)
#define FCNPC_ENTITY_MODE_NONE		(0)
#define FCNPC_ENTITY_MODE_COLANDREAS	(1)

#define FCNPC_MOVE_TYPE_AUTO		(-1)
#define FCNPC_MOVE_TYPE_WALK		(0)
#define FCNPC_MOVE_TYPE_RUN		(1)
#define FCNPC_MOVE_TYPE_SPRINT		(2)
#define FCNPC_MOVE_TYPE_DRIVE		(3)

#define FCNPC_MOVE_MODE_AUTO		(-1)
#define FCNPC_MOVE_MODE_NONE		(0)
#define FCNPC_MOVE_MODE_MAPANDREAS	(1)
#define FCNPC_MOVE_MODE_COLANDREAS	(2)

#define FCNPC_MOVE_PATHFINDING_AUTO	(-1)
#define FCNPC_MOVE_PATHFINDING_NONE	(0)
#define FCNPC_MOVE_PATHFINDING_Z	(1)
#define FCNPC_MOVE_PATHFINDING_RAYCAST	(2)

#define FCNPC_MOVE_SPEED_AUTO		(-1.0)
#define FCNPC_MOVE_SPEED_WALK		(0.1552086)
#define FCNPC_MOVE_SPEED_RUN		(0.56444)
#define FCNPC_MOVE_SPEED_SPRINT		(0.926784)

#define FCNPC_MAX_NODES			(64)

#define FCNPC_INVALID_MOVEPATH_ID	(-1)
#define FCNPC_INVALID_RECORD_ID		(-1)

#undef FCNPC_DISABLE_VERSION_CHECK

Callbacks

forward FCNPC_OnInit();
forward FCNPC_OnCreate(npcid);
forward FCNPC_OnDestroy(npcid);
forward FCNPC_OnSpawn(npcid);
forward FCNPC_OnRespawn(npcid);
forward FCNPC_OnDeath(npcid, killerid, reason);
forward FCNPC_OnUpdate(npcid);

forward FCNPC_OnTakeDamage(npcid, issuerid, Float:amount, weaponid, bodypart);
forward FCNPC_OnGiveDamage(npcid, damagedid, Float:amount, weaponid, bodypart);

forward FCNPC_OnReachDestination(npcid);

forward FCNPC_OnWeaponShot(npcid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
forward FCNPC_OnWeaponStateChange(npcid, weapon_state);

forward FCNPC_OnStreamIn(npcid, forplayerid);
forward FCNPC_OnStreamOut(npcid, forplayerid);

forward FCNPC_OnVehicleEntryComplete(npcid, vehicleid, seatid);
forward FCNPC_OnVehicleExitComplete(npcid, vehicleid);
forward FCNPC_OnVehicleTakeDamage(npcid, issuerid, vehicleid, Float:amount, weaponid, Float:fX, Float:fY, Float:fZ);

forward FCNPC_OnFinishPlayback(npcid);

forward FCNPC_OnFinishNode(npcid, nodeid);
forward FCNPC_OnFinishNodePoint(npcid, nodeid, pointid);
forward FCNPC_OnChangeNode(npcid, newnodeid, oldnodeid);

forward FCNPC_OnFinishMovePath(npcid, pathid);
forward FCNPC_OnFinishMovePathPoint(npcid, pathid, pointid);

forward FCNPC_OnChangeHeightPos(npcid, Float:newz, Float:oldz); // disabled by default, see FCNPC_SetMinHeightPosCall

Natives

native FCNPC_GetPluginVersion(version[], const size = sizeof(version));
native FCNPC_SetUpdateRate(rate);
native FCNPC_GetUpdateRate();
native FCNPC_SetTickRate(rate);
native FCNPC_GetTickRate();
native FCNPC_UseMoveMode(mode, bool:use = true);
native bool:FCNPC_IsMoveModeUsed(mode);
native FCNPC_UseMovePathfinding(pathfinding, bool:use = true);
native bool:FCNPC_IsMovePathfindingUsed(pathfinding);
native FCNPC_UseCrashLog(bool:use = true);
native bool:FCNPC_IsCrashLogUsed();

native FCNPC_Create(const name[]);
native FCNPC_Destroy(npcid);
native FCNPC_Spawn(npcid, skinid, Float:x, Float:y, Float:z);
native FCNPC_Respawn(npcid);
native bool:FCNPC_IsSpawned(npcid);
native FCNPC_Kill(npcid);
native bool:FCNPC_IsDead(npcid);
native bool:FCNPC_IsValid(npcid);
native bool:FCNPC_IsStreamedIn(npcid, forplayerid);
native bool:FCNPC_IsStreamedInForAnyone(npcid);
native FCNPC_GetValidArray(npcs[], const size = sizeof(npcs));

native FCNPC_SetPosition(npcid, Float:x, Float:y, Float:z);
native FCNPC_GivePosition(npcid, Float:x, Float:y, Float:z);
native FCNPC_GetPosition(npcid, &Float:x, &Float:y, &Float:z);
native FCNPC_SetAngle(npcid, Float:angle);
native Float:FCNPC_GiveAngle(npcid, Float:angle);
native FCNPC_SetAngleToPos(npcid, Float:x, Float:y);
native FCNPC_SetAngleToPlayer(npcid, playerid);
native Float:FCNPC_GetAngle(npcid);
native FCNPC_SetQuaternion(npcid, Float:w, Float:x, Float:y, Float:z);
native FCNPC_GiveQuaternion(npcid, Float:w, Float:x, Float:y, Float:z);
native FCNPC_GetQuaternion(npcid, &Float:w, &Float:x, &Float:y, &Float:z);
native FCNPC_SetVelocity(npcid, Float:x, Float:y, Float:z, bool:update_pos = false);
native FCNPC_GiveVelocity(npcid, Float:x, Float:y, Float:z, bool:update_pos = false);
native FCNPC_GetVelocity(npcid, &Float:x, &Float:y, &Float:z);
native FCNPC_SetSpeed(npcid, Float:speed);
native Float:FCNPC_GetSpeed(npcid);
native FCNPC_SetInterior(npcid, interiorid);
native FCNPC_GetInterior(npcid);
native FCNPC_SetVirtualWorld(npcid, worldid);
native FCNPC_GetVirtualWorld(npcid);

native FCNPC_SetHealth(npcid, Float:health);
native Float:FCNPC_GiveHealth(npcid, Float:health);
native Float:FCNPC_GetHealth(npcid);
native FCNPC_SetArmour(npcid, Float:armour);
native Float:FCNPC_GiveArmour(npcid, Float:armour);
native Float:FCNPC_GetArmour(npcid);

native FCNPC_SetInvulnerable(npcid, bool:invulnerable = true);
native bool:FCNPC_IsInvulnerable(npcid);

native FCNPC_SetSkin(npcid, skinid);
native FCNPC_GetSkin(npcid);
#if FCNPC_SAMP_03DL
	native FCNPC_GetCustomSkin(npcid);
#endif

native FCNPC_SetWeapon(npcid, weaponid);
native FCNPC_GetWeapon(npcid);
native FCNPC_SetAmmo(npcid, ammo);
native FCNPC_GiveAmmo(npcid, ammo);
native FCNPC_GetAmmo(npcid);
native FCNPC_SetAmmoInClip(npcid, ammo);
native FCNPC_GiveAmmoInClip(npcid, ammo);
native FCNPC_GetAmmoInClip(npcid);
native FCNPC_SetWeaponSkillLevel(npcid, skill, level);
native FCNPC_GiveWeaponSkillLevel(npcid, skill, level);
native FCNPC_GetWeaponSkillLevel(npcid, skill);
native FCNPC_SetWeaponState(npcid, weapon_state);
native FCNPC_GetWeaponState(npcid);

native FCNPC_SetWeaponReloadTime(npcid, weaponid, time);
native FCNPC_GetWeaponReloadTime(npcid, weaponid);
native FCNPC_GetWeaponActualReloadTime(npcid, weaponid);
native FCNPC_SetWeaponShootTime(npcid, weaponid, time);
native FCNPC_GetWeaponShootTime(npcid, weaponid);
native FCNPC_SetWeaponClipSize(npcid, weaponid, size);
native FCNPC_GetWeaponClipSize(npcid, weaponid);
native FCNPC_GetWeaponActualClipSize(npcid, weaponid);
native FCNPC_SetWeaponAccuracy(npcid, weaponid, Float:accuracy);
native Float:FCNPC_GetWeaponAccuracy(npcid, weaponid);
native FCNPC_SetWeaponInfo(npcid, weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
native FCNPC_GetWeaponInfo(npcid, weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);
native FCNPC_SetWeaponDefaultInfo(weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
native FCNPC_GetWeaponDefaultInfo(weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);

native FCNPC_SetKeys(npcid, ud_analog, lr_analog, keys);
native FCNPC_GetKeys(npcid, &ud_analog, &lr_analog, &keys);

native FCNPC_SetSpecialAction(npcid, actionid);
native FCNPC_GetSpecialAction(npcid);

native FCNPC_SetAnimation(npcid, animationid, Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
native FCNPC_SetAnimationByName(npcid, const name[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
native FCNPC_ResetAnimation(npcid);
native FCNPC_GetAnimation(npcid, &animationid = 0, &Float:fDelta = 4.1, &loop = 0, &lockx = 1, &locky = 1, &freeze = 0, &time = 1);
native FCNPC_ApplyAnimation(npcid, const animlib[], const animname[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
native FCNPC_ClearAnimations(npcid);

native FCNPC_SetFightingStyle(npcid, style);
native FCNPC_GetFightingStyle(npcid);

native FCNPC_UseReloading(npcid, bool:use = true);
native bool:FCNPC_IsReloadingUsed(npcid);
native FCNPC_UseInfiniteAmmo(npcid, bool:use = true);
native bool:FCNPC_IsInfiniteAmmoUsed(npcid);

native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stop_delay = 250);
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stop_delay = 250);
native FCNPC_Stop(npcid);
native bool:FCNPC_IsMoving(npcid);
native bool:FCNPC_IsMovingAtPlayer(npcid, playerid);
native FCNPC_GetDestinationPoint(npcid, &Float:x, &Float:y, &Float:z);

native FCNPC_AimAt(npcid, Float:x, Float:y, Float:z, bool:shoot = false, shoot_delay = -1, bool:set_angle = true, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0, between_check_mode = FCNPC_ENTITY_MODE_AUTO, between_check_flags = FCNPC_ENTITY_CHECK_ALL);
native FCNPC_AimAtPlayer(npcid, playerid, bool:shoot = false, shoot_delay = -1, bool:set_angle = true, Float:offset_x = 0.0, Float:offset_y = 0.0, Float:offset_z = 0.0, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0, between_check_mode = FCNPC_ENTITY_MODE_AUTO, between_check_flags = FCNPC_ENTITY_CHECK_ALL);
native FCNPC_StopAim(npcid);
native FCNPC_MeleeAttack(npcid, delay = -1, bool:fighting_style = false);
native FCNPC_StopAttack(npcid);
native bool:FCNPC_IsAttacking(npcid);
native bool:FCNPC_IsAiming(npcid);
native bool:FCNPC_IsAimingAtPlayer(npcid, playerid);
native FCNPC_GetAimingPlayer(npcid);
native bool:FCNPC_IsShooting(npcid);
native bool:FCNPC_IsReloading(npcid);
native FCNPC_TriggerWeaponShot(npcid, weaponid, hittype, hitid, Float:x, Float:y, Float:z, bool:is_hit = true, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0, between_check_mode = FCNPC_ENTITY_MODE_AUTO, between_check_flags = FCNPC_ENTITY_CHECK_ALL);
native FCNPC_GetClosestEntityInBetween(npcid, Float:x, Float:y, Float:z, Float:range, between_check_mode = FCNPC_ENTITY_MODE_AUTO, between_check_flags = FCNPC_ENTITY_CHECK_ALL, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0, &entity_id = -1, &entity_type = -1, &object_owner_id = INVALID_PLAYER_ID, &Float:point_x = 0.0, &Float:point_y = 0.0, &Float:point_z = 0.0);

native FCNPC_EnterVehicle(npcid, vehicleid, seatid, type = FCNPC_MOVE_TYPE_WALK);
native FCNPC_ExitVehicle(npcid);

native FCNPC_PutInVehicle(npcid, vehicleid, seatid);
native FCNPC_RemoveFromVehicle(npcid);
native FCNPC_GetVehicleID(npcid);
native FCNPC_GetVehicleSeat(npcid);
native FCNPC_UseVehicleSiren(npcid, bool:use = true);
native bool:FCNPC_IsVehicleSirenUsed(npcid);
native FCNPC_SetVehicleHealth(npcid, Float:health);
native Float:FCNPC_GetVehicleHealth(npcid);
native FCNPC_SetVehicleHydraThrusters(npcid, direction);
native FCNPC_GetVehicleHydraThrusters(npcid);
native FCNPC_SetVehicleGearState(npcid, gear_state);
native FCNPC_GetVehicleGearState(npcid);
native FCNPC_SetVehicleTrainSpeed(npcid, Float:speed);
native Float:FCNPC_GetVehicleTrainSpeed(npcid);

native FCNPC_SetSurfingOffsets(npcid, Float:x, Float:y, Float:z);
native FCNPC_GiveSurfingOffsets(npcid, Float:x, Float:y, Float:z);
native FCNPC_GetSurfingOffsets(npcid, &Float:x, &Float:y, &Float:z);
native FCNPC_SetSurfingVehicle(npcid, vehicleid);
native FCNPC_GetSurfingVehicle(npcid);
native FCNPC_SetSurfingObject(npcid, objectid);
native FCNPC_GetSurfingObject(npcid);
native FCNPC_SetSurfingPlayerObject(npcid, objectid);
native FCNPC_GetSurfingPlayerObject(npcid);
#if defined _streamer_included
	native FCNPC_SetSurfingDynamicObject(npcid, objectid);
	native FCNPC_GetSurfingDynamicObject(npcid);
#endif
native FCNPC_StopSurfing(npcid);

native FCNPC_StartPlayingPlayback(npcid, const file[] = "", recordid = FCNPC_INVALID_RECORD_ID, bool:auto_unload = false, Float:delta_x = 0.0, Float:delta_y  = 0.0, Float:delta_z  = 0.0, Float:delta_qw = 0.0, Float:delta_qx = 0.0, Float:delta_qy = 0.0, Float:delta_qz = 0.0);
native FCNPC_StopPlayingPlayback(npcid);
native FCNPC_PausePlayingPlayback(npcid);
native FCNPC_ResumePlayingPlayback(npcid);
native FCNPC_LoadPlayingPlayback(const file[]);
native FCNPC_UnloadPlayingPlayback(recordid);
native FCNPC_SetPlayingPlaybackPath(npcid, const path[]);
native FCNPC_GetPlayingPlaybackPath(npcid, path[], const size = sizeof(path));

native FCNPC_OpenNode(nodeid);
native FCNPC_CloseNode(nodeid);
native bool:FCNPC_IsNodeOpen(nodeid);
native FCNPC_GetNodeType(nodeid);
native FCNPC_SetNodePoint(nodeid, pointid);
native FCNPC_GetNodePointPosition(nodeid, &Float:x, &Float:y, &Float:z);
native FCNPC_GetNodePointCount(nodeid);
native FCNPC_GetNodeInfo(nodeid, &vehnodes, &pednodes, &navinode);
native FCNPC_PlayNode(npcid, nodeid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true);
native FCNPC_StopPlayingNode(npcid);
native FCNPC_PausePlayingNode(npcid);
native FCNPC_ResumePlayingNode(npcid);
native bool:FCNPC_IsPlayingNode(npcid);
native bool:FCNPC_IsPlayingNodePaused(npcid);

native FCNPC_CreateMovePath();
native FCNPC_DestroyMovePath(pathid);
native bool:FCNPC_IsValidMovePath(pathid);
native FCNPC_AddPointToMovePath(pathid, Float:x, Float:y, Float:z);
native FCNPC_AddPointsToMovePath(pathid, Float:points[][3], const size = sizeof(points));
native FCNPC_AddPointsToMovePath2(pathid, Float:points_x[], Float:points_y[], Float:points_z[], const size = sizeof(points_x));
native FCNPC_RemovePointFromMovePath(pathid, pointid);
native bool:FCNPC_IsValidMovePathPoint(pathid, pointid);
native FCNPC_GetMovePathPoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
native FCNPC_GetNumberMovePathPoint(pathid);
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);

native FCNPC_SetMoveMode(npcid, mode);
native FCNPC_GetMoveMode(npcid);
native FCNPC_SetMinHeightPosCall(npcid, Float:height);
native Float:FCNPC_GetMinHeightPosCall(npcid);

native FCNPC_ShowInTabListForPlayer(npcid, forplayerid);
native FCNPC_HideInTabListForPlayer(npcid, forplayerid);

Vendor Natives

For some reasons FCNPC includes some another plugins. You don't need to use this plugins separately.

MapAndreas

MapAndreas 1.2.1 included.

ColAndreas

Latest ColAndreas version included.

fcnpc's People

Contributors

0x416c69 avatar amyrahmady avatar fairuz-afdhal avatar is4code avatar karimcambridge avatar ormisicl avatar prineside avatar southclaws avatar vsergeenko777 avatar woutprovost avatar yousha avatar ziggi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fcnpc's Issues

Issue on FCNPC_OnStreamIn

Hello,

I have just noted that only one player can be streamed by a bot.

I spawned 2 bots side by side, and the callback has been called just one time (for one NPC) when I walked next to tne npc.

public FCNPC_OnStreamIn(npcid, forplayerid)
{
    printf("Player(%d) streamed in by NPC(%d)", forplayerid, npcid);
    Bot_AddPlayerStreamed(npcid, forplayerid);
}

Thanks for your help !

Crashing at startup

hello, every time i start FCNPC my samp_server.exe closes and a new file "fcnpc-crash" gets created.
I use the latest plugin and include, i put the require callbacks in the gamemode. Can you help, please?

Playback improvements

General improvements

http://forum.sa-mp.com/showpost.php?p=3673241&postcount=2614

  • Create class CRecording with Load method. This method load recording file from disk into memory and returning pointer or just returning pointer if file already in memory.

New functions

native FCNPC_LoadPlayingPlayback(file[]);
native FCNPC_UnloadPlayingPlayback(recordid);
native FCNPC_SetPlayingPlaybackPath(npcid, path[]);
native FCNPC_GetPlayingPlaybackPath(npcid, path[], const size = sizeof(path));

Updated functions

native FCNPC_StartPlayingPlayback(npcid, file[] = "", recordid = INVALID_RECORD_ID, bool:auto_unload = false);

New callbacks

forward FCNPC_OnFinishMovePath(npcid, pathid);
forward FCNPC_OnFinishMovePathPoint(npcid, pathid, pointid);

Разворот бота лицом к игроку

Привет, Ziggi. Использую этот плагин для создания ботов-зомби :) Но, вот возникла проблемка. Используя стандартный native FCNPC_SetAngle или FCNPC_AimAtPlayer, для установления бота лицом к игроку, после чего он начинает бить игрока (MeleeAttack), но его всегда разворачивает в любую сторону, но не к игроку. Бывает 1 раз из 10-ти ударит, и то если подловит. В общем, с чем это связано и возможно ли это пофиксить?

FCNPC Exception - Crash report

Just got this report after server restart:

`=========================== FCNPC Exception Handler ============================
Address: 0x6da5f3b8

Registers:
EAX: 0x0 - EBX: 0x1fc9710 - ECX: 0x0 - EDX: 0xf0
ESI: 0x4a - EDI: 0x66cf08 - EBP: 0x769834c8 - ESP: 0x18fe00

Stack:
0x0: 0x1fc9cfc - 0x4: 0x2b00020 - 0x8: 0x6da7448d - 0xC: 0x1fc9c50 - 0x10: 0x469dfb - 0x14: 0x1fc9710
0x18: 0x769810ff - 0x1C: 0x76981136 - 0x20: 0x0

Information:
System: Windows
SA-MP: 0.3.7 R2-1
FCNPC: 1.6.1

Functions:
FUNC_CPlayerPool__DeletePlayer: 0x466570
FUNC_CPlayer__Kill: 0x484620
FUNC_CPlayer__EnterVehicle: 0x484c70
FUNC_CPlayer__ExitVehicle: 0x484f50
FUNC_CPlayer__SpawnForWorld: 0x486d30
FUNC_GetVehicleModelInfo: 0x488240
FUNC_CConsole__GetIntVariable: 0x48b5b0
FUNC_ClientJoin_RPC: 0x4918f0

Pointers:
VAR_ServerAuthentication: 0x4f5fe8
VAR_NetVersion: 0xfd9

Offsets:
OFFSET_RemoteSystemManager: 0x33c
OFFSET_RemoteSystemSize: 0xcb8
OFFSET_RemoteSystem__ConnectMode: 0xcb0
OFFSET_RemoteSystem__Unknown: 0xcb5
=========================== FCNPC Exception Handler ============================`

FCNPC_MeleeAttack function

Hi,

FCNPC_MeleeAttack function doesn't work probably, the thing is, it doesn't work continuously, as it's supposed to be.

this is my simple code where no other suspicious editions of variables are out of this callback;

timer` ZombieMove[500](zombieid)
{
    new Float:x,Float:y,Float:z,Float:zombiepos[3];
    if(FCNPC_IsDead(zombieid)) return 1;
    GetPlayerPos(ZombieAttackPID[zombieid],x,y,z);
    if(IsPlayerInRangeOfPoint(zombieid,1.7,x,y,z))
    {
        ZombieIsAttack[zombieid] = 2;
        FCNPC_GetPosition(zombieid,zombiepos[0],zombiepos[1],zombiepos[2]);
        FCNPC_SetAngle(zombieid,DayZ_Z_GetAngleToPoint(zombiepos[0],zombiepos[1],x,y));
        **FCNPC_MeleeAttack(zombieid,100);**
        SendClientMessageToAll(-1, "DEBUG: ZOMBIE IS STILL ATTACKING - NEAR: 1.7 FEETS");

    }
    else if(IsPlayerInRangeOfPoint(zombieid,10.0,x,y,z))
    {
        if(ZombieIsAttack[zombieid] == 2)
        {
            FCNPC_Stop(zombieid);
            FCNPC_StopAttack(zombieid);
        }
        ZombieIsAttack[zombieid] = 1;
        FCNPC_GoTo(zombieid,x,y,z,MOVE_TYPE_AUTO,1,true);
        SendClientMessageToAll(-1, "DEBUG: ZOMBIE IS AWAY OF TARGET 10 FEETS");
    }
    else if(IsPlayerInRangeOfPoint(zombieid,PlayerRangeZAttack[ZombieAttackPID[zombieid]],x,y,z))
    {
        if(ZombieIsAttack[zombieid] == 2)
        {
            FCNPC_Stop(zombieid);
            FCNPC_StopAttack(zombieid);
        }
        ZombieIsAttack[zombieid] = 1;
        FCNPC_GoToPlayerEx(zombieid, ZombieAttackPID[zombieid],5,5,MOVE_TYPE_SPRINT);
        new str[90];
        format(str, 90, "ZOMBIE IS NOW AWAY OF THE TARGET WITHIN: %i FEETS", PlayerRangeZAttack[ZombieAttackPID[zombieid]]);
        SendClientMessageToAll(-1, str);
    }
    else
    {
        ZombieIsAttack[zombieid] = 0;
        PlayerRangeZAttack[ZombieAttackPID[zombieid]] = DefaultZAttackRange;
        SendClientMessageToAll(-1, "DEBUG: Player is now far away of the zombie.");
    }
    return 1;
}

the time between each melee attack is set to 100 millseconds, however, NPC's do a melee attack once

Compatibility with weapon-config.inc

Hi, it says that we need to declare functions in the script if we want it to work correctly.
Well the function OnPlayerTakeDamage is replaced with weapon-config.inc what should I do then, ignore? I guess not...

Thank you,
rt-2

Проблема с работой функции FCNPC_GoTo

Пробовал воспользоваться функцией FCNPC_GoTo но почему-то, после ее использования, NPC просто поворачиваются в каком то направлении и дальше не идут.
Пробовал потом использовать из примеров скрипт, FCNPC.pwn, все так же.. Но вот FCNPC_GoToPlayer работает отлично.
Может я что то упустил, но вроде использовал скрипт из примеров, и там код не менял.

Inquiry

Thats not an issue, but i want to ask whether you can implement FCNPC_GetWorld(int npcid) and FCNPC_SetWorld(int npcid, int worldId) ? :)

Shooting NPC and cheaters

First of all, thanks for maintaining this project! I'm glad to see NPCs are shooting again.

I was trying to create enemies with firearms and realized that I can't create sufficient protection against cheaters - simple GodMode cheat disables FCNPC_OnGiveDamage callback. NPCs are not completely accurate in shooting so I can't be sure that the lack of callback calls means cheating.

It would be nice if you add natives for bullet creation method to PAWN. I know I can use YSF for that but installation of one more plugin for just one function would be quite an overkill. Also, disabling default bullet creation would also be nice, so we can leave only shooting sounds and create bullets manually.

It may also be useful to invoke something like OnPlayerWeaponShot right when NPC shoots, even without bullet origin and hit positions, just to know when players will hear shot sound and see bullet particles.

How we can use these things against cheaters:
First of all, disable default NPC bullers and ignore FCNPC_OnGiveDamage as it is not safe to rely on it. Then in NPC version of OnPlayerWeaponShoot we use ColAndreas to cast a ray between NPC and its target. If there are no obstacles, we spawn a bullet which hits the target (we can also add some kind of accuracy here) and change target's health. As a result, no cheat will save player from being hit by NPC.

Thanks!

FCNPC_OnTakeDamage dispatching 9 parameters.

When using sampgdk's OnPublicCall function, you will see that the parameter count equals 9 for the OnTakeDamage event instead of 5.

    if(name == "FCNPC_OnTakeDamage")
    {
        int count = params[0] / sizeof(cell);
        for (int i = 0; i < count; i++)
        {
            auto value = params[i + 1];
            sampgdk_logprintf("FCNPC_OnTakeDamage #%i value: %i", i, value);
        }
    }

output:

FCNPC_OnTakeDamage #0 value: 499                //NPC ID
FCNPC_OnTakeDamage #1 value: 0                    //IssuerID
FCNPC_OnTakeDamage #2 value: 29                  //WeaponID
FCNPC_OnTakeDamage #3 value: 9                    //Bodypart
FCNPC_OnTakeDamage #4 value: 1090781184  //Health_loss Float Address
FCNPC_OnTakeDamage #5 value: 499 
FCNPC_OnTakeDamage #6 value: 1090781184
FCNPC_OnTakeDamage #7 value: 29
FCNPC_OnTakeDamage #8 value: 9

Анимации для бота

При создании бота и после его спавна, он должен принимать анимацию, но почему-то ничего не происходит, т.е бот просто стоит.

for(new i = 0; i < sizeof(ZombiesInfo); i++)
	{
		ZombiesInfo[i][Connect] = FCNPC_Create(ZombiesInfo[i][Name]);
		PreloadZAnimLib(ZombiesInfo[i][Connect],"CRACK");
 		FCNPC_Spawn(ZombiesInfo[i][Connect], ZombiesInfo[i][Skin], ZombiesInfo[i][SpX], ZombiesInfo[i]           [SpY], ZombiesInfo[i][SpZ]);
        FCNPC_ApplyAnimation(ZombiesInfo[i][Connect], "CRACK", "crckdeth2", 4.1, 0, 1, 1, 1, 1);
	}

Как видно пытался сделать подзагрузку анимации, безрезультатно.

stock PreloadZAnimLib(npcid, animlib[])return FCNPC_ApplyAnimation(npcid, animlib, "null", 0.0, 0, 0, 0, 1, 1);

Bad NPC sync with FCNPC_GoByMovePath

When I use function FCNPC_GoByMovePath and z value isn't the same (is lower or higher) then bot's sync looks like teleport from point to point. Is it cause by plugin or my internet connection? Actually I'm testing it on localhost.

Compile problem - The source directory not contain a CMakeLists.txt file

I cant compile this plugin in a Fresh system...

Error:

CMake Error at CMakeLists.txt:49 (add_subdirectory):
The source directory /root/FCNPC/lib/subhook does not contain a CMakeLists.txt file.
-- Configuring incomplete, errors occurred!

Platform:
GCC 5.3.0
Slackware 14 64-bit
x64 based system

Steps:
cd FCNPC
mkdir build
cd build
cmake .. <------ got error here
make

FCNPC - Debian 8.5

#Dear Ziggi!

I have a SaMp serverin Debian 8.5. We need FCNPC for fs, (filterscript) but your's not working, we do not know why. And we started search for this, but we finded only for Ubuntu. Can you help me? We got Debian 8.5 and it is not working.

Pathfinding

After ColAndreas integration (#7), need to add raycast pathfinding. Also need to add A* pathfinding for MapAndreas and ColAndreas.

#define FCNPC_MOVE_MODE_AUTO          (-1)
#define FCNPC_MOVE_MODE_NONE          (0)
#define FCNPC_MOVE_MODE_MAPANDREAS    (1)
#define FCNPC_MOVE_MODE_COLANDREAS    (2)

#define FCNPC_MOVE_PATHFINDING_AUTO    (-1)
#define FCNPC_MOVE_PATHFINDING_NONE    (0)
#define FCNPC_MOVE_PATHFINDING_Z       (1)
#define FCNPC_MOVE_PATHFINDING_RAYCAST (2)
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0, stopdelay = 250);

Movement bug

Possible related with #41.

Hello, I recently realized that my NPC was not setting the angle for the player correctly, because I calculate the angle taking the two positions (NPC and Player). But then I realized that the problem was not in the calculation, but in the position that FCNPC_GetPosition was returning, as in the image below, it is returning the position a little ahead of where I see the NPC (even if the NPC is stopped):

Studying a little more about this BUG, the same happens after using some function that moves the NPC. The function will always return around 1.0 meters from where npc's SKIN really is.

NOTE: The same is also true for FCNPC_SetAngleToPlayer. If the player is too close to the NPC, the angle will be reversed, causing the npc to stand with its back to the player.

Body disappearance

http://forum.sa-mp.com/showpost.php?p=3691458&postcount=2691

The issue is when the NPC is aiming or shooting at player, the upper body disappears.

Video: https://youtu.be/_QUNa4-mK8E

Plugin: FCNPC - Fully Controllable NPC v1.0.5
OS: Windows 10 x64
Code to reproduce:

#include <a_samp>
#include <fcnpc>
#include <izcmd>

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_RED  0xB35959AA

new npcid;

public OnFilterScriptInit()
{
    // Set the update rate
    FCNPC_SetUpdateRate(100);   
    // Create and spawn the NPC
    npcid = FCNPC_Create("Test_Bot");
    if(npcid == INVALID_PLAYER_ID)
    {
        printf("Warning: Failed to create NPC ID %d (%s)", npcid, "Test_Bot");
        return 1;
    }
    FCNPC_Spawn(npcid, random(299), 0, 0, 0);
    return 1;
}

public OnFilterScriptExit()
{
    FCNPC_Destroy(npcid);
    return 1;
}

CMD:nspawn(playerid,params[])
{
    new Float:pPos[3];
    GetPlayerPos(playerid,pPos[0],pPos[1],pPos[2]);
    FCNPC_SetPosition(npcid,pPos[0]+ 3.0,pPos[1],pPos[2]);
    return 1;
}

CMD:ngoto(playerid,params[])
{
    FCNPC_GoToPlayer(npcid,playerid);
    return 1;
}

CMD:ngun(playerid,params[])
{
    FCNPC_SetWeapon(npcid,30);
    FCNPC_SetAmmo(npcid,10);
    return 1;
}

CMD:naim(playerid,params[])
{
    FCNPC_AimAtPlayer(npcid,playerid);
    return 1;
}

CMD:nshoot(playerid,params[])
{
    FCNPC_ToggleReloading(npcid,false);
    FCNPC_ToggleInfiniteAmmo(npcid,true);
    FCNPC_AimAtPlayer(npcid,playerid,true);
    return 1;
}

Hey I have some news, I've just tried plugin FCNPC - Fully Controllable NPC v1.0.5 on my Ubuntu > server and everything works fine! The upper body DOES NOT dissapear.
So this only happens on my Windows Server - local pc server.

Add `Float:dist_offset` parameter to FCNPC_GoToPlayer

For replace function like this:

stock FCNPC_ComeToPlayer(npcid, playerid, Float:dist_offset = -0.5)
{
	new
		Float:npc_x, Float:npc_y, Float:npc_z,
		Float:npc_angle,
		Float:player_x, Float:player_y, Float:player_z,
		Float:distance,
		Float:result_x, Float:result_y;

	FCNPC_GetPosition(npcid, npc_x, npc_y, npc_z);
	npc_angle = FCNPC_GetAngle(npcid);
	GetPlayerPos(playerid, player_x, player_y, player_z);
	distance = VectorSize(npc_x - player_x, npc_y - player_y, npc_z - player_z);
	GetCoordsInFront(npc_x, npc_y, npc_angle, distance + dist_offset, result_x, result_y);

	FCNPC_GoTo(npcid, result_x, result_y, player_z);
}
native FCNPC_GoToPlayer(npcid, playerid, type = MOVE_TYPE_AUTO, Float:speed = MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0);

Continue updating for FCNPC_PausePlayingNode

Can you add an extra parameter to PausePlayingNode

native FCNPC_PausePlayingNode(npcid, continueUpdating = false);

if continueUpdating = true, then all you do is stop the node movement once, then continue to let the NPC be processed by everything but the node movement.

FCNPC_ToggleMapAndreasUsage

If an FCNPC is about to go under 0.0, turn off map andreas.

If an FCNPC is going higher than 0.0, turn on map andreas.

E.G, Hunter Quarry.

FCNPC_GetAnimation has issue

Hello, I want to obtain the current animation of a NPC created with this plugin, but when I try to get the animation ID with FCNPC_GetAnimation I always get 0 on animationid variable.

Tested with last version of FCNPC on Windows.

Code (OnGamemodeInit):

        new npcid;
        new nombre[24];
	for(new i = 0; i < MAX_ZOMBIES; i++)
	{
	    new skinran = random(MAX_ZOMBIES_SKINS);
		format(nombre, 24, "Zombie_%d", i + 1);
		npcid = FCNPC_Create(nombre);
		FCNPC_Spawn(npcid, ZombieSkins[skinran], ZombieSpawns[i][0], ZombieSpawns[i][1], ZombieSpawns[i][2]);
		FCNPC_SetAngle(npcid, ZombieSpawns[0][3]);
		FCNPC_SetInterior(npcid, 0);
                SetTimerEx("TestAnimation", 1000, true, "i", npcid);
	}

Code (TestAnimation public function):

forward TestAnimation (npcid);
public TestAnimation (npcid)
{
	new animlib[32], animacion[32], animationid, Float:fDelta, loop, lockx, locky, freeze, time;
	FCNPC_GetAnimation(npcid, animationid, fDelta, loop, lockx, locky, freeze, time);
	GetAnimationName(animationid,animlib,32,animacion,32);
	printf("Animlib: %s | Animacion: %s | id: %d | animationid %d", animlib, animacion, npcid, animationid);
	return 1;
}

And I get this: (Always, I enter on the server and zombies make a animation but dont show nothing)

[13:47:50] Animlib:  | Animacion:  | id: 253 | animationid 0
[13:47:51] Animlib:  | Animacion:  | id: 253 | animationid 0
[13:47:52] Animlib:  | Animacion:  | id: 253 | animationid 0
[13:47:53] Animlib:  | Animacion:  | id: 253 | animationid 0
[13:47:54] Animlib:  | Animacion:  | id: 253 | animationid 0

Note: I test with id 253 to avoid flood chat. (A NPC has id 151 - 259; 109 NPC = MAX_ZOMBIES; 259 = MAX_PLAYERS)

When zombie attacks calls this:
FCNPC_ApplyAnimation(npcid, "ped", "Shove_Partial", 4.1, true, true , true, true, 2900);

But stills showing in console:
Animlib: | Animacion: | id: 253 | animationid 0
And the animation "Shove Partial" (in this case) applies correctly to NPC.

PD: FCNPC_GetAnimation returns 1 when calls on TestAnimation

Thanks

Npc Damage

I dont know whether its a bug or not implemented, FCNPCs can't damage other FCNPCs.
I coded a bodyguard NPC and a zombie NPC and let them fight, but there does not any damage appear and the onTakeDamage event was not called.

And big thank for fixing this project! :)

Поворот npc

Привет.
Как мне повернуть бота на 10 градусов в лево\право, относительно его направления?
Так пытался

stock AI_MotionTurn(npcid, Float:incangle)
{
    new Float:fangle = FCNPC_GetAngle(npcid);
    FCNPC_Stop(npcid);
    FCNPC_SetAngle(npcid, fangle - incangle);
    return 1;
}

И так

stock AI_MotionTurn(npcid, Float:incangle)
{
    new Float:fangle;
    GetPlayerFacingAngle(npcid, fangle);
    FCNPC_Stop(npcid);
    SetPlayerFacingAngle(npcid, fangle - incangle);
    return 1;
}

А вызывал сток соответственно так AI_MotionTurn(npcid, 10.0);
Но какое бы значение я не ставил он поворачивается на более чем 90 градусов.
Может я что-то не догоняю?:(
Даже когда я ставлю просто FCNPC_SetAngle(npcid, incangle); Всеравно поворачивается на более чем нужно.

Documentation & precision

Hi everyone,

I am working with FCNPC for my bot system, nonetheless, I have an issue with bot moving.
When the bot target is higher than the bot, the bot is floating in the air. How can I fixe this bug?

I saw there is a possibility to use MapAndreas, I set the parameters to true, but nothing change.

And the last point: Do you plan to make a dcumentation ?

MAKE error: gnu/stubs-32.h: No such file or directory

I tried to MAKE it but got error:

bash-4.3# make
[ 3%] Building C object lib/subhook/CMakeFiles/subhook.dir/subhook.c.o In file included from /usr/include/features.h:392:0,
from /usr/include/unistd.h:25,
from /root/FCNPC/lib/subhook/subhook_unix.c:27,
from /root/FCNPC/lib/subhook/subhook.c:48:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
lib/subhook/CMakeFiles/subhook.dir/build.make:62: recipe for target 'lib/subhook/CMakeFiles/subhook.dir/subhook.c.o' failed
make[2]: *** [lib/subhook/CMakeFiles/subhook.dir/subhook.c.o] Error 1
CMakeFiles/Makefile2:470: recipe for target 'lib/subhook/CMakeFiles/subhook.dir/all' failed
make[1]: *** [lib/subhook/CMakeFiles/subhook.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Im using 64-bit OS.

Error: Function not registered... - FCNPC 1.6.1

FCNPC 1.6.1
CentOS
On hostskool.com

server.cfg

crashdetect.so sscanf.so streamer.so mysql.so mysql_static.so whirlpool.so FCNPC.so nativechecker.so

[01:09:12] Error: Function not registered: 'FCNPC_AimAtPlayer'
[01:09:12] Error: Function not registered: 'FCNPC_Spawn'
[01:09:12] Error: Function not registered: 'FCNPC_SetAngleToPlayer'
[01:09:12] Error: Function not registered: 'FCNPC_SetVirtualWorld'
[01:09:12] Error: Function not registered: 'FCNPC_SetInterior'
[01:09:12] Error: Function not registered: 'FCNPC_SetWeapon'
[01:09:12] Error: Function not registered: 'FCNPC_SetAmmo'
[01:09:12] Error: Function not registered: 'FCNPC_SetFightingStyle'
[01:09:12] Error: Function not registered: 'FCNPC_IsInvulnerable'
[01:09:12] Error: Function not registered: 'FCNPC_EnterVehicle'
[01:09:12] Error: Function not registered: 'FCNPC_ExitVehicle'
[01:09:12] Error: Function not registered: 'FCNPC_StopAim'
[01:09:12] Error: Function not registered: 'FCNPC_GetWeapon'
[01:09:12] Error: Function not registered: 'FCNPC_MeleeAttack'
[01:09:12] Error: Function not registered: 'FCNPC_StopAttack'
[01:09:12] Error: Function not registered: 'FCNPC_GetVehicleID'
[01:09:12] Error: Function not registered: 'FCNPC_GoToPlayer'
[01:09:12] Error: Function not registered: 'FCNPC_Create'
[01:09:12] Error: Function not registered: 'FCNPC_Destroy'
[01:09:12] Error: Function not registered: 'FCNPC_IsValid'

Compiling for centos 6.8 64bit

Something is wrong with the makefile?

$ cd FCNPC-1.5.0
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:49 (add_subdirectory):
  The source directory

    /home/usr/FCNPC-1.5.0/lib/subhook

  does not contain a CMakeLists.txt file.


-- Configuring incomplete, errors occurred!
See also "/home/usr/FCNPC-1.5.0/build/CMakeFiles/CMakeOutput.log".

What I did was change in CMakeLists.txt (just guessed)

add_subdirectory (
	${CMAKE_CURRENT_SOURCE_DIR}/lib/subhook
)

to

include_directories (
	${CMAKE_CURRENT_SOURCE_DIR}/lib/subhook
)

Which created a makefile but resulted in:

$ make
Scanning dependencies of target FCNPC
[  3%] Building CXX object CMakeFiles/FCNPC.dir/lib/fopen_s/fopen_s.cpp.o
[  7%] Building CXX object CMakeFiles/FCNPC.dir/src/CMovePath.cpp.o
In file included from /home/usr/FCNPC-1.5.0/src/CMovePath.cpp:11:0:
/home/usr/FCNPC-1.5.0/src/Main.hpp:52:29: fatal error: subhook/subhook.h: No such file or directory
 #include <subhook/subhook.h>
                             ^
compilation terminated.
make[2]: *** [CMakeFiles/FCNPC.dir/src/CMovePath.cpp.o] Error 1
make[1]: *** [CMakeFiles/FCNPC.dir/all] Error 2
make: *** [all] Error 2

Help please! How does one compile this for Centos 6.8

[Question] Shooting NPC

I've downloaded the plugin and started bg(bodyguard) example script and tested npc shooting and notice they shoot very fast and make my question how good are npc shooting other players. Can they be used for server if their fire rate is lowered (if possible).

Server crashing on 0.3.7 R2-1

The server is crashing when a player joins on an 0.3.7 R2-1 Server (this version). It was working fine with the precompiled version, but when I compile it myself, it will crash.

Here is the crash log:

======================== FCNPC Exception Handler ===============================
Address: 0x0040335F

Registers:
EAX: 0x00635718 - EBX: 0x00000018 - ECX: 0x0033F528 - EDX: 0x3492B084
ESI: 0x00000000 - EDI: 0x98ba8994 - EBP: 0x0033F534 - ESP: 0x0033F4EC

Stack:
0x0: 0x0033FCEC - 0x4: 0x0033F55C - 0x8: 0x0033FC28 - 0xC: 0x003511B9 - 0x10: 0x0033F534 - 0x14: 0x00000000
0x18: 0x00000000 - 0x1C: 0x00000018 - 0x20: 0x34929498

Functions:
FUNC_CPlayerPool__DeletePlayer: 0x466570
FUNC_CPlayer__Kill: 0x484620
FUNC_CPlayer__EnterVehicle: 0x484c70
FUNC_CPlayer__ExitVehicle: 0x484f50
FUNC_CPlayer__SpawnForWorld: 0x486d30
FUNC_GetVehicleModelInfo: 0x488240
FUNC_CConfig__GetValueAsInteger: 0x48b5b0
FUNC_CreateNPC_RPC: 0x4918f0
FUNC_RakServer__Send: 0x45a260


Pointers:
VAR_ServerAuthentication: 0x4f5fe8
VAR_ServerPtr: 0x6362c0
VAR_ConfigPtr: 0x633cb0
VAR_RakPeerPtr: 0x639ca0


Offsets:
OFFSET_NetVersion: 0xfd9
OFFSET_RemoteSystemManager: 0x33c
OFFSET_RemoteSystemSize: 0xcb8
OFFSET_RemoteSystem__ConnectMode: 0xcb0
OFFSET_RemoteSystem__Unknown: 0xcb5
OFFSET_SendBullet_RPC: 0x33
======================== FCNPC Exception Handler ===============================

Add offset for FCNPC_AimAtPlayer

If you place an NPC behind a counter object and make him shoot at you, he will shoot the counter instead. Needs a quick & easy fix imo for cleaner code

What I suggest is adding offset X, Y, Z to FCNPC_AimAtPlayer so NPC can shoot/attack at the head if desired.

e.g

FCNPC_AimAtPlayer(npcid, playerid, bool:shoot = false, shoot_delay = -1, bool:setangle = true, Float: offsetX = 0.0, Float: offsetY = 0.0, Float: offsetZ = 0.0);

// example, head shots
FCNPC_AimAtPlayer(npcid, playerid, true, -1, true, 0.0, 0.0, 0.5);

I would do this but I need to remember how to open a C++ project (been a while) 😆 😆 😆

Filterscripts examples

Hi there,

I decided to include the plugin on my project. At the beggining, I tested bg.pwn (FS) but NPC bots didn't follow me (I used the command /bg).

Futhermore, I tried the shooting function, but it didn't work correctly.

  • /bg shoot bot_id player_id => here, the bot juste aim at me
  • /bg reset bot_id => the bot started to shoot at me...

I tested with a blanck gamemode, it was the same problem.


I tried it on :

  • W10 64bits
  • Debian 8.5 64bits
  • SAMP version : 0.3.7 R2

FCNPC crash

=========================== FCNPC Exception Handler ============================
Address: 0x6CEB2FF1

Registers:
EAX: 0x00000000 - EBX: 0x00000000 - ECX: 0x0E05F32C - EDX: 0x00000001
ESI: 0x00000000 - EDI: 0xe05f308 - EBP: 0x0018FD1C - ESP: 0x0018FCF0

Stack:
0x0: 0x044492D0 - 0x4: 0x00000168 - 0x8: 0x021EF598 - 0xC: 0x0018FD44 - 0x10: 0x6D15A573 - 0x14: 0x0018FD50
0x18: 0x00000001 - 0x1C: 0x00691848 - 0x20: 0x00000000

Information:
System: Windows
SA-MP: 0.3.7 R2-1
FCNPC: 1.0.5

Functions:
FUNC_CPlayerPool__DeletePlayer: 0x466570
FUNC_CPlayer__Kill: 0x484620
FUNC_CPlayer__EnterVehicle: 0x484c70
FUNC_CPlayer__ExitVehicle: 0x484f50
FUNC_CPlayer__SpawnForWorld: 0x486d30
FUNC_GetVehicleModelInfo: 0x488240
FUNC_CConsole__GetIntVariable: 0x48b5b0
FUNC_ClientJoin_RPC: 0x4918f0

Pointers:
VAR_ServerAuthentication: 0x4f5fe8
VAR_NetVersion: 0xfd9

Offsets:
OFFSET_RemoteSystemManager: 0x33c
OFFSET_RemoteSystemSize: 0xcb8
OFFSET_RemoteSystem__ConnectMode: 0xcb0
OFFSET_RemoteSystem__Unknown: 0xcb5
=========================== FCNPC Exception Handler ============================

Notify of updates

How about adding mechanism that will check latest releases and tell us if we are using outdated version. Its a simple thing but i just spent like 2h debugging and testing shit just to find the problem and then realize there is a new version that fixes bloody damage system...

NPC is invulnerable when is set to false

Like title say FNPC is invulnerable even when is set to be off. Also notice because of this you can't set FNPC health and aways returning 100.000. I was using Bodyguards filterscript when i found it.

Servercrash with SQL-Plugin from Dan

We are using the SQL-Plugin from Dan (https://github.com/udan11/samp-plugin-sql). The server crash when there is a mistake in a quey which was executed. Please fix the bug.

Crash information:

=========================== FCNPC Exception Handler ============================
Signal 11 (Segmentation fault), address is (nil) from 0xf2b0ab98

Backtrace:
  #0 in plugins/fcnpc.so(_ZN17CExceptionHandler24ExceptionHandlerCallbackEiP7siginfoPv+0x164) [0xf2233c14]
  #1 in linux-gate.so.1(__kernel_rt_sigreturn+0) [0xf31fb410]
  #2 in plugins/sql.so(_ZN7Natives12sql_num_rowsEP6tagAMXPi+0x88) [0xf2b0ab98]
  #3 in /home/samp/sampServer() [0x80950e4]
  #4 in plugins/crashdetect.so(_ZN11CrashDetect13DoAmxCallbackEiPiS0_+0x49b) [0xf2ea594b]
  #5 in plugins/crashdetect.so(+0x1b8f8) [0xf2ea88f8]
  #6 in plugins/crashdetect.so(amx_Exec+0x18e6) [0xf2eac916]
  #7 in plugins/crashdetect.so(_ZN11CrashDetect9DoAmxExecEPii+0x96) [0xf2ea4be6]
  #8 in plugins/crashdetect.so(+0x1b659) [0xf2ea8659]
  #9 in plugins/streamer.so(+0x82ea) [0xf20882ea]

Information:
  System: GNU/Linux
  SA-MP: 0.3.7 R2-1
  FCNPC: 1.0.4

Functions:
  FUNC_CPlayerPool__DeletePlayer: 0x80d0a90
  FUNC_CPlayer__Kill: 0x80cb220
  FUNC_CPlayer__EnterVehicle: 0x80cc1c0
  FUNC_CPlayer__ExitVehicle: 0x80cc340
  FUNC_CPlayer__SpawnForWorld: 0x80ccfc0
  FUNC_GetVehicleModelInfo: 0x80d5d30
  FUNC_CConsole__GetIntVariable: 0x80a0070
  FUNC_ClientJoin_RPC: 0x80b0030

Pointers:
  VAR_ServerAuthentication: 0x81aa8a8
  VAR_NetVersion: 0xfd9

Offsets:
  OFFSET_RemoteSystemManager: 0x334
  OFFSET_RemoteSystemSize: 0xc69
  OFFSET_RemoteSystem__ConnectMode: 0xc62
  OFFSET_RemoteSystem__Unknown: 0xc67
=========================== FCNPC Exception Handler ============================

Reorganize memory addresses

  • SA-MP version checking should be implemented
  • Always add all known memory addresses to current version
  • Pattern finding should only work on unknown SA-MP versions

Weapon Accuracy

http://forum.sa-mp.com/showpost.php?p=3760346&postcount=2874

native FCNPC_SetWeaponAccuracy(npcid, weaponid, Float:accuracy);
native Float:FCNPC_GetWeaponAccuracy(npcid, weaponid);
native FCNPC_SetWeaponInfo(npcid, weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
native FCNPC_GetWeaponInfo(npcid, weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);
native FCNPC_SetWeaponDefaultInfo(weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
native FCNPC_GetWeaponDefaultInfo(weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);

//Float:accuracy
//Is a percentage value
//Possible values range from 0.0 to 1.0 (will never hit to will always hit)
//Defaults to 1.0 (will always hit)
//Example: 0.8 (will hit 80% of the time)

Random Crash

=========================== FCNPC Exception Handler ============================
Address: 0x702FD679

Registers:
EAX: 0x0000FFFF - EBX: 0x00000003 - ECX: 0x0071DAE8 - EDX: 0x0012FA00
ESI: 0x00000000 - EDI: 0x2ace848 - EBP: 0x0012F9A0 - ESP: 0x0012F9A0

Stack:
0x0: 0x0012F9B4 - 0x4: 0x702F7404 - 0x8: 0x0000FFFF - 0xC: 0x02ACE848 - 0x10: 0x00000001 - 0x14: 0x00000036
0x18: 0x0046C2E4 - 0x1C: 0x01449458 - 0x20: 0x0012FA00

Information:
  System: Windows
  SA-MP: 0.3.7 R2-1
  FCNPC: 1.0.2

Functions:
  FUNC_CPlayerPool__DeletePlayer: 0x466570
  FUNC_CPlayer__Kill: 0x484620
  FUNC_CPlayer__EnterVehicle: 0x484c70
  FUNC_CPlayer__ExitVehicle: 0x484f50
  FUNC_CPlayer__SpawnForWorld: 0x486d30
  FUNC_GetVehicleModelInfo: 0x488240
  FUNC_CConsole__GetIntVariable: 0x48b5b0
  FUNC_ClientJoin_RPC: 0x4918f0

Pointers:
  VAR_ServerAuthentication: 0x4f5fe8
  VAR_NetVersion: 0xfd9

Offsets:
  OFFSET_RemoteSystemManager: 0x33c
  OFFSET_RemoteSystemSize: 0xcb8
  OFFSET_RemoteSystem__ConnectMode: 0xcb0
  OFFSET_RemoteSystem__Unknown: 0xcb5
=========================== FCNPC Exception Handler ============================

Just created simple loader for NPC's and wanted to see if its gonna work as i expected.
Server crashed only after a minute or two without any reason.
Only three functions are used inside filterscript init (no FCNPC publics at all).
FCNPC_Create
FCNPC_Spawn
FCNPC_SetAngle

Plugins list: crashdetect mysql sscanf streamer MapAndreas PathFinder FCNPC
Pretty sure other plugins doesnt have anything to do with it. Also i didnt load height map or init MapAndreas in FCNPC (like i said only 3 functions above are used from FCNPC) .

After that i started server again, tested for like 5 minutes, shooting and killing NPC's, driving over them, not a single problem...

EDIT: Okey...maybe im insane but i just recreated crash, twice... When you drive a bike, and you fell from it (hit something and fly over), server crashes...Insane right? Can someone could confirm these?

EDIT2: Tested everything a little bit more and i concluded that crashes are happening due to player taking damage. (If you bow up yourself with rocked once, server crashes, even if you dont die). I tried to add FCNPC_OnTakeDamage callback and return both 1 or 0, it still crashes. But im now 100% sure its the damage system that makes problems.

Filterscripts examples

Hello,

Is the citiziens filterscript outdated ? I tried it and all the citiziens are on the sea.

Thanks,

Tyrar

SetAnimationByName does not work

I have put one NPC inside interior. When I enter the interior, the animation is not synced!

public FCNPC_OnSpawn( npcid )
{
    FCNPC_ApplyAnimation( npcid, "GANGS", "null", 0.0, 0, 0, 0, 0, 0 ); // preload
    FCNPC_ApplyAnimation( npcid, "GANGS", "leanIDLE", 3.0, 0, 1, 1, 1, 0 );
    FCNPC_SetAnimationByName( npcid, "GANGS:leanIDLE", 3.0, 0, 1, 1, 1, 0 );
    return 1;
}

Here's my code. Cheers.

Move path functions

http://forum.sa-mp.com/showthread.php?p=3673022#post3673022

forward FCNPC_OnFinishMovePath(npcid, pathid);
forward FCNPC_OnFinishMovePathPoint(npcid, pathid, pointid);

native FCNPC_CreateMovePath();
native FCNPC_DestroyMovePath(pathid);
native FCNPC_IsValidMovePath(pathid);
native FCNPC_AddPointToPath(pathid, Float:x, Float:y, Float:z);
native FCNPC_AddPointsToPath(pathid, Float:points[][3], const size = sizeof(points));
native FCNPC_RemovePointFromPath(pathid, pointid);
native FCNPC_IsValidMovePoint(pathid, pointid);
native FCNPC_GetMovePoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
native FCNPC_GetNumberMovePoint(pathid);
native FCNPC_GoByMovePath(npcid, pathid, type = MOVE_TYPE_AUTO, Float:speed = MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.