NPC/Bots implementation in VCMP 0.4 Servers

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

Previous topic - Next topic

habi2

Quote from: PSL on Jul 26, 2024, 08:52 AMHi Habi,What is the current status of NPC plugin updates :)  :)  :)
The new npc can connect to windows server. I have fixed all version error, etc. New npc knows different messages send by server -join, death, etc.
I have found new vcmp client sends onfoot and onfoot-aim packets differently. Rest all(vehicle drive, passenger,..) is assumed to be same.
This foot sync packets have extra 9 float values 4 of them always zero, other in range -1 to 1. When player angle is special like 0, pi/2, pi etc, some become exactly equal to 1 while others are 0 or 0.3 etc.


Moreover, when the player shoots an extra vector apart from aimdir and aimpos is send. This extra vector close to aimdir and its magnitude is always 1.

Interesting, huh ?

vitovc

new vector is most likely point at center of screen (camera)
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

PSL

Hi Habi.
Thank you very much for your explanation.  I have understood the development situation you mentioned.  I am looking forward to receiving your plug-in as soon as possible.  I am looking forward to and excited about it!
Thanks again for your hard work and the development of this plugin!

StingRay_

Hi habi.
I was running server on linux and when I used ConnectNPCEx, it just came:
sh: 1: /home/fidlar/vcmp/test: not found
Nothing else, and the npc was not connected. I found the path above to my server was truncated (originally 'test server'), it seemed spaces could not be included in the path, and with spaces removed it turned out fine. Trivial though, could this one be fixed? Thanks a lot for your continuous efforts.
Btw it worked fine with windows version plugin.

habi2

Quote from: StingRay_ on Aug 18, 2024, 05:15 PMHi habi.
I was running server on linux and when I used ConnectNPCEx, it just came:
sh: 1: /home/fidlar/vcmp/test: not found
Sorry i have not seen your message.
I will take care of this issue in next build.

vitovc

hi habi. please add InPoly function. its useful to calcualte model of vehicle's "collisions" (by rotated rectangles) on side of npc's scripts


inline bool Internal_InPoly(float fX, float fY,
    const unsigned int uiPoints, const AreaPoints fPoints[])
{
    // http://sidvind.com/wiki/Point-in-polygon:_Jordan_Curve_Theorem

    // The points creating the polygon
    float x1, x2;

    // How many times the ray crosses a line segment
    int crossings = 0;

    // Iterate through each line
    for (unsigned int i = 0; i < uiPoints; i++)
    {
        // This is done to ensure that we get the same result when
        // the line goes from left to right and right to left.
        if (fPoints[i].x < fPoints[(i + 1) % uiPoints].x)
        {
            x1 = fPoints[i].x;
            x2 = fPoints[(i + 1) % uiPoints].x;
        }
        else
        {
            x1 = fPoints[(i + 1) % uiPoints].x;
            x2 = fPoints[i].x;
        }

        // First check if the ray is able to cross the line
        if (fX > x1 && fX <= x2 && (fY < fPoints[i].y || fY <= fPoints[(i + 1) % uiPoints].y))
        {
            static const float eps = 0.000001f;

            // Calculate the equation of the line
            float dx = fPoints[(i + 1) % uiPoints].x - fPoints[i].x;
            float dy = fPoints[(i + 1) % uiPoints].y - fPoints[i].y;
            float k;

            if (fabs(dx) < eps)
                k = 0xffffffff;
            else
                k = dy / dx;

            float m = fPoints[i].y - k * fPoints[i].x;

            // Find if the ray crosses the line
            float y2 = k * fX + m;
            if (fY <= y2)
                crossings++;
        }
    }

    if (crossings % 2 == 1)
        return true;

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

habi2


habi2

#142
NPCClient v1.8 beta 3 Released - Now with 0.4.7.1 Support!

We're excited to announce the release of npcclient v1.8 beta 3! This release comes with several key updates and bug fixes that will improve compatibility and stability for VCMP servers.

What's New in v1.8 beta 3:
    • Added support for 0.4.7.1: Now fully compatible with the latest server version.
    • Fixed a possible bug in rel004 servers: Related to passenger updates, enhancing overall stability.
    • Fixed plugin truncating path to the server: When paths contain spaces using ConnectNPCEx/ConnectNPC.
    • New InPoly function: Added a function to check if a two-dimensional point is inside a polygon by providing the vertices of the polygon. This can help with advanced scripting and positioning logic.

    For more details on the changes, please refer to the full release notes: Release Notes

    Downloads:

    Operating SystemVersionDownload Link
    Windows0.4.7.1npc_vcmp_0471_windows_v1.8-beta-3.zip
    Linux x640.4.7.1npc_vcmp_0471_linux_x64_v1.8-beta-3.zip
    Linux x860.4.7.1npc_vcmp_0471_linux_x86_v1.8-beta-3.zip
    Windowsrel006npc_vcmp_rel006_windows_v1.8-beta-3.zip
    Linux x64rel006npc_vcmp_rel006_linux_x64_v1.8-beta-3.zip
    Linux x86rel006npc_vcmp_rel006_linux_x86_v1.8-beta-3.zip
    Windows/Linuxrel004npc_vcmp_rel004_win_lin_v1.8-beta-3.zip
    Source CodeAll versionsNPC-VCMP-master-v1.8-beta-3.zip
    API Plugin1.6npc_vcmp_plugin_API_1_6.zip

    ---

    Thank you all for your continued support and for using npcclient! Your feedback and dedication help us keep improving. Please feel free to share your thoughts and report any issues.

    Happy scripting!

    habi2

    #143
    NPCClient v1.8 Beta 4 Released

    We're releasing the latest beta for NPCClient, version 1.8 Beta 4, with several improvements and bug fixes:

    • Fixed Vehicle Driver not reset on player exit (GetVehicleDriver).
    • Added FireBullet function to enable NPC shooting.
    • API updated to 1.8.
    • Resolved issues with NPC entering vehicles as drivers and closing doors on exit.
    • NPCClient now supports store-file downloads with the option `-d` or `-D`.
    • Added GetStoreURL() for retrieving store-url of server (if http-downloads enabled in server)
    • Added manual NPC spawn option using `-M` or `--Manual-Spawn`. This prevents npc from automatically spawning.
    • Fixed crash issue with API (plugin.h).
    • New npc table in Squirrel script with functions: `npc.fire()`, `npc.punch()`, `npc.wep()`, `npc.prewep()`, `npc.sit()`, and `npc.stand()`.

    Downloads:
    Operating SystemVersionLink
    Windows0.4.7.1npc_vcmp_0471_windows_v1.8-beta-4.zip
    Linux x640.4.7.1npc_vcmp_0471_linux_x64_v1.8-beta-4.zip
    Linux x860.4.7.1npc_vcmp_0471_linux_x86_v1.8-beta-4.zip
    Windowsrel006npc_vcmp_rel006_windows_v1.8-beta-4.zip
    Linux x64rel006npc_vcmp_rel006_linux_x64_v1.8-beta-4.zip
    Linux x86rel006npc_vcmp_rel006_linux_x86_v1.8-beta-4.zip
    Windows/Linux (rel004)rel004npc_vcmp_rel004_win_lin_v1.8-beta-4.zip
    Source CodeAllNPC-VCMP-master-v1.8-beta-4.zip
    API Plugin1.8npc_vcmp_plugin_API_1_8.zip
    Windows (Setup)rel004, rel006, 0.4.7.1npcclient_v1.8_beta4_setup.exe

    Thank you for testing and providing feedback!

    Release Notes

    PSL

    Hey, Habi! Congratulations on your successful launch of NPC plug-in 1.8p4 version ah, along the way watching you constantly update and improve this plug-in, really admire your persistence and efforts. I know that every update is not easy, and I must have paid a lot of effort behind it. I believe that this new version will be loved and recognized by more players, you can boldly go ahead, I will always support you!

    MEGAMIND

    habi soon making npc.ai();

    great work man.. keep vcmp alive..

    habi2

    Hi PSL,
    Thank you for such encouraging words. It is because of you and other friend's interest that the project is still alive.
    I will see what can be done to make npc more better.

    Hi Megamind,
    Quote from: MEGAMIND on Oct 26, 2024, 07:26 AMhabi soon making npc.ai();

    great work man.. keep vcmp alive..
    Thank you

    MEGAMIND

    How does the npc gets a skin ?
    npc_pos <- Vector(-1750.44, -277.178, 14.8683);
    function OnNPCScriptLoad( params )
    {

    print("npcidle: running\n");
    }


    function OnNPCClassSelect()
    {
        if(GetPlayerTeam(GetMyID())==210)
          RequestSpawn();
        else
          RequestClass(CLASS_NEXT);
        return 1
    }

    function OnNPCSpawn()
    {


         SendChat("I have spawned");

    SetTimerEx("SetMyPos",700, 1, npc_pos );
    SetMyPos(npc_pos);

    }

    server side
    function onPlayerRequestClass( player, classID, team, skin )
    {
    AddClass(28, RGB( 124, 121, 121 ),212,Vector(-923.882, 406.665, 11.247), 188.3568,25,320,21,320,102,450);
    }
    @habi2

    habi2

    Hi Megamind

    The npc doesn't get skin. The npc04 plugin has code inside it for setting skin. It sets skin if any npc sends a setskin command. And when needed, our npc do send such commands.

    MEGAMIND

    #149
    Quote from: habi2 on Nov 07, 2024, 12:07 PMHi Megamind

    The npc doesn't get skin. The npc04 plugin has code inside it for setting skin. It sets skin if any npc sends a setskin command. And when needed, our npc do send such commands.
    how do i set the skin to it

    working on npcAI(text,player,tone);