NPC/Bots implementation in VCMP 0.4 Servers

Started by habi, Apr 01, 2022, 05:37 PM

Previous topic - Next topic

PSL

This is very nice and just what I needed, thanks to habi, the author of the NPC plugin.I'm looking forward to the next update.

PSL

HI, Habi, When I raced with the recorded car playback, the recorded car always accelerated slower than me in a straight line, even though I was accelerating at full speed while recording, is there a way to solve the problem of slow recording cars.

habi2

#92
Hi PSL thank you for reporting the issue.
This is a video of me racing with npc:
Video
As you can see, the npc car is racing ahead of me at full speed.

Was the server run on your pc or remote computer?

PSL

#93
Hi Habi, I saw your video, In the video you catch up with your video playback, That means the vehicle speed of the replay is slower,   I made a server that can race against NPCS, I'll advertise the server elsewhere. I ran 1:30 in the driver legend myself, but my replay ran 1:40, I can always catch up with my replay, So you figure out a way to make the playback vehicle faster.

My server is running on a remote computer.

habi2

#94
Hi PSL, can you confirm if this release candidates of v1.8 beta solves the issue of car not accelerating.

windows
linux-x64
linux-86
rel004
source-1.8-beta-zip
setup (installer)

Also thanks for confirming about location of server.

I decreased sleep time between cycles from 30 to 5 ms and found that cars are accelerating without lags. Also the time taken by npc to omplete the race now matches against the original time.

PSL

#95
HI Habi, I tried this version and the vehicle playback speed is almost exactly the same as the original speed, the vehicle playback speed issue has been fixed. Thank you for fixing this little bug. I really appreciate your update.
I found a problem in testing this version. When I hide an NPC's console, the NPC doesn't join the server.
ConnectNPC("[NPC]Jack","npcplayback.nut",false,"127.0.0.1","rpclib z-finder");  //Not Join
ConnectNPC("[NPC]Jack","npcplayback.nut",true,"127.0.0.1","rpclib z-finder");  //Join

habi2

#96
Quote from: PSL on Feb 17, 2024, 04:02 AMI found a problem in testing this version. When I hide an NPC's console, the NPC doesn't join the server.
ConnectNPC("[NPC]Jack","npcplayback.nut",false,"127.0.0.1","rpclib z-finder");  //Not Join
ConnectNPC("[NPC]Jack","npcplayback.nut",true,"127.0.0.1","rpclib z-finder");  //Join
This issue has been fixed. It was related to npc creating logfiles. Logfiles can now be found in folder npcscripts/logs whenever ConnectNPC is called with console parameter false.
Also,
QuoteCorrected API version to 1.6
Windows
Linux x64
Linux x86
rel004
Source-1.8-beta-zip
Setup (Installer)

What's New in v1.8 Beta?

From Release Notes on the wiki:

Quote
  • New Recording Type: Introducing PLAYER_RECORDING_TYPE_ALL for StartRecordingPlayerData, eliminating the need to specify whether the player is on foot or in a vehicle.

  • Captured Events: PLAYER_RECORDING_TYPE_ALL now supports capturing various events, including player updates, death, pickup events, checkpoint events, object touch/shot events, player chat, player command, private messages, and ClientScriptData.

  • StartRecordingAllPlayerData: A unified function to start recording on all players, including those who may join later.

  • Server Recording: Similar to StartRecordingAllPlayerData, but produces an hrec file with player join times and corresponding rec files for replay. Connected players act as NPCs, replicating player actions.

  • ConnectMultipleNpcs: Connects multiple NPCs from an hrec file produced by PutServerInRecordingMode.

  • recdir Configuration: Introduce recdir 2 in server.cfg to save playback recordings to npcscripts/recordings, with recdir 1 as the default.

  • Npcs with Strings: Npcs can now be called with strings, allowing for custom actions like "function OnNPCSpawn(){SendChat("I have spawned");}".

  • Logfiles: Each NPC now writes logfiles in the npcscripts folder.

  • New NPC Functions: Various new functions added for use by npcscripts, including Suicide, SetMyHealth, GetMyHealth, LookAtPos, LookAtPlayer, GetMyClass, RequestClassAbs, AmISpawned, GetMySkin, GetMyTeam, GetMyArmour, SendPrivMsg, SetConfig, GetPlayerColor, IsPlaybackRunning, IsPlaybackPaused, IsServerInRecordingMode.

  • Additional npc04relxx Plugin Functions: KickAllNPC, IsPlayerRecording, StartRecordingAllPlayerData, StopRecordingAllPlayerData, PutServerInRecordingMode, StopServerInRecordingMode, IsServerInRecordingMode.

  • Configurable max_npc: Added max_npc in server.cfg, optional and limits the number of NPCs in the server (values: 0 to 100, -1 for any number).

  • Console Notifications: Npcs now print their names in the console upon connection, e.g., "Connected. ID: 03 Name: John".

  • Bug Fixes: Fixed issues with NPC getting kicked, not holding weapons on spawn, and incorrect angles for newly streamed players.

  • Private Messages: NPCs can now send private messages.

PSL

#97
Hi Habi,  I tested the recording option, I captured myself getting on and getting off, it was very successful, recdir 2 was great, the log files were perfectly recorded, there were problems when I tested all the players.
This is the code I did to query the wiki. I will use this feature to record multiplayer races.I will continue to explore the features of this version.I may not be very good at using this feature yet, believe me, I just need a simple example and will learn the additional features in no time.
PutServerInRecordingMode("testfile",3,REC_ALLNAME);
StartRecordingPlayerData(PLAYER_RECORDING_TYPE_ALL,60,false); //error in here AN ERROR HAS OCCURED [The recname parameter must be string]
//Should the two codes be used together?

habi2

#98
Hi PSL, the two codes should not be used together. The correct way is
PutServerInRecordingMode("testfile",PLAYER_RECORDING_TYPE_ALL,REC_ALLNAME)
and
StopServerInRecordingMode()
This will automatically start recording data of all players.
Now when you call stop, it finishes recording. You will get testfile.hrec and n rec files, where n is the number of players who was in the server in between PutServerInRecordingMode and StopServerInRecordingMode.
Next use the plugin npc04relxx to start playback. Use
ConnectMultipleNpcs(testfile, "127.0.0.1",7);
which will connect the same 'n' npcs.
Notes
1. Use PutServerInRecordingMode (with flags
REC_ALLNAME) when server is empty. If this function is called when a players are already spawned, the npc when connected will have spawning problem.

PSL

Hi Habi, I'll try this tomorrow. Thank you for your teaching. I already understand.

PSL

Hi Habi. I started recording perfectly fine, generating hrec and some rec files, and when I did ConnectMultipleNpcs, the main console just shut down.
Here is the link to the file: https://file.io/lWGmWVUgd8ea
function onScriptLoad()
{
PutServerInRecordingMode("testfile",PLAYER_RECORDING_TYPE_ALL,REC_ALLNAME); //This code will be commented when the file is generated
}
function onPlayerPart(player,reason)
{
StopServerInRecordingMode(); //This code will be commented when the file is generated
}

function onPlayerCommand(player,cmd,text)
{
    if(cmd=="test2")
    {
        ConnectMultipleNpcs("testfile","127.0.0.1",7); // Create a recording file and run this command
    }
}

habi2

Hi PSL, i understand your server console is shutting down once you call ConnectMultipleNpcs function.
Unfortunately, i am on a travel and could not look at the problem.

PSL

Hi Habi, I am glad to know that you are traveling.  I wish you a fruitful journey and a pleasant and unforgettable trip.

PSL

Hi Habi, There was an error playing back the recording, and the vehicle stood still.  Error. Vehicle id from rec file different. See flags for overriding.
When I open the rec file, field2 is 141, When the NPC comes back to life, immediately create the vehicle with model ID 141, then put the NPC in the driving position, then execute the recording file with the RFC, and the NPC stays still.

habi2

#104
Hi PSL,
I understand that you create a vehicle with model ID 141 and put npc inside it and using RFC executed the playback recording.
That is correct, field2 is indeed model ID of the vehicle.

Playback type PLAYER_RECORDING_TYPE_ALL checks  whether vehicle.ID is same as that of recfile. This is saved in field1.
You can avoid this vechicleID check by using
StartRecordingPlayback(3,"cartest",PLAY_IGNORE_VEHICLEID)