|
Senior Member
Join Date: Feb 2019
Location: Turkey
|
09-01-2019
, 15:57
Re: Pathfinding for clients (client follow a path)
|
#3
|
Quote:
Originally Posted by Pelipoika
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
|
|
|
|