Raised This Month: $138 Target: $400
 34% 

Solved Pathfinding for clients (client follow a path)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EfeDursun125
Member
Join Date: Feb 2019
Location: Aydın
Old 09-01-2019 , 15:17   Pathfinding for clients (client follow a path)
Reply With Quote #1

Hello,
Sorry My English is Bad

I'm maked afk bot for tf2 (auto play bot for afk players) good working and unfinished but i maked waypoint system and not good. How to use module or make pathfinding system for client?

is there anything you can offer me for pathfinding???

afkbots need follow a path, please help me

Last edited by EfeDursun125; 09-02-2019 at 08:21.
EfeDursun125 is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-01-2019 , 15:42   Re: Pathfinding for clients (client follow a path)
Reply With Quote #2

https://github.com/Pelipoika/PathFollower Windows only tho

Test plugin:

Code:
#include <sourcemod>
#include <PathFollower>

public void OnPluginStart() 
{
    RegAdminCmd("sm_cg2m", CGTM, ADMFLAG_ROOT);
}

public Action CGTM(int client, int args) 
{
    char arg[MAX_NAME_LENGTH];
    GetCmdArg(1, arg, sizeof(arg));
    int x = FindTarget(client, arg);
    
    if (!PF_Exists(x)) 
    {
        PrintToChatAll("Does not exist, creating!");
        PF_Create(x, 18.0, 64.0, 1000.0, 0.6, MASK_PLAYERSOLID, 300.0, 2.0, 1.0);
    }
    
    PF_SetGoalEntity(x, client);
    
    PF_StartPathing(x);
    
    PF_EnableCallback(x, PFCB_Approach, Approach);
    
    return Plugin_Handled;
} 

float g_flGoal[MAXPLAYERS + 1][3];

public Action OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVel[3], float fAng[3], int &iWeapon)
{
    if(!IsPlayerAlive(client) || !PF_Exists(client))
        return Plugin_Continue;

    TF2_MoveTo(client, g_flGoal[client], fVel, fAng);

    return Plugin_Continue;
}

stock void TF2_MoveTo(int client, float flGoal[3], float fVel[3], float fAng[3])
{
    float flPos[3];
    GetClientAbsOrigin(client, flPos);

    float newmove[3];
    SubtractVectors(flGoal, flPos, newmove);
    
    newmove[1] = -newmove[1];
    
    float sin = Sine(fAng[1] * FLOAT_PI / 180.0);
    float cos = Cosine(fAng[1] * FLOAT_PI / 180.0);                        
    
    fVel[0] = cos * newmove[0] - sin * newmove[1];
    fVel[1] = sin * newmove[0] + cos * newmove[1];
    
    NormalizeVector(fVel, fVel);
    ScaleVector(fVel, 450.0);
}

public void Approach(int bot_entidx, const float dst[3])
{
    g_flGoal[bot_entidx][0] = dst[0];
    g_flGoal[bot_entidx][1] = dst[1];
    g_flGoal[bot_entidx][2] = dst[2];
}
__________________
Pelipoika is offline
EfeDursun125
Member
Join Date: Feb 2019
Location: Aydın
Old 09-01-2019 , 15:57   Re: Pathfinding for clients (client follow a path)
Reply With Quote #3

Quote:
Originally Posted by Pelipoika View Post
https://github.com/Pelipoika/PathFollower Windows only tho

Test plugin:

Code:
#include <sourcemod>
#include <PathFollower>

public void OnPluginStart() 
{
    RegAdminCmd("sm_cg2m", CGTM, ADMFLAG_ROOT);
}

public Action CGTM(int client, int args) 
{
    char arg[MAX_NAME_LENGTH];
    GetCmdArg(1, arg, sizeof(arg));
    int x = FindTarget(client, arg);
    
    if (!PF_Exists(x)) 
    {
        PrintToChatAll("Does not exist, creating!");
        PF_Create(x, 18.0, 64.0, 1000.0, 0.6, MASK_PLAYERSOLID, 300.0, 2.0, 1.0);
    }
    
    PF_SetGoalEntity(x, client);
    
    PF_StartPathing(x);
    
    PF_EnableCallback(x, PFCB_Approach, Approach);
    
    return Plugin_Handled;
} 

float g_flGoal[MAXPLAYERS + 1][3];

public Action OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVel[3], float fAng[3], int &iWeapon)
{
    if(!IsPlayerAlive(client) || !PF_Exists(client))
        return Plugin_Continue;

    TF2_MoveTo(client, g_flGoal[client], fVel, fAng);

    return Plugin_Continue;
}

stock void TF2_MoveTo(int client, float flGoal[3], float fVel[3], float fAng[3])
{
    float flPos[3];
    GetClientAbsOrigin(client, flPos);

    float newmove[3];
    SubtractVectors(flGoal, flPos, newmove);
    
    newmove[1] = -newmove[1];
    
    float sin = Sine(fAng[1] * FLOAT_PI / 180.0);
    float cos = Cosine(fAng[1] * FLOAT_PI / 180.0);                        
    
    fVel[0] = cos * newmove[0] - sin * newmove[1];
    fVel[1] = sin * newmove[0] + cos * newmove[1];
    
    NormalizeVector(fVel, fVel);
    ScaleVector(fVel, 450.0);
}

public void Approach(int bot_entidx, const float dst[3])
{
    g_flGoal[bot_entidx][0] = dst[0];
    g_flGoal[bot_entidx][1] = dst[1];
    g_flGoal[bot_entidx][2] = dst[2];
}
thank you, and i getting a error

[SM] Plugin pathfollowertest.smx failed to load: Required extension "PathFollower" file("PathFollower.ext") not running.

i can't see a extension in github
EfeDursun125 is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-01-2019 , 20:06   Re: Pathfinding for clients (client follow a path)
Reply With Quote #4

Quote:
Originally Posted by EfeDursun125 View Post
thank you, and i getting a error

[SM] Plugin pathfollowertest.smx failed to load: Required extension "PathFollower" file("PathFollower.ext") not running.

i can't see a extension in github
https://github.com/Pelipoika/PathFollower/releases ??
__________________
Pelipoika is offline
EfeDursun125
Member
Join Date: Feb 2019
Location: Aydın
Old 09-02-2019 , 06:25   Re: Pathfinding for clients (client follow a path)
Reply With Quote #5

Quote:
Originally Posted by Pelipoika View Post
ow, sorry i clicked to source code

EDIT : thank you

Last edited by EfeDursun125; 09-02-2019 at 07:36.
EfeDursun125 is offline
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

Forum Jump


All times are GMT -4. The time now is 02:59.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode