[Tutorial] Enhanced NPC Development
#1

Enhanced NPC Development
This is geared towards more experienced scripters.

Objective
Enhance our development environment by combining known NPC resources to provide an improved platform in which NPC's can be used.

The Idea
RNPC provides a very nice low level NPC implementation it is possible to create sequences in a programmatic fashion I really think this is underestimated at times with the focus put mostly on FCNPC. Now wouldn't it be nice if FCNPC could also have the capabilities of RNPC? Well the fact of the matter it already does RNPC simply creates recordings FCNPC has the ability to playback any recording. I will explain the steps required to achieve this system for your development purposes.

Advantages
1.) Provides a low level NPC builder
2.) Extends NPC possibilities
3.) Address issues by using the best result for the job for instance RNPC yields better movement across terrain than FCNPC but FCNPC is better for melee attacks on players yes it's true
4.) FCNPC is much easier to connect lots of NPCs quickly and effectively
5.) RNPC connects players at player slot 0 FNPC starts at maxplayers defined in server.cfg reducing .amx size

Requirements
FCNPC - https://sampforum.blast.hk/showthread.php?tid=428066 (For some reason some of the NPC resources are missing right now)
RNPC - https://sampforum.blast.hk/showthread.php?tid=355849
Patience - NPC development is very tedious take small steps and test everything you do!

Process
Configure your server.cfg
1.) Add RNPC and FCNPC plugins to your SAMP server
2.) Set maxplayers to MAX_PLAYERS+MAX_NPC you will need to define MAX_NPC in your gamemode
3.) Set maxnpc to MAX_NPC
4.) Save

Note: You won't need to have MAX_PLAYERS take into account NPC player ids this will optimize your variable sizes for instance if your server has 300 player slots and 200 npc slots MAX_PLAYERS should be 300 and MAX_NPC should be 200 but maxplayers in your server.cfg would be 500

Support Code
This is pretty much it, we just need a function for playing back recordings generated by RNPC this function takes care of that just call it after creating an RNPC build.
(Recommend to put this in FCNPC.inc)

At top of gamemode or your NPC include module
pawn Код:
#include <FCNPC>
#include <RNPC>
pawn Код:
stock FCNPC_StartRNPCPlayBack(npcid)
{
    new recname[16];
    format(recname, sizeof(recname), "rnpc%03d-00", npcid);
   
    FCNPC_StopRecordingPlayback(npcid);
    FCNPC_StartRecordingPlayback(npcid, recname);

    return 1;
}
Note: RNPC_StartBuildPlayback(npcid); does not work it won't work and can't work use the function above instead.

Conclusion
This was a very simple process to achieve a huge amount of extended functionality that FCNPC can utilize and it all but requires 5 minutes of work! But the results speak for themselves the best of both plugins are easily combined even newbies shouldn't have much trouble.

@Edit - Updated the function.
Reply
#2

nice tutorial mate...
Really helpfull and explanatory

Thanks for this
Reply
#3

nice tutorial bro...
Reply
#4

It's interesting, but you did not explain how a NPC spawn with this system, how to create NPC, how to interact with other players ... I think your tutorial can be even richer.

Reply
#5

Quote:
Originally Posted by DexX39
Посмотреть сообщение
It's interesting, but you did not explain how a NPC spawn with this system, how to create NPC, how to interact with other players ... I think your tutorial can be even richer.

There is really no need for that, it's meant for people who already know what they're doing
Reply
#6

No problem dude

Nice for me.
Reply
#7

Good idea.
but it would be better if you explained more in code part.
Reply
#8

Thanks for this!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)