NPC/Bots implementation in VCMP 0.4 Servers

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

Previous topic - Next topic

habi

#45
Quote from: Mikimon on Mar 07, 2023, 04:09 PMHabi bro, Im having an issue. This is pterodactyl panel
...
The index 'ConnectNPC' does not exist.
Hi Mikimon, i think the so called plugin 'npc04relxx' is not loaded in your panel. Did you forget to add to plugins line in server.cfg?

habi

#46
v.1.6 beta3 released on last month.
Link: Relase Notes and Downloads
Quote1.6 beta 2
*Now Vector.Length() and Vector.Normalized() functions to get magnitude and normalized copy of vector respectively.
*Added fields for SetLocalValue, GetLocalValue: V_ONFOOT_SPEED, V_AIMPOS, V_AIMDIR, V_POS, Q_CAR_ROTATION,
F_CAR_HEALTH, I_CAR_DAMAGE, V_CAR_SPEED, F_CAR_TURRETX, F_CAR_TURRETY.
*Bug fixed for function 'EnterVehicle'
*Bug fixed npc getting kicked for 'acquiring weapon' when exiting vehicle.
1.6 beta
*Supports reading and writing ServerData(Streams)
*LibRPC (Remote Procedure Calls) module available and included in npcscripts/plugins so that functions of NPC can be called from Server side( See RFC, F )
*Fixed a major bug while using ConsoleInput in linux( program would wait indefinitely unless Enter key is pressed )
*The functions of npc04relxx are exported.
*NPC dies if health set to zero from server
*NPC can attack player with guns with a single function ShootPlayer, added by the module LibAction.

Example:
RFC(0, "QuitServer")()This code is in scripts/main.nut.  It will execute the function 'QuitServer' in npc with id 0. As a result,  that npc disconnect itself. This is Remote Call Procedure.

habi

Linux plugin to connect npc's have an issue:
QuoteThe index 'ConnectNPC' does not exist.

This is fixed
Download npc04rel64.so

Kenneth Law

habi!! I'd like to say you really did a good job as you are more than making NPCs for VCMP. It contributes a lot to my plan of creating a completely new way for gameplay that has never existed in VCMP! What I mean is that does any of you still remember a mission in single-player in which Lance drives a helicopter towards Prawn Island with Tommy standing beside as a turret? Yeah that's the thing where habi's NPC system takes effect. I believe that with the help of NPC, the function can soon be made come true in my server (Extreme Racing). You guys may be curious about what the hell at all relation it has with NPC? But it's not the point. The point is that it'll soon be possible for players to experience the scene of smoothly firing from a flying helicopter regardless of any potential issues like lags, sync, etc. Thanks to habi again for his NPC system since it really plays a very important part in the process. It is expected that the project will be finished within 1 or 2 months. Hope you guys could join my server for a try the time when it's done.

Chicken

Hey habi, I used the SetMaxPlayersOut function, but I'm not sure what this function is for. Is it used to exceed the maxplayer slot? However,  I use this function, the server directly crashes.

habi

#50
Quote from: Chicken on May 20, 2023, 07:26 PMHey habi, I used the SetMaxPlayersOut function, but I'm not sure what this function is for. Is it used to exceed the maxplayer slot? However,  I use this function, the server directly crashes.
This issue was fixed. You need to download NPCHide(v3) and latest npc04relxx. Put both in plugins folder and then it will not crash.

SetMaxPlayersOut is not used to exceed the maxplayer slot, but to show it decreased in server browser.
"Suppose you have 10 npcs in server. When you hide npc from browser, it will show ( total players - 10 ) in browser. This later can create problem such as 20/30. Players cannot join because it is already 30 ( 20 + 10 npc ). To avoid these problem, we use SetMaxPlayersOut( 20 ). So 20 actual players can join 20/20.

Example:
SetMaxPlayersOut( 10 );

To change the maximum players 'as shown by the browser'.

habi

Quote from: Kenneth Law on May 20, 2023, 09:24 AMhabi!! I'd like to say you really did a good job as you are more than making NPCs for VCMP. It contributes a lot to my plan of creating a completely new way for gameplay that has never existed in VCMP! What I mean is that does any of you still remember a mission in single-player in which Lance drives a helicopter towards Prawn Island with Tommy standing beside as a turret? Yeah that's the thing where habi's NPC system takes effect. I believe that with the help of NPC, the function can soon be made come true in my server (Extreme Racing). You guys may be curious about what the hell at all relation it has with NPC? But it's not the point. The point is that it'll soon be possible for players to experience the scene of smoothly firing from a flying helicopter regardless of any potential issues like lags, sync, etc. Thanks to habi again for his NPC system since it really plays a very important part in the process. It is expected that the project will be finished within 1 or 2 months. Hope you guys could join my server for a try the time when it's done.
Thank you Kenneth Law. I wish you good luck with your project.

Chicken

Habi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?

habi

Quote from: Chicken on May 22, 2023, 01:05 PMHabi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?

Chicken, currently they do not have the function to request class and spawn. I will add these functions so that when dead, they can spawn again.



Chicken

Quote from: habi on May 23, 2023, 03:28 PM
Quote from: Chicken on May 22, 2023, 01:05 PMHabi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?

Chicken, currently they do not have the function to request class and spawn. I will add these functions so that when dead, they can spawn again.



OKay,You're great now. npc plugin is the best plugin,My friend

habi

#55
v1.6 beta4 patch2
-Now npc can select class and spawn.
Download
Windows npc_vcmp_rel006_windows_v1.6-beta5.zip (Updated to beta 5)
Linux npc_vcmp_rel006_linux_x64_v1.6-beta5.zip (Updated to beta 5)

You can use player.Spawn() from serverside also.

After spawning him, if you see health not correct like this:

Then do on server script:
//  scripts/main.nut
function onPlayerSpawn(player){if(IsPlayerNPC(player.ID))NewTimer("update",500,1,player.ID);}
function update(id){local p=FindPlayer(id);if(p)p.Pos=p.Pos;}



More information on this patch: release notes of beta4

PSL

My God, Habi brother, the NPC plugin you made is really powerful, I placed several NPCS in the city and recorded the action in advance, this effect is great, your plugin has more powerful functions, I will continue to study your plugin, to improve my server, in short, I think you are a talent.

habi

i am making an installer-interface for windows:
 


so that newbies can go ahead without much trouble.

Will be available in next version.

vitovc

Thanks for making version for rel004. I were planned to buy ryzen PC to host bots for my project but with your plugin I can host bots directly on linux server with low usage of CPU and no GPU at all. You are awesome.

...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

habi

#59
News: v1.7 beta released

Changelog
  • NPC can now use pickups, checkpoints, and objects.
  • Fixed disconnection/crash issue when using Vector._tostring method.
  • Fixed bugs related to crouching, reloading, and checking player actions.
  • Set console foreground intensity for windows console. It looks better now.

Downloads
Windowsnpc_vcmp_rel006_windows_v1.7-beta.zip
Linux x64npc_vcmp_rel006_linux_x64_v1.7-beta.zip
Linux x86npc_vcmp_rel006_linux_x86_v1.7-beta.zip
Windows/Linux (rel004)npc_vcmp_rel004_win_lin_v1.7-beta.zip
Windows Setupnpcclient-setup-v1.7-beta.exe
Source CodeNPC-VCMP-master-v1.7-beta.zip
API Plugin (v1.5)npc_vcmp_plugin_API_1_5.zip

New Functions
  • IsPickupStreamedIn(pickupid);
      Description: Checks if a pickup is streamed in for NPCs.
      Parameters:
      - pickupid: ID of the pickup to check.
      Returns: Whether the pickup is streamed in (true) or not (false).

  • GetPickupModel(pickupid);
      Description: Gets the model of a pickup.
      Parameters:
      - pickupid: ID of the pickup to query.
      Returns: Model ID of the pickup.

  • GetPickupAlpha(pickupid);
      Description: Gets the alpha value of a pickup.
      Parameters:
      - pickupid: ID of the pickup to query.
      Returns: Alpha value of the pickup.

  • GetPickupQuantity(pickupid);
      Description: Gets the quantity of items in a pickup.
      Parameters:
      - pickupid: ID of the pickup to query.
      Returns: Quantity of items in the pickup.

  • GetPickupPos(pickupid);
      Description: Gets the position of a pickup.
      Parameters:
      - pickupid: ID of the pickup to query.
      Returns: Position of the pickup as a vector.

  • GetPickupCount();
      Description: Gets the total count of pickups.
      Returns: Total count of pickups.

  • ClaimPickup(pickupid);
      Description: Claims a pickup for a player.
      Parameters:
      - pickupid: ID of the pickup to claim.
      Returns: Whether the pickup was successfully claimed (true) or not (false).

  • GetVehicleDriver(vehicleid);
      Description: Gets the driver of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: ID of the driver player or NPC.

  • GetVehicleModel(vehicleid);
      Description: Gets the model of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Model ID of the vehicle.

  • GetVehicleTurretRot(vehicleid);
      Description: Gets the turret rotation of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Turret rotation as a vector.

  • GetVehicleRotation(vehicleid);
      Description: Gets the rotation of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Rotation as a quaternion.

  • GetVehiclePos(vehicleid);
      Description: Gets the position of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Position as a vector.

  • GetVehicleSpeed(vehicleid);
      Description: Gets the speed of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Speed of the vehicle.

  • GetVehicleHealth(vehicleid);
      Description: Gets the health of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Health of the vehicle.

  • GetVehicleDamage(vehicleid);
      Description: Gets the damage of a vehicle.
      Parameters:
      - vehicleid: ID of the vehicle to query.
      Returns: Damage of the vehicle.

  • GetPlayerSpeed(playerid);
      Description: Gets the speed of a player.
      Parameters:
      - playerid: ID of the player to query.
      Returns: Speed of the player.

  • IsCheckpointStreamedIn(checkpointid);
      Description: Checks if a checkpoint is streamed in for NPCs.
      Parameters:
      - checkpointid: ID of the checkpoint to check.
      Returns: Whether the checkpoint is streamed in (true) or not (false).

  • GetCheckpointRadius(checkpointid);
      Description: Gets the radius of a checkpoint.
      Parameters:
      - checkpointid: ID of the checkpoint to query.
      Returns: Radius of the checkpoint.

  • GetCheckpointPos(checkpointid);
      Description: Gets the position of a checkpoint.
      Parameters:
      - checkpointid: ID of the checkpoint to query.
      Returns: Position of the checkpoint as a vector.

  • GetCheckpointColor(checkpointid);
      Description: Gets the color of a checkpoint.
      Parameters:
      - checkpointid: ID of the checkpoint to query.
      Returns: Color of the checkpoint in a table.

  • IsCheckpointSphere(checkpointid);
      Description: Checks if a checkpoint is a sphere.
      Parameters:
      - checkpointid: ID of the checkpoint to query.
      Returns: Whether the checkpoint is a sphere (true) or not (false).

  • ClaimEnterCheckpoint(checkpointid);
      Description: Claims entering a checkpoint.
      Parameters:
      - checkpointid: ID of the checkpoint to claim.
      Returns: Whether entering the checkpoint was successful (true) or not (false).

  • ClaimExitCheckpoint(checkpointid);
      Description: Claims exiting a checkpoint.
      Parameters:
      - checkpointid: ID of the checkpoint to claim.
      Returns: Whether exiting the checkpoint was successful (true) or not (false).

  • IsObjectStreamedIn(objectid);
      Description: Checks if an object is streamed in for NPCs.
      Parameters:
      - objectid: ID of the object to check.
      Returns: Whether the object is streamed in (true) or not (false).

  • GetObjectModel(objectid);
      Description: Gets the model of an object.
      Parameters:
      - objectid: ID of the object to query.
      Returns: Model ID of the object.

  • GetObjectPos(objectid);
      Description: Gets the position of an object.
      Parameters:
      - objectid: ID of the object to query.
      Returns: Position of the object as a vector.

  • GetObjectRotation(objectid);
      Description: Gets the rotation of an object.
      Parameters:
      - objectid: ID of the object to query.
      Returns: Rotation of the object as a quaternion.

  • GetObjectAlpha(objectid);
      Description: Gets the alpha value of an object.
      Parameters:
      - objectid: ID of the object to query.
      Returns: Alpha value of the object.

  • IsObjectTouchReportEnabled(objectid);
      Description: Checks if touch reporting is enabled for an object.
      Parameters:
      - objectid: ID of the object to check.
      Returns: Whether touch reporting is enabled (true) or not (false).

  • IsObjectShotReportEnabled(objectid);
      Description: Checks if shot reporting is enabled for an object.
      Parameters:
      - objectid: ID of the object to check.
      Returns: Whether shot reporting is enabled (true) or not (false).

  • ClaimObjectTouch(objectid);
      Description: Claims touching an object.
      Parameters:
      - objectid: ID of the object to claim.
      Returns: Whether touching the object was successful (true) or not (false).

  • ClaimObjectShot(objectid, weaponid);
      Description: Claims shooting an object.
      Parameters:
      - objectid: ID of the object to claim.
      - weaponid: ID of the weapon used for shooting.
      Returns: Whether shooting the object was successful (true) or not (false).

  • GetCheckpointCount();
      Description: Gets the total count of checkpoints.
      Returns: Total count of checkpoints.

  • GetObjectCount();
      Description: Gets the total count of objects.
      Returns: Total count of objects.
Callbacks/Events
  • OnPickupStreamIn(pickupid);
      Description: Triggered when a pickup is streamed in.
      Parameters:
      - pickupid: ID of the streamed-in pickup.

  • OnPickupDestroyed(pickupid);
      Description: Triggered when a pickup is destroyed.
      Parameters:
      - pickupid: ID of the destroyed pickup.

  • OnPickupUpdate(pickupid, updateType);
      Description: Triggered when a pickup is updated.
      Parameters:
      - pickupid: ID of the updated pickup.
      - updateType: Type of update.

  • OnCheckpointStreamIn(checkpointId);
      Description: Triggered when a checkpoint is streamed in.
      Parameters:
      - checkpointId: ID of the streamed-in checkpoint.

  • OnCheckpointDestroyed(checkpointId);
      Description: Triggered when a checkpoint is destroyed.
      Parameters:
      - checkpointId: ID of the destroyed checkpoint.

  • OnCheckpointUpdate(checkpointId, updateType);
      Description: Triggered when a checkpoint is updated.
      Parameters:
      - checkpointId: ID of the updated checkpoint.
      - updateType: Type of update.

  • OnObjectStreamIn(objectid);
      Description: Triggered when an object is streamed in.
      Parameters:
      - objectid: ID of the streamed-in object.

  • OnObjectDestroyed(objectid);
      Description: Triggered when an object is destroyed.
      Parameters:
      - objectid: ID of the destroyed object.

  • OnObjectUpdate(objectid, updateType);
      Description: Triggered when an object is updated.
      Parameters:
      - objectid: ID of the updated object.
      - updateType: Type of update.

  • OnTimeWeatherSync(timerate, minute, hour, weather);
      Description: Triggered when time and weather details are send by server.
      Parameters:
      - timerate: Timerate value.
      - minute: Current minute.
      - hour: Current hour.
      - weather: Weather value.
*above documentation generated by cgpt.

Note: Ensure to report any bugs or issues you encounter during usage.