SA-MP Forums Archive
[Plugin] RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] RNPC - Recordfree NPCs | Control NPCs without recording | DEV (/showthread.php?tid=355849)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Mauzen - 01.07.2012

Its been a while since I wrote about my experiences with the .rec files. Later, Joe Staff released a code snippet to generate rec files. Now I finally made use of this, as I planned to do all the time, and started creating a plugin to control NPCs by manipulating and creating rec files.
The generate code is now completely rewritten for a better performance, and more possibilities.

What RNPC does
RNPC currently offers complete control over OnFoot-NPCs. Easy or complex actions can be assembled in the script using the "build mode". Since 0.4, NPCs can also be killed. You can read about how it all works on the wiki page. Theres also some example code.
The plugin comes with a npcmode and include, that do most of the job.

What RNPC should do
RNPC is just in developement, but might already be useful for some people.
Im looking forward to add these functionalities some time:The list of course is open and not binding. Im asking you to give any suggestions you got, and Ill see if they can be realized.

Bugs
Creating a new recording file (using RNPC_CreateBuild) on the same slot the NPC is currently playing back will crash the NPC.
Fix: To be sure, create the new build on another slot. Due to the way of communcation, stopping the playback just before creating a new one is a typical race condition, the NPC might, or might not have stopped the playback when writing to the file then. So this can be a reason of seemingly random crashes. Since 0.3.3 you can use RNPC_CreateBuild_s to prevent this automatically.

Starting vehicle playbacks is delayed if the vehicle is far away from its recorded position.
Fix: This is a SA-MP issue, however it can be fixed when specifiing the vehicleid in RNPC_StartBuildPlayback. This will start the recording twice with a small delay, which seems to fix the problem.

Bad performance? Especially when controlling many NPCs in short intervals performance might suck. I highly suggest not to have your npcmodes on a physical hdd. At least outsource them to a ssd, this fixes most performance issues, increases the maximum lag-free number of npcs by a factor of 10 or so. Best case would be a ramdisk though. File access is the one huge bottleneck for this plugin, minimizing access times by putting those files in ram basically allows unlimited NPCs, or at least shifts the bottleneck to the CPU. Ive got a script somewhere to automatically mount/unmount a ramdisk as npcmodes folder in linux, ask me for that if you like, or better check how to do it yourself.

Missing DLLs?
If you get error messages about missing DLLs when starting the server, try installing Visual C++ redistributables.
MSVCP120.dll is part of this: http://www.microsoft.com/en-us/downl....aspx?id=40784 (x86 version)
Thanks to [D]ry[D]esert

Background info
The system behind it is quite easy.
When MoveRNPC is called, the plugin generates a .rec file for the movement from A to B. Then a clientmessage is sent to the npc, telling him that theres a new action in his record file. He plays it back, and reports back when its done.
The "build mode" is meant to assemble more complex actions than just walking. When starting it, the record file is created, and new segments are added whenever something is added in the script. This way the .rec file is built step-by-step, and can easily be played back after finishing it. As this is quite complicated if you arent familiar with the way .rec files work, Ill add CNPC-like Mid-level functions later.
The source currently contains MapAndreas. Dont get confused by that, I altered an old project and as im going to need MapAndreas anyways at a later stage I just kept it there.

Changelog
0.1: Initial release
0.2: Huge amount of changes, the plugin is now really useable for normal servers:0.2.1: Minor release0.3: Vehicle support (ugly release)0.3.3: Bugfixes (Testing release) (announcement post)0.3.4: User-friendliness0.4: Damage management update0.4.1: Bugfixes(That list is getting long, I should move the old updates to some other place soon)

Currently working on
(I cant and wont give any information about release dates)
(realtime) .rec file editing, NPC communication remake (no more strcmp) and better possibilities to add own NPC directives (that actually is a great way to reduce server load and so allow more NPCs, more about that idea later), enabling NPCs damaging normal players in lagcomp mode.

Some suggestion for useful SA-MP NPC updates
Ive been suggesting some of that stuff for years now. All of them would make NPCs in general, and especially RNPC much more powerful. This is my personal selection, just listing the "important" ones that got no nice script/plugin solution, so I still hope at least some of them will be realized some time. Sure theres a suggestion thread, but I thought this thread would be an even better place for this, as it also explains why RNPC is that limited in some aspects. Download
Version 0.3.1.1 Fixed RNPC_StopPlayback (25.2.2013), full package with 0.3.1 release version plugin (updated link)
Version 0.3.3 (24.5.2014) test release, complete with .dll .so and source (26.5.2014: Small fixes, thanks to [D]ry[D]esert, juandiegox and EnzoMetlc)
Version 0.3.4 (18.6.2014) Full package Consider this post for changes and infos
Version 0.4 (26.6.2014) Full package Consider this post for detailled changes and infos
Version 0.4.1 (3.12.2014) Full package consider this post for a detailled changelog (Special thanks to BlackWolf120)

Links fixed now, in case i go missing again, feel free to post mirrors here, if you like a mod could also add them in this post then.

Other stuff
ARNPC include by TheArcher - An "addon" for RNPC that fixes a bunch of bugs, and adds a bunch of new functions like RNPCFollowPlayer
RNPC Pool include - Great for reducing the amount of wasted player slots for NPCs, essential for streaming NPCs
An include for 0.4 for creating very basic zombie bots to test the new damage management
SAfull.hmap for lazy guys who dont want to get it from MapAndreas

Have fun, and give some feedback


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - WillyP - 01.07.2012

This. Is. Awesome.


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - zgintasz - 01.07.2012

Very good job! Keep it up .


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Michael@Belgium - 01.07.2012

Aw yeaaah Nice work !


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Kar - 01.07.2012

NICE!. I CAN'T WAIT FOR Vehicle support!


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Joe Staff - 01.07.2012

As I mentioned in my old thread, it should be relatively easy to create configuring functions pre-rec generation like so...

pawn Code:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext[1],"createrecording"))
    {
        RNPCSetKeys(KEY_WALK+KEY_AIM);
        RNPCSetWeapon(31);
        RNPCSetVehicleID(myvehicleid);
        RNPCIsMoving(false);
        RNPCGenerate(REC_ON_FOOT,X,Y,Z,X,Y,Z); //The second X,Y,Z representing a 'to destination'
    }
}



Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Mauzen - 01.07.2012

Quote:
Originally Posted by Joe Staff
View Post
As I mentioned in my old thread, it should be relatively easy to create configuring functions pre-rec generation like so...
Yes thats the way i planned to do it, seems to be the best way.
Structure will change a bit with the new generation code. Recordings will be appendable (already are in the current version, but just in the code, not useable with the include yet) so you can build a route or set of actions step by step, also including "pauses" without movements, as the current code just works with movements. Then you can set those configs for each step, this should give maximum control.

The biggest problem i got so far is making vehicle movements at least a bit smooth. Already thought about different ways to interpolate curves and turns. However the first vehicle version will just offer straight movements.


AW: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - BloodyEric - 01.07.2012

Awesome mauzen, awesome!

Best would of course be to find a way using the GPS Pathfinding stuff to make it like the 0.2.5 Actors work, but I know it is hardly possible.


Re: AW: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Mauzen - 01.07.2012

Quote:
Originally Posted by BloodyEric
View Post
Awesome mauzen, awesome!

Best would of course be to find a way using the GPS Pathfinding stuff to make it like the 0.2.5 Actors work, but I know it is hardly possible.
Hehe I indeed already thought about that. Using MapAndreas to evade obstacles, or navigating with the GTA nodes. But this will take a while.

Damn, im somehow curious myself how far this plugin will make it. I got tons of ideas.


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - TheArcher - 01.07.2012

Damn it, i was going to release such a idea today, but this looks better since its a plugin. Good job

Edit: You released almost everything we spoke in PM

Edit2: What about GTA path?


Respuesta: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - CaptainMactavish - 02.07.2012

AWESOME!
But it would be more awesome if you can make a NPC shoot or hit some player, we would be able to make a Splinter Cell/Metal Gear gamemode or a zombie gamemode.


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - miikeyy45 - 02.07.2012

THANK YOU!!!


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Lorenc_ - 02.07.2012

Excellent work Mauzen!!


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Hiddos - 02.07.2012

Looking nice, good luck with this project!


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - AIped - 02.07.2012

This is great, how much time are you spending on it each day ?


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Mauzen - 02.07.2012

Thanks guys!

Quote:
Originally Posted by CaptainMactavish
View Post
AWESOME!
But it would be more awesome if you can make a NPC shoot or hit some player, we would be able to make a Splinter Cell/Metal Gear gamemode or a zombie gamemode.
Hitting and shooting are both possible, but afaik NPCs cant aim, at least not without memory hacking, and I wont do any hacking in this plugin to keep away any rule-problems (and because I cant do it anyways ). Maybe NPC recordings will change in future samp versions to support synced aiming.
Attacking will later be possible simply by setting a npcs keys to KEY_FIRE.

Quote:
Originally Posted by AIped
View Post
This is great, how much time are you spending on it each day ?
The current version is the result of just one day of several hours of work. I got no real plan for the time. In general I either script something between 2-4 hours a day, or sometimes none at all

Quote:
Originally Posted by TheArcher
View Post
Edit: You released almost everything we spoke in PM

Edit2: What about GTA path?
Hehe true, we spoke about lots of cool things. Each of them deserves to be released
Ill probably take a look at the GTA paths and nodes when everything else is running fine. I think this can be a really good way for pathfinding, e.g. for automatic taxis or bus routes. If this is really gonna work, this will be quite a lot of fun


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Lorenc_ - 02.07.2012

Send a email at team@sa-mp.com to gain their permission to memory hack (if someone wants to modify it)


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - int3s0 - 02.07.2012

Thank you for this release, I'm going use it on my project that I'm working now.

Though, I have some questions which I'll ask you on pm.


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - AIped - 02.07.2012

This might be a question that you wont be able to answer yet, well im gonna ask anyway XD,
Would it be possible if these RNPC's of yours can enter/exit vehicle as passenger and driver in the future ?
if i see a npc jack someones car..that would be soooooo funny XD

P.S. OMG i cant wait to try out new npc feautures again thanks for putting new life into this.

greetz AIped/BoelieBeast


Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV - Babul - 02.07.2012

i will give it a try for sure, looks really promising!

@Mauzen: <Removed: This is the English language section.>