SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 01/07/2012, 03:21 PM   #1
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 3,692
Reputation: 834
Default RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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". 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, as well as a filterscript for testing.

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:
  • Vehicle support (done in V0.3)
  • Automatic playback queues (for creating routes or complex actions) (done in V0.2)
  • Support for NPC actions like animations, keys, etc (done in V0.2)
  • Automatic pathfinding
  • Mid-level functions to get rid of the build mode
  • NPC streaming
  • REC file repositioning to move existing actions to other places
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: Stop the NPC playback before creating the build, or create the build on another slot.

ConnectRNPC does not always return the correct ID when used in OnGameModeInit or main.
Fix: Create NPCs slightly delayed with a timer when the gamemode is fully loaded.

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.

Some people got problems with missing DLLs. Try downloading these and put them in your server directory:
msvcr100d.dll
msvcp100d.dll

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:
  • New "build mode" system and .rec generate code
  • Complete support for all OnFoot attributes
  • Greatly increased performance
0.2.1: Minor release
  • When using the defined movement speeds (RNPC_SPEED_WALK etc) the correct walking animation will be set.
  • Removed some old functions
  • Fixed some minor bugs
  • Linux version included
0.3: Vehicle support (ugly release)
  • Support for vehicle recordings
  • Included MapAndreas 1.1
  • Support for acceleration with a new movement generation
  • Some bugfixes and new functions
  • Probably a lot new bugs
Next release: 0.4: NPC process syncing (release some time after 21.12.2012)

Download
Version 0.1 (1.7.2012): .DLL + npcmode + include + source
Version 0.2 (3.7.2012): .DLL + npcmode + include + source + testfilterscript
Version 0.2.1 (4.7.2012): .DLL + .so and all the previous stuff
Version 0.3 (13.7.2012): .DLL and .so, etc
Version 0.3.1 Plugin (restored 28.10.2012): Plugin source, .so and .dll This might work with the 0.3 include file, but i didnt test it myself.
Version 0.3.1 Release compile (21.1.2013): .DLL and .so A release compile, shouldnt need the above dlls, and should run faster. Thanks to KingJ for explaining me how to do that.
Version 0.3.1.1 Fixed RNPC_StopPlayback (25.2.2013), full package with 0.3.1 release version plugin (updated link)

Third party
ARNPC include by TheArcher - An edited version of the RNPC include that fixes a bunch of bugs, and adds some new functions like RNPCFollowPlayer

Have fun, and give some feedback

Last edited by Mauzen; 30/01/2014 at 05:15 PM. Reason: bai kim!
Mauzen is offline   Reply With Quote
Old 01/07/2012, 03:26 PM   #2
WillyP
High-roller
 
WillyP's Avatar
 
Join Date: Jul 2010
Location: Durham, England
Posts: 2,232
Reputation: 63
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

This. Is. Awesome.
WillyP is offline   Reply With Quote
Old 01/07/2012, 03:30 PM   #3
zgintasz
Huge Clucker
 
Join Date: Oct 2011
Posts: 394
Reputation: 8
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

Very good job! Keep it up .
zgintasz is offline   Reply With Quote
Old 01/07/2012, 03:35 PM   #4
Michael@Belgium
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 2,474
Reputation: 815
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

Aw yeaaah Nice work !
Michael@Belgium is offline   Reply With Quote
Old 01/07/2012, 04:24 PM   #5
Kar
High-roller
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,713
Reputation: 254
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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

  • Are you prepared to get your wish? Twisted Metal SA-MP coming soon! Join the IRC Channel: #tm on irc.tl - @tmsamp_dev

server.lvcnr.net:7777 | samp://server.lvcnr.net:7777
www.lvcnr.net | @kcnrdev
Channel: #lvcnr on irc.tl
Kar is offline   Reply With Quote
Old 01/07/2012, 06:07 PM   #6
Joe Staff
High-roller
 
Joe Staff's Avatar
 
Join Date: Aug 2007
Posts: 2,789
Reputation: 330
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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'
    }
}
__________________
I hate your face.
Joe Staff is offline   Reply With Quote
Old 01/07/2012, 08:48 PM   #7
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 3,692
Reputation: 834
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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.
Mauzen is offline   Reply With Quote
Old 01/07/2012, 08:50 PM   #8
BloodyEric
Huge Clucker
 
BloodyEric's Avatar
 
Join Date: May 2008
Location: Berlin, Germany
Posts: 359
Reputation: 12
Default AW: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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.
BloodyEric is offline   Reply With Quote
Old 01/07/2012, 08:52 PM   #9
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 3,692
Reputation: 834
Default Re: AW: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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.
Mauzen is offline   Reply With Quote
Old 01/07/2012, 08:59 PM   #10
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,459
Reputation: 223
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

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?
__________________

Last edited by TheArcher; 01/07/2012 at 09:35 PM.
TheArcher is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control NPCs using Paths? Programie Scripting Help 2 16/06/2012 02:49 PM
Help with recording two npcs at once marharth Help Archive 3 13/08/2010 03:14 AM
Recording NPCs animation with new version (0.3b) Hernaner28 Help Archive 0 12/08/2010 01:17 AM
No NPCs regdude Server Support 5 08/07/2010 05:54 PM
[HELP] Npcs armyoftwo Help Archive 3 05/12/2009 09:43 AM


All times are GMT. The time now is 05:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.