• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Plugin] FCNPC for open.mp - the classic FCNPC API, ported
#1
FCNPC for open.mp - the classic FCNPC API, ported
Repo: https://github.com/Mac-Andreas/open.mp-FCNPC
Download (DLL + SO + INC + test script): releases/latest



What is this
Fully Controllable NPC - the classic FCNPC FCNPC_* Pawn API, re-implemented for open.mp.

The original FCNPC is a SA-MP plugin: it drives NPCs by patching the samp03svr binary at fixed memory addresses and injecting raw RakNet packets. That cannot work on open.mp - a different, open-source binary with a proper component SDK. open.mp instead ships a built-in NPC engine (INPCComponent).

This component is a compatibility layer: it re-exposes the FCNPC_* natives on top of INPCComponent, plus the remaining ~5% of FCNPC that open.mp's NPC engine does not provide. Existing FCNPC gamemodes run largely unmodified.

Status
All 182 FCNPC_* natives are declared in FCNPC.inc and implemented: 180 ported, 2 pending. Most call open.mp's INPC / INPCComponent / IPlayer directly; the features open.mp lacks are hand-rolled in this component. Full per-native breakdown is in port-status.md.

A couple of the gaps it fills (things bare INPCComponent does not do):
  • FCNPC_GoToPlayer - open.mp's moveToPlayer defaults autoRestart = false, so the NPC walks to the player's initial spot then stops. This port forces continuous re-tracking, so the NPC keeps chasing a moving player.
  • FCNPC_SetMoveMode (MAPANDREAS / COLANDREAS) - INPC::move does no terrain grounding (NPCs float / sit on roofs). The component samples ground Z each tick via the companion plugin while the NPC moves.
Nothing falls back to SA-MP.

Install
  1. Download the latest release.
  2. Put FCNPC.dll (Windows) / FCNPC.so (Linux) into your server's components/.
  3. Put FCNPC.inc into your Pawn qawno/include/.
  4. Make sure the NPC component is enabled in config.json (ships with open.mp).

Code:
#include <open.mp>
#include <FCNPC>

public OnGameModeInit()
{
    new id = FCNPC_Create("Bot");
    FCNPC_Spawn(id, 0, 1958.33, 1343.12, 15.36);
    return 1;
}

public OnPlayerConnect(playerid)
{
    // walk every bot to the new player
    new npcs[100], count = FCNPC_GetValidArray(npcs);
    for (new i = 0; i < count; i++)
        FCNPC_GoToPlayer(npcs[i], playerid, FCNPC_MOVE_TYPE_RUN);
    return 1;
}

Test it in-game (and see exactly what is ported)
The release ships fcnpc_test.pwn (also in the repo under test/). It is two things at once: a feature test that drives every category of the API live, and a showcase of what this port adds over the bare open.mp engine - so you can verify, in-game, the parts of FCNPC that INPCComponent never implemented.

Load it as a filterscript and type /fcnpc for a dialog menu:
  • Commands - spawn / walk / run / sprint / follow (chase) / aim / shoot / melee / animation / enter+exit vehicle / move-path patrol / play node / invulnerable / kill / respawn / stop all / destroy. One button per native group, run on a demo NPC in front of you.
  • Config - live tunables (move type/mode/pathfinding/speed, weapon/ammo/reloading/fighting style/accuracy, skin/health/armour, plugin update+tick rate, global ColAndreas/raycast modes) with defaults shown + restore-to-defaults.
  • Ported features (INPC vs FCNPC) - the important one. It spawns a native INPC NPC and an FCNPC NPC side by side, labelled with floating 3D text ("INPC" / "FCNPC") so you can tell them apart, and lets you fire the same action at both to compare. Every test prints three lines in chat: the intended behaviour, what bare INPC does, and what FCNPC does. Current comparisons:
    • Chase / autoRestart - INPC NPC_MoveToPlayer defaults autoRestart = false: it walks to your starting spot and stops, even as you move. FCNPC keeps re-tracking and chasing you. (This is the headline gap the port fills.)
    • Rotation - SetAngleToPlayer on the native INPC vs the FCNPC NPC, so the facing/orientation behaviour is directly comparable.
    This section is how the "remaining ~5% open.mp's NPC engine does not provide" stops being a claim and becomes something you watch happen.
  • Debug - on-screen HUD (state, health, weapon, moving, speed, distance to you).
Needs <open.mp>, <omp_npc> and <FCNPC> - no other dependencies.

Companion plugins
The collision / heightmap / surfing natives call the standalone plugins at runtime (the same companion-plugin model the original FCNPC used) - install the open.mp builds:
  • MapAndreas (heightmap Z) - Philip
  • ColAndreas (full map collision / raycasting) - Pottus, uL Chris42O, Slice
  • Streamer (dynamic objects, for FCNPC_*SurfingDynamicObject) - Incognito

Build from sourceopen.mp's Windows server is x86 and components must use the Microsoft C++ ABI. The repo includes a no-Visual-Studio cross-build (clang-cl + lld against the MSVC SDK via msvc-wine), a Windows CMake path, and a Linux .so path. CI builds FCNPC.dll + FCNPC.so and attaches them with FCNPC.inc to every tagged release.

Credits
  • Original FCNPC: OrMisicL (2013-2015), ziggi (2016-2024).
  • open.mp NPC engine (INPCComponent): the open.mp team.
  • open.mp port: Xyranaut.
  • Companion plugins: MapAndreas (Philip), ColAndreas (Pottus, uL Chris42O, Slice), Streamer (Incognito).


Bug reports / PRs welcome on the repo. Tested against open.mp 1.5.x.
Xyranaut
Founder & Developer
Mac Andreas
Away
  Reply


Messages In This Thread
FCNPC for open.mp - the classic FCNPC API, ported - by Xyranaut - 1 hour ago

Forum Jump: